@teable/app 6.1.4 → 6.1.6
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/build/cli.js +2 -2
- package/dist/build/index.js +2 -2
- package/dist/chunks/{O6KEZ2KL.js → 2RGK2EON.js} +2 -2
- package/dist/chunks/{TN5GZDH5.js → 2UHILLRW.js} +1 -1
- package/dist/chunks/{TDLQQFGT.js → GCWICK3X.js} +1 -1
- package/dist/chunks/{H3YCXVRL.js → QI7K66CG.js} +12 -2
- package/dist/chunks/V6KXHW3L.js +325 -0
- package/dist/client.js +2 -2
- package/dist/dev/host.js +10 -1
- package/dist/index.js +3 -3
- package/dist/protocol.d.ts +63 -0
- package/dist/protocol.js +15 -3
- package/dist/schema.js +2 -2
- package/dist/testing.js +4 -4
- package/dist/worker.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/RJHLCJUX.js +0 -146
package/dist/build/cli.js
CHANGED
package/dist/build/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
describeTables
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./2UHILLRW.js";
|
|
4
4
|
import {
|
|
5
5
|
CAPABILITIES,
|
|
6
6
|
PROTOCOL_VERSION,
|
|
7
7
|
admit,
|
|
8
8
|
isPageAccess
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./V6KXHW3L.js";
|
|
10
10
|
|
|
11
11
|
// src/server/errors.ts
|
|
12
12
|
import { z } from "zod";
|
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
DEV_PATHS,
|
|
6
6
|
PAGES_APP_META,
|
|
7
7
|
SESSION_PATH,
|
|
8
|
-
checkAccess
|
|
9
|
-
|
|
8
|
+
checkAccess,
|
|
9
|
+
spaceRoleOf
|
|
10
|
+
} from "./V6KXHW3L.js";
|
|
10
11
|
|
|
11
12
|
// src/build/index.ts
|
|
12
13
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -303,6 +304,15 @@ function remoteMiddleware(remote, appId) {
|
|
|
303
304
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
304
305
|
switch (`${req.method} ${url.pathname}`) {
|
|
305
306
|
case `GET ${SESSION_PATH}/sign-in`: {
|
|
307
|
+
const as = url.searchParams.get("as");
|
|
308
|
+
if (as === "anonymous" || spaceRoleOf(as) !== null) {
|
|
309
|
+
const who = as === "anonymous" ? "anonymous" : "token";
|
|
310
|
+
res.writeHead(302, {
|
|
311
|
+
Location: onHost(url.searchParams.get("return")),
|
|
312
|
+
"Set-Cookie": cookie(who)
|
|
313
|
+
});
|
|
314
|
+
return res.end();
|
|
315
|
+
}
|
|
306
316
|
if (!signedOut(req) && !url.searchParams.has("choose")) {
|
|
307
317
|
res.writeHead(302, { Location: onHost(url.searchParams.get("return")) });
|
|
308
318
|
return res.end();
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
// src/protocol.ts
|
|
2
|
+
var PROTOCOL_VERSION = 6;
|
|
3
|
+
var APP_COMPATIBILITY_DATE = "2026-12-01";
|
|
4
|
+
var SPACE_ROLES = ["owner", "creator", "editor", "commenter", "viewer"];
|
|
5
|
+
var EVERY_CAPABILITY = { files: true, http: true };
|
|
6
|
+
var CAPABILITIES = Object.keys(EVERY_CAPABILITY);
|
|
7
|
+
var ERROR_CODES = [
|
|
8
|
+
"BAD_INPUT",
|
|
9
|
+
"UNAUTHENTICATED",
|
|
10
|
+
"FORBIDDEN",
|
|
11
|
+
"NOT_FOUND",
|
|
12
|
+
"UNKNOWN_METHOD",
|
|
13
|
+
"CONFLICT",
|
|
14
|
+
"CONSTRAINT",
|
|
15
|
+
"RATE_LIMITED",
|
|
16
|
+
"INTERNAL"
|
|
17
|
+
];
|
|
18
|
+
var DEFAULT_CURRENCY = "USD";
|
|
19
|
+
var MINOR_UNITS = {
|
|
20
|
+
BIF: 0,
|
|
21
|
+
CLP: 0,
|
|
22
|
+
DJF: 0,
|
|
23
|
+
GNF: 0,
|
|
24
|
+
ISK: 0,
|
|
25
|
+
JPY: 0,
|
|
26
|
+
KMF: 0,
|
|
27
|
+
KRW: 0,
|
|
28
|
+
PYG: 0,
|
|
29
|
+
RWF: 0,
|
|
30
|
+
UGX: 0,
|
|
31
|
+
UYI: 0,
|
|
32
|
+
VND: 0,
|
|
33
|
+
VUV: 0,
|
|
34
|
+
XAF: 0,
|
|
35
|
+
XOF: 0,
|
|
36
|
+
XPF: 0,
|
|
37
|
+
BHD: 3,
|
|
38
|
+
IQD: 3,
|
|
39
|
+
JOD: 3,
|
|
40
|
+
KWD: 3,
|
|
41
|
+
LYD: 3,
|
|
42
|
+
OMR: 3,
|
|
43
|
+
TND: 3,
|
|
44
|
+
CLF: 4,
|
|
45
|
+
UYW: 4
|
|
46
|
+
};
|
|
47
|
+
function currencyDigits(currency) {
|
|
48
|
+
const code = currency.toUpperCase();
|
|
49
|
+
return Object.hasOwn(MINOR_UNITS, code) ? MINOR_UNITS[code] ?? 2 : 2;
|
|
50
|
+
}
|
|
51
|
+
var ERROR_STATUS = {
|
|
52
|
+
BAD_INPUT: 400,
|
|
53
|
+
UNAUTHENTICATED: 401,
|
|
54
|
+
FORBIDDEN: 403,
|
|
55
|
+
NOT_FOUND: 404,
|
|
56
|
+
UNKNOWN_METHOD: 404,
|
|
57
|
+
CONFLICT: 409,
|
|
58
|
+
CONSTRAINT: 422,
|
|
59
|
+
RATE_LIMITED: 429,
|
|
60
|
+
INTERNAL: 500
|
|
61
|
+
};
|
|
62
|
+
function isPageAccess(access) {
|
|
63
|
+
return access === "public" || SPACE_ROLES.includes(access);
|
|
64
|
+
}
|
|
65
|
+
var DEV_PATHS = {
|
|
66
|
+
deploy: "/__teable/deploy",
|
|
67
|
+
gate: "/__teable/gate",
|
|
68
|
+
worker: "/__teable/worker"
|
|
69
|
+
};
|
|
70
|
+
var ASSETS_HEADER = "X-Teable-Assets";
|
|
71
|
+
var SESSION_PATH = "/.teable";
|
|
72
|
+
var BRIDGE_PATH = `${SESSION_PATH}/bridge.js`;
|
|
73
|
+
function pagesBridge(origins) {
|
|
74
|
+
return `(${BRIDGE})(window, ${JSON.stringify(origins)});
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
var BRIDGE = String.raw`function (window, origins) {
|
|
78
|
+
if (window.parent === window || window.__teableBridge) return;
|
|
79
|
+
window.__teableBridge = true;
|
|
80
|
+
var document = window.document;
|
|
81
|
+
var asker = null;
|
|
82
|
+
var box = null;
|
|
83
|
+
var tag = null;
|
|
84
|
+
function post(message, origin) {
|
|
85
|
+
message.source = "teable-pages";
|
|
86
|
+
try {
|
|
87
|
+
window.parent.postMessage(message, origin);
|
|
88
|
+
} catch (error) {}
|
|
89
|
+
}
|
|
90
|
+
function where() {
|
|
91
|
+
return window.location.pathname + window.location.search + window.location.hash;
|
|
92
|
+
}
|
|
93
|
+
function announce() {
|
|
94
|
+
for (var i = 0; i < origins.length; i++) post({ type: "location", path: where() }, origins[i]);
|
|
95
|
+
}
|
|
96
|
+
function textOf(el) {
|
|
97
|
+
return (el.innerText || el.textContent || "").replace(/\s+/g, " ").trim().slice(0, 120);
|
|
98
|
+
}
|
|
99
|
+
function labelOf(el) {
|
|
100
|
+
var names = ["aria-label", "title", "alt", "placeholder"];
|
|
101
|
+
for (var i = 0; i < names.length; i++) {
|
|
102
|
+
var value = el.getAttribute(names[i]);
|
|
103
|
+
if (value) return value.slice(0, 120);
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
function escape(id) {
|
|
108
|
+
return window.CSS && window.CSS.escape ? window.CSS.escape(id) : id.replace(/[^\w-]/g, "\\$&");
|
|
109
|
+
}
|
|
110
|
+
function selectorOf(el) {
|
|
111
|
+
var steps = [];
|
|
112
|
+
for (var node = el; node && node.nodeType === 1 && steps.length < 6; node = node.parentElement) {
|
|
113
|
+
var name = node.tagName.toLowerCase();
|
|
114
|
+
if (node.id) {
|
|
115
|
+
steps.unshift(name + "#" + escape(node.id));
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
if (node === document.body || node === document.documentElement) {
|
|
119
|
+
steps.unshift(name);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
var parent = node.parentElement;
|
|
123
|
+
if (parent) {
|
|
124
|
+
var same = [];
|
|
125
|
+
for (var i = 0; i < parent.children.length; i++) {
|
|
126
|
+
if (parent.children[i].tagName === node.tagName) same.push(parent.children[i]);
|
|
127
|
+
}
|
|
128
|
+
if (same.length > 1) name += ":nth-of-type(" + (same.indexOf(node) + 1) + ")";
|
|
129
|
+
}
|
|
130
|
+
steps.unshift(name);
|
|
131
|
+
}
|
|
132
|
+
return steps.join(" > ");
|
|
133
|
+
}
|
|
134
|
+
function describe(el) {
|
|
135
|
+
var classes = [];
|
|
136
|
+
for (var i = 0; i < el.classList.length && classes.length < 5; i++) classes.push(el.classList[i]);
|
|
137
|
+
return {
|
|
138
|
+
path: where(),
|
|
139
|
+
tag: el.tagName.toLowerCase(),
|
|
140
|
+
text: textOf(el),
|
|
141
|
+
label: labelOf(el),
|
|
142
|
+
id: el.id || null,
|
|
143
|
+
classes: classes,
|
|
144
|
+
selector: selectorOf(el),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function show(el) {
|
|
148
|
+
if (!box) {
|
|
149
|
+
box = document.createElement("div");
|
|
150
|
+
box.setAttribute("data-teable-bridge", "");
|
|
151
|
+
box.style.cssText =
|
|
152
|
+
"position:fixed;z-index:2147483647;pointer-events:none;box-sizing:border-box;border:2px solid #2563eb;border-radius:4px;background:rgba(37,99,235,.08)";
|
|
153
|
+
tag = document.createElement("div");
|
|
154
|
+
tag.style.cssText =
|
|
155
|
+
"position:absolute;left:-2px;padding:0 6px;border-radius:4px;background:#2563eb;color:#fff;font:12px/18px system-ui,sans-serif;white-space:nowrap";
|
|
156
|
+
box.appendChild(tag);
|
|
157
|
+
document.documentElement.appendChild(box);
|
|
158
|
+
}
|
|
159
|
+
var rect = el.getBoundingClientRect();
|
|
160
|
+
box.style.display = "block";
|
|
161
|
+
box.style.top = rect.top + "px";
|
|
162
|
+
box.style.left = rect.left + "px";
|
|
163
|
+
box.style.width = rect.width + "px";
|
|
164
|
+
box.style.height = rect.height + "px";
|
|
165
|
+
tag.textContent = el.tagName.toLowerCase();
|
|
166
|
+
tag.style.top = rect.top < 24 ? "100%" : "-22px";
|
|
167
|
+
}
|
|
168
|
+
function targetOf(event) {
|
|
169
|
+
var el = event.target;
|
|
170
|
+
return el && el.nodeType === 1 && !(box && box.contains(el)) ? el : null;
|
|
171
|
+
}
|
|
172
|
+
function hover(event) {
|
|
173
|
+
var el = targetOf(event);
|
|
174
|
+
if (el) show(el);
|
|
175
|
+
}
|
|
176
|
+
function swallow(event) {
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
event.stopImmediatePropagation();
|
|
179
|
+
}
|
|
180
|
+
function pick(event) {
|
|
181
|
+
swallow(event);
|
|
182
|
+
var el = targetOf(event);
|
|
183
|
+
if (!el) return;
|
|
184
|
+
var to = asker;
|
|
185
|
+
stop();
|
|
186
|
+
post({ type: "picked", element: describe(el) }, to);
|
|
187
|
+
}
|
|
188
|
+
function key(event) {
|
|
189
|
+
if (event.key !== "Escape") return;
|
|
190
|
+
swallow(event);
|
|
191
|
+
var to = asker;
|
|
192
|
+
stop();
|
|
193
|
+
post({ type: "stopped" }, to);
|
|
194
|
+
}
|
|
195
|
+
var SWALLOWED = ["mousedown", "mouseup", "pointerdown", "pointerup", "dblclick", "auxclick", "contextmenu", "submit"];
|
|
196
|
+
function listen(on) {
|
|
197
|
+
var method = on ? "addEventListener" : "removeEventListener";
|
|
198
|
+
document[method]("mousemove", hover, true);
|
|
199
|
+
document[method]("click", pick, true);
|
|
200
|
+
document[method]("keydown", key, true);
|
|
201
|
+
for (var i = 0; i < SWALLOWED.length; i++) document[method](SWALLOWED[i], swallow, true);
|
|
202
|
+
}
|
|
203
|
+
function start(origin) {
|
|
204
|
+
if (asker === null) listen(true);
|
|
205
|
+
asker = origin;
|
|
206
|
+
document.documentElement.style.cursor = "crosshair";
|
|
207
|
+
}
|
|
208
|
+
function stop() {
|
|
209
|
+
if (asker !== null) listen(false);
|
|
210
|
+
asker = null;
|
|
211
|
+
if (box) box.style.display = "none";
|
|
212
|
+
document.documentElement.style.cursor = "";
|
|
213
|
+
}
|
|
214
|
+
window.addEventListener("message", function (event) {
|
|
215
|
+
if (origins.indexOf(event.origin) < 0) return;
|
|
216
|
+
var data = event.data;
|
|
217
|
+
if (!data || data.source !== "teable-builder" || data.type !== "inspect") return;
|
|
218
|
+
if (data.on) start(event.origin);
|
|
219
|
+
else stop();
|
|
220
|
+
});
|
|
221
|
+
["pushState", "replaceState"].forEach(function (name) {
|
|
222
|
+
var original = window.history[name];
|
|
223
|
+
window.history[name] = function () {
|
|
224
|
+
var result = original.apply(this, arguments);
|
|
225
|
+
announce();
|
|
226
|
+
return result;
|
|
227
|
+
};
|
|
228
|
+
});
|
|
229
|
+
window.addEventListener("popstate", announce);
|
|
230
|
+
window.addEventListener("hashchange", announce);
|
|
231
|
+
announce();
|
|
232
|
+
}`;
|
|
233
|
+
var APPS_PATH = "/api/v4/apps";
|
|
234
|
+
var FILE_NAME_HEADER = "X-File-Name";
|
|
235
|
+
function fileKeyPath(key) {
|
|
236
|
+
const slash = key.indexOf("/");
|
|
237
|
+
return `${key.slice(0, slash)}/${encodeURIComponent(key.slice(slash + 1))}`;
|
|
238
|
+
}
|
|
239
|
+
var DEPLOY_HEADERS = { commit: "X-Teable-Commit", message: "X-Teable-Message" };
|
|
240
|
+
var DEPLOY_PARTS = { server: "server", worker: "worker", pages: "pages" };
|
|
241
|
+
var PAGES_APP_META = "teable-app";
|
|
242
|
+
var SECRET_NAME_PATTERN = "[A-Z][A-Z0-9_]{0,63}";
|
|
243
|
+
var SECRET_NAME = new RegExp(`^${SECRET_NAME_PATTERN}$`);
|
|
244
|
+
function secretPlaceholder(name) {
|
|
245
|
+
return `{{secret:${name}}}`;
|
|
246
|
+
}
|
|
247
|
+
var SECRET_PLACEHOLDER = new RegExp(
|
|
248
|
+
`(?:\\{\\{|%7[Bb]%7[Bb])secret(?::|%3[Aa])(${SECRET_NAME_PATTERN})(?:\\}\\}|%7[Dd]%7[Dd])`,
|
|
249
|
+
"g"
|
|
250
|
+
);
|
|
251
|
+
function checkAccess(caller, access) {
|
|
252
|
+
if (caller.kind === "system") return null;
|
|
253
|
+
if (access === "internal") return "FORBIDDEN";
|
|
254
|
+
if (access === "public") return null;
|
|
255
|
+
if (caller.kind === "anonymous") return "UNAUTHENTICATED";
|
|
256
|
+
if (caller.role === null) return "FORBIDDEN";
|
|
257
|
+
return SPACE_ROLES.indexOf(caller.role) <= SPACE_ROLES.indexOf(access) ? null : "FORBIDDEN";
|
|
258
|
+
}
|
|
259
|
+
function admit(manifest, name, caller) {
|
|
260
|
+
const method = manifest.methods.find((m) => m.name === name);
|
|
261
|
+
if (method === void 0 || method.kind === "task") {
|
|
262
|
+
return { ok: false, error: { code: "UNKNOWN_METHOD", message: `No method "${name}"` } };
|
|
263
|
+
}
|
|
264
|
+
const denied = checkAccess(caller, method.access);
|
|
265
|
+
if (denied) {
|
|
266
|
+
return { ok: false, error: { code: denied, message: `Not allowed to call "${name}"` } };
|
|
267
|
+
}
|
|
268
|
+
return { ok: true, value: method };
|
|
269
|
+
}
|
|
270
|
+
function isMember(caller) {
|
|
271
|
+
return checkAccess(caller, "viewer") === null;
|
|
272
|
+
}
|
|
273
|
+
function isExposed(method) {
|
|
274
|
+
return method.kind !== "task" && method.access !== "internal";
|
|
275
|
+
}
|
|
276
|
+
function callableMethods(manifest, caller) {
|
|
277
|
+
return manifest.methods.filter((m) => isExposed(m) && checkAccess(caller, m.access) === null);
|
|
278
|
+
}
|
|
279
|
+
function spaceRoleOf(name) {
|
|
280
|
+
return SPACE_ROLES.find((role) => role === name) ?? null;
|
|
281
|
+
}
|
|
282
|
+
function roleAsAsked(role, asked) {
|
|
283
|
+
return asked !== null && SPACE_ROLES.indexOf(asked) > SPACE_ROLES.indexOf(role) ? asked : role;
|
|
284
|
+
}
|
|
285
|
+
function signedInAsAsked(role, asked) {
|
|
286
|
+
return asked === null || role === asked;
|
|
287
|
+
}
|
|
288
|
+
function rolesBelow(role) {
|
|
289
|
+
return SPACE_ROLES.slice(SPACE_ROLES.indexOf(role) + 1);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export {
|
|
293
|
+
PROTOCOL_VERSION,
|
|
294
|
+
APP_COMPATIBILITY_DATE,
|
|
295
|
+
SPACE_ROLES,
|
|
296
|
+
CAPABILITIES,
|
|
297
|
+
ERROR_CODES,
|
|
298
|
+
DEFAULT_CURRENCY,
|
|
299
|
+
currencyDigits,
|
|
300
|
+
ERROR_STATUS,
|
|
301
|
+
isPageAccess,
|
|
302
|
+
DEV_PATHS,
|
|
303
|
+
ASSETS_HEADER,
|
|
304
|
+
SESSION_PATH,
|
|
305
|
+
BRIDGE_PATH,
|
|
306
|
+
pagesBridge,
|
|
307
|
+
APPS_PATH,
|
|
308
|
+
FILE_NAME_HEADER,
|
|
309
|
+
fileKeyPath,
|
|
310
|
+
DEPLOY_HEADERS,
|
|
311
|
+
DEPLOY_PARTS,
|
|
312
|
+
PAGES_APP_META,
|
|
313
|
+
SECRET_NAME,
|
|
314
|
+
secretPlaceholder,
|
|
315
|
+
SECRET_PLACEHOLDER,
|
|
316
|
+
checkAccess,
|
|
317
|
+
admit,
|
|
318
|
+
isMember,
|
|
319
|
+
isExposed,
|
|
320
|
+
callableMethods,
|
|
321
|
+
spaceRoleOf,
|
|
322
|
+
roleAsAsked,
|
|
323
|
+
signedInAsAsked,
|
|
324
|
+
rolesBelow
|
|
325
|
+
};
|
package/dist/client.js
CHANGED
package/dist/dev/host.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
callableMethods,
|
|
11
11
|
checkAccess,
|
|
12
12
|
isMember
|
|
13
|
-
} from "../chunks/
|
|
13
|
+
} from "../chunks/V6KXHW3L.js";
|
|
14
14
|
|
|
15
15
|
// src/dev/host.ts
|
|
16
16
|
import { DurableObject, WorkerEntrypoint } from "cloudflare:workers";
|
|
@@ -239,6 +239,15 @@ async function session(request, url) {
|
|
|
239
239
|
switch (route) {
|
|
240
240
|
case "GET /sign-in": {
|
|
241
241
|
const returnTo = pathOnHost(url.searchParams.get("return"));
|
|
242
|
+
const as = PICKS.find(
|
|
243
|
+
(pick) => pick.who !== "outsider" && pick.who === url.searchParams.get("as")
|
|
244
|
+
);
|
|
245
|
+
if (as) {
|
|
246
|
+
return new Response(null, {
|
|
247
|
+
status: 302,
|
|
248
|
+
headers: { Location: returnTo, "Set-Cookie": cookie(as.who) }
|
|
249
|
+
});
|
|
250
|
+
}
|
|
242
251
|
const caller = callerOf(request);
|
|
243
252
|
if (caller.kind === "user" && !url.searchParams.has("choose")) {
|
|
244
253
|
return new Response(null, { status: 302, headers: { Location: returnTo } });
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createApp,
|
|
3
3
|
fail
|
|
4
|
-
} from "./chunks/
|
|
5
|
-
import "./chunks/
|
|
6
|
-
import "./chunks/
|
|
4
|
+
} from "./chunks/2RGK2EON.js";
|
|
5
|
+
import "./chunks/2UHILLRW.js";
|
|
6
|
+
import "./chunks/V6KXHW3L.js";
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
9
|
import { z } from "zod";
|
package/dist/protocol.d.ts
CHANGED
|
@@ -409,6 +409,57 @@ export interface SessionResponse {
|
|
|
409
409
|
caller: Caller;
|
|
410
410
|
expiresAt: number | null;
|
|
411
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* The bridge between the builder's Preview and an app's pages, in its frame:
|
|
414
|
+
* a script the runtime serves on the app's host (`BRIDGE_PATH`) and adds to
|
|
415
|
+
* the pages it frames there. It tells the builder where the page is, and,
|
|
416
|
+
* while the person picks an element to point the agent at, which they
|
|
417
|
+
* clicked. It answers only the builder's hosts, and tells only them.
|
|
418
|
+
*/
|
|
419
|
+
export declare const BRIDGE_PATH = "/.teable/bridge.js";
|
|
420
|
+
/** What the builder tells the bridge: start or stop picking an element. */
|
|
421
|
+
export interface BuilderMessage {
|
|
422
|
+
source: "teable-builder";
|
|
423
|
+
type: "inspect";
|
|
424
|
+
on: boolean;
|
|
425
|
+
}
|
|
426
|
+
/** An element the person picked in the Preview, as the bridge describes it. */
|
|
427
|
+
export interface PickedElement {
|
|
428
|
+
/** The page it is on: its path, query and fragment. */
|
|
429
|
+
path: string;
|
|
430
|
+
tag: string;
|
|
431
|
+
/** Its text, spaces collapsed, at most 120 characters. */
|
|
432
|
+
text: string;
|
|
433
|
+
/** What names it besides its text: its aria-label, title, alt or placeholder. */
|
|
434
|
+
label: string | null;
|
|
435
|
+
id: string | null;
|
|
436
|
+
/** Its first five classes. */
|
|
437
|
+
classes: string[];
|
|
438
|
+
/** A CSS selector for it, from its nearest ancestor with an id, at most six steps. */
|
|
439
|
+
selector: string;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* What the bridge tells the builder: where the page is (as it loads and as
|
|
443
|
+
* it moves), the element picked, or that picking stopped (Escape).
|
|
444
|
+
*/
|
|
445
|
+
export type PagesMessage = {
|
|
446
|
+
source: "teable-pages";
|
|
447
|
+
type: "location";
|
|
448
|
+
path: string;
|
|
449
|
+
} | {
|
|
450
|
+
source: "teable-pages";
|
|
451
|
+
type: "picked";
|
|
452
|
+
element: PickedElement;
|
|
453
|
+
} | {
|
|
454
|
+
source: "teable-pages";
|
|
455
|
+
type: "stopped";
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* The bridge's script, for a page framed by one of `origins` (the builder's
|
|
459
|
+
* hosts), which alone may ask it anything. Plain script, so that it runs
|
|
460
|
+
* in any app's pages, built with any SDK; `window` is the page's.
|
|
461
|
+
*/
|
|
462
|
+
export declare function pagesBridge(origins: readonly string[]): string;
|
|
412
463
|
/**
|
|
413
464
|
* Sent on `GET {APPS_PATH}/:appId/realtime`: `changes` after every call that
|
|
414
465
|
* changed data, and `deployed` after a new version went live, which can change
|
|
@@ -612,3 +663,15 @@ export declare function isMember(caller: Caller): boolean;
|
|
|
612
663
|
export declare function isExposed(method: MethodInfo): boolean;
|
|
613
664
|
/** The exposed methods this caller may call. */
|
|
614
665
|
export declare function callableMethods(manifest: AppManifest, caller: Caller): MethodInfo[];
|
|
666
|
+
/** A space role by its name; null for anything else. */
|
|
667
|
+
export declare function spaceRoleOf(name: unknown): SpaceRole | null;
|
|
668
|
+
/**
|
|
669
|
+
* The role a sign-in to an app's pages gives a person who asked to be at
|
|
670
|
+
* most `asked` (the builder's Preview, as another role): theirs, or the
|
|
671
|
+
* lower one asked for, never a higher one. Null asks for theirs.
|
|
672
|
+
*/
|
|
673
|
+
export declare function roleAsAsked(role: SpaceRole, asked: SpaceRole | null): SpaceRole;
|
|
674
|
+
/** Whether a session with `role` is what a sign-in asking for `asked` gives: none is needed. */
|
|
675
|
+
export declare function signedInAsAsked(role: SpaceRole, asked: SpaceRole | null): boolean;
|
|
676
|
+
/** The roles below `role`, highest first: those its holder may preview an app's pages as. */
|
|
677
|
+
export declare function rolesBelow(role: SpaceRole): SpaceRole[];
|
package/dist/protocol.js
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
APPS_PATH,
|
|
3
3
|
APP_COMPATIBILITY_DATE,
|
|
4
4
|
ASSETS_HEADER,
|
|
5
|
+
BRIDGE_PATH,
|
|
5
6
|
CAPABILITIES,
|
|
6
7
|
DEFAULT_CURRENCY,
|
|
7
8
|
DEPLOY_HEADERS,
|
|
@@ -24,12 +25,18 @@ import {
|
|
|
24
25
|
isExposed,
|
|
25
26
|
isMember,
|
|
26
27
|
isPageAccess,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
pagesBridge,
|
|
29
|
+
roleAsAsked,
|
|
30
|
+
rolesBelow,
|
|
31
|
+
secretPlaceholder,
|
|
32
|
+
signedInAsAsked,
|
|
33
|
+
spaceRoleOf
|
|
34
|
+
} from "./chunks/V6KXHW3L.js";
|
|
29
35
|
export {
|
|
30
36
|
APPS_PATH,
|
|
31
37
|
APP_COMPATIBILITY_DATE,
|
|
32
38
|
ASSETS_HEADER,
|
|
39
|
+
BRIDGE_PATH,
|
|
33
40
|
CAPABILITIES,
|
|
34
41
|
DEFAULT_CURRENCY,
|
|
35
42
|
DEPLOY_HEADERS,
|
|
@@ -52,5 +59,10 @@ export {
|
|
|
52
59
|
isExposed,
|
|
53
60
|
isMember,
|
|
54
61
|
isPageAccess,
|
|
55
|
-
|
|
62
|
+
pagesBridge,
|
|
63
|
+
roleAsAsked,
|
|
64
|
+
rolesBelow,
|
|
65
|
+
secretPlaceholder,
|
|
66
|
+
signedInAsAsked,
|
|
67
|
+
spaceRoleOf
|
|
56
68
|
};
|
package/dist/schema.js
CHANGED
package/dist/testing.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
methodName
|
|
3
|
-
} from "./chunks/
|
|
4
|
-
import "./chunks/
|
|
3
|
+
} from "./chunks/2RGK2EON.js";
|
|
4
|
+
import "./chunks/2UHILLRW.js";
|
|
5
5
|
import {
|
|
6
6
|
MethodError
|
|
7
|
-
} from "./chunks/
|
|
7
|
+
} from "./chunks/GCWICK3X.js";
|
|
8
8
|
import {
|
|
9
9
|
ERROR_STATUS
|
|
10
|
-
} from "./chunks/
|
|
10
|
+
} from "./chunks/V6KXHW3L.js";
|
|
11
11
|
|
|
12
12
|
// src/testing.ts
|
|
13
13
|
var OWNER = { kind: "user", userId: "test-owner", role: "owner", via: "api" };
|
package/dist/worker.js
CHANGED
package/package.json
CHANGED
package/dist/chunks/RJHLCJUX.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
// src/protocol.ts
|
|
2
|
-
var PROTOCOL_VERSION = 6;
|
|
3
|
-
var APP_COMPATIBILITY_DATE = "2026-12-01";
|
|
4
|
-
var SPACE_ROLES = ["owner", "creator", "editor", "commenter", "viewer"];
|
|
5
|
-
var EVERY_CAPABILITY = { files: true, http: true };
|
|
6
|
-
var CAPABILITIES = Object.keys(EVERY_CAPABILITY);
|
|
7
|
-
var ERROR_CODES = [
|
|
8
|
-
"BAD_INPUT",
|
|
9
|
-
"UNAUTHENTICATED",
|
|
10
|
-
"FORBIDDEN",
|
|
11
|
-
"NOT_FOUND",
|
|
12
|
-
"UNKNOWN_METHOD",
|
|
13
|
-
"CONFLICT",
|
|
14
|
-
"CONSTRAINT",
|
|
15
|
-
"RATE_LIMITED",
|
|
16
|
-
"INTERNAL"
|
|
17
|
-
];
|
|
18
|
-
var DEFAULT_CURRENCY = "USD";
|
|
19
|
-
var MINOR_UNITS = {
|
|
20
|
-
BIF: 0,
|
|
21
|
-
CLP: 0,
|
|
22
|
-
DJF: 0,
|
|
23
|
-
GNF: 0,
|
|
24
|
-
ISK: 0,
|
|
25
|
-
JPY: 0,
|
|
26
|
-
KMF: 0,
|
|
27
|
-
KRW: 0,
|
|
28
|
-
PYG: 0,
|
|
29
|
-
RWF: 0,
|
|
30
|
-
UGX: 0,
|
|
31
|
-
UYI: 0,
|
|
32
|
-
VND: 0,
|
|
33
|
-
VUV: 0,
|
|
34
|
-
XAF: 0,
|
|
35
|
-
XOF: 0,
|
|
36
|
-
XPF: 0,
|
|
37
|
-
BHD: 3,
|
|
38
|
-
IQD: 3,
|
|
39
|
-
JOD: 3,
|
|
40
|
-
KWD: 3,
|
|
41
|
-
LYD: 3,
|
|
42
|
-
OMR: 3,
|
|
43
|
-
TND: 3,
|
|
44
|
-
CLF: 4,
|
|
45
|
-
UYW: 4
|
|
46
|
-
};
|
|
47
|
-
function currencyDigits(currency) {
|
|
48
|
-
const code = currency.toUpperCase();
|
|
49
|
-
return Object.hasOwn(MINOR_UNITS, code) ? MINOR_UNITS[code] ?? 2 : 2;
|
|
50
|
-
}
|
|
51
|
-
var ERROR_STATUS = {
|
|
52
|
-
BAD_INPUT: 400,
|
|
53
|
-
UNAUTHENTICATED: 401,
|
|
54
|
-
FORBIDDEN: 403,
|
|
55
|
-
NOT_FOUND: 404,
|
|
56
|
-
UNKNOWN_METHOD: 404,
|
|
57
|
-
CONFLICT: 409,
|
|
58
|
-
CONSTRAINT: 422,
|
|
59
|
-
RATE_LIMITED: 429,
|
|
60
|
-
INTERNAL: 500
|
|
61
|
-
};
|
|
62
|
-
function isPageAccess(access) {
|
|
63
|
-
return access === "public" || SPACE_ROLES.includes(access);
|
|
64
|
-
}
|
|
65
|
-
var DEV_PATHS = {
|
|
66
|
-
deploy: "/__teable/deploy",
|
|
67
|
-
gate: "/__teable/gate",
|
|
68
|
-
worker: "/__teable/worker"
|
|
69
|
-
};
|
|
70
|
-
var ASSETS_HEADER = "X-Teable-Assets";
|
|
71
|
-
var SESSION_PATH = "/.teable";
|
|
72
|
-
var APPS_PATH = "/api/v4/apps";
|
|
73
|
-
var FILE_NAME_HEADER = "X-File-Name";
|
|
74
|
-
function fileKeyPath(key) {
|
|
75
|
-
const slash = key.indexOf("/");
|
|
76
|
-
return `${key.slice(0, slash)}/${encodeURIComponent(key.slice(slash + 1))}`;
|
|
77
|
-
}
|
|
78
|
-
var DEPLOY_HEADERS = { commit: "X-Teable-Commit", message: "X-Teable-Message" };
|
|
79
|
-
var DEPLOY_PARTS = { server: "server", worker: "worker", pages: "pages" };
|
|
80
|
-
var PAGES_APP_META = "teable-app";
|
|
81
|
-
var SECRET_NAME_PATTERN = "[A-Z][A-Z0-9_]{0,63}";
|
|
82
|
-
var SECRET_NAME = new RegExp(`^${SECRET_NAME_PATTERN}$`);
|
|
83
|
-
function secretPlaceholder(name) {
|
|
84
|
-
return `{{secret:${name}}}`;
|
|
85
|
-
}
|
|
86
|
-
var SECRET_PLACEHOLDER = new RegExp(
|
|
87
|
-
`(?:\\{\\{|%7[Bb]%7[Bb])secret(?::|%3[Aa])(${SECRET_NAME_PATTERN})(?:\\}\\}|%7[Dd]%7[Dd])`,
|
|
88
|
-
"g"
|
|
89
|
-
);
|
|
90
|
-
function checkAccess(caller, access) {
|
|
91
|
-
if (caller.kind === "system") return null;
|
|
92
|
-
if (access === "internal") return "FORBIDDEN";
|
|
93
|
-
if (access === "public") return null;
|
|
94
|
-
if (caller.kind === "anonymous") return "UNAUTHENTICATED";
|
|
95
|
-
if (caller.role === null) return "FORBIDDEN";
|
|
96
|
-
return SPACE_ROLES.indexOf(caller.role) <= SPACE_ROLES.indexOf(access) ? null : "FORBIDDEN";
|
|
97
|
-
}
|
|
98
|
-
function admit(manifest, name, caller) {
|
|
99
|
-
const method = manifest.methods.find((m) => m.name === name);
|
|
100
|
-
if (method === void 0 || method.kind === "task") {
|
|
101
|
-
return { ok: false, error: { code: "UNKNOWN_METHOD", message: `No method "${name}"` } };
|
|
102
|
-
}
|
|
103
|
-
const denied = checkAccess(caller, method.access);
|
|
104
|
-
if (denied) {
|
|
105
|
-
return { ok: false, error: { code: denied, message: `Not allowed to call "${name}"` } };
|
|
106
|
-
}
|
|
107
|
-
return { ok: true, value: method };
|
|
108
|
-
}
|
|
109
|
-
function isMember(caller) {
|
|
110
|
-
return checkAccess(caller, "viewer") === null;
|
|
111
|
-
}
|
|
112
|
-
function isExposed(method) {
|
|
113
|
-
return method.kind !== "task" && method.access !== "internal";
|
|
114
|
-
}
|
|
115
|
-
function callableMethods(manifest, caller) {
|
|
116
|
-
return manifest.methods.filter((m) => isExposed(m) && checkAccess(caller, m.access) === null);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export {
|
|
120
|
-
PROTOCOL_VERSION,
|
|
121
|
-
APP_COMPATIBILITY_DATE,
|
|
122
|
-
SPACE_ROLES,
|
|
123
|
-
CAPABILITIES,
|
|
124
|
-
ERROR_CODES,
|
|
125
|
-
DEFAULT_CURRENCY,
|
|
126
|
-
currencyDigits,
|
|
127
|
-
ERROR_STATUS,
|
|
128
|
-
isPageAccess,
|
|
129
|
-
DEV_PATHS,
|
|
130
|
-
ASSETS_HEADER,
|
|
131
|
-
SESSION_PATH,
|
|
132
|
-
APPS_PATH,
|
|
133
|
-
FILE_NAME_HEADER,
|
|
134
|
-
fileKeyPath,
|
|
135
|
-
DEPLOY_HEADERS,
|
|
136
|
-
DEPLOY_PARTS,
|
|
137
|
-
PAGES_APP_META,
|
|
138
|
-
SECRET_NAME,
|
|
139
|
-
secretPlaceholder,
|
|
140
|
-
SECRET_PLACEHOLDER,
|
|
141
|
-
checkAccess,
|
|
142
|
-
admit,
|
|
143
|
-
isMember,
|
|
144
|
-
isExposed,
|
|
145
|
-
callableMethods
|
|
146
|
-
};
|