@baasix/sdk 0.1.6 → 0.1.8
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 +222 -2
- package/dist/index.cjs +382 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +307 -0
- package/dist/index.d.ts +307 -0
- package/dist/index.js +382 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -365,6 +365,43 @@ declare class PermissionsModule {
|
|
|
365
365
|
* ```
|
|
366
366
|
*/
|
|
367
367
|
reloadCache(): Promise<void>;
|
|
368
|
+
/**
|
|
369
|
+
* Export all permissions (admin only)
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* const exported = await baasix.permissions.export();
|
|
374
|
+
* // Save to file or transfer
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
export(): Promise<{
|
|
378
|
+
permissions: Permission[];
|
|
379
|
+
exportedAt: string;
|
|
380
|
+
version: string;
|
|
381
|
+
}>;
|
|
382
|
+
/**
|
|
383
|
+
* Import permissions from exported data (admin only)
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```typescript
|
|
387
|
+
* const result = await baasix.permissions.import(exportedData, {
|
|
388
|
+
* overwrite: true
|
|
389
|
+
* });
|
|
390
|
+
* console.log('Imported:', result.imported, 'permissions');
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
import(data: {
|
|
394
|
+
permissions: Array<Partial<Permission>>;
|
|
395
|
+
}, options?: {
|
|
396
|
+
overwrite?: boolean;
|
|
397
|
+
}): Promise<{
|
|
398
|
+
imported: number;
|
|
399
|
+
skipped: number;
|
|
400
|
+
errors: Array<{
|
|
401
|
+
permission: Partial<Permission>;
|
|
402
|
+
error: string;
|
|
403
|
+
}>;
|
|
404
|
+
}>;
|
|
368
405
|
}
|
|
369
406
|
|
|
370
407
|
interface SettingsModuleConfig {
|
|
@@ -432,6 +469,55 @@ declare class SettingsModule {
|
|
|
432
469
|
* ```
|
|
433
470
|
*/
|
|
434
471
|
set<T>(key: string, value: T): Promise<Settings>;
|
|
472
|
+
/**
|
|
473
|
+
* Get settings by application URL (useful for multi-tenant apps)
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* const settings = await baasix.settings.getByAppUrl('https://myapp.example.com');
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
getByAppUrl(appUrl: string): Promise<Settings>;
|
|
481
|
+
/**
|
|
482
|
+
* Get email branding settings for the current tenant
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```typescript
|
|
486
|
+
* const branding = await baasix.settings.getBranding();
|
|
487
|
+
* console.log(branding.logo, branding.primaryColor);
|
|
488
|
+
* ```
|
|
489
|
+
*/
|
|
490
|
+
getBranding(): Promise<Record<string, unknown>>;
|
|
491
|
+
/**
|
|
492
|
+
* Test email configuration by sending a test email
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```typescript
|
|
496
|
+
* await baasix.settings.testEmail('admin@example.com');
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
499
|
+
testEmail(to: string): Promise<{
|
|
500
|
+
success: boolean;
|
|
501
|
+
message?: string;
|
|
502
|
+
}>;
|
|
503
|
+
/**
|
|
504
|
+
* Reload settings cache (admin only)
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```typescript
|
|
508
|
+
* await baasix.settings.reload();
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
reload(): Promise<void>;
|
|
512
|
+
/**
|
|
513
|
+
* Delete tenant settings (admin only, multi-tenant)
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* ```typescript
|
|
517
|
+
* await baasix.settings.deleteTenant();
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
520
|
+
deleteTenant(): Promise<void>;
|
|
435
521
|
}
|
|
436
522
|
|
|
437
523
|
interface ReportsModuleConfig {
|
|
@@ -771,6 +857,163 @@ declare class WorkflowsModule {
|
|
|
771
857
|
* ```
|
|
772
858
|
*/
|
|
773
859
|
duplicate(id: string, overrides?: Partial<Omit<Workflow, "id" | "createdAt" | "updatedAt">>): Promise<Workflow>;
|
|
860
|
+
/**
|
|
861
|
+
* Execute a specific node in a workflow
|
|
862
|
+
*
|
|
863
|
+
* @example
|
|
864
|
+
* ```typescript
|
|
865
|
+
* const result = await baasix.workflows.executeNode(
|
|
866
|
+
* 'workflow-uuid',
|
|
867
|
+
* 'node-id',
|
|
868
|
+
* { inputData: 'value' }
|
|
869
|
+
* );
|
|
870
|
+
* ```
|
|
871
|
+
*/
|
|
872
|
+
executeNode(workflowId: string, nodeId: string, triggerData?: Record<string, unknown>): Promise<WorkflowExecution>;
|
|
873
|
+
/**
|
|
874
|
+
* Get execution logs for a specific execution
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
* ```typescript
|
|
878
|
+
* const logs = await baasix.workflows.getExecutionLogs(
|
|
879
|
+
* 'workflow-uuid',
|
|
880
|
+
* 'execution-uuid'
|
|
881
|
+
* );
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
884
|
+
getExecutionLogs(workflowId: string, executionId: string): Promise<Array<{
|
|
885
|
+
timestamp: string;
|
|
886
|
+
level: string;
|
|
887
|
+
message: string;
|
|
888
|
+
nodeId?: string;
|
|
889
|
+
}>>;
|
|
890
|
+
/**
|
|
891
|
+
* Get workflow statistics
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* ```typescript
|
|
895
|
+
* const stats = await baasix.workflows.getStats('workflow-uuid');
|
|
896
|
+
* console.log(stats.totalExecutions, stats.successRate);
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
getStats(id: string): Promise<{
|
|
900
|
+
totalExecutions: number;
|
|
901
|
+
successCount: number;
|
|
902
|
+
failedCount: number;
|
|
903
|
+
successRate: number;
|
|
904
|
+
avgExecutionTime: number;
|
|
905
|
+
}>;
|
|
906
|
+
/**
|
|
907
|
+
* Validate a workflow definition
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* ```typescript
|
|
911
|
+
* const result = await baasix.workflows.validate({
|
|
912
|
+
* name: 'My Workflow',
|
|
913
|
+
* nodes: [...],
|
|
914
|
+
* edges: [...]
|
|
915
|
+
* });
|
|
916
|
+
* if (result.valid) {
|
|
917
|
+
* console.log('Workflow is valid');
|
|
918
|
+
* } else {
|
|
919
|
+
* console.log('Errors:', result.errors);
|
|
920
|
+
* }
|
|
921
|
+
* ```
|
|
922
|
+
*/
|
|
923
|
+
validate(workflow: Partial<Workflow>): Promise<{
|
|
924
|
+
valid: boolean;
|
|
925
|
+
errors?: Array<{
|
|
926
|
+
path: string;
|
|
927
|
+
message: string;
|
|
928
|
+
}>;
|
|
929
|
+
}>;
|
|
930
|
+
/**
|
|
931
|
+
* Export a single workflow
|
|
932
|
+
*
|
|
933
|
+
* @example
|
|
934
|
+
* ```typescript
|
|
935
|
+
* const exported = await baasix.workflows.export('workflow-uuid');
|
|
936
|
+
* // Save to file or transfer
|
|
937
|
+
* ```
|
|
938
|
+
*/
|
|
939
|
+
export(id: string): Promise<Workflow & {
|
|
940
|
+
exportedAt: string;
|
|
941
|
+
version: string;
|
|
942
|
+
}>;
|
|
943
|
+
/**
|
|
944
|
+
* Export multiple workflows
|
|
945
|
+
*
|
|
946
|
+
* @example
|
|
947
|
+
* ```typescript
|
|
948
|
+
* // Export all workflows
|
|
949
|
+
* const exported = await baasix.workflows.exportAll();
|
|
950
|
+
*
|
|
951
|
+
* // Export specific workflows
|
|
952
|
+
* const exported = await baasix.workflows.exportAll({
|
|
953
|
+
* ids: ['workflow-1', 'workflow-2']
|
|
954
|
+
* });
|
|
955
|
+
* ```
|
|
956
|
+
*/
|
|
957
|
+
exportAll(options?: {
|
|
958
|
+
ids?: string[];
|
|
959
|
+
includeInactive?: boolean;
|
|
960
|
+
}): Promise<{
|
|
961
|
+
workflows: Array<Workflow & {
|
|
962
|
+
exportedAt: string;
|
|
963
|
+
}>;
|
|
964
|
+
exportedAt: string;
|
|
965
|
+
version: string;
|
|
966
|
+
}>;
|
|
967
|
+
/**
|
|
968
|
+
* Preview workflow import without applying changes
|
|
969
|
+
*
|
|
970
|
+
* @example
|
|
971
|
+
* ```typescript
|
|
972
|
+
* const preview = await baasix.workflows.importPreview(file);
|
|
973
|
+
* console.log('Will import:', preview.workflows.length, 'workflows');
|
|
974
|
+
* console.log('Conflicts:', preview.conflicts);
|
|
975
|
+
* ```
|
|
976
|
+
*/
|
|
977
|
+
importPreview(file: File | {
|
|
978
|
+
uri: string;
|
|
979
|
+
name: string;
|
|
980
|
+
type: string;
|
|
981
|
+
}): Promise<{
|
|
982
|
+
workflows: Array<{
|
|
983
|
+
name: string;
|
|
984
|
+
id?: string;
|
|
985
|
+
isNew: boolean;
|
|
986
|
+
}>;
|
|
987
|
+
conflicts: Array<{
|
|
988
|
+
name: string;
|
|
989
|
+
existingId: string;
|
|
990
|
+
}>;
|
|
991
|
+
}>;
|
|
992
|
+
/**
|
|
993
|
+
* Import workflows from a file
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* ```typescript
|
|
997
|
+
* const result = await baasix.workflows.import(file, {
|
|
998
|
+
* overwrite: true
|
|
999
|
+
* });
|
|
1000
|
+
* console.log('Imported:', result.imported, 'workflows');
|
|
1001
|
+
* ```
|
|
1002
|
+
*/
|
|
1003
|
+
import(file: File | {
|
|
1004
|
+
uri: string;
|
|
1005
|
+
name: string;
|
|
1006
|
+
type: string;
|
|
1007
|
+
}, options?: {
|
|
1008
|
+
overwrite?: boolean;
|
|
1009
|
+
}): Promise<{
|
|
1010
|
+
imported: number;
|
|
1011
|
+
skipped: number;
|
|
1012
|
+
errors: Array<{
|
|
1013
|
+
name: string;
|
|
1014
|
+
error: string;
|
|
1015
|
+
}>;
|
|
1016
|
+
}>;
|
|
774
1017
|
}
|
|
775
1018
|
|
|
776
1019
|
interface SocketOptions {
|
|
@@ -835,6 +1078,22 @@ interface RoomUserEvent {
|
|
|
835
1078
|
socketId: string;
|
|
836
1079
|
timestamp: string;
|
|
837
1080
|
}
|
|
1081
|
+
interface RoomKickEvent {
|
|
1082
|
+
room: string;
|
|
1083
|
+
kickedBy: string | number;
|
|
1084
|
+
timestamp: string;
|
|
1085
|
+
}
|
|
1086
|
+
interface RoomCreatorChangedEvent {
|
|
1087
|
+
room: string;
|
|
1088
|
+
newCreatorSocketId: string;
|
|
1089
|
+
newCreatorUserId: string | number;
|
|
1090
|
+
timestamp: string;
|
|
1091
|
+
}
|
|
1092
|
+
interface RoomMember {
|
|
1093
|
+
socketId: string;
|
|
1094
|
+
userId: string | number;
|
|
1095
|
+
isCreator: boolean;
|
|
1096
|
+
}
|
|
838
1097
|
interface SubscriptionCallback<T = any> {
|
|
839
1098
|
(payload: SubscriptionPayload<T>): void;
|
|
840
1099
|
}
|
|
@@ -876,6 +1135,8 @@ declare class RealtimeModule {
|
|
|
876
1135
|
private workflowCallbacks;
|
|
877
1136
|
private roomCallbacks;
|
|
878
1137
|
private roomUserCallbacks;
|
|
1138
|
+
private kickCallbacks;
|
|
1139
|
+
private creatorChangedCallbacks;
|
|
879
1140
|
private connectionCallbacks;
|
|
880
1141
|
private reconnecting;
|
|
881
1142
|
private connectionPromise;
|
|
@@ -1029,6 +1290,52 @@ declare class RealtimeModule {
|
|
|
1029
1290
|
* ```
|
|
1030
1291
|
*/
|
|
1031
1292
|
leaveRoom(roomName: string): Promise<void>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Get the list of users currently in a room.
|
|
1295
|
+
* You must already be a member of the room to call this.
|
|
1296
|
+
*
|
|
1297
|
+
* @example
|
|
1298
|
+
* ```typescript
|
|
1299
|
+
* const members = await baasix.realtime.getRoomMembers('game:lobby');
|
|
1300
|
+
* members.forEach(m => {
|
|
1301
|
+
* console.log(m.userId, m.isCreator ? '(owner)' : '');
|
|
1302
|
+
* });
|
|
1303
|
+
* ```
|
|
1304
|
+
*/
|
|
1305
|
+
getRoomMembers(roomName: string): Promise<RoomMember[]>;
|
|
1306
|
+
/**
|
|
1307
|
+
* Kick a user from a custom room. Only the room creator may call this.
|
|
1308
|
+
*
|
|
1309
|
+
* @example
|
|
1310
|
+
* ```typescript
|
|
1311
|
+
* await baasix.realtime.kickFromRoom('game:lobby', 'user-id-123');
|
|
1312
|
+
* ```
|
|
1313
|
+
*/
|
|
1314
|
+
kickFromRoom(roomName: string, targetUserId: string | number): Promise<void>;
|
|
1315
|
+
/**
|
|
1316
|
+
* Listen for being kicked from a room.
|
|
1317
|
+
* The callback fires when the current user is removed by the room creator.
|
|
1318
|
+
* Room listeners are automatically cleaned up after the kick.
|
|
1319
|
+
*
|
|
1320
|
+
* @example
|
|
1321
|
+
* ```typescript
|
|
1322
|
+
* baasix.realtime.onKicked('game:lobby', ({ kickedBy }) => {
|
|
1323
|
+
* console.log(`You were kicked by user ${kickedBy}`);
|
|
1324
|
+
* });
|
|
1325
|
+
* ```
|
|
1326
|
+
*/
|
|
1327
|
+
onKicked(roomName: string, callback: (data: RoomKickEvent) => void): () => void;
|
|
1328
|
+
/**
|
|
1329
|
+
* Listen for room ownership changes (e.g. when the creator leaves).
|
|
1330
|
+
*
|
|
1331
|
+
* @example
|
|
1332
|
+
* ```typescript
|
|
1333
|
+
* baasix.realtime.onRoomCreatorChanged('game:lobby', ({ newCreatorUserId }) => {
|
|
1334
|
+
* console.log(`New room owner: ${newCreatorUserId}`);
|
|
1335
|
+
* });
|
|
1336
|
+
* ```
|
|
1337
|
+
*/
|
|
1338
|
+
onRoomCreatorChanged(roomName: string, callback: (data: RoomCreatorChangedEvent) => void): () => void;
|
|
1032
1339
|
/**
|
|
1033
1340
|
* Send a message to a room
|
|
1034
1341
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -365,6 +365,43 @@ declare class PermissionsModule {
|
|
|
365
365
|
* ```
|
|
366
366
|
*/
|
|
367
367
|
reloadCache(): Promise<void>;
|
|
368
|
+
/**
|
|
369
|
+
* Export all permissions (admin only)
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* const exported = await baasix.permissions.export();
|
|
374
|
+
* // Save to file or transfer
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
export(): Promise<{
|
|
378
|
+
permissions: Permission[];
|
|
379
|
+
exportedAt: string;
|
|
380
|
+
version: string;
|
|
381
|
+
}>;
|
|
382
|
+
/**
|
|
383
|
+
* Import permissions from exported data (admin only)
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```typescript
|
|
387
|
+
* const result = await baasix.permissions.import(exportedData, {
|
|
388
|
+
* overwrite: true
|
|
389
|
+
* });
|
|
390
|
+
* console.log('Imported:', result.imported, 'permissions');
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
import(data: {
|
|
394
|
+
permissions: Array<Partial<Permission>>;
|
|
395
|
+
}, options?: {
|
|
396
|
+
overwrite?: boolean;
|
|
397
|
+
}): Promise<{
|
|
398
|
+
imported: number;
|
|
399
|
+
skipped: number;
|
|
400
|
+
errors: Array<{
|
|
401
|
+
permission: Partial<Permission>;
|
|
402
|
+
error: string;
|
|
403
|
+
}>;
|
|
404
|
+
}>;
|
|
368
405
|
}
|
|
369
406
|
|
|
370
407
|
interface SettingsModuleConfig {
|
|
@@ -432,6 +469,55 @@ declare class SettingsModule {
|
|
|
432
469
|
* ```
|
|
433
470
|
*/
|
|
434
471
|
set<T>(key: string, value: T): Promise<Settings>;
|
|
472
|
+
/**
|
|
473
|
+
* Get settings by application URL (useful for multi-tenant apps)
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* const settings = await baasix.settings.getByAppUrl('https://myapp.example.com');
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
getByAppUrl(appUrl: string): Promise<Settings>;
|
|
481
|
+
/**
|
|
482
|
+
* Get email branding settings for the current tenant
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```typescript
|
|
486
|
+
* const branding = await baasix.settings.getBranding();
|
|
487
|
+
* console.log(branding.logo, branding.primaryColor);
|
|
488
|
+
* ```
|
|
489
|
+
*/
|
|
490
|
+
getBranding(): Promise<Record<string, unknown>>;
|
|
491
|
+
/**
|
|
492
|
+
* Test email configuration by sending a test email
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```typescript
|
|
496
|
+
* await baasix.settings.testEmail('admin@example.com');
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
499
|
+
testEmail(to: string): Promise<{
|
|
500
|
+
success: boolean;
|
|
501
|
+
message?: string;
|
|
502
|
+
}>;
|
|
503
|
+
/**
|
|
504
|
+
* Reload settings cache (admin only)
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```typescript
|
|
508
|
+
* await baasix.settings.reload();
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
reload(): Promise<void>;
|
|
512
|
+
/**
|
|
513
|
+
* Delete tenant settings (admin only, multi-tenant)
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* ```typescript
|
|
517
|
+
* await baasix.settings.deleteTenant();
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
520
|
+
deleteTenant(): Promise<void>;
|
|
435
521
|
}
|
|
436
522
|
|
|
437
523
|
interface ReportsModuleConfig {
|
|
@@ -771,6 +857,163 @@ declare class WorkflowsModule {
|
|
|
771
857
|
* ```
|
|
772
858
|
*/
|
|
773
859
|
duplicate(id: string, overrides?: Partial<Omit<Workflow, "id" | "createdAt" | "updatedAt">>): Promise<Workflow>;
|
|
860
|
+
/**
|
|
861
|
+
* Execute a specific node in a workflow
|
|
862
|
+
*
|
|
863
|
+
* @example
|
|
864
|
+
* ```typescript
|
|
865
|
+
* const result = await baasix.workflows.executeNode(
|
|
866
|
+
* 'workflow-uuid',
|
|
867
|
+
* 'node-id',
|
|
868
|
+
* { inputData: 'value' }
|
|
869
|
+
* );
|
|
870
|
+
* ```
|
|
871
|
+
*/
|
|
872
|
+
executeNode(workflowId: string, nodeId: string, triggerData?: Record<string, unknown>): Promise<WorkflowExecution>;
|
|
873
|
+
/**
|
|
874
|
+
* Get execution logs for a specific execution
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
* ```typescript
|
|
878
|
+
* const logs = await baasix.workflows.getExecutionLogs(
|
|
879
|
+
* 'workflow-uuid',
|
|
880
|
+
* 'execution-uuid'
|
|
881
|
+
* );
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
884
|
+
getExecutionLogs(workflowId: string, executionId: string): Promise<Array<{
|
|
885
|
+
timestamp: string;
|
|
886
|
+
level: string;
|
|
887
|
+
message: string;
|
|
888
|
+
nodeId?: string;
|
|
889
|
+
}>>;
|
|
890
|
+
/**
|
|
891
|
+
* Get workflow statistics
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* ```typescript
|
|
895
|
+
* const stats = await baasix.workflows.getStats('workflow-uuid');
|
|
896
|
+
* console.log(stats.totalExecutions, stats.successRate);
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
getStats(id: string): Promise<{
|
|
900
|
+
totalExecutions: number;
|
|
901
|
+
successCount: number;
|
|
902
|
+
failedCount: number;
|
|
903
|
+
successRate: number;
|
|
904
|
+
avgExecutionTime: number;
|
|
905
|
+
}>;
|
|
906
|
+
/**
|
|
907
|
+
* Validate a workflow definition
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* ```typescript
|
|
911
|
+
* const result = await baasix.workflows.validate({
|
|
912
|
+
* name: 'My Workflow',
|
|
913
|
+
* nodes: [...],
|
|
914
|
+
* edges: [...]
|
|
915
|
+
* });
|
|
916
|
+
* if (result.valid) {
|
|
917
|
+
* console.log('Workflow is valid');
|
|
918
|
+
* } else {
|
|
919
|
+
* console.log('Errors:', result.errors);
|
|
920
|
+
* }
|
|
921
|
+
* ```
|
|
922
|
+
*/
|
|
923
|
+
validate(workflow: Partial<Workflow>): Promise<{
|
|
924
|
+
valid: boolean;
|
|
925
|
+
errors?: Array<{
|
|
926
|
+
path: string;
|
|
927
|
+
message: string;
|
|
928
|
+
}>;
|
|
929
|
+
}>;
|
|
930
|
+
/**
|
|
931
|
+
* Export a single workflow
|
|
932
|
+
*
|
|
933
|
+
* @example
|
|
934
|
+
* ```typescript
|
|
935
|
+
* const exported = await baasix.workflows.export('workflow-uuid');
|
|
936
|
+
* // Save to file or transfer
|
|
937
|
+
* ```
|
|
938
|
+
*/
|
|
939
|
+
export(id: string): Promise<Workflow & {
|
|
940
|
+
exportedAt: string;
|
|
941
|
+
version: string;
|
|
942
|
+
}>;
|
|
943
|
+
/**
|
|
944
|
+
* Export multiple workflows
|
|
945
|
+
*
|
|
946
|
+
* @example
|
|
947
|
+
* ```typescript
|
|
948
|
+
* // Export all workflows
|
|
949
|
+
* const exported = await baasix.workflows.exportAll();
|
|
950
|
+
*
|
|
951
|
+
* // Export specific workflows
|
|
952
|
+
* const exported = await baasix.workflows.exportAll({
|
|
953
|
+
* ids: ['workflow-1', 'workflow-2']
|
|
954
|
+
* });
|
|
955
|
+
* ```
|
|
956
|
+
*/
|
|
957
|
+
exportAll(options?: {
|
|
958
|
+
ids?: string[];
|
|
959
|
+
includeInactive?: boolean;
|
|
960
|
+
}): Promise<{
|
|
961
|
+
workflows: Array<Workflow & {
|
|
962
|
+
exportedAt: string;
|
|
963
|
+
}>;
|
|
964
|
+
exportedAt: string;
|
|
965
|
+
version: string;
|
|
966
|
+
}>;
|
|
967
|
+
/**
|
|
968
|
+
* Preview workflow import without applying changes
|
|
969
|
+
*
|
|
970
|
+
* @example
|
|
971
|
+
* ```typescript
|
|
972
|
+
* const preview = await baasix.workflows.importPreview(file);
|
|
973
|
+
* console.log('Will import:', preview.workflows.length, 'workflows');
|
|
974
|
+
* console.log('Conflicts:', preview.conflicts);
|
|
975
|
+
* ```
|
|
976
|
+
*/
|
|
977
|
+
importPreview(file: File | {
|
|
978
|
+
uri: string;
|
|
979
|
+
name: string;
|
|
980
|
+
type: string;
|
|
981
|
+
}): Promise<{
|
|
982
|
+
workflows: Array<{
|
|
983
|
+
name: string;
|
|
984
|
+
id?: string;
|
|
985
|
+
isNew: boolean;
|
|
986
|
+
}>;
|
|
987
|
+
conflicts: Array<{
|
|
988
|
+
name: string;
|
|
989
|
+
existingId: string;
|
|
990
|
+
}>;
|
|
991
|
+
}>;
|
|
992
|
+
/**
|
|
993
|
+
* Import workflows from a file
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* ```typescript
|
|
997
|
+
* const result = await baasix.workflows.import(file, {
|
|
998
|
+
* overwrite: true
|
|
999
|
+
* });
|
|
1000
|
+
* console.log('Imported:', result.imported, 'workflows');
|
|
1001
|
+
* ```
|
|
1002
|
+
*/
|
|
1003
|
+
import(file: File | {
|
|
1004
|
+
uri: string;
|
|
1005
|
+
name: string;
|
|
1006
|
+
type: string;
|
|
1007
|
+
}, options?: {
|
|
1008
|
+
overwrite?: boolean;
|
|
1009
|
+
}): Promise<{
|
|
1010
|
+
imported: number;
|
|
1011
|
+
skipped: number;
|
|
1012
|
+
errors: Array<{
|
|
1013
|
+
name: string;
|
|
1014
|
+
error: string;
|
|
1015
|
+
}>;
|
|
1016
|
+
}>;
|
|
774
1017
|
}
|
|
775
1018
|
|
|
776
1019
|
interface SocketOptions {
|
|
@@ -835,6 +1078,22 @@ interface RoomUserEvent {
|
|
|
835
1078
|
socketId: string;
|
|
836
1079
|
timestamp: string;
|
|
837
1080
|
}
|
|
1081
|
+
interface RoomKickEvent {
|
|
1082
|
+
room: string;
|
|
1083
|
+
kickedBy: string | number;
|
|
1084
|
+
timestamp: string;
|
|
1085
|
+
}
|
|
1086
|
+
interface RoomCreatorChangedEvent {
|
|
1087
|
+
room: string;
|
|
1088
|
+
newCreatorSocketId: string;
|
|
1089
|
+
newCreatorUserId: string | number;
|
|
1090
|
+
timestamp: string;
|
|
1091
|
+
}
|
|
1092
|
+
interface RoomMember {
|
|
1093
|
+
socketId: string;
|
|
1094
|
+
userId: string | number;
|
|
1095
|
+
isCreator: boolean;
|
|
1096
|
+
}
|
|
838
1097
|
interface SubscriptionCallback<T = any> {
|
|
839
1098
|
(payload: SubscriptionPayload<T>): void;
|
|
840
1099
|
}
|
|
@@ -876,6 +1135,8 @@ declare class RealtimeModule {
|
|
|
876
1135
|
private workflowCallbacks;
|
|
877
1136
|
private roomCallbacks;
|
|
878
1137
|
private roomUserCallbacks;
|
|
1138
|
+
private kickCallbacks;
|
|
1139
|
+
private creatorChangedCallbacks;
|
|
879
1140
|
private connectionCallbacks;
|
|
880
1141
|
private reconnecting;
|
|
881
1142
|
private connectionPromise;
|
|
@@ -1029,6 +1290,52 @@ declare class RealtimeModule {
|
|
|
1029
1290
|
* ```
|
|
1030
1291
|
*/
|
|
1031
1292
|
leaveRoom(roomName: string): Promise<void>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Get the list of users currently in a room.
|
|
1295
|
+
* You must already be a member of the room to call this.
|
|
1296
|
+
*
|
|
1297
|
+
* @example
|
|
1298
|
+
* ```typescript
|
|
1299
|
+
* const members = await baasix.realtime.getRoomMembers('game:lobby');
|
|
1300
|
+
* members.forEach(m => {
|
|
1301
|
+
* console.log(m.userId, m.isCreator ? '(owner)' : '');
|
|
1302
|
+
* });
|
|
1303
|
+
* ```
|
|
1304
|
+
*/
|
|
1305
|
+
getRoomMembers(roomName: string): Promise<RoomMember[]>;
|
|
1306
|
+
/**
|
|
1307
|
+
* Kick a user from a custom room. Only the room creator may call this.
|
|
1308
|
+
*
|
|
1309
|
+
* @example
|
|
1310
|
+
* ```typescript
|
|
1311
|
+
* await baasix.realtime.kickFromRoom('game:lobby', 'user-id-123');
|
|
1312
|
+
* ```
|
|
1313
|
+
*/
|
|
1314
|
+
kickFromRoom(roomName: string, targetUserId: string | number): Promise<void>;
|
|
1315
|
+
/**
|
|
1316
|
+
* Listen for being kicked from a room.
|
|
1317
|
+
* The callback fires when the current user is removed by the room creator.
|
|
1318
|
+
* Room listeners are automatically cleaned up after the kick.
|
|
1319
|
+
*
|
|
1320
|
+
* @example
|
|
1321
|
+
* ```typescript
|
|
1322
|
+
* baasix.realtime.onKicked('game:lobby', ({ kickedBy }) => {
|
|
1323
|
+
* console.log(`You were kicked by user ${kickedBy}`);
|
|
1324
|
+
* });
|
|
1325
|
+
* ```
|
|
1326
|
+
*/
|
|
1327
|
+
onKicked(roomName: string, callback: (data: RoomKickEvent) => void): () => void;
|
|
1328
|
+
/**
|
|
1329
|
+
* Listen for room ownership changes (e.g. when the creator leaves).
|
|
1330
|
+
*
|
|
1331
|
+
* @example
|
|
1332
|
+
* ```typescript
|
|
1333
|
+
* baasix.realtime.onRoomCreatorChanged('game:lobby', ({ newCreatorUserId }) => {
|
|
1334
|
+
* console.log(`New room owner: ${newCreatorUserId}`);
|
|
1335
|
+
* });
|
|
1336
|
+
* ```
|
|
1337
|
+
*/
|
|
1338
|
+
onRoomCreatorChanged(roomName: string, callback: (data: RoomCreatorChangedEvent) => void): () => void;
|
|
1032
1339
|
/**
|
|
1033
1340
|
* Send a message to a room
|
|
1034
1341
|
*
|