@superblocksteam/library 2.0.89-next.1 → 2.0.89
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/jsx-dev-runtime/index.js +1 -1
- package/dist/{jsx-wrapper-C8LEtdzp.js → jsx-wrapper-DL2O6Y1G.js} +10 -84
- package/dist/jsx-wrapper-DL2O6Y1G.js.map +1 -0
- package/dist/lib/index.d.ts +35 -408
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +60 -654
- package/dist/lib/index.js.map +1 -1
- package/package.json +3 -5
- package/dist/jsx-wrapper-C8LEtdzp.js.map +0 -1
package/dist/lib/index.d.ts
CHANGED
|
@@ -2,11 +2,10 @@ import { Callback, ControlType, DataType, DataTypeString, EntityDefinition, Head
|
|
|
2
2
|
import { Dim, EditorConfig, EvaluateOrValueComputedArgs, Property, TailwindPropertyKey } from "@superblocksteam/library-shared";
|
|
3
3
|
import { DataRouter, Location, Params } from "react-router";
|
|
4
4
|
import * as React$2 from "react";
|
|
5
|
-
import React$1, { LegacyRef, ReactNode
|
|
5
|
+
import React$1, { LegacyRef, ReactNode } from "react";
|
|
6
6
|
import { OrchestratorViewMode, PlaceholderInfo, Profile } from "@superblocksteam/shared";
|
|
7
7
|
import { AiContextMode, AppToEditorMessage, Catalog, CatalogWithInternalDetails, ComponentRegistryShareState, ConsoleLogEntry, CreateChild, CreateChild as CreateChild$1, CreateRequest, DeleteMeLibraryApi, DeleteRequest, EditOperationPayload, EditOperationType, EditOperations, EditorConfig as EditorConfig$1, Entity, EntityOutputProp, InitData, InteractionMode, PayloadAction, PropertyInfo, ReparentRequest, RuntimeErrorData, RuntimeSyncComposite, SbApiRunOptions, SbElement, SbSelector, SetPropertiesRequest, SetPropertyRequest, SourceLocation, TransactionInfo, UrlState, ViteMessage, ViteMessageKind, WithBindingIdentifier } from "@superblocksteam/library-shared/types";
|
|
8
8
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
9
|
-
import { CompiledApi, CompiledStreamingApi } from "@superblocksteam/sdk-api";
|
|
10
9
|
import { Graph } from "@dagrejs/graphlib";
|
|
11
10
|
import { XYCoord } from "react-dnd";
|
|
12
11
|
|
|
@@ -32,20 +31,18 @@ type Group = {
|
|
|
32
31
|
name: string;
|
|
33
32
|
size: number;
|
|
34
33
|
};
|
|
35
|
-
type
|
|
34
|
+
type Profiles = {
|
|
36
35
|
available: Profile[];
|
|
37
36
|
selected?: Profile;
|
|
38
37
|
default: Profile;
|
|
39
38
|
};
|
|
40
|
-
/** @deprecated Use DataTags instead */
|
|
41
|
-
type Profiles = DataTags;
|
|
42
39
|
declare class SuperblocksAppContext {
|
|
43
40
|
private context?;
|
|
44
41
|
constructor();
|
|
45
42
|
get user(): User | undefined;
|
|
46
43
|
get groups(): Group[] | undefined;
|
|
47
44
|
get selectedProfile(): Profile | undefined;
|
|
48
|
-
get profiles():
|
|
45
|
+
get profiles(): Profiles | undefined;
|
|
49
46
|
setProfile(profileKey: string): void;
|
|
50
47
|
updateContext(context: Partial<SuperblocksAppContext>): void;
|
|
51
48
|
getGlobal(): {
|
|
@@ -62,14 +59,9 @@ declare class SuperblocksAppContext {
|
|
|
62
59
|
}
|
|
63
60
|
declare function useSuperblocksUser(): User | undefined;
|
|
64
61
|
declare function useSuperblocksGroups(): Group[] | undefined;
|
|
65
|
-
declare function useSuperblocksDataTags(): {
|
|
66
|
-
dataTags: DataTags | undefined;
|
|
67
|
-
setDataTag: (dataTagKey: string) => void;
|
|
68
|
-
};
|
|
69
|
-
/** @deprecated Use useSuperblocksDataTags instead */
|
|
70
62
|
declare function useSuperblocksProfiles(): {
|
|
71
|
-
profiles:
|
|
72
|
-
setProfile: (
|
|
63
|
+
profiles: Profiles | undefined;
|
|
64
|
+
setProfile: (profileKey: string) => void;
|
|
73
65
|
};
|
|
74
66
|
declare function getAppMode(): AppMode | undefined;
|
|
75
67
|
//#endregion
|
|
@@ -138,45 +130,6 @@ interface StreamEvent {
|
|
|
138
130
|
};
|
|
139
131
|
}
|
|
140
132
|
type RouteInfo = Omit<UrlState, "host" | "hostname" | "href" | "port" | "protocol">;
|
|
141
|
-
/**
|
|
142
|
-
* Schema representation for SDK API input/output/chunk schemas.
|
|
143
|
-
* Contains both TypeScript and JSON Schema formats for display in the UI.
|
|
144
|
-
*/
|
|
145
|
-
interface SdkApiSchemaInfo {
|
|
146
|
-
/** TypeScript type string representation, e.g., "{ userId: string; limit?: number }" */
|
|
147
|
-
typescript: string;
|
|
148
|
-
/** JSON Schema representation for the schema */
|
|
149
|
-
jsonSchema: object;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Metadata for an SDK API, sent from the library to ui-code-mode
|
|
153
|
-
* when an SDK API is registered.
|
|
154
|
-
*/
|
|
155
|
-
interface SdkApiMetadata {
|
|
156
|
-
/** Unique name of the API */
|
|
157
|
-
name: string;
|
|
158
|
-
/** Input schema information */
|
|
159
|
-
inputSchema: SdkApiSchemaInfo;
|
|
160
|
-
/** Output schema information (for non-streaming APIs) */
|
|
161
|
-
outputSchema?: SdkApiSchemaInfo;
|
|
162
|
-
/** Chunk schema information (for streaming APIs) */
|
|
163
|
-
chunkSchema?: SdkApiSchemaInfo;
|
|
164
|
-
/** Whether this is a streaming API */
|
|
165
|
-
isStreaming: boolean;
|
|
166
|
-
/** Declared integrations for this API */
|
|
167
|
-
integrations: Array<{
|
|
168
|
-
/** Key used in the API code to reference this integration */
|
|
169
|
-
key: string;
|
|
170
|
-
/** Plugin ID (e.g., "postgres", "slack") */
|
|
171
|
-
pluginId: string;
|
|
172
|
-
/** Integration name (e.g., "Production Postgres") */
|
|
173
|
-
name: string;
|
|
174
|
-
/** Integration ID (UUID) */
|
|
175
|
-
id: string;
|
|
176
|
-
}>;
|
|
177
|
-
/** TypeScript source code of the API */
|
|
178
|
-
sourceCode?: string;
|
|
179
|
-
}
|
|
180
133
|
type RouteChangePayload = Omit<UrlState, "host" | "hostname" | "href" | "pathname" | "port" | "protocol">;
|
|
181
134
|
type AiUpdatesPayload = {
|
|
182
135
|
parentToChild: {
|
|
@@ -231,11 +184,6 @@ type AgentInfo = {
|
|
|
231
184
|
};
|
|
232
185
|
type FromParentToChildMessageTypesMap = {
|
|
233
186
|
"sb-init": InitData;
|
|
234
|
-
"sdk-execute-api-internal": {
|
|
235
|
-
apiName: string;
|
|
236
|
-
input: Record<string, unknown>;
|
|
237
|
-
callbackId: string;
|
|
238
|
-
};
|
|
239
187
|
"sb-bootstrap-response": {
|
|
240
188
|
userId?: string;
|
|
241
189
|
appId: string;
|
|
@@ -290,17 +238,7 @@ type FromParentToChildMessageTypesMap = {
|
|
|
290
238
|
"canvas-scale-update": {
|
|
291
239
|
canvasScaleFactor: number;
|
|
292
240
|
};
|
|
293
|
-
/**
|
|
294
|
-
* Resolve a promise created by addNewPromise.
|
|
295
|
-
* Note: callbackId must be at the top level, not nested in payload.
|
|
296
|
-
* Payload contains the resolution value.
|
|
297
|
-
*/
|
|
298
241
|
"resolve-promise": unknown;
|
|
299
|
-
/**
|
|
300
|
-
* Reject a promise created by addNewPromise.
|
|
301
|
-
* Note: callbackId must be at the top level, not nested in payload.
|
|
302
|
-
* Payload contains the error object.
|
|
303
|
-
*/
|
|
304
242
|
"reject-promise": unknown;
|
|
305
243
|
"flash-element": {
|
|
306
244
|
elementId: string;
|
|
@@ -394,35 +332,6 @@ type FromParentToChildMessageTypesMap = {
|
|
|
394
332
|
callbackId: string;
|
|
395
333
|
sourceIds: string[];
|
|
396
334
|
};
|
|
397
|
-
/**
|
|
398
|
-
* Execute an SDK-based API by name in the iframe.
|
|
399
|
-
* The parent (ui-code-mode) sends this to the library iframe to execute the API.
|
|
400
|
-
*/
|
|
401
|
-
"sdk-execute-api": {
|
|
402
|
-
apiName: string;
|
|
403
|
-
input: Record<string, unknown>;
|
|
404
|
-
callbackId: string;
|
|
405
|
-
};
|
|
406
|
-
/**
|
|
407
|
-
* Send a chunk from a streaming query back to the library.
|
|
408
|
-
* Used during SDK streaming API execution.
|
|
409
|
-
*/
|
|
410
|
-
"sdk-stream-chunk": {
|
|
411
|
-
streamId: string;
|
|
412
|
-
chunk?: unknown;
|
|
413
|
-
done?: boolean;
|
|
414
|
-
error?: {
|
|
415
|
-
code: string;
|
|
416
|
-
message: string;
|
|
417
|
-
};
|
|
418
|
-
};
|
|
419
|
-
/**
|
|
420
|
-
* Request the TypeScript source code for an SDK API.
|
|
421
|
-
*/
|
|
422
|
-
"sdk-get-api-code": {
|
|
423
|
-
name: string;
|
|
424
|
-
callbackId: string;
|
|
425
|
-
};
|
|
426
335
|
};
|
|
427
336
|
type FromParentToChildMessageTypes = keyof FromParentToChildMessageTypesMap;
|
|
428
337
|
type FromChildToParentMessageTypesMap = {
|
|
@@ -441,17 +350,7 @@ type FromChildToParentMessageTypesMap = {
|
|
|
441
350
|
newWindow?: boolean;
|
|
442
351
|
};
|
|
443
352
|
"sb-iframe-track-changes": Record<string, unknown>;
|
|
444
|
-
/**
|
|
445
|
-
* Resolve a promise created by addNewPromise.
|
|
446
|
-
* Note: callbackId must be at the top level, not nested in payload.
|
|
447
|
-
* Payload contains the resolution value.
|
|
448
|
-
*/
|
|
449
353
|
"resolve-promise": unknown;
|
|
450
|
-
/**
|
|
451
|
-
* Reject a promise created by addNewPromise.
|
|
452
|
-
* Note: callbackId must be at the top level, not nested in payload.
|
|
453
|
-
* Payload contains the error object.
|
|
454
|
-
*/
|
|
455
354
|
"reject-promise": unknown;
|
|
456
355
|
"sb-editor-request-bootstrap": void;
|
|
457
356
|
"reload-configs": void;
|
|
@@ -508,63 +407,6 @@ type FromChildToParentMessageTypesMap = {
|
|
|
508
407
|
apiId: string;
|
|
509
408
|
callbackId: string;
|
|
510
409
|
};
|
|
511
|
-
/**
|
|
512
|
-
* Execute an integration query as part of SDK API execution.
|
|
513
|
-
* The parent (ui-code-mode) will dispatch executeRequestToIntegration
|
|
514
|
-
* and resolve the promise with the result.
|
|
515
|
-
*
|
|
516
|
-
* For language plugins (Python, JavaScript), the input parameter contains
|
|
517
|
-
* bindings that should be passed to the API execution request for {{}} resolution.
|
|
518
|
-
*/
|
|
519
|
-
"sdk-execute-query": {
|
|
520
|
-
integrationId: string;
|
|
521
|
-
request: Record<string, unknown>;
|
|
522
|
-
input?: Record<string, unknown>;
|
|
523
|
-
callbackId: string;
|
|
524
|
-
};
|
|
525
|
-
/**
|
|
526
|
-
* Execute an SDK-based API by name.
|
|
527
|
-
* The parent (ui-code-mode) will load the API, validate inputs,
|
|
528
|
-
* and execute it with the provided input.
|
|
529
|
-
*
|
|
530
|
-
* This message is sent from the library iframe to request API execution.
|
|
531
|
-
*/
|
|
532
|
-
"sdk-execute-api": {
|
|
533
|
-
apiName: string;
|
|
534
|
-
input: Record<string, unknown>;
|
|
535
|
-
callbackId: string;
|
|
536
|
-
};
|
|
537
|
-
/**
|
|
538
|
-
* Resolve integration configs before SDK API execution.
|
|
539
|
-
* The parent (ui-code-mode) will look up each integration by ID,
|
|
540
|
-
* ensure it's authenticated, and return the resolved configs.
|
|
541
|
-
*
|
|
542
|
-
* This enables upfront auth checks before API execution starts.
|
|
543
|
-
*/
|
|
544
|
-
"sdk-resolve-integrations": {
|
|
545
|
-
integrations: Array<{
|
|
546
|
-
key: string;
|
|
547
|
-
pluginId: string;
|
|
548
|
-
id: string;
|
|
549
|
-
}>;
|
|
550
|
-
callbackId: string;
|
|
551
|
-
};
|
|
552
|
-
/**
|
|
553
|
-
* Execute a streaming integration query as part of SDK streaming API execution.
|
|
554
|
-
* The parent (ui-code-mode) will dispatch streaming execution and send
|
|
555
|
-
* chunks back via sdk-stream-chunk messages.
|
|
556
|
-
*/
|
|
557
|
-
"sdk-execute-streaming-query": {
|
|
558
|
-
integrationId: string;
|
|
559
|
-
request: Record<string, unknown>;
|
|
560
|
-
streamId: string;
|
|
561
|
-
};
|
|
562
|
-
/**
|
|
563
|
-
* Cancel an in-progress streaming query.
|
|
564
|
-
*/
|
|
565
|
-
"sdk-cancel-stream": {
|
|
566
|
-
streamId: string;
|
|
567
|
-
};
|
|
568
410
|
"set-apis-deployed-mode": {
|
|
569
411
|
apis: Array<DeleteMeLibraryApi & {
|
|
570
412
|
scopeId: string;
|
|
@@ -620,67 +462,6 @@ type FromChildToParentMessageTypesMap = {
|
|
|
620
462
|
eventName: string;
|
|
621
463
|
payload: Record<string, unknown>;
|
|
622
464
|
};
|
|
623
|
-
/**
|
|
624
|
-
* Notify the parent when an SDK API is registered (loaded).
|
|
625
|
-
* Contains metadata including input/output schemas for display in the UI.
|
|
626
|
-
*/
|
|
627
|
-
"sdk-api-registered": {
|
|
628
|
-
name: string;
|
|
629
|
-
metadata: SdkApiMetadata;
|
|
630
|
-
};
|
|
631
|
-
/**
|
|
632
|
-
* Notify the parent when an SDK API is unregistered (HMR unload).
|
|
633
|
-
*/
|
|
634
|
-
"sdk-api-unregistered": {
|
|
635
|
-
name: string;
|
|
636
|
-
};
|
|
637
|
-
/**
|
|
638
|
-
* Notify the parent when an SDK API's source code has been updated.
|
|
639
|
-
* Used for HMR to update the code viewer without full re-registration.
|
|
640
|
-
*/
|
|
641
|
-
"sdk-api-source-updated": {
|
|
642
|
-
name: string;
|
|
643
|
-
sourceCode: string;
|
|
644
|
-
};
|
|
645
|
-
/**
|
|
646
|
-
* Response to sdk-get-api-code request with the TypeScript source code.
|
|
647
|
-
*/
|
|
648
|
-
"sdk-api-code-response": {
|
|
649
|
-
callbackId: string;
|
|
650
|
-
name: string;
|
|
651
|
-
code?: string;
|
|
652
|
-
error?: string;
|
|
653
|
-
};
|
|
654
|
-
/**
|
|
655
|
-
* Notify the parent when an SDK API execution starts (from app code).
|
|
656
|
-
* Used for tracking executions in the SDK API editor's execution log.
|
|
657
|
-
*/
|
|
658
|
-
"sdk-api-execution-started": {
|
|
659
|
-
executionId: string;
|
|
660
|
-
apiName: string;
|
|
661
|
-
input: Record<string, unknown>;
|
|
662
|
-
};
|
|
663
|
-
/**
|
|
664
|
-
* Notify the parent when an SDK API execution completes successfully.
|
|
665
|
-
*/
|
|
666
|
-
"sdk-api-execution-completed": {
|
|
667
|
-
executionId: string;
|
|
668
|
-
apiName: string;
|
|
669
|
-
output: unknown;
|
|
670
|
-
durationMs: number;
|
|
671
|
-
};
|
|
672
|
-
/**
|
|
673
|
-
* Notify the parent when an SDK API execution fails.
|
|
674
|
-
*/
|
|
675
|
-
"sdk-api-execution-failed": {
|
|
676
|
-
executionId: string;
|
|
677
|
-
apiName: string;
|
|
678
|
-
error: {
|
|
679
|
-
code: string;
|
|
680
|
-
message: string;
|
|
681
|
-
};
|
|
682
|
-
durationMs: number;
|
|
683
|
-
};
|
|
684
465
|
} & AppToEditorMessage<PropertiesPanelDefinition$1>;
|
|
685
466
|
type FromChildToParentMessageTypes = keyof FromChildToParentMessageTypesMap;
|
|
686
467
|
//#endregion
|
|
@@ -1112,22 +893,6 @@ declare class EditStore {
|
|
|
1112
893
|
}
|
|
1113
894
|
//#endregion
|
|
1114
895
|
//#region src/lib/internal-details/lib/root-store.d.ts
|
|
1115
|
-
/**
|
|
1116
|
-
* User information extracted from JWT for SDK API execution.
|
|
1117
|
-
* Matches the ApiUser interface from @superblocksteam/sdk-api.
|
|
1118
|
-
*/
|
|
1119
|
-
interface SdkApiUser {
|
|
1120
|
-
/** Unique user identifier from JWT */
|
|
1121
|
-
readonly userId: string;
|
|
1122
|
-
/** User's email address (if available) */
|
|
1123
|
-
readonly email?: string;
|
|
1124
|
-
/** User's display name (if available) */
|
|
1125
|
-
readonly name?: string;
|
|
1126
|
-
/** User's group memberships from JWT */
|
|
1127
|
-
readonly groups: string[];
|
|
1128
|
-
/** Custom claims from JWT */
|
|
1129
|
-
readonly customClaims: Readonly<Record<string, unknown>>;
|
|
1130
|
-
}
|
|
1131
896
|
declare class RootStore {
|
|
1132
897
|
apis: ApiManager;
|
|
1133
898
|
componentRegistry: ComponentRegistry;
|
|
@@ -1137,29 +902,8 @@ declare class RootStore {
|
|
|
1137
902
|
applicationId: string | undefined;
|
|
1138
903
|
userId: string | undefined;
|
|
1139
904
|
windowOriginUrl: string | undefined;
|
|
1140
|
-
/**
|
|
1141
|
-
* Current user info for SDK API execution.
|
|
1142
|
-
* Populated from JWT claims when available.
|
|
1143
|
-
*/
|
|
1144
|
-
sdkUser: SdkApiUser;
|
|
1145
|
-
/**
|
|
1146
|
-
* Whether the SDK API feature is enabled.
|
|
1147
|
-
* Derived from the application's templateName (see `isSdkApiTemplate()`).
|
|
1148
|
-
* Passed to the library via the `clark.sdk-api.enabled` bootstrap flag.
|
|
1149
|
-
* When false, the YAML-based API system is used instead.
|
|
1150
|
-
*/
|
|
1151
|
-
sdkApiEnabled: boolean;
|
|
1152
905
|
private editorRegisteredCallbacks;
|
|
1153
906
|
constructor();
|
|
1154
|
-
/**
|
|
1155
|
-
* Updates the SDK user info from JWT claims or bootstrap data.
|
|
1156
|
-
*/
|
|
1157
|
-
setSdkUser(user: Partial<SdkApiUser>): void;
|
|
1158
|
-
/**
|
|
1159
|
-
* Sets the SDK API feature flag state.
|
|
1160
|
-
* Called during bootstrap with the value from feature flags.
|
|
1161
|
-
*/
|
|
1162
|
-
setSdkApiEnabled(enabled: boolean): void;
|
|
1163
907
|
setEditStore(editStore: EditStore): void;
|
|
1164
908
|
notifyEditorRegistered(): void;
|
|
1165
909
|
onEditorRegistered(fn: () => void): void;
|
|
@@ -1639,168 +1383,51 @@ type ApiInterfaces<Name extends string> = Name extends keyof SuperblocksAPIRegis
|
|
|
1639
1383
|
output: never;
|
|
1640
1384
|
};
|
|
1641
1385
|
/**
|
|
1642
|
-
*
|
|
1386
|
+
* React hook for executing Superblocks APIs with type-safe inputs and outputs.
|
|
1643
1387
|
*
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1646
|
-
*/
|
|
1647
|
-
|
|
1648
|
-
/** Helper type to extract input type from a CompiledApi */
|
|
1649
|
-
type ApiInput<T> = T extends CompiledApi<infer TInput, any> ? TInput : never;
|
|
1650
|
-
/** Helper type to extract output type from a CompiledApi */
|
|
1651
|
-
type ApiOutput<T> = T extends CompiledApi<any, infer TOutput> ? TOutput : never;
|
|
1652
|
-
/** Return type for useApi hook */
|
|
1653
|
-
interface UseApiResult<TInput, TOutput> {
|
|
1654
|
-
run: (inputs: TInput) => Promise<TOutput | undefined>;
|
|
1655
|
-
cancel: () => Promise<void>;
|
|
1656
|
-
}
|
|
1657
|
-
/**
|
|
1658
|
-
* API Registry interface for type inference.
|
|
1659
|
-
*
|
|
1660
|
-
* This interface is used with useTypedApi to enable automatic type inference.
|
|
1661
|
-
* Apps define their own ApiRegistry type and pass it to useTypedApi.
|
|
1388
|
+
* @param name - The name of the registered API to execute
|
|
1389
|
+
* @returns An object with `run` and `cancel` functions
|
|
1662
1390
|
*
|
|
1663
1391
|
* @example
|
|
1664
1392
|
* ```typescript
|
|
1665
|
-
*
|
|
1666
|
-
* const apis = { GetUsers, CreateOrder } as const;
|
|
1667
|
-
* export type ApiRegistry = typeof apis;
|
|
1393
|
+
* const myApi = useApiStateful("getUserData");
|
|
1668
1394
|
*
|
|
1669
|
-
*
|
|
1670
|
-
*
|
|
1671
|
-
*
|
|
1672
|
-
*
|
|
1395
|
+
* try {
|
|
1396
|
+
* const result = await myApi.run({ userId: "123" });
|
|
1397
|
+
* console.log(result);
|
|
1398
|
+
* } catch (error) {
|
|
1399
|
+
* // error is a string describing what went wrong
|
|
1400
|
+
* console.error(error);
|
|
1401
|
+
* }
|
|
1673
1402
|
* ```
|
|
1674
|
-
*/
|
|
1675
|
-
interface ApiRegistry {}
|
|
1676
|
-
/**
|
|
1677
|
-
* Conditional return type for useApi.
|
|
1678
|
-
* Returns typed result if the API name is in the registry, otherwise unknown.
|
|
1679
|
-
*/
|
|
1680
|
-
type UseApiReturnType<TName extends string> = TName extends keyof ApiRegistry ? UseApiResult<ApiInput<ApiRegistry[TName]>, ApiOutput<ApiRegistry[TName]>> : UseApiResult<unknown, unknown>;
|
|
1681
|
-
/**
|
|
1682
|
-
* React hook for executing YAML-based Superblocks APIs.
|
|
1683
|
-
*
|
|
1684
|
-
* This is the legacy API system that uses `rootStore.apis.runApiByPath`.
|
|
1685
|
-
* It remains the default when the `sdkApiEnabled` flag is off.
|
|
1686
|
-
*
|
|
1687
|
-
* @param name - The name of the registered API to execute
|
|
1688
|
-
* @returns An object with `run` and `cancel` functions
|
|
1689
|
-
*/
|
|
1690
|
-
declare function useApiStateful<Name extends RegisteredAPINames, Inputs = ApiInterfaces<Name>["input"], Response = ApiInterfaces<Name>["output"]>(name: Name): {
|
|
1691
|
-
run: (inputs?: Inputs) => Promise<Response | undefined>;
|
|
1692
|
-
cancel: () => Promise<void>;
|
|
1693
|
-
};
|
|
1694
|
-
/**
|
|
1695
|
-
* React hook for calling APIs with automatic type inference.
|
|
1696
1403
|
*
|
|
1697
|
-
*
|
|
1698
|
-
* a message to the parent frame which loads and executes the SDK-based API.
|
|
1404
|
+
* ## Error Handling
|
|
1699
1405
|
*
|
|
1700
|
-
* When
|
|
1701
|
-
*
|
|
1406
|
+
* When an API execution fails, the `run` function throws a **string** error message.
|
|
1407
|
+
* The error format can be one of:
|
|
1702
1408
|
*
|
|
1703
|
-
*
|
|
1704
|
-
*
|
|
1409
|
+
* - **Client errors (4xx)**: System error message from the server
|
|
1410
|
+
* - Example: `"Authentication failed"`, `"Invalid request parameters"`
|
|
1705
1411
|
*
|
|
1706
|
-
*
|
|
1707
|
-
*
|
|
1708
|
-
*/
|
|
1709
|
-
declare function useApi<TName extends string>(apiName: TName): UseApiReturnType<TName>;
|
|
1710
|
-
declare function useApi<TApi extends CompiledApi<unknown, unknown>>(apiName: string): UseApiResult<ApiInput<TApi>, ApiOutput<TApi>>;
|
|
1711
|
-
/**
|
|
1712
|
-
* Type for a registry of compiled APIs.
|
|
1713
|
-
* Used with useTypedApi to enable automatic type inference.
|
|
1714
|
-
*/
|
|
1715
|
-
type AnyApiRegistry = Record<string, CompiledApi<any, any>>;
|
|
1716
|
-
/**
|
|
1717
|
-
* Typed useApi function signature for a specific registry.
|
|
1718
|
-
*/
|
|
1719
|
-
type TypedUseApi<TRegistry extends AnyApiRegistry> = <TName extends keyof TRegistry & string>(apiName: TName) => UseApiResult<ApiInput<TRegistry[TName]>, ApiOutput<TRegistry[TName]>>;
|
|
1720
|
-
/**
|
|
1721
|
-
* Creates a typed version of useApi bound to a specific API registry type.
|
|
1412
|
+
* - **API execution errors**: Formatted message from unhandled API errors
|
|
1413
|
+
* - Example: `"Error in API: Division by zero"`, `"Error in API: Database connection failed"`
|
|
1722
1414
|
*
|
|
1723
|
-
*
|
|
1724
|
-
*
|
|
1415
|
+
* - **Infrastructure errors**: High-level error messages
|
|
1416
|
+
* - Example: `"No application ID was found"`, `"No active agent found"`
|
|
1725
1417
|
*
|
|
1726
|
-
*
|
|
1727
|
-
*/
|
|
1728
|
-
declare function useTypedApi<TRegistry extends AnyApiRegistry>(): TypedUseApi<TRegistry>;
|
|
1729
|
-
//#endregion
|
|
1730
|
-
//#region src/lib/internal-details/use-streaming-api.d.ts
|
|
1731
|
-
/**
|
|
1732
|
-
* React hook for calling streaming SDK APIs with real-time chunk delivery.
|
|
1733
|
-
*
|
|
1734
|
-
* Returns an AsyncGenerator that yields chunks as they arrive, allowing
|
|
1735
|
-
* natural iteration with `for await...of`.
|
|
1736
|
-
*
|
|
1737
|
-
* @param api - The imported CompiledStreamingApi definition
|
|
1738
|
-
* @returns Object with `stream` function and `cancel` function
|
|
1418
|
+
* The error is also logged to the console before being thrown.
|
|
1739
1419
|
*
|
|
1740
|
-
*
|
|
1741
|
-
* ```typescript
|
|
1742
|
-
* import StreamChatApi from "../apis/StreamChat/api";
|
|
1743
|
-
* import { useStreamingApi } from "@superblocksteam/library";
|
|
1744
|
-
*
|
|
1745
|
-
* const { stream, cancel } = useStreamingApi(StreamChatApi);
|
|
1420
|
+
* ## Usage Notes
|
|
1746
1421
|
*
|
|
1747
|
-
*
|
|
1748
|
-
*
|
|
1749
|
-
*
|
|
1750
|
-
*
|
|
1751
|
-
* console.log(chunk.text);
|
|
1752
|
-
* // Update UI with each chunk
|
|
1753
|
-
* }
|
|
1754
|
-
* ```
|
|
1755
|
-
*
|
|
1756
|
-
* @example With try/catch for error handling
|
|
1757
|
-
* ```typescript
|
|
1758
|
-
* const { stream } = useStreamingApi(StreamChatApi);
|
|
1759
|
-
*
|
|
1760
|
-
* try {
|
|
1761
|
-
* for await (const chunk of stream({ prompt: "Hello!" })) {
|
|
1762
|
-
* appendToOutput(chunk.text);
|
|
1763
|
-
* }
|
|
1764
|
-
* console.log("Stream completed!");
|
|
1765
|
-
* } catch (error) {
|
|
1766
|
-
* console.error("Stream error:", error);
|
|
1767
|
-
* }
|
|
1768
|
-
* ```
|
|
1422
|
+
* - Always wrap `run()` calls in try/catch blocks to handle errors gracefully
|
|
1423
|
+
* - Errors are thrown as strings, not Error objects
|
|
1424
|
+
* - If the API executes successfully but returns no data, `run()` returns `undefined`
|
|
1425
|
+
* - Use `cancel()` to abort in-flight API requests
|
|
1769
1426
|
*/
|
|
1770
|
-
declare function
|
|
1771
|
-
|
|
1772
|
-
cancel: () => void
|
|
1427
|
+
declare function useApiStateful<Name extends RegisteredAPINames, Inputs = ApiInterfaces<Name>["input"], Response = ApiInterfaces<Name>["output"]>(name: Name): {
|
|
1428
|
+
run: (inputs?: Inputs) => Promise<Response | undefined>;
|
|
1429
|
+
cancel: () => Promise<void>;
|
|
1773
1430
|
};
|
|
1774
|
-
/**
|
|
1775
|
-
* @deprecated Use the new AsyncGenerator-based API instead.
|
|
1776
|
-
* Callback options for streaming API execution.
|
|
1777
|
-
*/
|
|
1778
|
-
interface StreamingCallbacks<TChunk> {
|
|
1779
|
-
/** Called for each chunk as it arrives */
|
|
1780
|
-
onChunk?: (chunk: TChunk, index: number) => void;
|
|
1781
|
-
/** Called when streaming completes successfully */
|
|
1782
|
-
onComplete?: (totalChunks: number) => void;
|
|
1783
|
-
/** Called if an error occurs during streaming */
|
|
1784
|
-
onError?: (error: {
|
|
1785
|
-
code: string;
|
|
1786
|
-
message: string;
|
|
1787
|
-
}) => void;
|
|
1788
|
-
}
|
|
1789
|
-
/**
|
|
1790
|
-
* @deprecated Use the new AsyncGenerator-based API instead.
|
|
1791
|
-
* Result of a streaming API execution.
|
|
1792
|
-
*/
|
|
1793
|
-
interface StreamingResult {
|
|
1794
|
-
/** Whether the streaming completed successfully */
|
|
1795
|
-
success: boolean;
|
|
1796
|
-
/** Total number of chunks received */
|
|
1797
|
-
totalChunks: number;
|
|
1798
|
-
/** Error details if success is false */
|
|
1799
|
-
error?: {
|
|
1800
|
-
code: string;
|
|
1801
|
-
message: string;
|
|
1802
|
-
};
|
|
1803
|
-
}
|
|
1804
1431
|
//#endregion
|
|
1805
1432
|
//#region src/lib/user-facing/global-functions.d.ts
|
|
1806
1433
|
declare function logoutIntegrations(): Promise<void>;
|
|
@@ -1982,5 +1609,5 @@ declare function useEmbedEvent(eventName: string, handler: (payload: Record<stri
|
|
|
1982
1609
|
*/
|
|
1983
1610
|
declare function useEmitEmbedEvent(): (eventName: string, payload?: Record<string, unknown>) => void;
|
|
1984
1611
|
//#endregion
|
|
1985
|
-
export { type AgentInfo,
|
|
1612
|
+
export { type AgentInfo, App, type CreateChild, type CreationContext, type EditorConfig, type EditorTemplate, type FromChildToParentMessageTypes, type FromChildToParentMessageTypesMap, type FromParentToChildMessageTypes, type FromParentToChildMessageTypesMap, PageNotFound, Prop, type PropertiesPanelDefinition, Property, PropsCategory, RouteLoadError, Section, Superblocks, SbProvider as SuperblocksProvider, embedStore, getAppMode, logoutIntegrations, registerComponent, tailwindStylesCategory, useApiStateful as useApi, useEmbedEvent, useEmbedProperties, useEmitEmbedEvent, useSuperblocksGroups, useSuperblocksProfiles, useSuperblocksUser };
|
|
1986
1613
|
//# sourceMappingURL=index.d.ts.map
|