@teable/app 7.0.0 → 7.0.2

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/DPGYFUG5.js";
6
- import "../chunks/SY3BAXHH.js";
5
+ } from "../chunks/N57JCM5C.js";
6
+ import "../chunks/55AX7R35.js";
7
7
 
8
8
  // src/build/cli.ts
9
9
  import { mkdirSync, rmSync, writeFileSync } from "node:fs";
@@ -3,8 +3,8 @@ import {
3
3
  buildWorker,
4
4
  sqlAsText,
5
5
  teable
6
- } from "../chunks/DPGYFUG5.js";
7
- import "../chunks/SY3BAXHH.js";
6
+ } from "../chunks/N57JCM5C.js";
7
+ import "../chunks/55AX7R35.js";
8
8
  export {
9
9
  buildServer,
10
10
  buildWorker,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_CURRENCY,
3
3
  currencyDigits
4
- } from "./SY3BAXHH.js";
4
+ } from "./55AX7R35.js";
5
5
 
6
6
  // src/schema.ts
7
7
  import { getTableColumns, getTableName, is } from "drizzle-orm";
@@ -263,6 +263,7 @@ var BRIDGE = String.raw`function (window, origins) {
263
263
  }`;
264
264
  var APPS_PATH = "/api/v4/apps";
265
265
  var FILE_NAME_HEADER = "X-File-Name";
266
+ var PREVIEW_QUERY = "preview";
266
267
  function fileKeyPath(key) {
267
268
  const slash = key.indexOf("/");
268
269
  return `${key.slice(0, slash)}/${encodeURIComponent(key.slice(slash + 1))}`;
@@ -340,6 +341,7 @@ export {
340
341
  pagesBridge,
341
342
  APPS_PATH,
342
343
  FILE_NAME_HEADER,
344
+ PREVIEW_QUERY,
343
345
  fileKeyPath,
344
346
  DEPLOY_HEADERS,
345
347
  DEPLOY_PARTS,
@@ -2,9 +2,10 @@ import {
2
2
  APPS_PATH,
3
3
  ERROR_STATUS,
4
4
  FILE_NAME_HEADER,
5
+ PREVIEW_QUERY,
5
6
  SESSION_PATH,
6
7
  fileKeyPath
7
- } from "./SY3BAXHH.js";
8
+ } from "./55AX7R35.js";
8
9
 
9
10
  // src/client.ts
10
11
  var MethodError = class extends Error {
@@ -30,7 +31,8 @@ function createClient(options) {
30
31
  const page = globalThis.location;
31
32
  const base = () => options.baseUrl ?? page?.origin ?? "";
32
33
  const doFetch = options.fetch ?? globalThis.fetch.bind(globalThis);
33
- const dataKey = ["teable-app", options.appId];
34
+ const dataKey = [options.preview ? "teable-preview" : "teable-app", options.appId];
35
+ const scope = options.preview ? `?${PREVIEW_QUERY}=1` : "";
34
36
  async function request(path, init = {
35
37
  method: "GET"
36
38
  }, prefix = `${APPS_PATH}/${options.appId}`) {
@@ -64,7 +66,7 @@ function createClient(options) {
64
66
  let attempt = 0;
65
67
  let timer;
66
68
  const connect = (retry) => {
67
- const url = new URL(`${base()}${APPS_PATH}/${options.appId}/realtime`);
69
+ const url = new URL(`${base()}${APPS_PATH}/${options.appId}/realtime${scope}`);
68
70
  url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
69
71
  socket = new WebSocket(url.toString());
70
72
  socket.onopen = () => {
@@ -92,9 +94,9 @@ function createClient(options) {
92
94
  return {
93
95
  appId: options.appId,
94
96
  dataKey,
95
- manifestKey: ["teable-manifest", options.appId],
96
- call: ((method, input) => request(`/methods/${method}`, json(input))),
97
- manifest: async () => await request("/manifest"),
97
+ manifestKey: [options.preview ? "teable-preview-manifest" : "teable-manifest", options.appId],
98
+ call: ((method, input) => request(`/methods/${method}${scope}`, json(input))),
99
+ manifest: async () => await request(`/manifest${scope}`),
98
100
  members: async () => (await request("/members")).members,
99
101
  accounts: async () => (await request("/accounts")).accounts,
100
102
  queryKey: (method, input) => [...dataKey, method, input ?? {}],
@@ -10,7 +10,7 @@ import {
10
10
  isMember,
11
11
  pagesBridge,
12
12
  spaceRoleOf
13
- } from "./SY3BAXHH.js";
13
+ } from "./55AX7R35.js";
14
14
 
15
15
  // src/build/index.ts
16
16
  import { existsSync, readFileSync } from "node:fs";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  describeTables
3
- } from "./MV7KRBHD.js";
3
+ } from "./2VHESBP6.js";
4
4
  import {
5
5
  CAPABILITIES,
6
6
  PROTOCOL_VERSION,
7
7
  admit,
8
8
  isPageAccess
9
- } from "./SY3BAXHH.js";
9
+ } from "./55AX7R35.js";
10
10
 
11
11
  // src/server/errors.ts
12
12
  import { z } from "zod";
package/dist/client.d.ts CHANGED
@@ -89,6 +89,14 @@ export interface ClientOptions {
89
89
  /** A bearer identity token. Pages on the platform's domain use the identity cookie instead. */
90
90
  token?: () => string | null | undefined;
91
91
  fetch?: typeof fetch;
92
+ /**
93
+ * The app's preview instead of its live version (ADR 0022), from the
94
+ * platform's hosts, for those who may publish the app: its manifest, its
95
+ * methods on its copy of the data, and its realtime, under keys of its
96
+ * own. Files are the app's either way. On the preview's own host, pages
97
+ * call it without this.
98
+ */
99
+ preview?: boolean;
92
100
  }
93
101
  export interface AppClient<S> {
94
102
  readonly appId: string;
package/dist/client.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  MethodError,
3
3
  createClient
4
- } from "./chunks/CFKHMHDT.js";
5
- import "./chunks/SY3BAXHH.js";
4
+ } from "./chunks/HOJZKDRT.js";
5
+ import "./chunks/55AX7R35.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/SY3BAXHH.js";
13
+ } from "../chunks/55AX7R35.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/O4WQUPBV.js";
5
- import "./chunks/MV7KRBHD.js";
6
- import "./chunks/SY3BAXHH.js";
4
+ } from "./chunks/TSMB4OBX.js";
5
+ import "./chunks/2VHESBP6.js";
6
+ import "./chunks/55AX7R35.js";
7
7
 
8
8
  // src/index.ts
9
9
  import { z } from "zod";
@@ -588,6 +588,13 @@ export type RealtimeMessage = {
588
588
  export declare const APPS_PATH = "/api/v4/apps";
589
589
  /** The header that names an uploaded file (URI-encoded); the body is its bytes. */
590
590
  export declare const FILE_NAME_HEADER = "X-File-Name";
591
+ /**
592
+ * The query parameter, set to `1`, by which a request on the platform's
593
+ * hosts names the app's preview (ADR 0022): the builder's views call it so,
594
+ * and signing in to it starts so. On the preview's own host every call is
595
+ * the preview's.
596
+ */
597
+ export declare const PREVIEW_QUERY = "preview";
591
598
  /** A file's key (`<uuid>/<name>`) as it goes in a URL path: the name encoded. */
592
599
  export declare function fileKeyPath(key: string): string;
593
600
  /**
@@ -639,6 +646,33 @@ export declare const DEPLOY_PARTS: {
639
646
  * another app: they would call that app's API, not this one's.
640
647
  */
641
648
  export declare const PAGES_APP_META = "teable-app";
649
+ /**
650
+ * An app's preview (ADR 0022): a version deployed on a copy of the live
651
+ * database, not live, with its pages at a host of their own. `GET
652
+ * {APPS_PATH}/:appId/preview` answers `PreviewResponse`; `POST` takes what a
653
+ * version's deploy takes (`DEPLOY_PARTS`, `DEPLOY_HEADERS`) and answers the
654
+ * new preview (201), replacing the one before with a new copy of the live
655
+ * data; `DELETE` ends it; `POST …/preview/publish` deploys it as the next
656
+ * version (`DeployResponse`). A new live version ends it either way.
657
+ */
658
+ export interface PreviewInfo {
659
+ /** When it was deployed, in epoch milliseconds. */
660
+ createdAt: number;
661
+ /** The user who deployed it. */
662
+ deployedBy: string | null;
663
+ /** The git commit its bundle was built from. */
664
+ commit: string | null;
665
+ /** That commit's subject. */
666
+ message: string | null;
667
+ /** The live version whose data it started from; null when none was live. */
668
+ basedOn: number | null;
669
+ manifest: AppManifest;
670
+ /** Where its pages are, for those who may publish the app; null without pages. */
671
+ pagesUrl: string | null;
672
+ }
673
+ export interface PreviewResponse {
674
+ preview: PreviewInfo | null;
675
+ }
642
676
  /**
643
677
  * `POST {APPS_PATH}/:appId/rollback` with `{ "to": <version> }` deploys that
644
678
  * version's bundle again, as a new version. Its answer (201) is a deploy's,
package/dist/protocol.js CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  ERROR_STATUS,
13
13
  FILE_NAME_HEADER,
14
14
  PAGES_APP_META,
15
+ PREVIEW_QUERY,
15
16
  PROTOCOL_VERSION,
16
17
  SECRET_NAME,
17
18
  SECRET_PLACEHOLDER,
@@ -32,7 +33,7 @@ import {
32
33
  secretPlaceholder,
33
34
  signedInAsAsked,
34
35
  spaceRoleOf
35
- } from "./chunks/SY3BAXHH.js";
36
+ } from "./chunks/55AX7R35.js";
36
37
  export {
37
38
  APPS_PATH,
38
39
  APP_COMPATIBILITY_DATE,
@@ -47,6 +48,7 @@ export {
47
48
  ERROR_STATUS,
48
49
  FILE_NAME_HEADER,
49
50
  PAGES_APP_META,
51
+ PREVIEW_QUERY,
50
52
  PROTOCOL_VERSION,
51
53
  SECRET_NAME,
52
54
  SECRET_PLACEHOLDER,
package/dist/schema.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  col,
4
4
  describeTables,
5
5
  schemaOf
6
- } from "./chunks/MV7KRBHD.js";
7
- import "./chunks/SY3BAXHH.js";
6
+ } from "./chunks/2VHESBP6.js";
7
+ import "./chunks/55AX7R35.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/O4WQUPBV.js";
4
- import "./chunks/MV7KRBHD.js";
3
+ } from "./chunks/TSMB4OBX.js";
4
+ import "./chunks/2VHESBP6.js";
5
5
  import {
6
6
  MethodError
7
- } from "./chunks/CFKHMHDT.js";
7
+ } from "./chunks/HOJZKDRT.js";
8
8
  import {
9
9
  ERROR_STATUS
10
- } from "./chunks/SY3BAXHH.js";
10
+ } from "./chunks/55AX7R35.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/CFKHMHDT.js";
3
+ } from "./chunks/HOJZKDRT.js";
4
4
  import {
5
5
  ERROR_STATUS
6
- } from "./chunks/SY3BAXHH.js";
6
+ } from "./chunks/55AX7R35.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": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "Write a Teable app as a Drizzle schema plus methods",
5
5
  "license": "MIT",
6
6
  "repository": {