@objectstack/client 4.0.4 → 4.0.5
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/dist/index.d.mts +864 -5
- package/dist/index.d.ts +864 -5
- package/dist/index.js +1267 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1265 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +38 -13
- package/.turbo/turbo-build.log +0 -22
- package/CHANGELOG.md +0 -645
- package/CLIENT_SERVER_INTEGRATION_TESTS.md +0 -939
- package/CLIENT_SPEC_COMPLIANCE.md +0 -361
- package/src/client.feed.test.ts +0 -273
- package/src/client.hono.test.ts +0 -169
- package/src/client.msw.test.ts +0 -223
- package/src/client.test.ts +0 -891
- package/src/index.ts +0 -1889
- package/src/query-builder.ts +0 -337
- package/src/realtime-api.ts +0 -208
- package/tests/integration/01-discovery.test.ts +0 -68
- package/tests/integration/README.md +0 -72
- package/tsconfig.json +0 -11
- package/vitest.config.ts +0 -13
- package/vitest.integration.config.ts +0 -18
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FilterCondition, QueryAST, SortNode, AggregationNode } from '@objectstack/spec/data';
|
|
2
|
-
import { MetadataEvent, DataEvent, ApiRoutes, GetDiscoveryResponse, WellKnownCapabilities, GetMetaTypesResponse, GetMetaItemsResponse, MetadataCacheRequest, MetadataCacheResponse, LoginRequest, SessionResponse, RegisterRequest, FileUploadResponse, GetPresignedUrlRequest, PresignedUrlResponse, InitiateChunkedUploadRequest, InitiateChunkedUploadResponse, UploadChunkResponse, CompleteChunkedUploadRequest, CompleteChunkedUploadResponse, CheckPermissionRequest, CheckPermissionResponse, GetObjectPermissionsResponse, GetEffectivePermissionsResponse, RealtimeConnectRequest, RealtimeConnectResponse, RealtimeSubscribeRequest, RealtimeSubscribeResponse, SetPresenceRequest, GetPresenceResponse, GetWorkflowConfigResponse, GetWorkflowStateResponse, WorkflowTransitionRequest, WorkflowTransitionResponse, WorkflowApproveRequest, WorkflowApproveResponse, WorkflowRejectRequest, WorkflowRejectResponse, ListViewsResponse, GetViewResponse, CreateViewRequest, CreateViewResponse, UpdateViewRequest, UpdateViewResponse, DeleteViewResponse, RegisterDeviceRequest, RegisterDeviceResponse, UnregisterDeviceResponse, GetNotificationPreferencesResponse, UpdateNotificationPreferencesRequest, UpdateNotificationPreferencesResponse, ListNotificationsResponse, MarkNotificationsReadResponse, MarkAllNotificationsReadResponse, AiNlqRequest, AiNlqResponse, AiSuggestRequest, AiSuggestResponse, AiInsightsRequest, AiInsightsResponse, GetLocalesResponse, GetTranslationsResponse, GetFieldLabelsResponse, GetFeedResponse, CreateFeedItemResponse, UpdateFeedItemResponse, DeleteFeedItemResponse, AddReactionResponse, RemoveReactionResponse, PinFeedItemResponse, UnpinFeedItemResponse, StarFeedItemResponse, UnstarFeedItemResponse, SearchFeedResponse, GetChangelogResponse, SubscribeResponse, UnsubscribeResponse,
|
|
2
|
+
import { MetadataEvent, DataEvent, ApiRoutes, GetDiscoveryResponse, WellKnownCapabilities, GetMetaTypesResponse, GetMetaItemsResponse, MetadataCacheRequest, MetadataCacheResponse, BatchUpdateRequest, BatchUpdateResponse, BatchOptions, LoginRequest, SessionResponse, RegisterRequest, FileUploadResponse, GetPresignedUrlRequest, PresignedUrlResponse, InitiateChunkedUploadRequest, InitiateChunkedUploadResponse, UploadChunkResponse, CompleteChunkedUploadRequest, CompleteChunkedUploadResponse, CheckPermissionRequest, CheckPermissionResponse, GetObjectPermissionsResponse, GetEffectivePermissionsResponse, RealtimeConnectRequest, RealtimeConnectResponse, RealtimeSubscribeRequest, RealtimeSubscribeResponse, SetPresenceRequest, GetPresenceResponse, GetWorkflowConfigResponse, GetWorkflowStateResponse, WorkflowTransitionRequest, WorkflowTransitionResponse, WorkflowApproveRequest, WorkflowApproveResponse, WorkflowRejectRequest, WorkflowRejectResponse, ListViewsResponse, GetViewResponse, CreateViewRequest, CreateViewResponse, UpdateViewRequest, UpdateViewResponse, DeleteViewResponse, RegisterDeviceRequest, RegisterDeviceResponse, UnregisterDeviceResponse, GetNotificationPreferencesResponse, UpdateNotificationPreferencesRequest, UpdateNotificationPreferencesResponse, ListNotificationsResponse, MarkNotificationsReadResponse, MarkAllNotificationsReadResponse, AiNlqRequest, AiNlqResponse, AiSuggestRequest, AiSuggestResponse, AiInsightsRequest, AiInsightsResponse, GetLocalesResponse, GetTranslationsResponse, GetFieldLabelsResponse, GetFeedResponse, CreateFeedItemResponse, UpdateFeedItemResponse, DeleteFeedItemResponse, AddReactionResponse, RemoveReactionResponse, PinFeedItemResponse, UnpinFeedItemResponse, StarFeedItemResponse, UnstarFeedItemResponse, SearchFeedResponse, GetChangelogResponse, SubscribeResponse, UnsubscribeResponse, StandardErrorCode, ErrorCategory } from '@objectstack/spec/api';
|
|
3
3
|
export { AddReactionResponse, AiInsightsRequest, AiInsightsResponse, AiNlqRequest, AiNlqResponse, AiSuggestRequest, AiSuggestResponse, AuthFeaturesConfig, AuthProviderInfo, BatchOperationResult, BatchOptions, BatchRecord, BatchUpdateRequest, BatchUpdateResponse, CheckPermissionRequest, CheckPermissionResponse, CreateFeedItemResponse, CreateViewResponse, DeleteFeedItemResponse, DeleteManyRequest, DeleteViewResponse, EmailPasswordConfigPublic, ErrorCategory, GetAuthConfigResponse, GetChangelogResponse, GetDiscoveryResponse, GetEffectivePermissionsResponse, GetFeedResponse, GetFieldLabelsResponse, GetLocalesResponse, GetMetaItemsResponse, GetMetaTypesResponse, GetObjectPermissionsResponse, GetPresenceResponse, GetTranslationsResponse, GetViewResponse, GetWorkflowConfigResponse, GetWorkflowStateResponse, ListNotificationsResponse, ListViewsResponse, MetadataCacheRequest, MetadataCacheResponse, PinFeedItemResponse, RealtimeConnectRequest, RealtimeConnectResponse, RealtimeSubscribeRequest, RealtimeSubscribeResponse, RefreshTokenRequest, RegisterDeviceRequest, RegisterDeviceResponse, RegisterRequest, RemoveReactionResponse, SearchFeedResponse, StandardErrorCode, StarFeedItemResponse, SubscribeResponse, UnpinFeedItemResponse, UnstarFeedItemResponse, UnsubscribeResponse, UpdateFeedItemResponse, UpdateManyRequest, UpdateViewResponse, WellKnownCapabilities, WorkflowApproveRequest, WorkflowApproveResponse, WorkflowRejectRequest, WorkflowRejectResponse, WorkflowTransitionRequest, WorkflowTransitionResponse } from '@objectstack/spec/api';
|
|
4
|
-
import { Logger } from '@objectstack/core';
|
|
4
|
+
import { Logger } from '@objectstack/core/logger';
|
|
5
5
|
import { RealtimeEventPayload } from '@objectstack/spec/contracts';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -263,6 +263,14 @@ interface ClientConfig {
|
|
|
263
263
|
* Enable debug logging
|
|
264
264
|
*/
|
|
265
265
|
debug?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Active project id (UUID of `sys_project`). When present, the
|
|
268
|
+
* client injects an `X-Project-Id` header on every request so the
|
|
269
|
+
* server's tenant router can resolve the physical data-plane database.
|
|
270
|
+
*
|
|
271
|
+
* @see docs/adr/0002-project-database-isolation.md
|
|
272
|
+
*/
|
|
273
|
+
projectId?: string;
|
|
266
274
|
}
|
|
267
275
|
/**
|
|
268
276
|
* Discovery Result
|
|
@@ -366,6 +374,7 @@ interface StandardError {
|
|
|
366
374
|
declare class ObjectStackClient {
|
|
367
375
|
private baseUrl;
|
|
368
376
|
private token?;
|
|
377
|
+
private projectId?;
|
|
369
378
|
private fetchImpl;
|
|
370
379
|
private discoveryInfo?;
|
|
371
380
|
private logger;
|
|
@@ -377,7 +386,7 @@ declare class ObjectStackClient {
|
|
|
377
386
|
connect(): Promise<{
|
|
378
387
|
version: string;
|
|
379
388
|
name?: string | undefined;
|
|
380
|
-
environment?: "
|
|
389
|
+
environment?: "production" | "sandbox" | "development" | undefined;
|
|
381
390
|
routes?: {
|
|
382
391
|
data: string;
|
|
383
392
|
metadata: string;
|
|
@@ -403,7 +412,7 @@ declare class ObjectStackClient {
|
|
|
403
412
|
} | undefined;
|
|
404
413
|
services?: Record<string, {
|
|
405
414
|
enabled: boolean;
|
|
406
|
-
status: "
|
|
415
|
+
status: "available" | "registered" | "unavailable" | "degraded" | "stub";
|
|
407
416
|
handlerReady?: boolean | undefined;
|
|
408
417
|
route?: string | undefined;
|
|
409
418
|
provider?: string | undefined;
|
|
@@ -564,6 +573,538 @@ declare class ObjectStackClient {
|
|
|
564
573
|
message?: string;
|
|
565
574
|
}>;
|
|
566
575
|
};
|
|
576
|
+
/**
|
|
577
|
+
* Environment Management Services
|
|
578
|
+
*
|
|
579
|
+
* Environments are the v4.1+ isolation primitive — each project owns a
|
|
580
|
+
* physically separate data-plane database. All Studio-level switching goes
|
|
581
|
+
* through this API.
|
|
582
|
+
*
|
|
583
|
+
* Endpoints:
|
|
584
|
+
* - GET /api/v1/cloud/projects → list environments
|
|
585
|
+
* - GET /api/v1/cloud/projects/:id → get one (with database info)
|
|
586
|
+
* - POST /api/v1/cloud/projects → provision a new project
|
|
587
|
+
* - PATCH /api/v1/cloud/projects/:id → update (displayName, plan, status, …)
|
|
588
|
+
* - POST /api/v1/cloud/projects/:id/activate → set as session's active project
|
|
589
|
+
* - POST /api/v1/cloud/projects/:id/credentials/rotate → rotate credential
|
|
590
|
+
*
|
|
591
|
+
* @see docs/adr/0002-project-database-isolation.md
|
|
592
|
+
*/
|
|
593
|
+
projects: {
|
|
594
|
+
/**
|
|
595
|
+
* List environments visible to the current session. Optionally filter
|
|
596
|
+
* by organization (control-plane query — not routed through a data-plane DB).
|
|
597
|
+
*/
|
|
598
|
+
list: (filters?: {
|
|
599
|
+
organization_id?: string;
|
|
600
|
+
env_type?: string;
|
|
601
|
+
status?: string;
|
|
602
|
+
}) => Promise<{
|
|
603
|
+
projects: any[];
|
|
604
|
+
total: number;
|
|
605
|
+
}>;
|
|
606
|
+
/**
|
|
607
|
+
* Get a single project (joined with its database and membership row).
|
|
608
|
+
*/
|
|
609
|
+
get: (id: string) => Promise<{
|
|
610
|
+
project: any;
|
|
611
|
+
database?: any;
|
|
612
|
+
credential?: any;
|
|
613
|
+
membership?: any;
|
|
614
|
+
organization?: any;
|
|
615
|
+
}>;
|
|
616
|
+
/**
|
|
617
|
+
* Provision a new project. Delegates to
|
|
618
|
+
* `ProjectProvisioningService.provisionProject` on the server.
|
|
619
|
+
*/
|
|
620
|
+
create: (req: {
|
|
621
|
+
organization_id: string;
|
|
622
|
+
slug?: string;
|
|
623
|
+
display_name: string;
|
|
624
|
+
env_type?: string;
|
|
625
|
+
project_type?: string;
|
|
626
|
+
plan?: string;
|
|
627
|
+
region?: string;
|
|
628
|
+
driver?: string;
|
|
629
|
+
is_default?: boolean;
|
|
630
|
+
is_system?: boolean;
|
|
631
|
+
storage_limit_mb?: number;
|
|
632
|
+
clone_from_project_id?: string;
|
|
633
|
+
template_id?: string;
|
|
634
|
+
metadata?: Record<string, unknown>;
|
|
635
|
+
}) => Promise<{
|
|
636
|
+
project: any;
|
|
637
|
+
database: any;
|
|
638
|
+
}>;
|
|
639
|
+
/**
|
|
640
|
+
* Update a project (display_name, plan, status, is_default, metadata).
|
|
641
|
+
*/
|
|
642
|
+
update: (id: string, patch: Record<string, unknown>) => Promise<{
|
|
643
|
+
project: any;
|
|
644
|
+
}>;
|
|
645
|
+
/**
|
|
646
|
+
* Cascade-delete a project: cleans up credential/member/package_installation
|
|
647
|
+
* rows, releases the physical database via the provisioning adapter, and
|
|
648
|
+
* removes the `sys_project` row. Default projects require `force: true`.
|
|
649
|
+
*/
|
|
650
|
+
delete: (id: string, opts?: {
|
|
651
|
+
force?: boolean;
|
|
652
|
+
}) => Promise<{
|
|
653
|
+
deleted: boolean;
|
|
654
|
+
projectId: string;
|
|
655
|
+
warnings: string[];
|
|
656
|
+
}>;
|
|
657
|
+
/**
|
|
658
|
+
* Activate this project for the current session. The server writes
|
|
659
|
+
* `active_environment_id` on the better-auth session; subsequent requests
|
|
660
|
+
* are routed to this project's database.
|
|
661
|
+
*/
|
|
662
|
+
activate: (id: string) => Promise<{
|
|
663
|
+
project: any;
|
|
664
|
+
sessionUpdated: boolean;
|
|
665
|
+
}>;
|
|
666
|
+
/**
|
|
667
|
+
* Rotate the active database credential for this project.
|
|
668
|
+
*/
|
|
669
|
+
rotateCredential: (id: string, plaintext: string) => Promise<{
|
|
670
|
+
credential: any;
|
|
671
|
+
}>;
|
|
672
|
+
/**
|
|
673
|
+
* Update the hostname bound to this project. Validates format and
|
|
674
|
+
* uniqueness server-side; invalidates the dispatcher's routing cache.
|
|
675
|
+
*/
|
|
676
|
+
updateHostname: (id: string, hostname: string) => Promise<{
|
|
677
|
+
project: any;
|
|
678
|
+
}>;
|
|
679
|
+
/**
|
|
680
|
+
* Retry provisioning for a project stuck in `failed` (or
|
|
681
|
+
* `provisioning`) state. The server re-runs the driver handshake; on
|
|
682
|
+
* success the project flips to `active`, on failure it stays
|
|
683
|
+
* `failed` with `metadata.provisioningError` updated.
|
|
684
|
+
*/
|
|
685
|
+
retryProvisioning: (id: string) => Promise<{
|
|
686
|
+
project: any;
|
|
687
|
+
}>;
|
|
688
|
+
/**
|
|
689
|
+
* List members of a project (per-project RBAC).
|
|
690
|
+
*/
|
|
691
|
+
listMembers: (id: string) => Promise<{
|
|
692
|
+
members: any[];
|
|
693
|
+
}>;
|
|
694
|
+
/**
|
|
695
|
+
* List ObjectQL drivers registered on the server. Useful for populating a
|
|
696
|
+
* driver selector when provisioning a new project (memory / turso /
|
|
697
|
+
* future sql drivers). Returned `name` is the short alias (e.g. `memory`,
|
|
698
|
+
* `turso`); `driverId` is the full FQN (e.g. `com.objectstack.driver.memory`).
|
|
699
|
+
*/
|
|
700
|
+
listDrivers: () => Promise<{
|
|
701
|
+
drivers: Array<{
|
|
702
|
+
name: string;
|
|
703
|
+
driverId: string;
|
|
704
|
+
}>;
|
|
705
|
+
total: number;
|
|
706
|
+
}>;
|
|
707
|
+
/**
|
|
708
|
+
* List available project templates. Templates are seeded into the project
|
|
709
|
+
* database once at provisioning time when `template_id` is supplied.
|
|
710
|
+
*/
|
|
711
|
+
listTemplates: () => Promise<{
|
|
712
|
+
templates: Array<{
|
|
713
|
+
id: string;
|
|
714
|
+
label: string;
|
|
715
|
+
description: string;
|
|
716
|
+
category?: string;
|
|
717
|
+
}>;
|
|
718
|
+
total: number;
|
|
719
|
+
}>;
|
|
720
|
+
/**
|
|
721
|
+
* Per-project package installation management (Power Apps "solution" model).
|
|
722
|
+
* Install records are stored in the environment's own database.
|
|
723
|
+
*/
|
|
724
|
+
packages: {
|
|
725
|
+
/** List all packages installed in a specific project. */
|
|
726
|
+
list: (envId: string) => Promise<{
|
|
727
|
+
packages: any[];
|
|
728
|
+
total: number;
|
|
729
|
+
}>;
|
|
730
|
+
/** Install a package into the project. */
|
|
731
|
+
install: (envId: string, body: {
|
|
732
|
+
packageId: string;
|
|
733
|
+
version?: string;
|
|
734
|
+
settings?: Record<string, unknown>;
|
|
735
|
+
enableOnInstall?: boolean;
|
|
736
|
+
}) => Promise<{
|
|
737
|
+
package: any;
|
|
738
|
+
}>;
|
|
739
|
+
/** Get a single installation record. */
|
|
740
|
+
get: (envId: string, pkgId: string) => Promise<{
|
|
741
|
+
package: any;
|
|
742
|
+
}>;
|
|
743
|
+
/** Enable a previously disabled package. */
|
|
744
|
+
enable: (envId: string, pkgId: string) => Promise<{
|
|
745
|
+
package: any;
|
|
746
|
+
}>;
|
|
747
|
+
/** Disable an installed package (metadata will not be loaded). */
|
|
748
|
+
disable: (envId: string, pkgId: string) => Promise<{
|
|
749
|
+
package: any;
|
|
750
|
+
}>;
|
|
751
|
+
/** Uninstall a package from the project. Forbidden for scope=platform packages. */
|
|
752
|
+
uninstall: (envId: string, pkgId: string) => Promise<{
|
|
753
|
+
id: string;
|
|
754
|
+
success: boolean;
|
|
755
|
+
}>;
|
|
756
|
+
/** Upgrade an installed package to a newer version. */
|
|
757
|
+
upgrade: (envId: string, pkgId: string, targetVersion?: string) => Promise<{
|
|
758
|
+
package: any;
|
|
759
|
+
}>;
|
|
760
|
+
};
|
|
761
|
+
};
|
|
762
|
+
/**
|
|
763
|
+
* Project-scoped client factory.
|
|
764
|
+
*
|
|
765
|
+
* Returns a thin wrapper around the data / meta / packages namespaces that
|
|
766
|
+
* prefixes every request with `/api/v1/projects/:projectId/...`. Use this
|
|
767
|
+
* when the server has `enableProjectScoping: true` in its REST API config.
|
|
768
|
+
*
|
|
769
|
+
* Backward compatibility: `client.data.*`, `client.meta.*`, and
|
|
770
|
+
* `client.packages.*` continue to work unchanged; they hit unscoped routes
|
|
771
|
+
* and rely on hostname / `X-Project-Id` header / session resolution.
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
* ```ts
|
|
775
|
+
* const scoped = client.project('00000000-0000-0000-0000-000000000001');
|
|
776
|
+
* const tasks = await scoped.data.find('task', { top: 10 });
|
|
777
|
+
* const objects = await scoped.meta.getItems('object');
|
|
778
|
+
* ```
|
|
779
|
+
*/
|
|
780
|
+
project(projectId: string): ScopedProjectClient;
|
|
781
|
+
/** @internal */
|
|
782
|
+
_baseUrl(): string;
|
|
783
|
+
/** @internal */
|
|
784
|
+
_fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
785
|
+
/** @internal */
|
|
786
|
+
_unwrap<T>(res: Response): Promise<T>;
|
|
787
|
+
/** @internal */
|
|
788
|
+
_isFilterAST(v: unknown): boolean;
|
|
789
|
+
/**
|
|
790
|
+
* Organization Services
|
|
791
|
+
*
|
|
792
|
+
* Thin wrapper around better-auth's organization plugin endpoints, which
|
|
793
|
+
* are mounted under `/api/v1/auth/organization/**`. Used by the Studio
|
|
794
|
+
* OrganizationSwitcher and the /orgs management routes.
|
|
795
|
+
*/
|
|
796
|
+
organizations: {
|
|
797
|
+
/**
|
|
798
|
+
* List organizations the current user belongs to.
|
|
799
|
+
* GET /api/v1/auth/organization/list
|
|
800
|
+
*/
|
|
801
|
+
list: () => Promise<{
|
|
802
|
+
organizations: Array<{
|
|
803
|
+
id: string;
|
|
804
|
+
name: string;
|
|
805
|
+
slug?: string;
|
|
806
|
+
logo?: string;
|
|
807
|
+
metadata?: any;
|
|
808
|
+
}>;
|
|
809
|
+
}>;
|
|
810
|
+
/**
|
|
811
|
+
* Create a new organization.
|
|
812
|
+
* POST /api/v1/auth/organization/create
|
|
813
|
+
*/
|
|
814
|
+
create: (req: {
|
|
815
|
+
name: string;
|
|
816
|
+
slug?: string;
|
|
817
|
+
logo?: string;
|
|
818
|
+
metadata?: Record<string, unknown>;
|
|
819
|
+
}) => Promise<any>;
|
|
820
|
+
/**
|
|
821
|
+
* Update an existing organization.
|
|
822
|
+
* POST /api/v1/auth/organization/update
|
|
823
|
+
*
|
|
824
|
+
* better-auth requires the caller to be an owner/admin (server-side
|
|
825
|
+
* enforcement); the body shape is `{ organizationId, data: {...} }`.
|
|
826
|
+
*/
|
|
827
|
+
update: (organizationId: string, data: {
|
|
828
|
+
name?: string;
|
|
829
|
+
slug?: string;
|
|
830
|
+
logo?: string;
|
|
831
|
+
metadata?: Record<string, unknown>;
|
|
832
|
+
}) => Promise<any>;
|
|
833
|
+
/**
|
|
834
|
+
* Set the active organization on the current session. The server writes
|
|
835
|
+
* `activeOrganizationId` on the better-auth session, which downstream
|
|
836
|
+
* handlers (e.g. `EnvironmentProvisioningService`) consult.
|
|
837
|
+
*
|
|
838
|
+
* POST /api/v1/auth/organization/set-active
|
|
839
|
+
*/
|
|
840
|
+
setActive: (organizationId: string) => Promise<any>;
|
|
841
|
+
/**
|
|
842
|
+
* Get full organization detail (members, invitations, teams).
|
|
843
|
+
* GET /api/v1/auth/organization/get-full-organization?organizationId=...
|
|
844
|
+
*/
|
|
845
|
+
get: (organizationId: string) => Promise<any>;
|
|
846
|
+
/**
|
|
847
|
+
* List members of an organization.
|
|
848
|
+
*/
|
|
849
|
+
listMembers: (organizationId: string) => Promise<any>;
|
|
850
|
+
/**
|
|
851
|
+
* Invite a user to the organization.
|
|
852
|
+
*/
|
|
853
|
+
invite: (req: {
|
|
854
|
+
email: string;
|
|
855
|
+
role?: string;
|
|
856
|
+
organizationId?: string;
|
|
857
|
+
}) => Promise<any>;
|
|
858
|
+
/**
|
|
859
|
+
* Leave the given organization.
|
|
860
|
+
*/
|
|
861
|
+
leave: (organizationId: string) => Promise<any>;
|
|
862
|
+
/**
|
|
863
|
+
* Delete an organization via better-auth's organization plugin.
|
|
864
|
+
*
|
|
865
|
+
* POST /api/v1/auth/organization/delete
|
|
866
|
+
*
|
|
867
|
+
* better-auth removes the organization row, all members, and all
|
|
868
|
+
* pending invitations. Project teardown (per-project DBs, etc.) is
|
|
869
|
+
* handled server-side by hooks attached to the organization plugin.
|
|
870
|
+
*/
|
|
871
|
+
delete: (organizationId: string) => Promise<any>;
|
|
872
|
+
/**
|
|
873
|
+
* Remove a member from an organization.
|
|
874
|
+
*
|
|
875
|
+
* better-auth: POST /organization/remove-member
|
|
876
|
+
* Body: `{ memberIdOrEmail, organizationId? }` — note the parameter is the
|
|
877
|
+
* **member id** (the row id from `member` table) or the user's email; it
|
|
878
|
+
* is *not* the bare `userId`. Server enforces owner/admin permission.
|
|
879
|
+
*/
|
|
880
|
+
removeMember: (organizationId: string, params: {
|
|
881
|
+
memberIdOrEmail: string;
|
|
882
|
+
}) => Promise<any>;
|
|
883
|
+
/**
|
|
884
|
+
* Change a member's role in an organization (owner/admin only).
|
|
885
|
+
*
|
|
886
|
+
* better-auth: POST /organization/update-member-role
|
|
887
|
+
* Body: `{ memberId, role, organizationId? }`. The `memberId` is the
|
|
888
|
+
* `member` table row id (not user id). `role` is one of the configured
|
|
889
|
+
* organisation roles (default: `owner | admin | member`).
|
|
890
|
+
*/
|
|
891
|
+
updateMemberRole: (organizationId: string, params: {
|
|
892
|
+
memberId: string;
|
|
893
|
+
role: string;
|
|
894
|
+
}) => Promise<any>;
|
|
895
|
+
/**
|
|
896
|
+
* Look up the calling user's membership row in the given organisation.
|
|
897
|
+
* Useful for permission checks on the client without having to scan the
|
|
898
|
+
* full member list.
|
|
899
|
+
*
|
|
900
|
+
* better-auth: GET /organization/get-active-member?organizationId=…
|
|
901
|
+
*/
|
|
902
|
+
getActiveMember: (organizationId: string) => Promise<any>;
|
|
903
|
+
/**
|
|
904
|
+
* Invitation lifecycle — wraps better-auth's organization-plugin
|
|
905
|
+
* invitation endpoints. Always go through here instead of writing to
|
|
906
|
+
* `sys_invitation` via the data API: the better-auth writers handle
|
|
907
|
+
* status transitions, expiry, dedupe, and the `sendInvitationEmail`
|
|
908
|
+
* side-effect that the auth-manager wires up.
|
|
909
|
+
*/
|
|
910
|
+
invitations: {
|
|
911
|
+
/**
|
|
912
|
+
* List pending/accepted/canceled invitations for an organization.
|
|
913
|
+
* Requires owner/admin role on that org.
|
|
914
|
+
*
|
|
915
|
+
* better-auth: GET /organization/list-invitations?organizationId=…
|
|
916
|
+
*/
|
|
917
|
+
list: (organizationId: string) => Promise<{
|
|
918
|
+
invitations: Array<{
|
|
919
|
+
id: string;
|
|
920
|
+
email: string;
|
|
921
|
+
role: string;
|
|
922
|
+
status: "pending" | "accepted" | "rejected" | "canceled";
|
|
923
|
+
organizationId: string;
|
|
924
|
+
inviterId: string;
|
|
925
|
+
expiresAt: string;
|
|
926
|
+
teamId?: string | null;
|
|
927
|
+
}>;
|
|
928
|
+
}>;
|
|
929
|
+
/**
|
|
930
|
+
* List the **current user's** incoming invitations across every
|
|
931
|
+
* organisation. Used by the per-user "Invitations" inbox page.
|
|
932
|
+
*
|
|
933
|
+
* better-auth: GET /organization/list-user-invitations
|
|
934
|
+
*/
|
|
935
|
+
listMine: () => Promise<{
|
|
936
|
+
invitations: Array<{
|
|
937
|
+
id: string;
|
|
938
|
+
email: string;
|
|
939
|
+
role: string;
|
|
940
|
+
status: string;
|
|
941
|
+
organizationId: string;
|
|
942
|
+
inviterId: string;
|
|
943
|
+
expiresAt: string;
|
|
944
|
+
}>;
|
|
945
|
+
}>;
|
|
946
|
+
/** better-auth: POST /organization/cancel-invitation */
|
|
947
|
+
cancel: (invitationId: string) => Promise<any>;
|
|
948
|
+
/** better-auth: POST /organization/accept-invitation */
|
|
949
|
+
accept: (invitationId: string) => Promise<any>;
|
|
950
|
+
/** better-auth: POST /organization/reject-invitation */
|
|
951
|
+
reject: (invitationId: string) => Promise<any>;
|
|
952
|
+
/**
|
|
953
|
+
* "Resend" an invitation. better-auth has no first-class resend
|
|
954
|
+
* endpoint, so we implement it as cancel-then-invite: cancel the old
|
|
955
|
+
* row (so its status flips to `canceled` and audit hooks fire), then
|
|
956
|
+
* issue a fresh invite. The new invite re-runs `sendInvitationEmail`
|
|
957
|
+
* on the server, so the recipient gets a brand-new accept URL.
|
|
958
|
+
*
|
|
959
|
+
* If `cancel()` fails (e.g. invite already accepted) the error is
|
|
960
|
+
* re-thrown without re-inviting.
|
|
961
|
+
*/
|
|
962
|
+
resend: (invitation: {
|
|
963
|
+
id?: string;
|
|
964
|
+
email: string;
|
|
965
|
+
role?: string;
|
|
966
|
+
organizationId: string;
|
|
967
|
+
teamId?: string | null;
|
|
968
|
+
}) => Promise<any>;
|
|
969
|
+
};
|
|
970
|
+
/**
|
|
971
|
+
* Team management — only available when the organisation plugin is
|
|
972
|
+
* configured with `teams: { enabled: true }` on the server. Calls return
|
|
973
|
+
* a 4xx if teams aren't enabled; UI should hide the section in that case.
|
|
974
|
+
*/
|
|
975
|
+
teams: {
|
|
976
|
+
/** better-auth: GET /organization/list-teams?organizationId=… */
|
|
977
|
+
list: (organizationId: string) => Promise<{
|
|
978
|
+
teams: Array<{
|
|
979
|
+
id: string;
|
|
980
|
+
name: string;
|
|
981
|
+
organizationId: string;
|
|
982
|
+
createdAt?: string;
|
|
983
|
+
}>;
|
|
984
|
+
}>;
|
|
985
|
+
/** better-auth: POST /organization/create-team */
|
|
986
|
+
create: (req: {
|
|
987
|
+
name: string;
|
|
988
|
+
organizationId: string;
|
|
989
|
+
}) => Promise<any>;
|
|
990
|
+
/** better-auth: POST /organization/update-team */
|
|
991
|
+
update: (params: {
|
|
992
|
+
teamId: string;
|
|
993
|
+
data: {
|
|
994
|
+
name?: string;
|
|
995
|
+
};
|
|
996
|
+
}) => Promise<any>;
|
|
997
|
+
/** better-auth: POST /organization/remove-team */
|
|
998
|
+
delete: (params: {
|
|
999
|
+
teamId: string;
|
|
1000
|
+
organizationId?: string;
|
|
1001
|
+
}) => Promise<any>;
|
|
1002
|
+
/** better-auth: GET /organization/list-team-members?teamId=… */
|
|
1003
|
+
listMembers: (teamId: string) => Promise<{
|
|
1004
|
+
members: Array<{
|
|
1005
|
+
id: string;
|
|
1006
|
+
teamId: string;
|
|
1007
|
+
userId: string;
|
|
1008
|
+
}>;
|
|
1009
|
+
}>;
|
|
1010
|
+
/** better-auth: POST /organization/add-team-member */
|
|
1011
|
+
addMember: (params: {
|
|
1012
|
+
teamId: string;
|
|
1013
|
+
userId: string;
|
|
1014
|
+
}) => Promise<any>;
|
|
1015
|
+
/** better-auth: POST /organization/remove-team-member */
|
|
1016
|
+
removeMember: (params: {
|
|
1017
|
+
teamId: string;
|
|
1018
|
+
userId: string;
|
|
1019
|
+
}) => Promise<any>;
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
/**
|
|
1023
|
+
* OAuth / OpenID Connect Provider — admin endpoints exposed by
|
|
1024
|
+
* `@better-auth/oauth-provider` (when enabled on the server). Lets users
|
|
1025
|
+
* register their own OAuth client applications, list them, and revoke them.
|
|
1026
|
+
*
|
|
1027
|
+
* All endpoints are mounted under the auth route, e.g. `/api/v1/auth/oauth2/*`.
|
|
1028
|
+
*/
|
|
1029
|
+
oauth: {
|
|
1030
|
+
applications: {
|
|
1031
|
+
/**
|
|
1032
|
+
* Register a new OAuth client application.
|
|
1033
|
+
* POST /api/v1/auth/oauth2/create-client (authenticated)
|
|
1034
|
+
*
|
|
1035
|
+
* Returns the freshly-issued `client_id` and `client_secret`.
|
|
1036
|
+
* The secret is only returned at creation time — store it securely.
|
|
1037
|
+
*/
|
|
1038
|
+
register: (req: {
|
|
1039
|
+
client_name?: string;
|
|
1040
|
+
name?: string;
|
|
1041
|
+
redirect_uris: string[];
|
|
1042
|
+
token_endpoint_auth_method?: "none" | "client_secret_basic" | "client_secret_post";
|
|
1043
|
+
grant_types?: string[];
|
|
1044
|
+
response_types?: string[];
|
|
1045
|
+
client_uri?: string;
|
|
1046
|
+
logo_uri?: string;
|
|
1047
|
+
scope?: string;
|
|
1048
|
+
scopes?: string[];
|
|
1049
|
+
contacts?: string[];
|
|
1050
|
+
tos_uri?: string;
|
|
1051
|
+
policy_uri?: string;
|
|
1052
|
+
metadata?: Record<string, unknown>;
|
|
1053
|
+
}) => Promise<any>;
|
|
1054
|
+
/**
|
|
1055
|
+
* Get a single OAuth application by its `client_id`.
|
|
1056
|
+
* GET /api/v1/auth/oauth2/get-client?client_id=...
|
|
1057
|
+
*/
|
|
1058
|
+
get: (clientId: string) => Promise<any>;
|
|
1059
|
+
/**
|
|
1060
|
+
* Get a single OAuth application's public fields (no auth required
|
|
1061
|
+
* once the user has signed in). Used by the consent screen.
|
|
1062
|
+
* GET /api/v1/auth/oauth2/public-client?client_id=...
|
|
1063
|
+
*/
|
|
1064
|
+
getPublic: (clientId: string) => Promise<any>;
|
|
1065
|
+
/**
|
|
1066
|
+
* List OAuth applications visible to the current user.
|
|
1067
|
+
*
|
|
1068
|
+
* Uses `@better-auth/oauth-provider`'s `/oauth2/get-clients` endpoint
|
|
1069
|
+
* which returns clients owned by the current user (and their
|
|
1070
|
+
* organization, if applicable).
|
|
1071
|
+
*/
|
|
1072
|
+
list: () => Promise<{
|
|
1073
|
+
applications: Array<Record<string, any>>;
|
|
1074
|
+
}>;
|
|
1075
|
+
/**
|
|
1076
|
+
* Delete an OAuth application by its `client_id`.
|
|
1077
|
+
* POST /api/v1/auth/oauth2/delete-client
|
|
1078
|
+
*
|
|
1079
|
+
* Tokens and consents referencing the client cascade-delete via the
|
|
1080
|
+
* better-auth schema's `onDelete: cascade` foreign keys.
|
|
1081
|
+
*/
|
|
1082
|
+
delete: (clientId: string) => Promise<any>;
|
|
1083
|
+
};
|
|
1084
|
+
/**
|
|
1085
|
+
* Submit the user's decision to a pending consent request.
|
|
1086
|
+
* POST /api/v1/auth/oauth2/consent
|
|
1087
|
+
*
|
|
1088
|
+
* Called by the consent screen after the user accepts or denies. The
|
|
1089
|
+
* `oauth_query` is the raw query string of the consent page URL — it
|
|
1090
|
+
* carries the signed authorization request that the consent endpoint
|
|
1091
|
+
* verifies before issuing the authorization code.
|
|
1092
|
+
*/
|
|
1093
|
+
consent: (req: {
|
|
1094
|
+
accept: boolean;
|
|
1095
|
+
scope?: string;
|
|
1096
|
+
oauth_query?: string;
|
|
1097
|
+
}) => Promise<any>;
|
|
1098
|
+
};
|
|
1099
|
+
/**
|
|
1100
|
+
* Update the active project id used for subsequent requests.
|
|
1101
|
+
* Pass `undefined` to clear (falls back to the session default).
|
|
1102
|
+
*/
|
|
1103
|
+
setProjectId(projectId: string | undefined): void;
|
|
1104
|
+
/**
|
|
1105
|
+
* Current active project id (if set).
|
|
1106
|
+
*/
|
|
1107
|
+
getProjectId(): string | undefined;
|
|
567
1108
|
/**
|
|
568
1109
|
* Authentication Services
|
|
569
1110
|
*/
|
|
@@ -593,12 +1134,212 @@ declare class ObjectStackClient {
|
|
|
593
1134
|
* Uses better-auth endpoint: POST /sign-up/email
|
|
594
1135
|
*/
|
|
595
1136
|
register: (request: RegisterRequest) => Promise<SessionResponse>;
|
|
1137
|
+
/**
|
|
1138
|
+
* Initiate OAuth sign-in via a social or OIDC provider.
|
|
1139
|
+
*
|
|
1140
|
+
* - Social providers (Google, GitHub, etc.): calls POST /sign-in/social with `{ provider }`.
|
|
1141
|
+
* - OIDC/enterprise providers: calls POST /sign-in/oauth2 with `{ providerId }`.
|
|
1142
|
+
*
|
|
1143
|
+
* After the provider callback better-auth sets the session cookie and redirects to `callbackURL`.
|
|
1144
|
+
*/
|
|
1145
|
+
signInWithProvider: (provider: string, opts?: {
|
|
1146
|
+
callbackURL?: string;
|
|
1147
|
+
errorCallbackURL?: string;
|
|
1148
|
+
type?: "social" | "oidc";
|
|
1149
|
+
}) => Promise<void>;
|
|
596
1150
|
/**
|
|
597
1151
|
* Refresh an authentication token
|
|
598
1152
|
* Note: better-auth handles token refresh automatically via /get-session
|
|
599
1153
|
* @param _refreshToken - Not used (better-auth handles refresh automatically)
|
|
600
1154
|
*/
|
|
601
1155
|
refreshToken: (_refreshToken: string) => Promise<SessionResponse>;
|
|
1156
|
+
/**
|
|
1157
|
+
* Probe the framework-only `/auth/bootstrap-status` endpoint to determine
|
|
1158
|
+
* whether the very first owner has been provisioned. The Account portal's
|
|
1159
|
+
* `/setup` route uses this to decide whether to render the bootstrap form
|
|
1160
|
+
* or bounce the user straight to `/login`.
|
|
1161
|
+
*/
|
|
1162
|
+
bootstrapStatus: () => Promise<{
|
|
1163
|
+
hasOwner: boolean;
|
|
1164
|
+
}>;
|
|
1165
|
+
/**
|
|
1166
|
+
* Update the current user's profile.
|
|
1167
|
+
*
|
|
1168
|
+
* better-auth: POST /update-user — accepts `{ name?, image?, ... }`
|
|
1169
|
+
* (any custom user fields configured on the server). Returns the
|
|
1170
|
+
* updated user.
|
|
1171
|
+
*/
|
|
1172
|
+
updateUser: (data: {
|
|
1173
|
+
name?: string;
|
|
1174
|
+
image?: string | null;
|
|
1175
|
+
[key: string]: unknown;
|
|
1176
|
+
}) => Promise<any>;
|
|
1177
|
+
/**
|
|
1178
|
+
* Change the current user's password (email/password accounts only).
|
|
1179
|
+
*
|
|
1180
|
+
* better-auth: POST /change-password.
|
|
1181
|
+
* Set `revokeOtherSessions: true` to invalidate every other session
|
|
1182
|
+
* after the change.
|
|
1183
|
+
*/
|
|
1184
|
+
changePassword: (req: {
|
|
1185
|
+
currentPassword: string;
|
|
1186
|
+
newPassword: string;
|
|
1187
|
+
revokeOtherSessions?: boolean;
|
|
1188
|
+
}) => Promise<any>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Begin a change-email flow. better-auth sends a verification mail to
|
|
1191
|
+
* the new address; the change only takes effect after the user clicks
|
|
1192
|
+
* the link.
|
|
1193
|
+
*
|
|
1194
|
+
* better-auth: POST /change-email — `{ newEmail, callbackURL? }`.
|
|
1195
|
+
*/
|
|
1196
|
+
changeEmail: (req: {
|
|
1197
|
+
newEmail: string;
|
|
1198
|
+
callbackURL?: string;
|
|
1199
|
+
}) => Promise<any>;
|
|
1200
|
+
/**
|
|
1201
|
+
* Re-send the email-verification link to the current user (or any
|
|
1202
|
+
* address when called as an admin). better-auth: POST /send-verification-email.
|
|
1203
|
+
*/
|
|
1204
|
+
sendVerificationEmail: (req: {
|
|
1205
|
+
email: string;
|
|
1206
|
+
callbackURL?: string;
|
|
1207
|
+
}) => Promise<any>;
|
|
1208
|
+
/**
|
|
1209
|
+
* Verify an email-verification token (the link target).
|
|
1210
|
+
*
|
|
1211
|
+
* better-auth: GET /verify-email?token=…&callbackURL=…
|
|
1212
|
+
*/
|
|
1213
|
+
verifyEmail: (params: {
|
|
1214
|
+
token: string;
|
|
1215
|
+
callbackURL?: string;
|
|
1216
|
+
}) => Promise<any>;
|
|
1217
|
+
/**
|
|
1218
|
+
* Permanently delete the current user. better-auth supports two flows:
|
|
1219
|
+
*
|
|
1220
|
+
* 1. With a fresh-session password challenge: POST `{ password }`.
|
|
1221
|
+
* 2. With an emailed deletion-confirmation token: POST `{ token }`,
|
|
1222
|
+
* typically following an out-of-band confirmation step.
|
|
1223
|
+
*
|
|
1224
|
+
* Server policy decides which is required; pass whichever you have.
|
|
1225
|
+
*/
|
|
1226
|
+
deleteUser: (req: {
|
|
1227
|
+
password?: string;
|
|
1228
|
+
token?: string;
|
|
1229
|
+
callbackURL?: string;
|
|
1230
|
+
}) => Promise<any>;
|
|
1231
|
+
/**
|
|
1232
|
+
* Active-session management. Wraps better-auth's session endpoints so
|
|
1233
|
+
* the Account portal's `/account/sessions` page can list every device
|
|
1234
|
+
* the user is signed in from and revoke them individually or in bulk.
|
|
1235
|
+
*/
|
|
1236
|
+
sessions: {
|
|
1237
|
+
/** better-auth: GET /list-sessions — returns the current user's sessions. */
|
|
1238
|
+
list: () => Promise<{
|
|
1239
|
+
sessions: Array<{
|
|
1240
|
+
id: string;
|
|
1241
|
+
token: string;
|
|
1242
|
+
userId: string;
|
|
1243
|
+
userAgent?: string;
|
|
1244
|
+
ipAddress?: string;
|
|
1245
|
+
createdAt: string;
|
|
1246
|
+
expiresAt: string;
|
|
1247
|
+
}>;
|
|
1248
|
+
}>;
|
|
1249
|
+
/** better-auth: POST /revoke-session — revoke a single session by token. */
|
|
1250
|
+
revoke: (token: string) => Promise<any>;
|
|
1251
|
+
/** better-auth: POST /revoke-other-sessions — keep current, kill the rest. */
|
|
1252
|
+
revokeOthers: () => Promise<any>;
|
|
1253
|
+
/** better-auth: POST /revoke-sessions — kill every session for this user. */
|
|
1254
|
+
revokeAll: () => Promise<any>;
|
|
1255
|
+
};
|
|
1256
|
+
/**
|
|
1257
|
+
* Two-factor authentication (TOTP + backup codes). Requires the
|
|
1258
|
+
* `twoFactor` plugin to be enabled on the server (see
|
|
1259
|
+
* `plugin-auth` config). Endpoints live under `/two-factor/*`.
|
|
1260
|
+
*/
|
|
1261
|
+
twoFactor: {
|
|
1262
|
+
/**
|
|
1263
|
+
* Start enrolment. Server returns a TOTP URI (`otpauth://...`) which
|
|
1264
|
+
* the UI renders as a QR code; the user then calls `verifyTotp` to
|
|
1265
|
+
* confirm and finish enabling.
|
|
1266
|
+
*/
|
|
1267
|
+
enable: (req: {
|
|
1268
|
+
password: string;
|
|
1269
|
+
}) => Promise<{
|
|
1270
|
+
totpURI?: string;
|
|
1271
|
+
backupCodes?: string[];
|
|
1272
|
+
}>;
|
|
1273
|
+
/**
|
|
1274
|
+
* Confirm a TOTP code — used to finalise enrolment after `enable()`
|
|
1275
|
+
* or to step up an existing 2FA-enabled session. `trustDevice` (when
|
|
1276
|
+
* supported by the server config) suppresses the 2FA challenge on
|
|
1277
|
+
* this browser for the configured trust period.
|
|
1278
|
+
*/
|
|
1279
|
+
verifyTotp: (req: {
|
|
1280
|
+
code: string;
|
|
1281
|
+
trustDevice?: boolean;
|
|
1282
|
+
}) => Promise<any>;
|
|
1283
|
+
/** Disable 2FA for the current user. Requires the password again. */
|
|
1284
|
+
disable: (req: {
|
|
1285
|
+
password: string;
|
|
1286
|
+
}) => Promise<any>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Issue a fresh set of backup codes (invalidating any previous set).
|
|
1289
|
+
* Display them once — the server only stores hashes.
|
|
1290
|
+
*/
|
|
1291
|
+
generateBackupCodes: (req: {
|
|
1292
|
+
password: string;
|
|
1293
|
+
}) => Promise<{
|
|
1294
|
+
backupCodes: string[];
|
|
1295
|
+
}>;
|
|
1296
|
+
/**
|
|
1297
|
+
* Verify a 2FA backup code in lieu of a TOTP. Useful as a recovery
|
|
1298
|
+
* affordance when the user has lost their authenticator app.
|
|
1299
|
+
*/
|
|
1300
|
+
verifyBackupCode: (req: {
|
|
1301
|
+
code: string;
|
|
1302
|
+
}) => Promise<any>;
|
|
1303
|
+
};
|
|
1304
|
+
/**
|
|
1305
|
+
* Linked credentials — i.e. the rows in better-auth's `account` table
|
|
1306
|
+
* (one per provider × user). Lets the user see and unlink their social
|
|
1307
|
+
* / OIDC connections from the Account portal.
|
|
1308
|
+
*/
|
|
1309
|
+
accounts: {
|
|
1310
|
+
/** better-auth: GET /list-accounts */
|
|
1311
|
+
list: () => Promise<{
|
|
1312
|
+
accounts: Array<{
|
|
1313
|
+
id: string;
|
|
1314
|
+
providerId: string;
|
|
1315
|
+
accountId: string;
|
|
1316
|
+
createdAt?: string;
|
|
1317
|
+
updatedAt?: string;
|
|
1318
|
+
}>;
|
|
1319
|
+
}>;
|
|
1320
|
+
/**
|
|
1321
|
+
* Unlink a provider connection.
|
|
1322
|
+
* better-auth: POST /unlink-account — `{ providerId, accountId? }`.
|
|
1323
|
+
* `accountId` is required when the user has more than one account
|
|
1324
|
+
* for the same provider.
|
|
1325
|
+
*/
|
|
1326
|
+
unlink: (req: {
|
|
1327
|
+
providerId: string;
|
|
1328
|
+
accountId?: string;
|
|
1329
|
+
}) => Promise<any>;
|
|
1330
|
+
/**
|
|
1331
|
+
* Link an additional social provider to the current user.
|
|
1332
|
+
* better-auth: POST /link-social — `{ provider, callbackURL }`. The
|
|
1333
|
+
* server returns a redirect URL; the caller should `window.location`
|
|
1334
|
+
* to it (mirroring `signInWithProvider`).
|
|
1335
|
+
*/
|
|
1336
|
+
linkSocial: (req: {
|
|
1337
|
+
provider: string;
|
|
1338
|
+
callbackURL?: string;
|
|
1339
|
+
}) => Promise<{
|
|
1340
|
+
url?: string;
|
|
1341
|
+
}>;
|
|
1342
|
+
};
|
|
602
1343
|
};
|
|
603
1344
|
/**
|
|
604
1345
|
* Storage Services
|
|
@@ -689,6 +1430,22 @@ declare class ObjectStackClient {
|
|
|
689
1430
|
*/
|
|
690
1431
|
get: (flowName: string, runId: string) => Promise<any>;
|
|
691
1432
|
};
|
|
1433
|
+
/**
|
|
1434
|
+
* Flat aliases mirroring the ScopedProjectClient.automation surface so
|
|
1435
|
+
* Studio (and other consumers) can use the same call shape regardless of
|
|
1436
|
+
* whether they hold a scoped or unscoped client.
|
|
1437
|
+
*/
|
|
1438
|
+
/** Alias for `automation.get` — fetch a flow definition by name. */
|
|
1439
|
+
getFlow: <T = any>(name: string) => Promise<T>;
|
|
1440
|
+
/** Execute (trigger) a flow with an execution context. */
|
|
1441
|
+
execute: <T = any>(name: string, ctx?: Record<string, any>) => Promise<T>;
|
|
1442
|
+
/** Alias for `automation.runs.list`. */
|
|
1443
|
+
listRuns: <T = any>(flowName: string, opts?: {
|
|
1444
|
+
limit?: number;
|
|
1445
|
+
cursor?: string;
|
|
1446
|
+
}) => Promise<T>;
|
|
1447
|
+
/** Alias for `automation.runs.get`. */
|
|
1448
|
+
getRun: <T = any>(flowName: string, runId: string) => Promise<T>;
|
|
692
1449
|
};
|
|
693
1450
|
/**
|
|
694
1451
|
* Event Subscription API
|
|
@@ -1018,5 +1775,107 @@ declare class ObjectStackClient {
|
|
|
1018
1775
|
*/
|
|
1019
1776
|
private getRoute;
|
|
1020
1777
|
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Project-scoped sub-client.
|
|
1780
|
+
*
|
|
1781
|
+
* Wraps an {@link ObjectStackClient} and prefixes every request with
|
|
1782
|
+
* `/api/v1/projects/:projectId/...` so a single client instance can talk to
|
|
1783
|
+
* multiple projects without mutating global state.
|
|
1784
|
+
*
|
|
1785
|
+
* The scoped client exposes the same shape as the `data`, `meta`, `batch`,
|
|
1786
|
+
* and `packages` namespaces on `ObjectStackClient` — only the URL prefix
|
|
1787
|
+
* differs. The server-side dual-mode route registration (see
|
|
1788
|
+
* `packages/rest/src/rest-server.ts`) accepts both shapes when
|
|
1789
|
+
* `projectResolution` is `'auto'` or `'optional'`.
|
|
1790
|
+
*/
|
|
1791
|
+
declare class ScopedProjectClient {
|
|
1792
|
+
private readonly parent;
|
|
1793
|
+
private readonly projectId;
|
|
1794
|
+
constructor(parent: ObjectStackClient, projectId: string);
|
|
1795
|
+
/** The projectId this client is scoped to. */
|
|
1796
|
+
getProjectId(): string;
|
|
1797
|
+
/** Prefix segment inserted between the baseUrl and the resource path. */
|
|
1798
|
+
private scope;
|
|
1799
|
+
private url;
|
|
1800
|
+
/**
|
|
1801
|
+
* Metadata operations scoped to this project.
|
|
1802
|
+
*/
|
|
1803
|
+
meta: {
|
|
1804
|
+
getTypes: () => Promise<GetMetaTypesResponse>;
|
|
1805
|
+
getItems: (type: string, options?: {
|
|
1806
|
+
packageId?: string;
|
|
1807
|
+
}) => Promise<GetMetaItemsResponse>;
|
|
1808
|
+
getItem: (type: string, name: string, options?: {
|
|
1809
|
+
packageId?: string;
|
|
1810
|
+
}) => Promise<unknown>;
|
|
1811
|
+
saveItem: (type: string, name: string, item: any) => Promise<unknown>;
|
|
1812
|
+
deleteItem: (type: string, name: string) => Promise<{
|
|
1813
|
+
type: string;
|
|
1814
|
+
name: string;
|
|
1815
|
+
deleted: boolean;
|
|
1816
|
+
}>;
|
|
1817
|
+
};
|
|
1818
|
+
/**
|
|
1819
|
+
* Data operations scoped to this project.
|
|
1820
|
+
*
|
|
1821
|
+
* Mirrors the query / find / get / create / update / delete / batch
|
|
1822
|
+
* surface on {@link ObjectStackClient}. URL construction differs only
|
|
1823
|
+
* in the prefix — query parameter serialization is identical.
|
|
1824
|
+
*/
|
|
1825
|
+
data: {
|
|
1826
|
+
query: <T = any>(object: string, query: Partial<QueryAST>) => Promise<PaginatedResult<T>>;
|
|
1827
|
+
find: <T = any>(object: string, options?: QueryOptions | QueryOptionsV2) => Promise<PaginatedResult<T>>;
|
|
1828
|
+
get: <T = any>(object: string, id: string) => Promise<GetDataResult<T>>;
|
|
1829
|
+
create: <T = any>(object: string, data: Partial<T>) => Promise<CreateDataResult<T>>;
|
|
1830
|
+
createMany: <T = any>(object: string, data: Partial<T>[]) => Promise<T[]>;
|
|
1831
|
+
update: <T = any>(object: string, id: string, data: Partial<T>) => Promise<UpdateDataResult<T>>;
|
|
1832
|
+
batch: (object: string, request: BatchUpdateRequest) => Promise<BatchUpdateResponse>;
|
|
1833
|
+
updateMany: <T = any>(object: string, records: Array<{
|
|
1834
|
+
id: string;
|
|
1835
|
+
data: Partial<T>;
|
|
1836
|
+
}>, options?: BatchOptions) => Promise<BatchUpdateResponse>;
|
|
1837
|
+
delete: (object: string, id: string) => Promise<DeleteDataResult>;
|
|
1838
|
+
deleteMany: (object: string, ids: string[], options?: BatchOptions) => Promise<BatchUpdateResponse>;
|
|
1839
|
+
};
|
|
1840
|
+
/**
|
|
1841
|
+
* Package management scoped to this project.
|
|
1842
|
+
* Only the read-path is exposed here — publish / delete remain on the
|
|
1843
|
+
* global `client.packages` namespace for now, pending dedicated per-project
|
|
1844
|
+
* package tests.
|
|
1845
|
+
*/
|
|
1846
|
+
packages: {
|
|
1847
|
+
list: () => Promise<{
|
|
1848
|
+
packages: any[];
|
|
1849
|
+
total: number;
|
|
1850
|
+
}>;
|
|
1851
|
+
get: (id: string, version?: string) => Promise<{
|
|
1852
|
+
package: any;
|
|
1853
|
+
}>;
|
|
1854
|
+
};
|
|
1855
|
+
/**
|
|
1856
|
+
* Automation (Flow) operations scoped to this project.
|
|
1857
|
+
*
|
|
1858
|
+
* Thin wrapper around the dispatcher's automation routes, mounted under
|
|
1859
|
+
* `/api/v1/projects/:projectId/automation/...`. Surface mirrors the methods
|
|
1860
|
+
* needed by Studio's Flow viewer: read flow definition, execute (trigger),
|
|
1861
|
+
* list runs, fetch a single run.
|
|
1862
|
+
*/
|
|
1863
|
+
automation: {
|
|
1864
|
+
/** Fetch a flow definition by name. */
|
|
1865
|
+
getFlow: <T = any>(name: string) => Promise<T>;
|
|
1866
|
+
/**
|
|
1867
|
+
* Execute (trigger) a flow by name. The request body is forwarded as the
|
|
1868
|
+
* automation execution context (e.g. `{ params, trigger }`).
|
|
1869
|
+
*/
|
|
1870
|
+
execute: <T = any>(name: string, ctx?: Record<string, any>) => Promise<T>;
|
|
1871
|
+
/** List recent runs for a flow. */
|
|
1872
|
+
listRuns: <T = any>(flowName: string, opts?: {
|
|
1873
|
+
limit?: number;
|
|
1874
|
+
cursor?: string;
|
|
1875
|
+
}) => Promise<T>;
|
|
1876
|
+
/** Fetch a single run (with step log) for a flow. */
|
|
1877
|
+
getRun: <T = any>(flowName: string, runId: string) => Promise<T>;
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1021
1880
|
|
|
1022
|
-
export { type ApiRouteType, type ClientConfig, type CreateDataResult, type DeleteDataResult, type DiscoveryResult, FilterBuilder, type GetDataResult, ObjectStackClient, type PaginatedResult, QueryBuilder, type QueryOptions, type QueryOptionsV2, RealtimeAPI, type RealtimeEventHandler, type RealtimeSubscriptionFilter, type StandardError, type UpdateDataResult, createFilter, createQuery };
|
|
1881
|
+
export { type ApiRouteType, type ClientConfig, type CreateDataResult, type DeleteDataResult, type DiscoveryResult, FilterBuilder, type GetDataResult, ObjectStackClient, type PaginatedResult, QueryBuilder, type QueryOptions, type QueryOptionsV2, RealtimeAPI, type RealtimeEventHandler, type RealtimeSubscriptionFilter, ScopedProjectClient, type StandardError, type UpdateDataResult, createFilter, createQuery };
|