@oxy-hq/sdk 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +206 -10
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +206 -10
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{react-CVdWXcu8.mjs → react-5HGW_0oy.mjs} +24 -24
- package/dist/react-5HGW_0oy.mjs.map +1 -0
- package/dist/{react-BeweGSYF.cjs → react-BAiiXftp.cjs} +29 -29
- package/dist/react-BAiiXftp.cjs.map +1 -0
- package/dist/{react-BnpR8VRJ.d.mts → react-DnBdQ8dG.d.cts} +16 -16
- package/dist/react-DnBdQ8dG.d.cts.map +1 -0
- package/dist/{react-BnpR8VRJ.d.cts → react-DnBdQ8dG.d.mts} +16 -16
- package/dist/react-DnBdQ8dG.d.mts.map +1 -0
- package/dist/shell.cjs +3 -3
- package/dist/shell.cjs.map +1 -1
- package/dist/shell.d.cts +3 -3
- package/dist/shell.d.mts +3 -3
- package/dist/shell.mjs +3 -3
- package/dist/shell.mjs.map +1 -1
- package/package.json +8 -8
- package/dist/react-BeweGSYF.cjs.map +0 -1
- package/dist/react-BnpR8VRJ.d.cts.map +0 -1
- package/dist/react-BnpR8VRJ.d.mts.map +0 -1
- package/dist/react-CVdWXcu8.mjs.map +0 -1
|
@@ -30,7 +30,7 @@ let react = require("react");
|
|
|
30
30
|
react = __toESM(react, 1);
|
|
31
31
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
32
32
|
|
|
33
|
-
//#region src/
|
|
33
|
+
//#region src/custom-app/logger.ts
|
|
34
34
|
let activeLogger = createConsoleLogger();
|
|
35
35
|
/** Replace the global logger. Pass `null` to silence everything. */
|
|
36
36
|
function setOxyAppLogger(logger) {
|
|
@@ -70,9 +70,9 @@ function silentLogger() {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
//#endregion
|
|
73
|
-
//#region src/
|
|
73
|
+
//#region src/custom-app/errors.ts
|
|
74
74
|
/**
|
|
75
|
-
* Error thrown by all
|
|
75
|
+
* Error thrown by all custom-app hooks when an API call returns a
|
|
76
76
|
* non-2xx response. Carries the structured `code` + `hint` the server
|
|
77
77
|
* emits so bundle UIs can render an actionable message instead of
|
|
78
78
|
* "404: { ...json... }".
|
|
@@ -119,12 +119,12 @@ async function apiErrorFromResponse(resp) {
|
|
|
119
119
|
}
|
|
120
120
|
const ARCH_DOC = "internal-docs/customer-apps.md";
|
|
121
121
|
/** Interpret a thrown error as a structured report for UI display. */
|
|
122
|
-
function
|
|
122
|
+
function interpretCustomAppError(err) {
|
|
123
123
|
const message = err instanceof Error ? err.message : String(err);
|
|
124
124
|
if (/Failed to load oxy-app\.json.*HTTP 404/.test(message)) return {
|
|
125
125
|
title: "Manifest not found",
|
|
126
126
|
message,
|
|
127
|
-
hint: "The bundle is being served, but oxy-app.json was not. Check that public/oxy-app.json is committed in the
|
|
127
|
+
hint: "The bundle is being served, but oxy-app.json was not. Check that public/oxy-app.json is committed in the custom-app repo and that the build copied it into the static output. If you're using Next.js, anything under public/ is auto-copied to out/.",
|
|
128
128
|
docs: ARCH_DOC
|
|
129
129
|
};
|
|
130
130
|
if (/Failed to load oxy-app\.json/.test(message)) return {
|
|
@@ -160,7 +160,7 @@ function interpretCustomerAppError(err) {
|
|
|
160
160
|
if (/^403:.*SELECT.*WITH/im.test(message)) return {
|
|
161
161
|
title: "Query rejected — read-only endpoint",
|
|
162
162
|
message,
|
|
163
|
-
hint: "This proxy only runs SELECT or WITH queries. Mutations (INSERT/UPDATE/DELETE/DROP) are not allowed from
|
|
163
|
+
hint: "This proxy only runs SELECT or WITH queries. Mutations (INSERT/UPDATE/DELETE/DROP) are not allowed from custom-app bundles.",
|
|
164
164
|
docs: ARCH_DOC
|
|
165
165
|
};
|
|
166
166
|
if (/^403:/m.test(message)) return {
|
|
@@ -196,7 +196,7 @@ function interpretCustomerAppError(err) {
|
|
|
196
196
|
if (/Unexpected token '<'|<!doctype/i.test(message)) return {
|
|
197
197
|
title: "Fetched HTML where JSON was expected",
|
|
198
198
|
message,
|
|
199
|
-
hint: "Most likely the built bundle is stale — built against an old SDK whose endpoints no longer exist on the server. Rebuild the bundle (vite build) with @oxy-hq/sdk@^2.0.0 and reload. If the bundle is current, check that OXY_APP_BASE_PATH matches the path the
|
|
199
|
+
hint: "Most likely the built bundle is stale — built against an old SDK whose endpoints no longer exist on the server. Rebuild the bundle (vite build) with @oxy-hq/sdk@^2.0.0 and reload. If the bundle is current, check that OXY_APP_BASE_PATH matches the path the custom-app row is served at.",
|
|
200
200
|
docs: ARCH_DOC
|
|
201
201
|
};
|
|
202
202
|
return {
|
|
@@ -208,7 +208,7 @@ function interpretCustomerAppError(err) {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
//#endregion
|
|
211
|
-
//#region src/
|
|
211
|
+
//#region src/custom-app/inject.ts
|
|
212
212
|
/**
|
|
213
213
|
* Read the runtime app-config oxy injected at serve time. Returns
|
|
214
214
|
* `undefined` outside the browser or when the global isn't set
|
|
@@ -221,18 +221,18 @@ function readInjectedAppConfig() {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
//#endregion
|
|
224
|
-
//#region src/
|
|
224
|
+
//#region src/custom-app/manifest.ts
|
|
225
225
|
let cached = null;
|
|
226
226
|
/**
|
|
227
227
|
* Load + validate the manifest. Cached after the first call so callers
|
|
228
228
|
* can invoke this from every component without coordinating.
|
|
229
229
|
*/
|
|
230
|
-
function
|
|
230
|
+
function loadCustomAppManifest(options = {}) {
|
|
231
231
|
if (!cached) cached = fetchAndValidate(options);
|
|
232
232
|
return cached;
|
|
233
233
|
}
|
|
234
234
|
/** For tests: reset the cache between runs. */
|
|
235
|
-
function
|
|
235
|
+
function _resetCustomAppManifestCacheForTest() {
|
|
236
236
|
cached = null;
|
|
237
237
|
}
|
|
238
238
|
async function fetchAndValidate(options) {
|
|
@@ -254,7 +254,7 @@ async function fetchAndValidate(options) {
|
|
|
254
254
|
status: res.status,
|
|
255
255
|
statusText: res.statusText
|
|
256
256
|
});
|
|
257
|
-
throw new Error(`Failed to load oxy-app.json from ${manifestUrl} (HTTP ${res.status}). The
|
|
257
|
+
throw new Error(`Failed to load oxy-app.json from ${manifestUrl} (HTTP ${res.status}). The custom-app repo must commit this file alongside the bundle.`);
|
|
258
258
|
}
|
|
259
259
|
const manifest = validateManifest(await res.json(), manifestUrl);
|
|
260
260
|
const resolved = {
|
|
@@ -319,7 +319,7 @@ const FUNCTION_NAME_RE = /^[a-z][a-z0-9-]{0,63}$/;
|
|
|
319
319
|
/**
|
|
320
320
|
* Validate the optional `functions` map. Each key is a function name;
|
|
321
321
|
* each value declares how the function is invoked. Mirrors the
|
|
322
|
-
* server-side validation in `
|
|
322
|
+
* server-side validation in `custom_apps_publish.rs` so a bad
|
|
323
323
|
* manifest fails at build, not at publish.
|
|
324
324
|
*/
|
|
325
325
|
function validateFunctions(raw) {
|
|
@@ -397,7 +397,7 @@ function isRecord(v) {
|
|
|
397
397
|
}
|
|
398
398
|
|
|
399
399
|
//#endregion
|
|
400
|
-
//#region src/
|
|
400
|
+
//#region src/custom-app/function-invoke.ts
|
|
401
401
|
const inflight$1 = /* @__PURE__ */ new Map();
|
|
402
402
|
/**
|
|
403
403
|
* Dedup key for an invocation: function name + its (stable-serialized) body,
|
|
@@ -423,7 +423,7 @@ function sharedFunctionInvoke(key, run) {
|
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
//#endregion
|
|
426
|
-
//#region src/
|
|
426
|
+
//#region src/custom-app/function-sse.ts
|
|
427
427
|
/**
|
|
428
428
|
* Read a `text/event-stream` function response to completion. Resolves with the
|
|
429
429
|
* decoded result + captured logs, or rejects (with `.logs` attached) on an
|
|
@@ -480,7 +480,7 @@ async function readFunctionSseStream(resp) {
|
|
|
480
480
|
}
|
|
481
481
|
|
|
482
482
|
//#endregion
|
|
483
|
-
//#region src/
|
|
483
|
+
//#region src/custom-app/interpolate.ts
|
|
484
484
|
/**
|
|
485
485
|
* Interpolate `{{ params.X }}` and `{{ params.X | sqlquote }}` placeholders
|
|
486
486
|
* in a SQL template.
|
|
@@ -509,7 +509,7 @@ function interpolateSqlParams(sql, params) {
|
|
|
509
509
|
}
|
|
510
510
|
|
|
511
511
|
//#endregion
|
|
512
|
-
//#region src/
|
|
512
|
+
//#region src/custom-app/markdown.ts
|
|
513
513
|
/**
|
|
514
514
|
* Allowlist for `[text](url)` href values in agent-emitted markdown.
|
|
515
515
|
* Markdown comes from an LLM, which sits across an external trust
|
|
@@ -585,7 +585,7 @@ function isTableStart(lines, idx) {
|
|
|
585
585
|
}
|
|
586
586
|
|
|
587
587
|
//#endregion
|
|
588
|
-
//#region src/
|
|
588
|
+
//#region src/custom-app/query-cache.ts
|
|
589
589
|
const SWR_TTL_MS = 3e4;
|
|
590
590
|
const inflight = /* @__PURE__ */ new Map();
|
|
591
591
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -629,7 +629,7 @@ async function sharedQuery(fetcher, projectId, sql, db, opts = {}) {
|
|
|
629
629
|
}
|
|
630
630
|
|
|
631
631
|
//#endregion
|
|
632
|
-
//#region src/
|
|
632
|
+
//#region src/custom-app/react.tsx
|
|
633
633
|
function defaultFetcher(input, init) {
|
|
634
634
|
return fetch(input, {
|
|
635
635
|
credentials: "include",
|
|
@@ -670,7 +670,7 @@ function OxyAppProvider(props) {
|
|
|
670
670
|
});
|
|
671
671
|
react.useEffect(() => {
|
|
672
672
|
let cancelled = false;
|
|
673
|
-
|
|
673
|
+
loadCustomAppManifest(manifestOptions).then((resolved) => {
|
|
674
674
|
if (!cancelled) setState({
|
|
675
675
|
status: "ready",
|
|
676
676
|
resolved,
|
|
@@ -679,7 +679,7 @@ function OxyAppProvider(props) {
|
|
|
679
679
|
}).catch((e) => {
|
|
680
680
|
if (!cancelled) setState({
|
|
681
681
|
status: "error",
|
|
682
|
-
error:
|
|
682
|
+
error: interpretCustomAppError(e),
|
|
683
683
|
fetcher
|
|
684
684
|
});
|
|
685
685
|
});
|
|
@@ -781,7 +781,7 @@ function useOxyApp() {
|
|
|
781
781
|
}
|
|
782
782
|
/**
|
|
783
783
|
* Execute an ad-hoc SQL query against the project linked to this
|
|
784
|
-
*
|
|
784
|
+
* custom app. The query is specified inline by the caller; no
|
|
785
785
|
* manifest declaration is involved.
|
|
786
786
|
*
|
|
787
787
|
* Re-runs whenever `input` or enabled `params` change. Use the
|
|
@@ -2312,10 +2312,10 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
2312
2312
|
return __toESM;
|
|
2313
2313
|
}
|
|
2314
2314
|
});
|
|
2315
|
-
Object.defineProperty(exports, '
|
|
2315
|
+
Object.defineProperty(exports, '_resetCustomAppManifestCacheForTest', {
|
|
2316
2316
|
enumerable: true,
|
|
2317
2317
|
get: function () {
|
|
2318
|
-
return
|
|
2318
|
+
return _resetCustomAppManifestCacheForTest;
|
|
2319
2319
|
}
|
|
2320
2320
|
});
|
|
2321
2321
|
Object.defineProperty(exports, 'apiErrorFromResponse', {
|
|
@@ -2330,16 +2330,16 @@ Object.defineProperty(exports, 'getOxyAppLogger', {
|
|
|
2330
2330
|
return getOxyAppLogger;
|
|
2331
2331
|
}
|
|
2332
2332
|
});
|
|
2333
|
-
Object.defineProperty(exports, '
|
|
2333
|
+
Object.defineProperty(exports, 'interpretCustomAppError', {
|
|
2334
2334
|
enumerable: true,
|
|
2335
2335
|
get: function () {
|
|
2336
|
-
return
|
|
2336
|
+
return interpretCustomAppError;
|
|
2337
2337
|
}
|
|
2338
2338
|
});
|
|
2339
|
-
Object.defineProperty(exports, '
|
|
2339
|
+
Object.defineProperty(exports, 'loadCustomAppManifest', {
|
|
2340
2340
|
enumerable: true,
|
|
2341
2341
|
get: function () {
|
|
2342
|
-
return
|
|
2342
|
+
return loadCustomAppManifest;
|
|
2343
2343
|
}
|
|
2344
2344
|
});
|
|
2345
2345
|
Object.defineProperty(exports, 'readInjectedAppConfig', {
|
|
@@ -2402,4 +2402,4 @@ Object.defineProperty(exports, 'useTrackEvent', {
|
|
|
2402
2402
|
return useTrackEvent;
|
|
2403
2403
|
}
|
|
2404
2404
|
});
|
|
2405
|
-
//# sourceMappingURL=react-
|
|
2405
|
+
//# sourceMappingURL=react-BAiiXftp.cjs.map
|