@fusedio/widget-sdk 0.1.0 → 0.1.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/bridge.js +14 -9
- package/dist/define-catalog.js +4 -1
- package/dist/define-component.js +4 -1
- package/dist/form.js +18 -12
- package/dist/hooks/use-allowed-sources.js +12 -9
- package/dist/hooks/use-allowed-udf-names.js +11 -8
- package/dist/hooks/use-canvas-params.js +12 -9
- package/dist/hooks/use-duckdb-sql.js +63 -58
- package/dist/hooks/use-fused-param.js +34 -31
- package/dist/hooks/use-json-ui-edge-animation.js +6 -3
- package/dist/hooks/use-json-ui-log.js +23 -18
- package/dist/hooks/use-json-ui-udf-info.js +6 -3
- package/dist/hooks/use-param-substitution.js +25 -22
- package/dist/hooks/use-udf-output.js +33 -24
- package/dist/hooks/use-upload-access-check.js +9 -6
- package/dist/hooks/use-url-signing.js +22 -17
- package/dist/index.js +62 -19
- package/dist/protocol.js +8 -4
- package/dist/types.js +2 -1
- package/dist/utils/sql-placeholders.js +36 -22
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @fusedio/widget-sdk — public surface.
|
|
3
4
|
*
|
|
@@ -14,27 +15,69 @@
|
|
|
14
15
|
* Catalog components depend only on these hooks and types. They do not need
|
|
15
16
|
* to know about Jotai, BroadcastChannel internals, or the workbench source.
|
|
16
17
|
*/
|
|
18
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(o, k2, desc);
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
30
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.useJsonUiEdgeAnimation = exports.useJsonUiUdfInfo = exports.useJsonUiLogClear = exports.useJsonUiLogs = exports.useJsonUiLog = exports.useUploadAccessCheck = exports.SIGNED_URL_SCHEMES = exports.useMediaSrc = exports.useUrlSigning = exports.useVfsRegistration = exports.useDuckDbSqlQueryPreprocessing = exports.useDuckDbSqlQuery = exports.parseUdfColumnQuery = exports.isUdfQuery = exports.useUdfColumnValues = exports.useUdfColumnValue = exports.useUdfDataFrameSample = exports.useRequestUdfReexecute = exports.useUdfOutputByName = exports.useParamSubstitution = exports.useAllowedUdfNames = exports.useAllowedSources = exports.useCanvasParams = exports.useFusedParam = exports.defineCatalog = exports.defineComponent = void 0;
|
|
17
34
|
// ── Part 1: Provider contract ────────────────────────────────────────────────
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
35
|
+
__exportStar(require("./protocol"), exports);
|
|
36
|
+
__exportStar(require("./bridge"), exports);
|
|
37
|
+
__exportStar(require("./form"), exports);
|
|
21
38
|
// ── Part 2: Hook types ───────────────────────────────────────────────────────
|
|
22
|
-
|
|
39
|
+
__exportStar(require("./types"), exports);
|
|
23
40
|
// ── Part 3: Catalog component registration ───────────────────────────────────
|
|
24
|
-
|
|
25
|
-
|
|
41
|
+
var define_component_1 = require("./define-component");
|
|
42
|
+
Object.defineProperty(exports, "defineComponent", { enumerable: true, get: function () { return define_component_1.defineComponent; } });
|
|
43
|
+
var define_catalog_1 = require("./define-catalog");
|
|
44
|
+
Object.defineProperty(exports, "defineCatalog", { enumerable: true, get: function () { return define_catalog_1.defineCatalog; } });
|
|
26
45
|
// ── Part 2: Hooks ────────────────────────────────────────────────────────────
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
var use_fused_param_1 = require("./hooks/use-fused-param");
|
|
47
|
+
Object.defineProperty(exports, "useFusedParam", { enumerable: true, get: function () { return use_fused_param_1.useFusedParam; } });
|
|
48
|
+
var use_canvas_params_1 = require("./hooks/use-canvas-params");
|
|
49
|
+
Object.defineProperty(exports, "useCanvasParams", { enumerable: true, get: function () { return use_canvas_params_1.useCanvasParams; } });
|
|
50
|
+
var use_allowed_sources_1 = require("./hooks/use-allowed-sources");
|
|
51
|
+
Object.defineProperty(exports, "useAllowedSources", { enumerable: true, get: function () { return use_allowed_sources_1.useAllowedSources; } });
|
|
52
|
+
var use_allowed_udf_names_1 = require("./hooks/use-allowed-udf-names");
|
|
53
|
+
Object.defineProperty(exports, "useAllowedUdfNames", { enumerable: true, get: function () { return use_allowed_udf_names_1.useAllowedUdfNames; } });
|
|
54
|
+
var use_param_substitution_1 = require("./hooks/use-param-substitution");
|
|
55
|
+
Object.defineProperty(exports, "useParamSubstitution", { enumerable: true, get: function () { return use_param_substitution_1.useParamSubstitution; } });
|
|
56
|
+
var use_udf_output_1 = require("./hooks/use-udf-output");
|
|
57
|
+
Object.defineProperty(exports, "useUdfOutputByName", { enumerable: true, get: function () { return use_udf_output_1.useUdfOutputByName; } });
|
|
58
|
+
Object.defineProperty(exports, "useRequestUdfReexecute", { enumerable: true, get: function () { return use_udf_output_1.useRequestUdfReexecute; } });
|
|
59
|
+
Object.defineProperty(exports, "useUdfDataFrameSample", { enumerable: true, get: function () { return use_udf_output_1.useUdfDataFrameSample; } });
|
|
60
|
+
Object.defineProperty(exports, "useUdfColumnValue", { enumerable: true, get: function () { return use_udf_output_1.useUdfColumnValue; } });
|
|
61
|
+
Object.defineProperty(exports, "useUdfColumnValues", { enumerable: true, get: function () { return use_udf_output_1.useUdfColumnValues; } });
|
|
62
|
+
Object.defineProperty(exports, "isUdfQuery", { enumerable: true, get: function () { return use_udf_output_1.isUdfQuery; } });
|
|
63
|
+
Object.defineProperty(exports, "parseUdfColumnQuery", { enumerable: true, get: function () { return use_udf_output_1.parseUdfColumnQuery; } });
|
|
64
|
+
var use_duckdb_sql_1 = require("./hooks/use-duckdb-sql");
|
|
65
|
+
Object.defineProperty(exports, "useDuckDbSqlQuery", { enumerable: true, get: function () { return use_duckdb_sql_1.useDuckDbSqlQuery; } });
|
|
66
|
+
Object.defineProperty(exports, "useDuckDbSqlQueryPreprocessing", { enumerable: true, get: function () { return use_duckdb_sql_1.useDuckDbSqlQueryPreprocessing; } });
|
|
67
|
+
Object.defineProperty(exports, "useVfsRegistration", { enumerable: true, get: function () { return use_duckdb_sql_1.useVfsRegistration; } });
|
|
68
|
+
var use_url_signing_1 = require("./hooks/use-url-signing");
|
|
69
|
+
Object.defineProperty(exports, "useUrlSigning", { enumerable: true, get: function () { return use_url_signing_1.useUrlSigning; } });
|
|
70
|
+
Object.defineProperty(exports, "useMediaSrc", { enumerable: true, get: function () { return use_url_signing_1.useMediaSrc; } });
|
|
71
|
+
Object.defineProperty(exports, "SIGNED_URL_SCHEMES", { enumerable: true, get: function () { return use_url_signing_1.SIGNED_URL_SCHEMES; } });
|
|
72
|
+
var use_upload_access_check_1 = require("./hooks/use-upload-access-check");
|
|
73
|
+
Object.defineProperty(exports, "useUploadAccessCheck", { enumerable: true, get: function () { return use_upload_access_check_1.useUploadAccessCheck; } });
|
|
74
|
+
var use_json_ui_log_1 = require("./hooks/use-json-ui-log");
|
|
75
|
+
Object.defineProperty(exports, "useJsonUiLog", { enumerable: true, get: function () { return use_json_ui_log_1.useJsonUiLog; } });
|
|
76
|
+
Object.defineProperty(exports, "useJsonUiLogs", { enumerable: true, get: function () { return use_json_ui_log_1.useJsonUiLogs; } });
|
|
77
|
+
Object.defineProperty(exports, "useJsonUiLogClear", { enumerable: true, get: function () { return use_json_ui_log_1.useJsonUiLogClear; } });
|
|
78
|
+
var use_json_ui_udf_info_1 = require("./hooks/use-json-ui-udf-info");
|
|
79
|
+
Object.defineProperty(exports, "useJsonUiUdfInfo", { enumerable: true, get: function () { return use_json_ui_udf_info_1.useJsonUiUdfInfo; } });
|
|
80
|
+
var use_json_ui_edge_animation_1 = require("./hooks/use-json-ui-edge-animation");
|
|
81
|
+
Object.defineProperty(exports, "useJsonUiEdgeAnimation", { enumerable: true, get: function () { return use_json_ui_edge_animation_1.useJsonUiEdgeAnimation; } });
|
|
39
82
|
// ── Pure utilities (re-exported for advanced workbench paths) ────────────────
|
|
40
|
-
|
|
83
|
+
__exportStar(require("./utils/sql-placeholders"), exports);
|
package/dist/protocol.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParameterMessageType = exports.PARAMETER_BROADCAST_CHANNEL = void 0;
|
|
4
|
+
exports.isStandardMessage = isStandardMessage;
|
|
1
5
|
/**
|
|
2
6
|
* The Fused workbench listens on this BroadcastChannel for parameter updates
|
|
3
7
|
* from all components — both built-in and 3rd-party catalogs. The channel name
|
|
4
8
|
* is part of the public protocol; do not change it without coordinating with
|
|
5
9
|
* the workbench listener and all in-the-wild catalogs.
|
|
6
10
|
*/
|
|
7
|
-
|
|
11
|
+
exports.PARAMETER_BROADCAST_CHANNEL = "parameter-updates";
|
|
8
12
|
/**
|
|
9
13
|
* Discriminator for parameter messages on the BroadcastChannel.
|
|
10
14
|
*
|
|
@@ -13,15 +17,15 @@ export const PARAMETER_BROADCAST_CHANNEL = "parameter-updates";
|
|
|
13
17
|
* - `VIEWPORT` — map viewport bounds: `{ west, south, east, north }`
|
|
14
18
|
* - `CLEAR` — clear a parameter for this source (value will be `null`)
|
|
15
19
|
*/
|
|
16
|
-
|
|
20
|
+
var ParameterMessageType;
|
|
17
21
|
(function (ParameterMessageType) {
|
|
18
22
|
ParameterMessageType["PARAM"] = "param";
|
|
19
23
|
ParameterMessageType["RANGE"] = "range";
|
|
20
24
|
ParameterMessageType["VIEWPORT"] = "viewport";
|
|
21
25
|
ParameterMessageType["CLEAR"] = "clear";
|
|
22
|
-
})(ParameterMessageType || (ParameterMessageType = {}));
|
|
26
|
+
})(ParameterMessageType || (exports.ParameterMessageType = ParameterMessageType = {}));
|
|
23
27
|
/** Type guard that verifies an unknown object is a valid StandardMessage. */
|
|
24
|
-
|
|
28
|
+
function isStandardMessage(msg) {
|
|
25
29
|
if (typeof msg !== "object" || msg === null)
|
|
26
30
|
return false;
|
|
27
31
|
const m = msg;
|
package/dist/types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Pure parsing/substitution utilities for widget SQL strings.
|
|
3
4
|
*
|
|
@@ -10,15 +11,28 @@
|
|
|
10
11
|
* These helpers are also used by the host (workbench bridge) for VFS
|
|
11
12
|
* registration; lifting them into the SDK keeps a single source of truth.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SIGNABLE_URL_LITERAL_REGEX = exports.SQL_SOURCE_PLACEHOLDER_REGEX = exports.SQL_PARAM_REGEX = void 0;
|
|
16
|
+
exports.escapeSqlValue = escapeSqlValue;
|
|
17
|
+
exports.substituteSqlParams = substituteSqlParams;
|
|
18
|
+
exports.extractSqlParams = extractSqlParams;
|
|
19
|
+
exports.parseOverridesString = parseOverridesString;
|
|
20
|
+
exports.parseSqlUdfPlaceholders = parseSqlUdfPlaceholders;
|
|
21
|
+
exports.extractSignableUrls = extractSignableUrls;
|
|
22
|
+
exports.rewriteSignedUrls = rewriteSignedUrls;
|
|
23
|
+
exports.getDollarRefName = getDollarRefName;
|
|
24
|
+
exports.resolveOverrideValue = resolveOverrideValue;
|
|
25
|
+
exports.canonicalOverrideKey = canonicalOverrideKey;
|
|
26
|
+
exports.computePlaceholderKey = computePlaceholderKey;
|
|
27
|
+
exports.SQL_PARAM_REGEX = /\$([a-zA-Z_][a-zA-Z0-9_]*)/g;
|
|
28
|
+
exports.SQL_SOURCE_PLACEHOLDER_REGEX = /\{\{(\w+)(?:\?([^}]*))?\}\}/g;
|
|
15
29
|
/**
|
|
16
30
|
* Matches `'scheme://...'` literals inside a SQL string. We deliberately
|
|
17
31
|
* limit to single-quoted string literals so that bare identifiers or
|
|
18
32
|
* comments containing a URL-like token aren't treated as paths to sign.
|
|
19
33
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
34
|
+
exports.SIGNABLE_URL_LITERAL_REGEX = /'((?:s3|gs|fd):\/\/[^'\n]+)'/g;
|
|
35
|
+
function escapeSqlValue(value) {
|
|
22
36
|
if (value == null)
|
|
23
37
|
return "''";
|
|
24
38
|
if (typeof value === "number" && !Number.isNaN(value))
|
|
@@ -46,8 +60,8 @@ function isInsideSingleQuotedSqlString(sql, offset) {
|
|
|
46
60
|
* `$param` lives inside a single-quoted string literal, only the raw
|
|
47
61
|
* quote-escaped value is spliced in so we don't add nested quotes.
|
|
48
62
|
*/
|
|
49
|
-
|
|
50
|
-
return sql.replace(SQL_PARAM_REGEX, (_match, paramName, offset) => {
|
|
63
|
+
function substituteSqlParams(sql, paramValues) {
|
|
64
|
+
return sql.replace(exports.SQL_PARAM_REGEX, (_match, paramName, offset) => {
|
|
51
65
|
const value = paramValues[paramName];
|
|
52
66
|
const raw = value == null ? "" : String(value);
|
|
53
67
|
if (isInsideSingleQuotedSqlString(sql, offset)) {
|
|
@@ -57,11 +71,11 @@ export function substituteSqlParams(sql, paramValues) {
|
|
|
57
71
|
});
|
|
58
72
|
}
|
|
59
73
|
/** Extract all SQL parameter names from `$param_name` references. */
|
|
60
|
-
|
|
74
|
+
function extractSqlParams(sql) {
|
|
61
75
|
const seen = new Set();
|
|
62
76
|
const out = [];
|
|
63
|
-
SQL_PARAM_REGEX.lastIndex = 0;
|
|
64
|
-
for (const m of sql.matchAll(SQL_PARAM_REGEX)) {
|
|
77
|
+
exports.SQL_PARAM_REGEX.lastIndex = 0;
|
|
78
|
+
for (const m of sql.matchAll(exports.SQL_PARAM_REGEX)) {
|
|
65
79
|
const name = m[1];
|
|
66
80
|
if (seen.has(name))
|
|
67
81
|
continue;
|
|
@@ -70,7 +84,7 @@ export function extractSqlParams(sql) {
|
|
|
70
84
|
}
|
|
71
85
|
return out;
|
|
72
86
|
}
|
|
73
|
-
|
|
87
|
+
function parseOverridesString(rawOverrides) {
|
|
74
88
|
if (!rawOverrides)
|
|
75
89
|
return null;
|
|
76
90
|
const result = {};
|
|
@@ -105,11 +119,11 @@ export function parseOverridesString(rawOverrides) {
|
|
|
105
119
|
* occurrences in source order, preserving duplicates so callers can
|
|
106
120
|
* substitute by start/end offsets.
|
|
107
121
|
*/
|
|
108
|
-
|
|
122
|
+
function parseSqlUdfPlaceholders(sql) {
|
|
109
123
|
const placeholders = [];
|
|
110
124
|
let match;
|
|
111
|
-
SQL_SOURCE_PLACEHOLDER_REGEX.lastIndex = 0;
|
|
112
|
-
while ((match = SQL_SOURCE_PLACEHOLDER_REGEX.exec(sql)) !== null) {
|
|
125
|
+
exports.SQL_SOURCE_PLACEHOLDER_REGEX.lastIndex = 0;
|
|
126
|
+
while ((match = exports.SQL_SOURCE_PLACEHOLDER_REGEX.exec(sql)) !== null) {
|
|
113
127
|
const [fullMatch, name, rawOverrides] = match;
|
|
114
128
|
placeholders.push({
|
|
115
129
|
match: fullMatch,
|
|
@@ -125,14 +139,14 @@ export function parseSqlUdfPlaceholders(sql) {
|
|
|
125
139
|
* Extract every signable URL appearing as a single-quoted string literal,
|
|
126
140
|
* deduped, in first-occurrence order.
|
|
127
141
|
*/
|
|
128
|
-
|
|
142
|
+
function extractSignableUrls(sql) {
|
|
129
143
|
if (!sql)
|
|
130
144
|
return [];
|
|
131
145
|
const seen = new Set();
|
|
132
146
|
const out = [];
|
|
133
|
-
SIGNABLE_URL_LITERAL_REGEX.lastIndex = 0;
|
|
147
|
+
exports.SIGNABLE_URL_LITERAL_REGEX.lastIndex = 0;
|
|
134
148
|
let match;
|
|
135
|
-
while ((match = SIGNABLE_URL_LITERAL_REGEX.exec(sql)) !== null) {
|
|
149
|
+
while ((match = exports.SIGNABLE_URL_LITERAL_REGEX.exec(sql)) !== null) {
|
|
136
150
|
const url = match[1];
|
|
137
151
|
if (!seen.has(url)) {
|
|
138
152
|
seen.add(url);
|
|
@@ -146,10 +160,10 @@ export function extractSignableUrls(sql) {
|
|
|
146
160
|
* from `signedMap`. Literals whose URL is missing from the map are left
|
|
147
161
|
* untouched.
|
|
148
162
|
*/
|
|
149
|
-
|
|
163
|
+
function rewriteSignedUrls(sql, signedMap) {
|
|
150
164
|
if (!sql)
|
|
151
165
|
return sql;
|
|
152
|
-
return sql.replace(SIGNABLE_URL_LITERAL_REGEX, (literal, url) => {
|
|
166
|
+
return sql.replace(exports.SIGNABLE_URL_LITERAL_REGEX, (literal, url) => {
|
|
153
167
|
const signed = signedMap[url];
|
|
154
168
|
if (!signed)
|
|
155
169
|
return literal;
|
|
@@ -161,7 +175,7 @@ export function rewriteSignedUrls(sql, signedMap) {
|
|
|
161
175
|
// ============================================================================
|
|
162
176
|
const DOLLAR_REF_RE = /^\$([a-zA-Z_][a-zA-Z0-9_]*)$/;
|
|
163
177
|
/** Return the param name if `value` is a single `$name` reference. */
|
|
164
|
-
|
|
178
|
+
function getDollarRefName(value) {
|
|
165
179
|
const trimmed = value.trim();
|
|
166
180
|
const m = DOLLAR_REF_RE.exec(trimmed);
|
|
167
181
|
return m ? m[1] : null;
|
|
@@ -172,7 +186,7 @@ export function getDollarRefName(value) {
|
|
|
172
186
|
* missing entirely (key not in the map), marks the result as `unresolved`
|
|
173
187
|
* so callers can keep the placeholder pending until upstream params settle.
|
|
174
188
|
*/
|
|
175
|
-
|
|
189
|
+
function resolveOverrideValue(rawValue, paramValues) {
|
|
176
190
|
const m = DOLLAR_REF_RE.exec(rawValue);
|
|
177
191
|
if (!m) {
|
|
178
192
|
return { value: rawValue, unresolved: false };
|
|
@@ -191,13 +205,13 @@ export function resolveOverrideValue(rawValue, paramValues) {
|
|
|
191
205
|
* Canonical registry key for `(name, overrides)`. Bare placeholders use the
|
|
192
206
|
* name alone; overrides are sorted by key and joined with `&`.
|
|
193
207
|
*/
|
|
194
|
-
|
|
208
|
+
function canonicalOverrideKey(overrides) {
|
|
195
209
|
return Object.keys(overrides)
|
|
196
210
|
.sort()
|
|
197
211
|
.map((k) => `${k}=${overrides[k]}`)
|
|
198
212
|
.join("&");
|
|
199
213
|
}
|
|
200
|
-
|
|
214
|
+
function computePlaceholderKey(name, overrides) {
|
|
201
215
|
if (!overrides)
|
|
202
216
|
return name;
|
|
203
217
|
return `${name}#${canonicalOverrideKey(overrides)}`;
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fusedio/widget-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "SDK for building custom json-ui components for the Fused workbench",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"type": "module",
|
|
7
6
|
"main": "dist/index.js",
|
|
8
7
|
"types": "dist/index.d.ts",
|
|
9
8
|
"exports": {
|
|
10
9
|
".": {
|
|
11
10
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"
|
|
11
|
+
"default": "./dist/index.js"
|
|
13
12
|
}
|
|
14
13
|
},
|
|
15
14
|
"files": [
|