@picobase_app/client 0.2.0 → 0.5.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.
package/README.md CHANGED
@@ -8,7 +8,7 @@ TypeScript SDK for PicoBase — add auth, database, realtime, and file storage t
8
8
  npm install @picobase_app/client
9
9
  ```
10
10
 
11
- > ⚠️ **Important:** Install `@picobase_app/client`, **NOT** `pocketbase` directly. PicoBase wraps PocketBase with managed hosting features. If you accidentally installed `pocketbase`, remove it from your dependencies.
11
+ > ⚠️ **Important:** Always install `@picobase_app/client`. If you accidentally installed `pocketbase`, remove it that's an internal dependency, not the user-facing SDK.
12
12
 
13
13
  ## Quickstart
14
14
 
@@ -178,11 +178,11 @@ const results = await pb.rpc('search_products', {
178
178
  })
179
179
  ```
180
180
 
181
- RPC calls are mapped to custom PocketBase endpoints at `/api/rpc/{functionName}`. You'll need to implement these routes in your PocketBase instance. See the [PocketBase routing docs](https://pocketbase.io/docs/js-routing/) for details.
181
+ RPC calls are mapped to custom endpoints at `/api/rpc/{functionName}`. You can implement these routes in your PicoBase instance.
182
182
 
183
183
  ## File Storage
184
184
 
185
- PocketBase stores files as fields on records. Use the storage module to get URLs.
185
+ PicoBase stores files as fields on records. Use the storage module to get URLs.
186
186
 
187
187
  ```typescript
188
188
  const user = await pb.collection('users').getOne('USER_ID')
@@ -208,12 +208,12 @@ pb.auth.setCollection('members')
208
208
  await pb.auth.signIn({ email: 'member@example.com', password: 'pass' })
209
209
  ```
210
210
 
211
- ### Raw PocketBase access
211
+ ### Raw access (advanced)
212
212
 
213
- The underlying PocketBase SDK instance is exposed for advanced use cases.
213
+ The underlying client instance is exposed for advanced use cases.
214
214
 
215
215
  ```typescript
216
- // Access the PocketBase client directly
216
+ // Access the internal client directly
217
217
  const health = await pb.pb.health.check()
218
218
 
219
219
  // Custom API endpoint
@@ -299,4 +299,4 @@ result.items[0].title // string — fully typed!
299
299
  | `pb.collection(name)` | `PicoBaseCollection` | CRUD operations on a collection |
300
300
  | `pb.realtime` | `PicoBaseRealtime` | Realtime subscriptions |
301
301
  | `pb.storage` | `PicoBaseStorage` | File URLs and tokens |
302
- | `pb.pb` | `PocketBase` | Underlying PocketBase SDK instance |
302
+ | `pb.pb` | `PocketBase` | Underlying internal client instance |
package/dist/index.d.mts CHANGED
@@ -57,6 +57,33 @@ interface FileOptions {
57
57
  token?: string;
58
58
  download?: boolean;
59
59
  }
60
+ type CollectionType = 'base' | 'auth' | 'view';
61
+ interface CollectionModel {
62
+ id: string;
63
+ created: string;
64
+ updated: string;
65
+ name: string;
66
+ type: CollectionType;
67
+ system: boolean;
68
+ schema: SchemaField[];
69
+ indexes: string[];
70
+ listRule: string | null;
71
+ viewRule: string | null;
72
+ createRule: string | null;
73
+ updateRule: string | null;
74
+ deleteRule: string | null;
75
+ options: Record<string, unknown>;
76
+ }
77
+ interface SchemaField {
78
+ system: boolean;
79
+ id: string;
80
+ name: string;
81
+ type: string;
82
+ required: boolean;
83
+ presentable: boolean;
84
+ unique: boolean;
85
+ options: Record<string, unknown>;
86
+ }
60
87
 
61
88
  /**
62
89
  * Auth module — handles user sign-up, sign-in, OAuth, and session management.
@@ -384,6 +411,31 @@ declare class PicoBaseStorage {
384
411
  getFileToken(): Promise<string>;
385
412
  }
386
413
 
414
+ declare class PicoBaseAdmin {
415
+ private pb;
416
+ constructor(pb: PocketBase);
417
+ /**
418
+ * Fetch a list of all collections.
419
+ */
420
+ listCollections(): Promise<CollectionModel[]>;
421
+ /**
422
+ * Fetch a single collection by ID or name.
423
+ */
424
+ getCollection(idOrName: string): Promise<CollectionModel>;
425
+ /**
426
+ * Create a new collection.
427
+ */
428
+ createCollection(data: Partial<CollectionModel>): Promise<CollectionModel>;
429
+ /**
430
+ * Update an existing collection.
431
+ */
432
+ updateCollection(idOrName: string, data: Partial<CollectionModel>): Promise<CollectionModel>;
433
+ /**
434
+ * Delete a collection.
435
+ */
436
+ deleteCollection(idOrName: string): Promise<boolean>;
437
+ }
438
+
387
439
  declare class PicoBaseClient {
388
440
  /** The underlying PocketBase SDK instance. Exposed for advanced usage. */
389
441
  readonly pb: PocketBase;
@@ -393,6 +445,8 @@ declare class PicoBaseClient {
393
445
  readonly realtime: PicoBaseRealtime;
394
446
  /** Storage module — get file URLs and tokens. */
395
447
  readonly storage: PicoBaseStorage;
448
+ /** Admin module — manage collections (requires admin API key). */
449
+ readonly admin: PicoBaseAdmin;
396
450
  private readonly apiKey;
397
451
  private readonly options;
398
452
  constructor(url: string, apiKey: string, options?: PicoBaseClientOptions);
@@ -548,4 +602,4 @@ declare class RpcError extends PicoBaseError {
548
602
  constructor(functionName: string, status: number, details?: unknown);
549
603
  }
550
604
 
551
- export { type AuthEvent, type AuthResponse, type AuthStateChange, type AuthStateChangeCallback, AuthorizationError, CollectionNotFoundError, ConfigurationError, type FileOptions, InstanceUnavailableError, type ListOptions, type OAuthSignInOptions, PicoBaseAuth, PicoBaseClient, type PicoBaseClientOptions, PicoBaseCollection, PicoBaseError, PicoBaseRealtime, PicoBaseStorage, type RealtimeAction, type RealtimeCallback, RecordNotFoundError, type RecordQueryOptions, RequestError, RpcError, type SignInOptions, type SignUpOptions, type UnsubscribeFunc, createClient };
605
+ export { type AuthEvent, type AuthResponse, type AuthStateChange, type AuthStateChangeCallback, AuthorizationError, CollectionNotFoundError, ConfigurationError, type FileOptions, InstanceUnavailableError, type ListOptions, type OAuthSignInOptions, PicoBaseAdmin, PicoBaseAuth, PicoBaseClient, type PicoBaseClientOptions, PicoBaseCollection, PicoBaseError, PicoBaseRealtime, PicoBaseStorage, type RealtimeAction, type RealtimeCallback, RecordNotFoundError, type RecordQueryOptions, RequestError, RpcError, type SignInOptions, type SignUpOptions, type UnsubscribeFunc, createClient };
package/dist/index.d.ts CHANGED
@@ -57,6 +57,33 @@ interface FileOptions {
57
57
  token?: string;
58
58
  download?: boolean;
59
59
  }
60
+ type CollectionType = 'base' | 'auth' | 'view';
61
+ interface CollectionModel {
62
+ id: string;
63
+ created: string;
64
+ updated: string;
65
+ name: string;
66
+ type: CollectionType;
67
+ system: boolean;
68
+ schema: SchemaField[];
69
+ indexes: string[];
70
+ listRule: string | null;
71
+ viewRule: string | null;
72
+ createRule: string | null;
73
+ updateRule: string | null;
74
+ deleteRule: string | null;
75
+ options: Record<string, unknown>;
76
+ }
77
+ interface SchemaField {
78
+ system: boolean;
79
+ id: string;
80
+ name: string;
81
+ type: string;
82
+ required: boolean;
83
+ presentable: boolean;
84
+ unique: boolean;
85
+ options: Record<string, unknown>;
86
+ }
60
87
 
61
88
  /**
62
89
  * Auth module — handles user sign-up, sign-in, OAuth, and session management.
@@ -384,6 +411,31 @@ declare class PicoBaseStorage {
384
411
  getFileToken(): Promise<string>;
385
412
  }
386
413
 
414
+ declare class PicoBaseAdmin {
415
+ private pb;
416
+ constructor(pb: PocketBase);
417
+ /**
418
+ * Fetch a list of all collections.
419
+ */
420
+ listCollections(): Promise<CollectionModel[]>;
421
+ /**
422
+ * Fetch a single collection by ID or name.
423
+ */
424
+ getCollection(idOrName: string): Promise<CollectionModel>;
425
+ /**
426
+ * Create a new collection.
427
+ */
428
+ createCollection(data: Partial<CollectionModel>): Promise<CollectionModel>;
429
+ /**
430
+ * Update an existing collection.
431
+ */
432
+ updateCollection(idOrName: string, data: Partial<CollectionModel>): Promise<CollectionModel>;
433
+ /**
434
+ * Delete a collection.
435
+ */
436
+ deleteCollection(idOrName: string): Promise<boolean>;
437
+ }
438
+
387
439
  declare class PicoBaseClient {
388
440
  /** The underlying PocketBase SDK instance. Exposed for advanced usage. */
389
441
  readonly pb: PocketBase;
@@ -393,6 +445,8 @@ declare class PicoBaseClient {
393
445
  readonly realtime: PicoBaseRealtime;
394
446
  /** Storage module — get file URLs and tokens. */
395
447
  readonly storage: PicoBaseStorage;
448
+ /** Admin module — manage collections (requires admin API key). */
449
+ readonly admin: PicoBaseAdmin;
396
450
  private readonly apiKey;
397
451
  private readonly options;
398
452
  constructor(url: string, apiKey: string, options?: PicoBaseClientOptions);
@@ -548,4 +602,4 @@ declare class RpcError extends PicoBaseError {
548
602
  constructor(functionName: string, status: number, details?: unknown);
549
603
  }
550
604
 
551
- export { type AuthEvent, type AuthResponse, type AuthStateChange, type AuthStateChangeCallback, AuthorizationError, CollectionNotFoundError, ConfigurationError, type FileOptions, InstanceUnavailableError, type ListOptions, type OAuthSignInOptions, PicoBaseAuth, PicoBaseClient, type PicoBaseClientOptions, PicoBaseCollection, PicoBaseError, PicoBaseRealtime, PicoBaseStorage, type RealtimeAction, type RealtimeCallback, RecordNotFoundError, type RecordQueryOptions, RequestError, RpcError, type SignInOptions, type SignUpOptions, type UnsubscribeFunc, createClient };
605
+ export { type AuthEvent, type AuthResponse, type AuthStateChange, type AuthStateChangeCallback, AuthorizationError, CollectionNotFoundError, ConfigurationError, type FileOptions, InstanceUnavailableError, type ListOptions, type OAuthSignInOptions, PicoBaseAdmin, PicoBaseAuth, PicoBaseClient, type PicoBaseClientOptions, PicoBaseCollection, PicoBaseError, PicoBaseRealtime, PicoBaseStorage, type RealtimeAction, type RealtimeCallback, RecordNotFoundError, type RecordQueryOptions, RequestError, RpcError, type SignInOptions, type SignUpOptions, type UnsubscribeFunc, createClient };