@teable/app 6.1.7 → 6.1.8

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 CHANGED
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  buildServer,
4
4
  buildWorker
5
- } from "../chunks/QI7K66CG.js";
6
- import "../chunks/V6KXHW3L.js";
5
+ } from "../chunks/KOPAQ575.js";
6
+ import "../chunks/ERQJZOEM.js";
7
7
 
8
8
  // src/build/cli.ts
9
9
  import { mkdirSync, rmSync, writeFileSync } from "node:fs";
@@ -68,6 +68,13 @@ export interface TeableOptions {
68
68
  url: string;
69
69
  token?: string;
70
70
  };
71
+ /**
72
+ * A builder that shows these pages in its Preview in development: its
73
+ * address. The pages get the Preview's bridge for it, as the runtime adds
74
+ * it on the app's host (ADR 0017), so the Preview follows them, picks from
75
+ * them and hears their errors.
76
+ */
77
+ builder?: string;
71
78
  }
72
79
  type Next = (error?: unknown) => void;
73
80
  type Middleware = (req: IncomingMessage, res: ServerResponse, next: Next) => void;
@@ -131,15 +138,25 @@ export declare function teable(options?: TeableOptions): {
131
138
  };
132
139
  };
133
140
  }>;
134
- /** The pages name the app they are built for: a deploy to another app refuses them. */
135
- transformIndexHtml(): {
141
+ /**
142
+ * The pages name the app they are built for: a deploy to another app
143
+ * refuses them. Served for a builder, they start with its bridge.
144
+ */
145
+ transformIndexHtml(): ({
136
146
  tag: string;
137
147
  attrs: {
138
148
  name: string;
139
149
  content: string;
140
150
  };
141
151
  injectTo: string;
142
- }[];
152
+ } | {
153
+ tag: string;
154
+ attrs: {
155
+ src: string;
156
+ defer: boolean;
157
+ };
158
+ injectTo: string;
159
+ })[];
143
160
  configureServer(server: DevServer): (() => void) | undefined;
144
161
  };
145
162
  export {};
@@ -3,8 +3,8 @@ import {
3
3
  buildWorker,
4
4
  sqlAsText,
5
5
  teable
6
- } from "../chunks/QI7K66CG.js";
7
- import "../chunks/V6KXHW3L.js";
6
+ } from "../chunks/KOPAQ575.js";
7
+ import "../chunks/ERQJZOEM.js";
8
8
  export {
9
9
  buildServer,
10
10
  buildWorker,
@@ -228,6 +228,36 @@ var BRIDGE = String.raw`function (window, origins) {
228
228
  });
229
229
  window.addEventListener("popstate", announce);
230
230
  window.addEventListener("hashchange", announce);
231
+ var failures = 0;
232
+ function said(value) {
233
+ if (typeof value === "string") return value;
234
+ try {
235
+ var json = JSON.stringify(value);
236
+ if (json !== undefined && json !== "{}") return json;
237
+ } catch (error) {}
238
+ return String(value);
239
+ }
240
+ function fail(kind, error, otherwise, at) {
241
+ if (failures >= 20) return;
242
+ failures++;
243
+ var known = error !== null && typeof error === "object" && typeof error.message === "string";
244
+ var message = known ? (error.name ? error.name + ": " : "") + error.message : said(otherwise);
245
+ var stack = known && typeof error.stack === "string" && error.stack ? error.stack : at;
246
+ var report = {
247
+ path: where(),
248
+ kind: kind,
249
+ message: message.slice(0, 1000),
250
+ stack: stack ? stack.slice(0, 4000) : null,
251
+ };
252
+ for (var i = 0; i < origins.length; i++) post({ type: "error", error: report }, origins[i]);
253
+ }
254
+ window.addEventListener("error", function (event) {
255
+ var at = event.filename ? event.filename + ":" + event.lineno + ":" + event.colno : null;
256
+ fail("error", event.error, event.message, at);
257
+ });
258
+ window.addEventListener("unhandledrejection", function (event) {
259
+ fail("rejection", event.reason, event.reason, null);
260
+ });
231
261
  announce();
232
262
  }`;
233
263
  var APPS_PATH = "/api/v4/apps";
@@ -4,7 +4,7 @@ import {
4
4
  FILE_NAME_HEADER,
5
5
  SESSION_PATH,
6
6
  fileKeyPath
7
- } from "./V6KXHW3L.js";
7
+ } from "./ERQJZOEM.js";
8
8
 
9
9
  // src/client.ts
10
10
  var MethodError = class extends Error {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  describeTables
3
- } from "./2UHILLRW.js";
3
+ } from "./QPDT7M6Y.js";
4
4
  import {
5
5
  CAPABILITIES,
6
6
  PROTOCOL_VERSION,
7
7
  admit,
8
8
  isPageAccess
9
- } from "./V6KXHW3L.js";
9
+ } from "./ERQJZOEM.js";
10
10
 
11
11
  // src/server/errors.ts
12
12
  import { z } from "zod";
@@ -2,12 +2,14 @@ import {
2
2
  APPS_PATH,
3
3
  APP_COMPATIBILITY_DATE,
4
4
  ASSETS_HEADER,
5
+ BRIDGE_PATH,
5
6
  DEV_PATHS,
6
7
  PAGES_APP_META,
7
8
  SESSION_PATH,
8
9
  checkAccess,
10
+ pagesBridge,
9
11
  spaceRoleOf
10
- } from "./V6KXHW3L.js";
12
+ } from "./ERQJZOEM.js";
11
13
 
12
14
  // src/build/index.ts
13
15
  import { existsSync, readFileSync } from "node:fs";
@@ -150,12 +152,14 @@ function teable(options = {}) {
150
152
  let appId = options.appId ?? "app";
151
153
  let workerd = "";
152
154
  const serving = (command) => command === "serve" && !process.env.VITEST;
155
+ let builder = null;
153
156
  return {
154
157
  name: "teable",
155
158
  async config(config, env) {
156
159
  appId = options.appId ?? appIdOf(config.root ?? process.cwd());
157
160
  const define = { "import.meta.env.VITE_TEABLE_APP_ID": JSON.stringify(appId) };
158
161
  if (!serving(env.command)) return { define };
162
+ builder = options.builder ? new URL(options.builder).origin : null;
159
163
  const { remote } = options;
160
164
  let target;
161
165
  let configure;
@@ -180,11 +184,36 @@ function teable(options = {}) {
180
184
  server: { proxy: { [APPS_PATH]: proxy, ...remote ? {} : { [SESSION_PATH]: proxy } } }
181
185
  };
182
186
  },
183
- /** The pages name the app they are built for: a deploy to another app refuses them. */
187
+ /**
188
+ * The pages name the app they are built for: a deploy to another app
189
+ * refuses them. Served for a builder, they start with its bridge.
190
+ */
184
191
  transformIndexHtml() {
185
- return [{ tag: "meta", attrs: { name: PAGES_APP_META, content: appId }, injectTo: "head" }];
192
+ const meta = {
193
+ tag: "meta",
194
+ attrs: { name: PAGES_APP_META, content: appId },
195
+ injectTo: "head"
196
+ };
197
+ if (builder === null) return [meta];
198
+ const bridge = {
199
+ tag: "script",
200
+ attrs: { src: BRIDGE_PATH, defer: true },
201
+ injectTo: "head-prepend"
202
+ };
203
+ return [bridge, meta];
186
204
  },
187
205
  configureServer(server) {
206
+ if (builder !== null) {
207
+ const script = pagesBridge([builder]);
208
+ server.middlewares.use((req, res, next) => {
209
+ if (req.url?.split("?")[0] !== BRIDGE_PATH) return next();
210
+ res.writeHead(200, {
211
+ "Content-Type": "text/javascript; charset=utf-8",
212
+ "Cache-Control": "no-cache"
213
+ });
214
+ res.end(script);
215
+ });
216
+ }
188
217
  if (!workerd && !options.remote) return;
189
218
  if (options.remote) {
190
219
  server.middlewares.use(remoteMiddleware(options.remote, appId));
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_CURRENCY,
3
3
  currencyDigits
4
- } from "./V6KXHW3L.js";
4
+ } from "./ERQJZOEM.js";
5
5
 
6
6
  // src/schema.ts
7
7
  import { getTableColumns, getTableName, is } from "drizzle-orm";
package/dist/client.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  MethodError,
3
3
  createClient
4
- } from "./chunks/GCWICK3X.js";
5
- import "./chunks/V6KXHW3L.js";
4
+ } from "./chunks/GMRE3ZBW.js";
5
+ import "./chunks/ERQJZOEM.js";
6
6
  export {
7
7
  MethodError,
8
8
  createClient
package/dist/dev/host.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  callableMethods,
11
11
  checkAccess,
12
12
  isMember
13
- } from "../chunks/V6KXHW3L.js";
13
+ } from "../chunks/ERQJZOEM.js";
14
14
 
15
15
  // src/dev/host.ts
16
16
  import { DurableObject, WorkerEntrypoint } from "cloudflare:workers";
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createApp,
3
3
  fail
4
- } from "./chunks/2RGK2EON.js";
5
- import "./chunks/2UHILLRW.js";
6
- import "./chunks/V6KXHW3L.js";
4
+ } from "./chunks/K5LVABM3.js";
5
+ import "./chunks/QPDT7M6Y.js";
6
+ import "./chunks/ERQJZOEM.js";
7
7
 
8
8
  // src/index.ts
9
9
  import { z } from "zod";
@@ -412,9 +412,10 @@ export interface SessionResponse {
412
412
  /**
413
413
  * The bridge between the builder's Preview and an app's pages, in its frame:
414
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.
415
+ * the pages it frames there. It tells the builder where the page is, the
416
+ * errors the page does not catch, and, while the person picks an element to
417
+ * point the agent at, which they clicked. It answers only the builder's
418
+ * hosts, and tells only them.
418
419
  */
419
420
  export declare const BRIDGE_PATH = "/.teable/bridge.js";
420
421
  /** What the builder tells the bridge: start or stop picking an element. */
@@ -438,9 +439,24 @@ export interface PickedElement {
438
439
  /** A CSS selector for it, from its nearest ancestor with an id, at most six steps. */
439
440
  selector: string;
440
441
  }
442
+ /**
443
+ * What went wrong in a page that nothing in it caught: an error its scripts
444
+ * threw, or a promise they left rejected, as the bridge reports it.
445
+ */
446
+ export interface PageError {
447
+ /** The page it happened on: its path, query and fragment. */
448
+ path: string;
449
+ /** Thrown (`error`), or a promise rejected with nothing to handle it (`rejection`). */
450
+ kind: "error" | "rejection";
451
+ /** The error's name and message, or what was thrown, at most 1,000 characters. */
452
+ message: string;
453
+ /** Its stack as the browser gives it, else where it was thrown if known; at most 4,000 characters. */
454
+ stack: string | null;
455
+ }
441
456
  /**
442
457
  * 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).
458
+ * it moves), the element picked, that picking stopped (Escape), or an error
459
+ * the page did not catch (the first twenty of each page it loads).
444
460
  */
445
461
  export type PagesMessage = {
446
462
  source: "teable-pages";
@@ -453,11 +469,17 @@ export type PagesMessage = {
453
469
  } | {
454
470
  source: "teable-pages";
455
471
  type: "stopped";
472
+ } | {
473
+ source: "teable-pages";
474
+ type: "error";
475
+ error: PageError;
456
476
  };
457
477
  /**
458
478
  * The bridge's script, for a page framed by one of `origins` (the builder's
459
479
  * 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.
480
+ * in any app's pages, built with any SDK; `window` is the page's. It hears
481
+ * the page's errors from where it runs, so it runs before the page's own
482
+ * scripts: first in the page's head.
461
483
  */
462
484
  export declare function pagesBridge(origins: readonly string[]): string;
463
485
  /**
package/dist/protocol.js CHANGED
@@ -31,7 +31,7 @@ import {
31
31
  secretPlaceholder,
32
32
  signedInAsAsked,
33
33
  spaceRoleOf
34
- } from "./chunks/V6KXHW3L.js";
34
+ } from "./chunks/ERQJZOEM.js";
35
35
  export {
36
36
  APPS_PATH,
37
37
  APP_COMPATIBILITY_DATE,
package/dist/schema.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  col,
4
4
  describeTables,
5
5
  schemaOf
6
- } from "./chunks/2UHILLRW.js";
7
- import "./chunks/V6KXHW3L.js";
6
+ } from "./chunks/QPDT7M6Y.js";
7
+ import "./chunks/ERQJZOEM.js";
8
8
  export {
9
9
  attachment,
10
10
  col,
package/dist/testing.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  methodName
3
- } from "./chunks/2RGK2EON.js";
4
- import "./chunks/2UHILLRW.js";
3
+ } from "./chunks/K5LVABM3.js";
4
+ import "./chunks/QPDT7M6Y.js";
5
5
  import {
6
6
  MethodError
7
- } from "./chunks/GCWICK3X.js";
7
+ } from "./chunks/GMRE3ZBW.js";
8
8
  import {
9
9
  ERROR_STATUS
10
- } from "./chunks/V6KXHW3L.js";
10
+ } from "./chunks/ERQJZOEM.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
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  MethodError
3
- } from "./chunks/GCWICK3X.js";
3
+ } from "./chunks/GMRE3ZBW.js";
4
4
  import {
5
5
  ERROR_STATUS
6
- } from "./chunks/V6KXHW3L.js";
6
+ } from "./chunks/ERQJZOEM.js";
7
7
 
8
8
  // src/worker.ts
9
9
  function thrower(caller) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teable/app",
3
- "version": "6.1.7",
3
+ "version": "6.1.8",
4
4
  "description": "Write a Teable app as a Drizzle schema plus methods",
5
5
  "license": "MIT",
6
6
  "repository": {