@teable/app 7.0.1 → 7.0.3

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/WOZYDEVS.js";
6
+ import "../chunks/UAHL536U.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/WOZYDEVS.js";
7
+ import "../chunks/UAHL536U.js";
8
8
  export {
9
9
  buildServer,
10
10
  buildWorker,
@@ -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 "./UAHL536U.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 ?? {}],
@@ -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))}`;
@@ -270,6 +271,16 @@ function fileKeyPath(key) {
270
271
  var DEPLOY_HEADERS = { commit: "X-Teable-Commit", message: "X-Teable-Message" };
271
272
  var DEPLOY_PARTS = { server: "server", worker: "worker", pages: "pages" };
272
273
  var PAGES_APP_META = "teable-app";
274
+ var BADGE_RULES = ["required", "optional", "off"];
275
+ var SITE_LIMITS = { title: 120, description: 500, iconBytes: 1024 * 1024 };
276
+ var SITE_ICON_TYPES = [
277
+ "image/png",
278
+ "image/jpeg",
279
+ "image/webp",
280
+ "image/svg+xml",
281
+ "image/x-icon",
282
+ "image/vnd.microsoft.icon"
283
+ ];
273
284
  var SECRET_NAME_PATTERN = "[A-Z][A-Z0-9_]{0,63}";
274
285
  var SECRET_NAME = new RegExp(`^${SECRET_NAME_PATTERN}$`);
275
286
  function secretPlaceholder(name) {
@@ -340,10 +351,14 @@ export {
340
351
  pagesBridge,
341
352
  APPS_PATH,
342
353
  FILE_NAME_HEADER,
354
+ PREVIEW_QUERY,
343
355
  fileKeyPath,
344
356
  DEPLOY_HEADERS,
345
357
  DEPLOY_PARTS,
346
358
  PAGES_APP_META,
359
+ BADGE_RULES,
360
+ SITE_LIMITS,
361
+ SITE_ICON_TYPES,
347
362
  SECRET_NAME,
348
363
  secretPlaceholder,
349
364
  SECRET_PLACEHOLDER,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_CURRENCY,
3
3
  currencyDigits
4
- } from "./SY3BAXHH.js";
4
+ } from "./UAHL536U.js";
5
5
 
6
6
  // src/schema.ts
7
7
  import { getTableColumns, getTableName, is } from "drizzle-orm";
@@ -10,7 +10,7 @@ import {
10
10
  isMember,
11
11
  pagesBridge,
12
12
  spaceRoleOf
13
- } from "./SY3BAXHH.js";
13
+ } from "./UAHL536U.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 "./VUAUTXE2.js";
4
4
  import {
5
5
  CAPABILITIES,
6
6
  PROTOCOL_VERSION,
7
7
  admit,
8
8
  isPageAccess
9
- } from "./SY3BAXHH.js";
9
+ } from "./UAHL536U.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/C74GVJIJ.js";
5
+ import "./chunks/UAHL536U.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/UAHL536U.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/WVY4PINE.js";
5
+ import "./chunks/VUAUTXE2.js";
6
+ import "./chunks/UAHL536U.js";
7
7
 
8
8
  // src/index.ts
9
9
  import { z } from "zod";
@@ -407,8 +407,9 @@ export declare const ASSETS_HEADER = "X-Teable-Assets";
407
407
  * Where the runtime answers on an app's own host before its Worker (ADR
408
408
  * 0014): `sign-in?return=<path>` (to Teable and back), `callback`,
409
409
  * `session` (`SessionResponse`) and `sign-out` (POST); for an app's accounts
410
- * (ADR 0021), `sign-in/email` and `sign-in/code` (POST, `SignInCodeRequest`).
411
- * With `${APPS_PATH}/`,
410
+ * (ADR 0021), `sign-in/email` and `sign-in/code` (POST, `SignInCodeRequest`);
411
+ * and the icon its creators set and the script of its badge (ADR 0023),
412
+ * `icon` and `badge.js`. With `${APPS_PATH}/`,
412
413
  * the app's own API there, the app's Worker never sees these paths.
413
414
  */
414
415
  export declare const SESSION_PATH = "/.teable";
@@ -588,6 +589,13 @@ export type RealtimeMessage = {
588
589
  export declare const APPS_PATH = "/api/v4/apps";
589
590
  /** The header that names an uploaded file (URI-encoded); the body is its bytes. */
590
591
  export declare const FILE_NAME_HEADER = "X-File-Name";
592
+ /**
593
+ * The query parameter, set to `1`, by which a request on the platform's
594
+ * hosts names the app's preview (ADR 0022): the builder's views call it so,
595
+ * and signing in to it starts so. On the preview's own host every call is
596
+ * the preview's.
597
+ */
598
+ export declare const PREVIEW_QUERY = "preview";
591
599
  /** A file's key (`<uuid>/<name>`) as it goes in a URL path: the name encoded. */
592
600
  export declare function fileKeyPath(key: string): string;
593
601
  /**
@@ -743,6 +751,72 @@ export interface AppSubdomain {
743
751
  /** `https://<subdomain>.teable.uk`, or its id's host; null when it has neither. */
744
752
  url: string | null;
745
753
  }
754
+ /**
755
+ * Whether an app's pages show the "Build with Teable" badge (ADR 0023), as
756
+ * the old platform decides from its space's plan: always (`required`),
757
+ * unless its creators hide it (`optional`), or never (`off`).
758
+ */
759
+ export type BadgeRule = "required" | "optional" | "off";
760
+ /** What a badge rule may be. */
761
+ export declare const BADGE_RULES: readonly ["required", "optional", "off"];
762
+ /**
763
+ * An app's site info (ADR 0023), as `GET {APPS_PATH}/:appId/site` says it
764
+ * to its creators: the title, description and icon the runtime puts in its
765
+ * pages' head over what their code says, each null to leave the pages'
766
+ * own; and its badge.
767
+ */
768
+ export interface AppSite {
769
+ title: string | null;
770
+ description: string | null;
771
+ /** The icon, as a `data:` URL; null: the pages' own. */
772
+ icon: string | null;
773
+ badge: {
774
+ rule: BadgeRule;
775
+ /** Whether its creators hid it, which counts only where the rule is `optional`. */
776
+ hidden: boolean;
777
+ /** Whether the pages show it. */
778
+ shown: boolean;
779
+ };
780
+ }
781
+ /**
782
+ * What `PUT {APPS_PATH}/:appId/site` takes: any of these, the rest staying
783
+ * as they are. An empty title or description is null; an icon is its type
784
+ * (`SITE_ICON_TYPES`) and its bytes in base64.
785
+ */
786
+ export interface SiteInput {
787
+ title?: string | null;
788
+ description?: string | null;
789
+ icon?: {
790
+ type: string;
791
+ content: string;
792
+ } | null;
793
+ hideBadge?: boolean;
794
+ }
795
+ /** How long a site's title and description may be, in characters, and its icon, in bytes. */
796
+ export declare const SITE_LIMITS: {
797
+ readonly title: 120;
798
+ readonly description: 500;
799
+ readonly iconBytes: number;
800
+ };
801
+ /** The types an app's icon may be. */
802
+ export declare const SITE_ICON_TYPES: readonly ["image/png", "image/jpeg", "image/webp", "image/svg+xml", "image/x-icon", "image/vnd.microsoft.icon"];
803
+ /**
804
+ * An app's usage (ADR 0006), as `GET {APPS_PATH}/:appId/usage` says it to
805
+ * its creators: per UTC day and kind, the calls its methods ran (`call`),
806
+ * its task runs (`task`) and the requests it sent out (`http`), with how
807
+ * long they took, from `from` to `to` (YYYY-MM-DD, both counted). Days
808
+ * without use are left out.
809
+ */
810
+ export interface AppUsage {
811
+ from: string;
812
+ to: string;
813
+ days: {
814
+ day: string;
815
+ kind: "call" | "task" | "http";
816
+ quantity: number;
817
+ durationMs: number;
818
+ }[];
819
+ }
746
820
  /**
747
821
  * A secret of an app (ADR 0015), as `GET {APPS_PATH}/:appId/secrets` lists
748
822
  * them for its creators: by name, never by value. The app's code writes
package/dist/protocol.js CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  APPS_PATH,
3
3
  APP_COMPATIBILITY_DATE,
4
4
  ASSETS_HEADER,
5
+ BADGE_RULES,
5
6
  BRIDGE_PATH,
6
7
  CAPABILITIES,
7
8
  DEFAULT_CURRENCY,
@@ -12,11 +13,14 @@ import {
12
13
  ERROR_STATUS,
13
14
  FILE_NAME_HEADER,
14
15
  PAGES_APP_META,
16
+ PREVIEW_QUERY,
15
17
  PROTOCOL_VERSION,
16
18
  SECRET_NAME,
17
19
  SECRET_PLACEHOLDER,
18
20
  SESSION_PATH,
19
21
  SIGN_IN_ACCOUNTS,
22
+ SITE_ICON_TYPES,
23
+ SITE_LIMITS,
20
24
  SPACE_ROLES,
21
25
  admit,
22
26
  callableMethods,
@@ -32,11 +36,12 @@ import {
32
36
  secretPlaceholder,
33
37
  signedInAsAsked,
34
38
  spaceRoleOf
35
- } from "./chunks/SY3BAXHH.js";
39
+ } from "./chunks/UAHL536U.js";
36
40
  export {
37
41
  APPS_PATH,
38
42
  APP_COMPATIBILITY_DATE,
39
43
  ASSETS_HEADER,
44
+ BADGE_RULES,
40
45
  BRIDGE_PATH,
41
46
  CAPABILITIES,
42
47
  DEFAULT_CURRENCY,
@@ -47,11 +52,14 @@ export {
47
52
  ERROR_STATUS,
48
53
  FILE_NAME_HEADER,
49
54
  PAGES_APP_META,
55
+ PREVIEW_QUERY,
50
56
  PROTOCOL_VERSION,
51
57
  SECRET_NAME,
52
58
  SECRET_PLACEHOLDER,
53
59
  SESSION_PATH,
54
60
  SIGN_IN_ACCOUNTS,
61
+ SITE_ICON_TYPES,
62
+ SITE_LIMITS,
55
63
  SPACE_ROLES,
56
64
  admit,
57
65
  callableMethods,
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/VUAUTXE2.js";
7
+ import "./chunks/UAHL536U.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/WVY4PINE.js";
4
+ import "./chunks/VUAUTXE2.js";
5
5
  import {
6
6
  MethodError
7
- } from "./chunks/CFKHMHDT.js";
7
+ } from "./chunks/C74GVJIJ.js";
8
8
  import {
9
9
  ERROR_STATUS
10
- } from "./chunks/SY3BAXHH.js";
10
+ } from "./chunks/UAHL536U.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/C74GVJIJ.js";
4
4
  import {
5
5
  ERROR_STATUS
6
- } from "./chunks/SY3BAXHH.js";
6
+ } from "./chunks/UAHL536U.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.1",
3
+ "version": "7.0.3",
4
4
  "description": "Write a Teable app as a Drizzle schema plus methods",
5
5
  "license": "MIT",
6
6
  "repository": {