@iglo.tech/iglo.base 0.0.0-stage → 1.0.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/LICENSE +18 -0
  3. package/README.md +778 -2
  4. package/dist/iglo-base.es.mjs +4 -0
  5. package/dist/iglo-base.es.mjs.map +34 -0
  6. package/dist/ssr-astro.es.mjs +4 -0
  7. package/dist/ssr-astro.es.mjs.map +12 -0
  8. package/dist/ssr-browser-client.es.mjs +4 -0
  9. package/dist/ssr-browser-client.es.mjs.map +13 -0
  10. package/dist/ssr-browser.es.mjs +4 -0
  11. package/dist/ssr-browser.es.mjs.map +10 -0
  12. package/dist/ssr-next.es.mjs +4 -0
  13. package/dist/ssr-next.es.mjs.map +12 -0
  14. package/dist/ssr-nuxt.es.mjs +4 -0
  15. package/dist/ssr-nuxt.es.mjs.map +12 -0
  16. package/dist/ssr-react-router.es.mjs +4 -0
  17. package/dist/ssr-react-router.es.mjs.map +12 -0
  18. package/dist/ssr-sveltekit.es.mjs +4 -0
  19. package/dist/ssr-sveltekit.es.mjs.map +12 -0
  20. package/dist/ssr.es.mjs +4 -0
  21. package/dist/ssr.es.mjs.map +22 -0
  22. package/dist/types/src/Client.d.ts +233 -0
  23. package/dist/types/src/ClientResponseError.d.ts +22 -0
  24. package/dist/types/src/index.d.ts +18 -0
  25. package/dist/types/src/services/BackupService.d.ts +59 -0
  26. package/dist/types/src/services/BaseService.d.ts +8 -0
  27. package/dist/types/src/services/BatchService.d.ts +56 -0
  28. package/dist/types/src/services/CollectionService.d.ts +47 -0
  29. package/dist/types/src/services/CronService.d.ts +20 -0
  30. package/dist/types/src/services/CrudService.d.ts +85 -0
  31. package/dist/types/src/services/FileService.d.ts +19 -0
  32. package/dist/types/src/services/HealthService.d.ts +16 -0
  33. package/dist/types/src/services/LogService.d.ts +35 -0
  34. package/dist/types/src/services/RealtimeService.d.ts +124 -0
  35. package/dist/types/src/services/RecordService.d.ts +374 -0
  36. package/dist/types/src/services/SQLService.d.ts +21 -0
  37. package/dist/types/src/services/SettingsService.d.ts +46 -0
  38. package/dist/types/src/ssr/adapter.d.ts +133 -0
  39. package/dist/types/src/ssr/astro.d.ts +27 -0
  40. package/dist/types/src/ssr/browser-client.d.ts +100 -0
  41. package/dist/types/src/ssr/browser-token.d.ts +29 -0
  42. package/dist/types/src/ssr/browser.d.ts +1 -0
  43. package/dist/types/src/ssr/cache.d.ts +9 -0
  44. package/dist/types/src/ssr/cookies.d.ts +68 -0
  45. package/dist/types/src/ssr/csrf.d.ts +38 -0
  46. package/dist/types/src/ssr/index.d.ts +12 -0
  47. package/dist/types/src/ssr/next.d.ts +53 -0
  48. package/dist/types/src/ssr/no-store-fetch.d.ts +7 -0
  49. package/dist/types/src/ssr/nuxt.d.ts +41 -0
  50. package/dist/types/src/ssr/oauth2.d.ts +56 -0
  51. package/dist/types/src/ssr/popup.d.ts +14 -0
  52. package/dist/types/src/ssr/react-router.d.ts +53 -0
  53. package/dist/types/src/ssr/renew.d.ts +25 -0
  54. package/dist/types/src/ssr/server-client.d.ts +83 -0
  55. package/dist/types/src/ssr/superuser-client.d.ts +24 -0
  56. package/dist/types/src/ssr/sveltekit.d.ts +44 -0
  57. package/dist/types/src/ssr/types.d.ts +118 -0
  58. package/dist/types/src/stores/AsyncAuthStore.d.ts +52 -0
  59. package/dist/types/src/stores/BaseAuthStore.d.ts +104 -0
  60. package/dist/types/src/stores/LocalAuthStore.d.ts +48 -0
  61. package/dist/types/src/tools/cookie.d.ts +31 -0
  62. package/dist/types/src/tools/dtos.d.ts +122 -0
  63. package/dist/types/src/tools/formdata.d.ts +30 -0
  64. package/dist/types/src/tools/jwt.d.ts +14 -0
  65. package/dist/types/src/tools/legacy.d.ts +2 -0
  66. package/dist/types/src/tools/loose.d.ts +5 -0
  67. package/dist/types/src/tools/options.d.ts +91 -0
  68. package/dist/types/src/tools/refresh.d.ts +3 -0
  69. package/package.json +73 -4
@@ -0,0 +1,233 @@
1
+ import type { Loose, LooseObject } from "./tools/loose.js";
2
+ import { BaseAuthStore } from "./stores/BaseAuthStore.js";
3
+ import { SettingsService } from "./services/SettingsService.js";
4
+ import { RecordService } from "./services/RecordService.js";
5
+ import { CollectionService } from "./services/CollectionService.js";
6
+ import { LogService } from "./services/LogService.js";
7
+ import { RealtimeService } from "./services/RealtimeService.js";
8
+ import { HealthService } from "./services/HealthService.js";
9
+ import { FileService } from "./services/FileService.js";
10
+ import { BackupService } from "./services/BackupService.js";
11
+ import { CronService } from "./services/CronService.js";
12
+ import { SQLService } from "./services/SQLService.js";
13
+ import { BatchService } from "./services/BatchService.js";
14
+ import { type RecordModel } from "./tools/dtos.js";
15
+ import { type SendOptions, type FileOptions } from "./tools/options.js";
16
+ export interface BeforeSendResult {
17
+ [key: string]: Loose;
18
+ url?: string;
19
+ options?: LooseObject;
20
+ }
21
+ /**
22
+ * PocketBase JS Client.
23
+ */
24
+ export default class Client {
25
+ /**
26
+ * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').
27
+ */
28
+ baseURL: string;
29
+ /**
30
+ * Legacy getter alias for baseURL.
31
+ * @deprecated Please replace with baseURL.
32
+ */
33
+ get baseUrl(): string;
34
+ /**
35
+ * Legacy setter alias for baseURL.
36
+ * @deprecated Please replace with baseURL.
37
+ */
38
+ set baseUrl(v: string);
39
+ /**
40
+ * Hook that get triggered right before sending the fetch request,
41
+ * allowing you to inspect and modify the url and request options.
42
+ *
43
+ * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options
44
+ *
45
+ * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.
46
+ *
47
+ * Example:
48
+ * ```js
49
+ * const pb = new PocketBase("https://example.com")
50
+ *
51
+ * pb.beforeSend = function (url, options) {
52
+ * options.headers = Object.assign({}, options.headers, {
53
+ * 'X-Custom-Header': 'example',
54
+ * })
55
+ *
56
+ * return { url, options }
57
+ * }
58
+ *
59
+ * // use the created client as usual...
60
+ * ```
61
+ */
62
+ beforeSend?: (url: string, options: SendOptions) => BeforeSendResult | Promise<BeforeSendResult>;
63
+ /**
64
+ * Hook that get triggered after successfully sending the fetch request,
65
+ * allowing you to inspect/modify the response object and its parsed data.
66
+ *
67
+ * Returns the new Promise resolved `data` that will be returned to the client.
68
+ *
69
+ * Example:
70
+ * ```js
71
+ * const pb = new PocketBase("https://example.com")
72
+ *
73
+ * pb.afterSend = function (response, data, options) {
74
+ * if (response.status != 200) {
75
+ * throw new ClientResponseError({
76
+ * url: response.url,
77
+ * status: response.status,
78
+ * response: { ... },
79
+ * })
80
+ * }
81
+ *
82
+ * return data;
83
+ * }
84
+ *
85
+ * // use the created client as usual...
86
+ * ```
87
+ */
88
+ afterSend?: ((response: Response, data: Loose) => Loose) & ((response: Response, data: Loose, options: SendOptions) => Loose);
89
+ /**
90
+ * Optional language code (default to `en-US`) that will be sent
91
+ * with the requests to the server as `Accept-Language` header.
92
+ */
93
+ lang: string;
94
+ /**
95
+ * A replaceable instance of the local auth store service.
96
+ */
97
+ authStore: BaseAuthStore;
98
+ /**
99
+ * An instance of the service that handles the **Settings APIs**.
100
+ */
101
+ readonly settings: SettingsService;
102
+ /**
103
+ * An instance of the service that handles the **Collection APIs**.
104
+ */
105
+ readonly collections: CollectionService;
106
+ /**
107
+ * An instance of the service that handles the **File APIs**.
108
+ */
109
+ readonly files: FileService;
110
+ /**
111
+ * An instance of the service that handles the **Log APIs**.
112
+ */
113
+ readonly logs: LogService;
114
+ /**
115
+ * An instance of the service that handles the **Realtime APIs**.
116
+ */
117
+ readonly realtime: RealtimeService;
118
+ /**
119
+ * An instance of the service that handles the **Health APIs**.
120
+ */
121
+ readonly health: HealthService;
122
+ /**
123
+ * An instance of the service that handles the **Backup APIs**.
124
+ */
125
+ readonly backups: BackupService;
126
+ /**
127
+ * An instance of the service that handles the **Cron APIs**.
128
+ */
129
+ readonly crons: CronService;
130
+ /**
131
+ * An instance of the service that handles the **SQL APIs**.
132
+ */
133
+ readonly sql: SQLService;
134
+ private cancelControllers;
135
+ private recordServices;
136
+ private enableAutoCancellation;
137
+ constructor(baseURL?: string, authStore?: BaseAuthStore | null, lang?: string);
138
+ /**
139
+ * @deprecated
140
+ * With PocketBase v0.23.0 admins are converted to a regular auth
141
+ * collection named "_superusers", aka. you can use directly collection("_superusers").
142
+ */
143
+ get admins(): RecordService;
144
+ /**
145
+ * Creates a new batch handler for sending multiple transactional
146
+ * create/update/upsert/delete collection requests in one network call.
147
+ *
148
+ * Example:
149
+ * ```js
150
+ * const batch = pb.createBatch();
151
+ *
152
+ * batch.collection("example1").create({ ... })
153
+ * batch.collection("example2").update("RECORD_ID", { ... })
154
+ * batch.collection("example3").delete("RECORD_ID")
155
+ * batch.collection("example4").upsert({ ... })
156
+ *
157
+ * await batch.send()
158
+ * ```
159
+ */
160
+ createBatch(): BatchService;
161
+ /**
162
+ * Returns the RecordService associated to the specified collection.
163
+ */
164
+ collection<M = RecordModel>(idOrName: string): RecordService<M>;
165
+ /**
166
+ * Globally enable or disable auto cancellation for pending duplicated requests.
167
+ */
168
+ autoCancellation(enable: boolean): Client;
169
+ /**
170
+ * Cancels single request by its cancellation key.
171
+ */
172
+ cancelRequest(requestKey: string): Client;
173
+ /**
174
+ * Cancels all pending requests.
175
+ */
176
+ cancelAllRequests(): Client;
177
+ /**
178
+ * Constructs a filter expression with placeholders populated from a parameters object.
179
+ *
180
+ * Placeholder parameters are defined with the `{:paramName}` notation.
181
+ *
182
+ * The following parameter values are supported:
183
+ *
184
+ * - `string`
185
+ * - `number`
186
+ * - `boolean`
187
+ * - `null`
188
+ * - `undefined` (stringified as "null")
189
+ * - `Date` object (_stringified into the PocketBase datetime format_)
190
+ * - everything else is converted to a string using `JSON.stringify()`
191
+ *
192
+ * Example:
193
+ *
194
+ * ```js
195
+ * pb.collection("example").getFirstListItem(pb.filter(
196
+ * 'title ~ {:title} && created >= {:created}',
197
+ * { title: "example", created: new Date()}
198
+ * ))
199
+ * ```
200
+ */
201
+ filter(raw: string, params?: LooseObject): string;
202
+ /**
203
+ * @deprecated Please use `pb.files.getURL()`.
204
+ */
205
+ getFileUrl(record: LooseObject, filename: string, queryParams?: FileOptions): string;
206
+ /**
207
+ * @deprecated Please use `pb.buildURL()`.
208
+ */
209
+ buildUrl(path: string): string;
210
+ /**
211
+ * Builds a full client url by safely concatenating the provided path.
212
+ */
213
+ buildURL(path: string): string;
214
+ /**
215
+ * Sends an api http request.
216
+ *
217
+ * @throws {ClientResponseError}
218
+ */
219
+ send<T = Loose>(path: string, options: SendOptions): Promise<T>;
220
+ /**
221
+ * Shallow copy the provided object and takes care to initialize
222
+ * any options required to preserve the backward compatability.
223
+ *
224
+ * @param {SendOptions} options
225
+ * @return {SendOptions}
226
+ */
227
+ private initSendOptions;
228
+ /**
229
+ * Extracts the header with the provided name in case-insensitive manner.
230
+ * Returns `null` if no header matching the name is found.
231
+ */
232
+ private getHeader;
233
+ }
@@ -0,0 +1,22 @@
1
+ import type { Loose, LooseObject } from "./tools/loose.js";
2
+ /**
3
+ * ClientResponseError is a custom Error class that is intended to wrap
4
+ * and normalize any error thrown by `Client.send()`.
5
+ */
6
+ export declare class ClientResponseError extends Error {
7
+ url: string;
8
+ status: number;
9
+ response: LooseObject;
10
+ isAbort: boolean;
11
+ originalError: Loose;
12
+ constructor(errData?: unknown);
13
+ /**
14
+ * Alias for `this.response` for backward compatibility.
15
+ */
16
+ get data(): LooseObject;
17
+ /**
18
+ * Make a POJO's copy of the current error class instance.
19
+ * @see https://github.com/vuex-orm/vuex-orm/issues/255
20
+ */
21
+ toJSON(): this;
22
+ }
@@ -0,0 +1,18 @@
1
+ import Client from "./Client.js";
2
+ export * from "./Client.js";
3
+ export * from "./ClientResponseError.js";
4
+ export * from "./services/CollectionService.js";
5
+ export * from "./services/HealthService.js";
6
+ export * from "./services/LogService.js";
7
+ export * from "./services/RealtimeService.js";
8
+ export * from "./services/RecordService.js";
9
+ export * from "./services/CrudService.js";
10
+ export * from "./services/BatchService.js";
11
+ export * from "./stores/AsyncAuthStore.js";
12
+ export * from "./stores/BaseAuthStore.js";
13
+ export * from "./stores/LocalAuthStore.js";
14
+ export * from "./tools/dtos.js";
15
+ export * from "./tools/options.js";
16
+ export * from "./tools/cookie.js";
17
+ export * from "./tools/jwt.js";
18
+ export default Client;
@@ -0,0 +1,59 @@
1
+ import type { LooseObject } from "../tools/loose.js";
2
+ import { BaseService } from "./BaseService.js";
3
+ import { type CommonOptions } from "../tools/options.js";
4
+ export interface BackupFileInfo {
5
+ key: string;
6
+ size: number;
7
+ modified: string;
8
+ }
9
+ export declare class BackupService extends BaseService {
10
+ /**
11
+ * Returns list with all available backup files.
12
+ *
13
+ * @throws {ClientResponseError}
14
+ */
15
+ getFullList(options?: CommonOptions): Promise<Array<BackupFileInfo>>;
16
+ /**
17
+ * Initializes a new backup.
18
+ *
19
+ * @throws {ClientResponseError}
20
+ */
21
+ create(basename: string, options?: CommonOptions): Promise<boolean>;
22
+ /**
23
+ * Uploads an existing backup file.
24
+ *
25
+ * Example:
26
+ *
27
+ * ```js
28
+ * await pb.backups.upload({
29
+ * file: new Blob([...]),
30
+ * });
31
+ * ```
32
+ *
33
+ * @throws {ClientResponseError}
34
+ */
35
+ upload(bodyParams: LooseObject | FormData, options?: CommonOptions): Promise<boolean>;
36
+ /**
37
+ * Deletes a single backup file.
38
+ *
39
+ * @throws {ClientResponseError}
40
+ */
41
+ delete(key: string, options?: CommonOptions): Promise<boolean>;
42
+ /**
43
+ * Initializes an app data restore from an existing backup.
44
+ *
45
+ * @throws {ClientResponseError}
46
+ */
47
+ restore(key: string, options?: CommonOptions): Promise<boolean>;
48
+ /**
49
+ * @deprecated Please use `getDownloadURL()`.
50
+ */
51
+ getDownloadUrl(token: string, key: string): string;
52
+ /**
53
+ * Builds a download url for a single existing backup using a
54
+ * superuser file token and the backup file key.
55
+ *
56
+ * The file token can be generated via `pb.files.getToken()`.
57
+ */
58
+ getDownloadURL(token: string, key: string): string;
59
+ }
@@ -0,0 +1,8 @@
1
+ import Client from "../Client.js";
2
+ /**
3
+ * BaseService class that should be inherited from all API services.
4
+ */
5
+ export declare abstract class BaseService {
6
+ readonly client: Client;
7
+ constructor(client: Client);
8
+ }
@@ -0,0 +1,56 @@
1
+ import type { Loose, LooseObject } from "../tools/loose.js";
2
+ import { BaseService } from "./BaseService.js";
3
+ import { type SendOptions, type RecordOptions } from "../tools/options.js";
4
+ export interface BatchRequest {
5
+ method: string;
6
+ url: string;
7
+ json?: LooseObject;
8
+ files?: {
9
+ [key: string]: Array<Loose>;
10
+ };
11
+ headers?: {
12
+ [key: string]: string;
13
+ };
14
+ }
15
+ export interface BatchRequestResult {
16
+ status: number;
17
+ body: Loose;
18
+ }
19
+ export declare class BatchService extends BaseService {
20
+ private requests;
21
+ private subs;
22
+ /**
23
+ * Starts constructing a batch request entry for the specified collection.
24
+ */
25
+ collection(collectionIdOrName: string): SubBatchService;
26
+ /**
27
+ * Sends the batch requests.
28
+ *
29
+ * @throws {ClientResponseError}
30
+ */
31
+ send(options?: SendOptions): Promise<Array<BatchRequestResult>>;
32
+ }
33
+ export declare class SubBatchService {
34
+ private requests;
35
+ private readonly collectionIdOrName;
36
+ constructor(requests: Array<BatchRequest>, collectionIdOrName: string);
37
+ /**
38
+ * Registers a record upsert request into the current batch queue.
39
+ *
40
+ * The request will be executed as update if `bodyParams` have a valid existing record `id` value, otherwise - create.
41
+ */
42
+ upsert(bodyParams?: LooseObject | FormData, options?: RecordOptions): void;
43
+ /**
44
+ * Registers a record create request into the current batch queue.
45
+ */
46
+ create(bodyParams?: LooseObject | FormData, options?: RecordOptions): void;
47
+ /**
48
+ * Registers a record update request into the current batch queue.
49
+ */
50
+ update(id: string, bodyParams?: LooseObject | FormData, options?: RecordOptions): void;
51
+ /**
52
+ * Registers a record delete request into the current batch queue.
53
+ */
54
+ delete(id: string, options?: SendOptions): void;
55
+ private prepareRequest;
56
+ }
@@ -0,0 +1,47 @@
1
+ import type { LooseObject } from "../tools/loose.js";
2
+ import { CrudService } from "./CrudService.js";
3
+ import { type CommonOptions } from "../tools/options.js";
4
+ import { type CollectionModel, type ConfigurableOAuth2Provider } from "../tools/dtos.js";
5
+ export declare class CollectionService extends CrudService<CollectionModel> {
6
+ /**
7
+ * @inheritdoc
8
+ */
9
+ get baseCrudPath(): string;
10
+ /**
11
+ * Imports the provided collections.
12
+ *
13
+ * If `deleteMissing` is `true`, all local collections and their fields,
14
+ * that are not present in the imported configuration, WILL BE DELETED
15
+ * (including their related records data)!
16
+ *
17
+ * @throws {ClientResponseError}
18
+ */
19
+ import(collections: Array<CollectionModel>, deleteMissing?: boolean, options?: CommonOptions): Promise<true>;
20
+ /**
21
+ * Deletes all records associated with the specified collection.
22
+ *
23
+ * @throws {ClientResponseError}
24
+ */
25
+ truncate(collectionIdOrName: string, options?: CommonOptions): Promise<true>;
26
+ /**
27
+ * Returns type indexed map with scaffolded collection models
28
+ * populated with their default field values.
29
+ *
30
+ * @throws {ClientResponseError}
31
+ */
32
+ getScaffolds(options?: CommonOptions): Promise<{
33
+ [key: string]: CollectionModel;
34
+ }>;
35
+ /**
36
+ * Returns a list with all configurable OAuth2 providers.
37
+ *
38
+ * @throws {ClientResponseError}
39
+ */
40
+ getAllOAuth2Providers(options?: CommonOptions): Promise<Array<ConfigurableOAuth2Provider>>;
41
+ /**
42
+ * Executes the specified view query and returns a sample of the resulting records.
43
+ *
44
+ * @throws {ClientResponseError}
45
+ */
46
+ dryRunViewQuery(query: string, options?: CommonOptions): Promise<Array<LooseObject>>;
47
+ }
@@ -0,0 +1,20 @@
1
+ import { BaseService } from "./BaseService.js";
2
+ import { type CommonOptions } from "../tools/options.js";
3
+ export interface CronJob {
4
+ id: string;
5
+ expression: string;
6
+ }
7
+ export declare class CronService extends BaseService {
8
+ /**
9
+ * Returns list with all registered cron jobs.
10
+ *
11
+ * @throws {ClientResponseError}
12
+ */
13
+ getFullList(options?: CommonOptions): Promise<Array<CronJob>>;
14
+ /**
15
+ * Runs the specified cron job.
16
+ *
17
+ * @throws {ClientResponseError}
18
+ */
19
+ run(jobId: string, options?: CommonOptions): Promise<boolean>;
20
+ }
@@ -0,0 +1,85 @@
1
+ import type { LooseObject } from "../tools/loose.js";
2
+ import { BaseService } from "./BaseService.js";
3
+ import { type ListResult } from "../tools/dtos.js";
4
+ import { type CommonOptions, type ListOptions, type FullListOptions } from "../tools/options.js";
5
+ export declare abstract class CrudService<M> extends BaseService {
6
+ /**
7
+ * Base path for the crud actions (without trailing slash, eg. '/admins').
8
+ */
9
+ abstract get baseCrudPath(): string;
10
+ /**
11
+ * Response data decoder.
12
+ */
13
+ decode<T = M>(data: Record<string, unknown>): T;
14
+ /**
15
+ * Returns a promise with all list items batch fetched at once
16
+ * (by default 1000 items per request; to change it set the `batch` query param).
17
+ *
18
+ * You can use the generic T to supply a wrapper type of the crud model.
19
+ *
20
+ * @throws {ClientResponseError}
21
+ */
22
+ getFullList<T = M>(options?: FullListOptions): Promise<Array<T>>;
23
+ /**
24
+ * Legacy version of getFullList with explicitly specified batch size.
25
+ */
26
+ getFullList<T = M>(batch?: number, options?: ListOptions): Promise<Array<T>>;
27
+ /**
28
+ * Returns paginated items list.
29
+ *
30
+ * You can use the generic T to supply a wrapper type of the crud model.
31
+ *
32
+ * @throws {ClientResponseError}
33
+ */
34
+ getList<T = M>(page?: number, perPage?: number, options?: ListOptions): Promise<ListResult<T>>;
35
+ /**
36
+ * Returns the first found item by the specified filter.
37
+ *
38
+ * Internally it calls `getList(1, 1, { filter, skipTotal })` and
39
+ * returns the first found item.
40
+ *
41
+ * You can use the generic T to supply a wrapper type of the crud model.
42
+ *
43
+ * For consistency with `getOne`, this method will throw a 404
44
+ * ClientResponseError if no item was found.
45
+ *
46
+ * @throws {ClientResponseError}
47
+ */
48
+ getFirstListItem<T = M>(filter: string, options?: CommonOptions): Promise<T>;
49
+ /**
50
+ * Returns single item by its id.
51
+ *
52
+ * You can use the generic T to supply a wrapper type of the crud model.
53
+ *
54
+ * If `id` is empty it will throw a 404 error.
55
+ *
56
+ * @throws {ClientResponseError}
57
+ */
58
+ getOne<T = M>(id: string, options?: CommonOptions): Promise<T>;
59
+ /**
60
+ * Creates a new item.
61
+ *
62
+ * You can use the generic T to supply a wrapper type of the crud model.
63
+ *
64
+ * @throws {ClientResponseError}
65
+ */
66
+ create<T = M>(bodyParams?: LooseObject | FormData, options?: CommonOptions): Promise<T>;
67
+ /**
68
+ * Updates an existing item by its id.
69
+ *
70
+ * You can use the generic T to supply a wrapper type of the crud model.
71
+ *
72
+ * @throws {ClientResponseError}
73
+ */
74
+ update<T = M>(id: string, bodyParams?: LooseObject | FormData, options?: CommonOptions): Promise<T>;
75
+ /**
76
+ * Deletes an existing item by its id.
77
+ *
78
+ * @throws {ClientResponseError}
79
+ */
80
+ delete(id: string, options?: CommonOptions): Promise<boolean>;
81
+ /**
82
+ * Returns a promise with all list items batch fetched at once.
83
+ */
84
+ protected _getFullList<T = M>(batchSize?: number, options?: ListOptions): Promise<Array<T>>;
85
+ }
@@ -0,0 +1,19 @@
1
+ import type { LooseObject } from "../tools/loose.js";
2
+ import { BaseService } from "./BaseService.js";
3
+ import { type CommonOptions, type FileOptions } from "../tools/options.js";
4
+ export declare class FileService extends BaseService {
5
+ /**
6
+ * @deprecated Please replace with `pb.files.getURL()`.
7
+ */
8
+ getUrl(record: LooseObject, filename: string, queryParams?: FileOptions): string;
9
+ /**
10
+ * Builds and returns an absolute record file url for the provided filename.
11
+ */
12
+ getURL(record: LooseObject, filename: string, queryParams?: FileOptions): string;
13
+ /**
14
+ * Requests a new private file access token for the current auth model.
15
+ *
16
+ * @throws {ClientResponseError}
17
+ */
18
+ getToken(options?: CommonOptions): Promise<string>;
19
+ }
@@ -0,0 +1,16 @@
1
+ import type { LooseObject } from "../tools/loose.js";
2
+ import { BaseService } from "./BaseService.js";
3
+ import { type CommonOptions } from "../tools/options.js";
4
+ export interface HealthCheckResponse {
5
+ code: number;
6
+ message: string;
7
+ data: LooseObject;
8
+ }
9
+ export declare class HealthService extends BaseService {
10
+ /**
11
+ * Checks the health status of the api.
12
+ *
13
+ * @throws {ClientResponseError}
14
+ */
15
+ check(options?: CommonOptions): Promise<HealthCheckResponse>;
16
+ }
@@ -0,0 +1,35 @@
1
+ import { BaseService } from "./BaseService.js";
2
+ import { type ListResult, type LogModel } from "../tools/dtos.js";
3
+ import { type CommonOptions, type ListOptions, type LogStatsOptions } from "../tools/options.js";
4
+ export interface HourlyStats {
5
+ total: number;
6
+ date: string;
7
+ }
8
+ export declare class LogService extends BaseService {
9
+ /**
10
+ * Returns paginated logs list.
11
+ *
12
+ * @throws {ClientResponseError}
13
+ */
14
+ getList(page?: number, perPage?: number, options?: ListOptions): Promise<ListResult<LogModel>>;
15
+ /**
16
+ * Returns a single log by its id.
17
+ *
18
+ * If `id` is empty it will throw a 404 error.
19
+ *
20
+ * @throws {ClientResponseError}
21
+ */
22
+ getOne(id: string, options?: CommonOptions): Promise<LogModel>;
23
+ /**
24
+ * Returns logs statistics.
25
+ *
26
+ * @throws {ClientResponseError}
27
+ */
28
+ getStats(options?: LogStatsOptions): Promise<Array<HourlyStats>>;
29
+ /**
30
+ * Deletes all logs.
31
+ *
32
+ * @throws {ClientResponseError}
33
+ */
34
+ truncate(options?: CommonOptions): Promise<true>;
35
+ }