@superblocksteam/library 2.0.93 → 2.0.94-next.1
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-DdcywsRY.js} +189 -9
- package/dist/jsx-wrapper-DdcywsRY.js.map +1 -0
- package/dist/lib/index.d.ts +96 -30
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +188 -31
- package/dist/lib/index.js.map +1 -1
- package/package.json +17 -18
- package/dist/jsx-wrapper-C8LEtdzp.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as root_store_default, t as makeWrappedComponent, x as api_hmr_tracker_default } from "../jsx-wrapper-DdcywsRY.js";
|
|
2
2
|
import { SOURCE_ID_ATTRIBUTE } from "@superblocksteam/library-shared";
|
|
3
3
|
import * as ReactJsxDevRuntime from "react/jsx-dev-runtime";
|
|
4
4
|
|
|
@@ -1599,6 +1599,12 @@ function sendNotification({ message, description, duration, key = getKey("succes
|
|
|
1599
1599
|
});
|
|
1600
1600
|
}
|
|
1601
1601
|
|
|
1602
|
+
//#endregion
|
|
1603
|
+
//#region src/lib/utils/generate-id.ts
|
|
1604
|
+
const generateId = () => {
|
|
1605
|
+
return Math.random().toString(36).substring(2, 15);
|
|
1606
|
+
};
|
|
1607
|
+
|
|
1602
1608
|
//#endregion
|
|
1603
1609
|
//#region src/lib/internal-details/scope/types.ts
|
|
1604
1610
|
const AppMode = {
|
|
@@ -1842,12 +1848,6 @@ function getTraceContextHeadersFromSpan(span) {
|
|
|
1842
1848
|
return traceContextHeaders;
|
|
1843
1849
|
}
|
|
1844
1850
|
|
|
1845
|
-
//#endregion
|
|
1846
|
-
//#region src/lib/utils/generate-id.ts
|
|
1847
|
-
const generateId = () => {
|
|
1848
|
-
return Math.random().toString(36).substring(2, 15);
|
|
1849
|
-
};
|
|
1850
|
-
|
|
1851
1851
|
//#endregion
|
|
1852
1852
|
//#region src/lib/internal-details/lib/types.ts
|
|
1853
1853
|
let SystemErrorType = /* @__PURE__ */ function(SystemErrorType$1) {
|
|
@@ -2540,6 +2540,103 @@ var ApiManager = class {
|
|
|
2540
2540
|
}
|
|
2541
2541
|
return stepLogs;
|
|
2542
2542
|
}
|
|
2543
|
+
/**
|
|
2544
|
+
* Execute an SDK API directly via the orchestrator's v3/execute endpoint.
|
|
2545
|
+
* Reads execution context (profile, branch, tokens) from rootStore so the
|
|
2546
|
+
* caller doesn't need to resolve them through the parent frame.
|
|
2547
|
+
*/
|
|
2548
|
+
async executeSdkApiV3(apiName, inputs) {
|
|
2549
|
+
const applicationId = this.rootStore.applicationId;
|
|
2550
|
+
if (!applicationId) return {
|
|
2551
|
+
success: false,
|
|
2552
|
+
error: {
|
|
2553
|
+
code: "NO_APP_ID",
|
|
2554
|
+
message: "No application ID found"
|
|
2555
|
+
}
|
|
2556
|
+
};
|
|
2557
|
+
await this.rootStore.awaitDiscovery();
|
|
2558
|
+
const entryPoint = this.rootStore.getApiEntryPoint(apiName);
|
|
2559
|
+
if (!entryPoint) return {
|
|
2560
|
+
success: false,
|
|
2561
|
+
error: {
|
|
2562
|
+
code: "UNKNOWN_API",
|
|
2563
|
+
message: `No entryPoint registered for API "${apiName}". Was it discovered?`
|
|
2564
|
+
}
|
|
2565
|
+
};
|
|
2566
|
+
const profile = this.rootStore.profile;
|
|
2567
|
+
const branchName = this.rootStore.branchName;
|
|
2568
|
+
const commitId = this.rootStore.commitId;
|
|
2569
|
+
const editMode$1 = isEditMode();
|
|
2570
|
+
const appMode$1 = getAppMode();
|
|
2571
|
+
const viewMode = editMode$1 ? ViewMode.EDITOR : appMode$1 === AppMode.PREVIEW ? ViewMode.PREVIEW : ViewMode.DEPLOYED;
|
|
2572
|
+
const profileKey = profile?.key ?? "default";
|
|
2573
|
+
const agentBaseUrl = this.getRandomAgentBaseUrl(profileKey);
|
|
2574
|
+
if (!agentBaseUrl) return {
|
|
2575
|
+
success: false,
|
|
2576
|
+
error: {
|
|
2577
|
+
code: "NO_AGENT",
|
|
2578
|
+
message: "Unable to resolve agent for API execution"
|
|
2579
|
+
}
|
|
2580
|
+
};
|
|
2581
|
+
const body = {
|
|
2582
|
+
applicationId,
|
|
2583
|
+
inputs,
|
|
2584
|
+
viewMode,
|
|
2585
|
+
entryPoint
|
|
2586
|
+
};
|
|
2587
|
+
if (profile) body.profile = profile;
|
|
2588
|
+
if (editMode$1 && branchName) body.branchName = branchName;
|
|
2589
|
+
if (!editMode$1 && commitId) body.commitId = commitId;
|
|
2590
|
+
try {
|
|
2591
|
+
const response = await fetch(`${agentBaseUrl}v3/execute`, {
|
|
2592
|
+
method: "POST",
|
|
2593
|
+
headers: {
|
|
2594
|
+
"Content-Type": "application/json",
|
|
2595
|
+
[SUPERBLOCKS_AUTHORIZATION_HEADER]: `Bearer ${this.accessToken}`,
|
|
2596
|
+
Authorization: `Bearer ${this.token}`,
|
|
2597
|
+
[SUPERBLOCKS_REQUEST_ID_HEADER]: generateId()
|
|
2598
|
+
},
|
|
2599
|
+
body: JSON.stringify(body)
|
|
2600
|
+
});
|
|
2601
|
+
if (!response.ok) {
|
|
2602
|
+
const text = await response.text();
|
|
2603
|
+
let message;
|
|
2604
|
+
try {
|
|
2605
|
+
const json = JSON.parse(text);
|
|
2606
|
+
message = json?.responseMeta?.error?.message ?? json?.error?.message ?? json?.message ?? text;
|
|
2607
|
+
} catch {
|
|
2608
|
+
message = text || `HTTP ${response.status}`;
|
|
2609
|
+
}
|
|
2610
|
+
return {
|
|
2611
|
+
success: false,
|
|
2612
|
+
error: {
|
|
2613
|
+
code: "SYSTEM_ERROR",
|
|
2614
|
+
message
|
|
2615
|
+
}
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
const result = await response.json();
|
|
2619
|
+
if (result.errors?.length) return {
|
|
2620
|
+
success: false,
|
|
2621
|
+
error: {
|
|
2622
|
+
code: "EXECUTION_ERROR",
|
|
2623
|
+
message: result.errors[0].message
|
|
2624
|
+
}
|
|
2625
|
+
};
|
|
2626
|
+
return {
|
|
2627
|
+
success: true,
|
|
2628
|
+
output: result.output?.result
|
|
2629
|
+
};
|
|
2630
|
+
} catch (error) {
|
|
2631
|
+
return {
|
|
2632
|
+
success: false,
|
|
2633
|
+
error: {
|
|
2634
|
+
code: "NETWORK_ERROR",
|
|
2635
|
+
message: error instanceof Error ? error.message : "Network error occurred"
|
|
2636
|
+
}
|
|
2637
|
+
};
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2543
2640
|
@action async cancelApi(apiName, _scopeId) {
|
|
2544
2641
|
const abortController = this.runningApiControllers[apiName];
|
|
2545
2642
|
if (!abortController) {
|
|
@@ -3087,6 +3184,24 @@ var RootStore = class {
|
|
|
3087
3184
|
* When false, the YAML-based API system is used instead.
|
|
3088
3185
|
*/
|
|
3089
3186
|
sdkApiEnabled = false;
|
|
3187
|
+
/** Selected integration profile for orchestrator API calls */
|
|
3188
|
+
profile;
|
|
3189
|
+
/** Current git branch name for editor-mode API execution */
|
|
3190
|
+
branchName;
|
|
3191
|
+
/** Deployed/preview commit ID for non-editor API execution */
|
|
3192
|
+
commitId;
|
|
3193
|
+
/**
|
|
3194
|
+
* Maps API name → entryPoint path (relative to app root).
|
|
3195
|
+
* Populated by sdk-api-discovery during edit mode.
|
|
3196
|
+
* Used by executeSdkApiV3 to resolve the correct file path for the orchestrator.
|
|
3197
|
+
*/
|
|
3198
|
+
apiEntryPoints = /* @__PURE__ */ new Map();
|
|
3199
|
+
/**
|
|
3200
|
+
* Resolves when the initial SDK API discovery pass completes.
|
|
3201
|
+
* executeSdkApiV3 awaits this so callers don't race against discovery.
|
|
3202
|
+
*/
|
|
3203
|
+
_discoveryPromise;
|
|
3204
|
+
_resolveDiscovery;
|
|
3090
3205
|
editorRegisteredCallbacks = [];
|
|
3091
3206
|
constructor() {
|
|
3092
3207
|
this.apis = new api_store_default(this);
|
|
@@ -3100,7 +3215,13 @@ var RootStore = class {
|
|
|
3100
3215
|
sdkUser: observable.ref,
|
|
3101
3216
|
setSdkUser: action,
|
|
3102
3217
|
sdkApiEnabled: observable,
|
|
3103
|
-
setSdkApiEnabled: action
|
|
3218
|
+
setSdkApiEnabled: action,
|
|
3219
|
+
profile: observable.ref,
|
|
3220
|
+
setProfile: action,
|
|
3221
|
+
branchName: observable,
|
|
3222
|
+
setBranchName: action,
|
|
3223
|
+
commitId: observable,
|
|
3224
|
+
setCommitId: action
|
|
3104
3225
|
});
|
|
3105
3226
|
}
|
|
3106
3227
|
/**
|
|
@@ -3118,9 +3239,68 @@ var RootStore = class {
|
|
|
3118
3239
|
/**
|
|
3119
3240
|
* Sets the SDK API feature flag state.
|
|
3120
3241
|
* Called during bootstrap with the value from feature flags.
|
|
3242
|
+
*
|
|
3243
|
+
* When enabling, pre-initializes the discovery gate immediately so that
|
|
3244
|
+
* any component whose useEffect runs before IframeConnected's reaction
|
|
3245
|
+
* useEffect (children run before parents in React) will correctly block
|
|
3246
|
+
* on awaitDiscovery() instead of resolving immediately with no entry points.
|
|
3121
3247
|
*/
|
|
3122
3248
|
setSdkApiEnabled(enabled) {
|
|
3123
3249
|
this.sdkApiEnabled = enabled;
|
|
3250
|
+
if (enabled && !this._resolveDiscovery) this.initDiscoveryGate();
|
|
3251
|
+
}
|
|
3252
|
+
setProfile(profile) {
|
|
3253
|
+
this.profile = profile;
|
|
3254
|
+
}
|
|
3255
|
+
setBranchName(branchName) {
|
|
3256
|
+
this.branchName = branchName;
|
|
3257
|
+
}
|
|
3258
|
+
setCommitId(commitId) {
|
|
3259
|
+
this.commitId = commitId;
|
|
3260
|
+
}
|
|
3261
|
+
setApiEntryPoint(apiName, entryPoint) {
|
|
3262
|
+
this.apiEntryPoints.set(apiName, entryPoint);
|
|
3263
|
+
}
|
|
3264
|
+
getApiEntryPoint(apiName) {
|
|
3265
|
+
return this.apiEntryPoints.get(apiName);
|
|
3266
|
+
}
|
|
3267
|
+
clearApiEntryPoints() {
|
|
3268
|
+
this.apiEntryPoints.clear();
|
|
3269
|
+
}
|
|
3270
|
+
/**
|
|
3271
|
+
* Initialise (or re-initialise) the discovery gate. Called when discovery
|
|
3272
|
+
* starts so that executeSdkApiV3 awaits before checking entry points.
|
|
3273
|
+
* Always creates a fresh promise so HMR re-discovery is also gated.
|
|
3274
|
+
* Resolves any in-flight promise before replacing it so callers awaiting
|
|
3275
|
+
* the old gate (e.g. from before HMR re-triggered discovery) do not hang.
|
|
3276
|
+
*/
|
|
3277
|
+
initDiscoveryGate() {
|
|
3278
|
+
this._resolveDiscovery?.();
|
|
3279
|
+
this._discoveryPromise = new Promise((resolve) => {
|
|
3280
|
+
this._resolveDiscovery = resolve;
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
/**
|
|
3284
|
+
* Signal that the initial discovery pass has finished (success or failure).
|
|
3285
|
+
*/
|
|
3286
|
+
notifyDiscoveryComplete() {
|
|
3287
|
+
this._resolveDiscovery?.();
|
|
3288
|
+
this._resolveDiscovery = void 0;
|
|
3289
|
+
}
|
|
3290
|
+
/**
|
|
3291
|
+
* Returns true if a discovery gate exists and has not yet been resolved.
|
|
3292
|
+
* Used by discoverAndRegisterSdkApis to avoid re-initializing the gate
|
|
3293
|
+
* when setSdkApiEnabled already pre-initialized it.
|
|
3294
|
+
*/
|
|
3295
|
+
hasUnresolvedGate() {
|
|
3296
|
+
return !!this._resolveDiscovery;
|
|
3297
|
+
}
|
|
3298
|
+
/**
|
|
3299
|
+
* Returns a promise that resolves once initial discovery has completed.
|
|
3300
|
+
* Resolves immediately if discovery already finished or was never started.
|
|
3301
|
+
*/
|
|
3302
|
+
awaitDiscovery() {
|
|
3303
|
+
return this._discoveryPromise ?? Promise.resolve();
|
|
3124
3304
|
}
|
|
3125
3305
|
setEditStore(editStore) {
|
|
3126
3306
|
if (this.editStore) return;
|
|
@@ -3777,5 +3957,5 @@ const useJSXContext = () => {
|
|
|
3777
3957
|
};
|
|
3778
3958
|
|
|
3779
3959
|
//#endregion
|
|
3780
|
-
export {
|
|
3781
|
-
//# sourceMappingURL=jsx-wrapper-
|
|
3960
|
+
export { useSuperblocksProfiles as A, createManagedPropsList as B, rejectById as C, useSuperblocksContext as D, getAppMode as E, editorBridge as F, getEditStore as G, PropsCategory as H, iframeMessageHandler as I, isEmbeddedBySuperblocksFirstParty as L, generateId as M, sendNotification as N, useSuperblocksDataTags as O, colors as P, sendMessageImmediately as R, addNewPromise as S, SuperblocksContextProvider as T, Section as U, Prop as V, createPropertiesPanelDefinition as W, root_store_default as _, FixWithClarkButton as a, getContextFromTraceHeaders as b, ErrorContent as c, ErrorMessage as d, ErrorStack as f, StyledClarkIcon as g, SecondaryButton as h, getWidgetRectAnchorName as i, useSuperblocksUser as j, useSuperblocksGroups as k, ErrorDetails as l, ErrorTitle as m, useJSXContext as n, ActionsContainer as o, ErrorSummary as p, getWidgetAnchorName as r, ErrorContainer as s, makeWrappedComponent as t, ErrorIconContainer as u, startEditorSync as v, resolveById as w, api_hmr_tracker_default as x, createIframeSpan as y, isEditMode as z };
|
|
3961
|
+
//# sourceMappingURL=jsx-wrapper-DdcywsRY.js.map
|