@teable/app 7.0.2 → 7.0.4

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/N57JCM5C.js";
6
- import "../chunks/55AX7R35.js";
5
+ } from "../chunks/UDRXJPLD.js";
6
+ import "../chunks/N6PYNICH.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/N57JCM5C.js";
7
- import "../chunks/55AX7R35.js";
6
+ } from "../chunks/UDRXJPLD.js";
7
+ import "../chunks/N6PYNICH.js";
8
8
  export {
9
9
  buildServer,
10
10
  buildWorker,
@@ -271,6 +271,23 @@ function fileKeyPath(key) {
271
271
  var DEPLOY_HEADERS = { commit: "X-Teable-Commit", message: "X-Teable-Message" };
272
272
  var DEPLOY_PARTS = { server: "server", worker: "worker", pages: "pages" };
273
273
  var PAGES_APP_META = "teable-app";
274
+ var DOMAIN_NAME = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
275
+ function normalizeDomain(input) {
276
+ return input.trim().toLowerCase().replace(/^https?:\/\//, "").replace(/\/+$/, "").replace(/\.$/, "");
277
+ }
278
+ function isDomainName(domain) {
279
+ return domain.length <= 253 && DOMAIN_NAME.test(domain);
280
+ }
281
+ var BADGE_RULES = ["required", "optional", "off"];
282
+ var SITE_LIMITS = { title: 120, description: 500, iconBytes: 1024 * 1024 };
283
+ var SITE_ICON_TYPES = [
284
+ "image/png",
285
+ "image/jpeg",
286
+ "image/webp",
287
+ "image/svg+xml",
288
+ "image/x-icon",
289
+ "image/vnd.microsoft.icon"
290
+ ];
274
291
  var SECRET_NAME_PATTERN = "[A-Z][A-Z0-9_]{0,63}";
275
292
  var SECRET_NAME = new RegExp(`^${SECRET_NAME_PATTERN}$`);
276
293
  function secretPlaceholder(name) {
@@ -346,6 +363,11 @@ export {
346
363
  DEPLOY_HEADERS,
347
364
  DEPLOY_PARTS,
348
365
  PAGES_APP_META,
366
+ normalizeDomain,
367
+ isDomainName,
368
+ BADGE_RULES,
369
+ SITE_LIMITS,
370
+ SITE_ICON_TYPES,
349
371
  SECRET_NAME,
350
372
  secretPlaceholder,
351
373
  SECRET_PLACEHOLDER,
@@ -5,7 +5,7 @@ import {
5
5
  PREVIEW_QUERY,
6
6
  SESSION_PATH,
7
7
  fileKeyPath
8
- } from "./55AX7R35.js";
8
+ } from "./N6PYNICH.js";
9
9
 
10
10
  // src/client.ts
11
11
  var MethodError = class extends Error {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  describeTables
3
- } from "./2VHESBP6.js";
3
+ } from "./QNWCYG6K.js";
4
4
  import {
5
5
  CAPABILITIES,
6
6
  PROTOCOL_VERSION,
7
7
  admit,
8
8
  isPageAccess
9
- } from "./55AX7R35.js";
9
+ } from "./N6PYNICH.js";
10
10
 
11
11
  // src/server/errors.ts
12
12
  import { z } from "zod";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_CURRENCY,
3
3
  currencyDigits
4
- } from "./55AX7R35.js";
4
+ } from "./N6PYNICH.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 "./55AX7R35.js";
13
+ } from "./N6PYNICH.js";
14
14
 
15
15
  // src/build/index.ts
16
16
  import { existsSync, readFileSync } from "node:fs";
package/dist/client.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  MethodError,
3
3
  createClient
4
- } from "./chunks/HOJZKDRT.js";
5
- import "./chunks/55AX7R35.js";
4
+ } from "./chunks/OXDV76VZ.js";
5
+ import "./chunks/N6PYNICH.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/55AX7R35.js";
13
+ } from "../chunks/N6PYNICH.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/TSMB4OBX.js";
5
- import "./chunks/2VHESBP6.js";
6
- import "./chunks/55AX7R35.js";
4
+ } from "./chunks/QHPLAVFD.js";
5
+ import "./chunks/QNWCYG6K.js";
6
+ import "./chunks/N6PYNICH.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";
@@ -750,6 +751,111 @@ export interface AppSubdomain {
750
751
  /** `https://<subdomain>.teable.uk`, or its id's host; null when it has neither. */
751
752
  url: string | null;
752
753
  }
754
+ /**
755
+ * A DNS record people add at their DNS provider for an app's own domain
756
+ * (ADR 0024): its name within their zone (`@` for its root).
757
+ */
758
+ export interface DomainRecord {
759
+ type: "CNAME";
760
+ name: string;
761
+ value: string;
762
+ }
763
+ /**
764
+ * A domain as people type it, as the runtime takes it for an app's own
765
+ * (ADR 0024), and as the old platform did: trimmed, in lower case, without
766
+ * scheme, trailing slashes or a trailing dot.
767
+ */
768
+ export declare function normalizeDomain(input: string): string;
769
+ /** Whether `domain`, normalized, is a host name of two labels or more, 253 characters at most, ending in letters. */
770
+ export declare function isDomainName(domain: string): boolean;
771
+ /**
772
+ * An app's own domain (ADR 0024), as `{APPS_PATH}/:appId/domain` says it
773
+ * to its creators: the domain they bound, or null; `pending` until
774
+ * Cloudflare has validated it and issued its certificate, then `active`,
775
+ * while its pages are there; the record to add for it; and why it is not
776
+ * active yet, in Cloudflare's words. The space's plan decides whether the
777
+ * app may have one, and when a lapsed plan's domain is released.
778
+ */
779
+ export interface AppDomain {
780
+ domain: string | null;
781
+ status: "pending" | "active" | null;
782
+ records: DomainRecord[];
783
+ problem: string | null;
784
+ /** When Cloudflare was last asked about it (epoch milliseconds); null before. */
785
+ checkedAt: number | null;
786
+ /** Whether the space's plan includes own domains (Business and above). */
787
+ allowed: boolean;
788
+ /** When the domain is released, the plan no longer including it (epoch milliseconds); null while it does. */
789
+ releasesAt: number | null;
790
+ /** Where its pages are now: the domain while it is active, else its subdomain or its id's host. */
791
+ url: string | null;
792
+ }
793
+ /**
794
+ * Whether an app's pages show the "Build with Teable" badge (ADR 0023), as
795
+ * the old platform decides from its space's plan: always (`required`),
796
+ * unless its creators hide it (`optional`), or never (`off`).
797
+ */
798
+ export type BadgeRule = "required" | "optional" | "off";
799
+ /** What a badge rule may be. */
800
+ export declare const BADGE_RULES: readonly ["required", "optional", "off"];
801
+ /**
802
+ * An app's site info (ADR 0023), as `GET {APPS_PATH}/:appId/site` says it
803
+ * to its creators: the title, description and icon the runtime puts in its
804
+ * pages' head over what their code says, each null to leave the pages'
805
+ * own; and its badge.
806
+ */
807
+ export interface AppSite {
808
+ title: string | null;
809
+ description: string | null;
810
+ /** The icon, as a `data:` URL; null: the pages' own. */
811
+ icon: string | null;
812
+ badge: {
813
+ rule: BadgeRule;
814
+ /** Whether its creators hid it, which counts only where the rule is `optional`. */
815
+ hidden: boolean;
816
+ /** Whether the pages show it. */
817
+ shown: boolean;
818
+ };
819
+ }
820
+ /**
821
+ * What `PUT {APPS_PATH}/:appId/site` takes: any of these, the rest staying
822
+ * as they are. An empty title or description is null; an icon is its type
823
+ * (`SITE_ICON_TYPES`) and its bytes in base64.
824
+ */
825
+ export interface SiteInput {
826
+ title?: string | null;
827
+ description?: string | null;
828
+ icon?: {
829
+ type: string;
830
+ content: string;
831
+ } | null;
832
+ hideBadge?: boolean;
833
+ }
834
+ /** How long a site's title and description may be, in characters, and its icon, in bytes. */
835
+ export declare const SITE_LIMITS: {
836
+ readonly title: 120;
837
+ readonly description: 500;
838
+ readonly iconBytes: number;
839
+ };
840
+ /** The types an app's icon may be. */
841
+ export declare const SITE_ICON_TYPES: readonly ["image/png", "image/jpeg", "image/webp", "image/svg+xml", "image/x-icon", "image/vnd.microsoft.icon"];
842
+ /**
843
+ * An app's usage (ADR 0006), as `GET {APPS_PATH}/:appId/usage` says it to
844
+ * its creators: per UTC day and kind, the calls its methods ran (`call`),
845
+ * its task runs (`task`) and the requests it sent out (`http`), with how
846
+ * long they took, from `from` to `to` (YYYY-MM-DD, both counted). Days
847
+ * without use are left out.
848
+ */
849
+ export interface AppUsage {
850
+ from: string;
851
+ to: string;
852
+ days: {
853
+ day: string;
854
+ kind: "call" | "task" | "http";
855
+ quantity: number;
856
+ durationMs: number;
857
+ }[];
858
+ }
753
859
  /**
754
860
  * A secret of an app (ADR 0015), as `GET {APPS_PATH}/:appId/secrets` lists
755
861
  * 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,
@@ -18,26 +19,31 @@ import {
18
19
  SECRET_PLACEHOLDER,
19
20
  SESSION_PATH,
20
21
  SIGN_IN_ACCOUNTS,
22
+ SITE_ICON_TYPES,
23
+ SITE_LIMITS,
21
24
  SPACE_ROLES,
22
25
  admit,
23
26
  callableMethods,
24
27
  checkAccess,
25
28
  currencyDigits,
26
29
  fileKeyPath,
30
+ isDomainName,
27
31
  isExposed,
28
32
  isMember,
29
33
  isPageAccess,
34
+ normalizeDomain,
30
35
  pagesBridge,
31
36
  roleAsAsked,
32
37
  rolesBelow,
33
38
  secretPlaceholder,
34
39
  signedInAsAsked,
35
40
  spaceRoleOf
36
- } from "./chunks/55AX7R35.js";
41
+ } from "./chunks/N6PYNICH.js";
37
42
  export {
38
43
  APPS_PATH,
39
44
  APP_COMPATIBILITY_DATE,
40
45
  ASSETS_HEADER,
46
+ BADGE_RULES,
41
47
  BRIDGE_PATH,
42
48
  CAPABILITIES,
43
49
  DEFAULT_CURRENCY,
@@ -54,15 +60,19 @@ export {
54
60
  SECRET_PLACEHOLDER,
55
61
  SESSION_PATH,
56
62
  SIGN_IN_ACCOUNTS,
63
+ SITE_ICON_TYPES,
64
+ SITE_LIMITS,
57
65
  SPACE_ROLES,
58
66
  admit,
59
67
  callableMethods,
60
68
  checkAccess,
61
69
  currencyDigits,
62
70
  fileKeyPath,
71
+ isDomainName,
63
72
  isExposed,
64
73
  isMember,
65
74
  isPageAccess,
75
+ normalizeDomain,
66
76
  pagesBridge,
67
77
  roleAsAsked,
68
78
  rolesBelow,
package/dist/schema.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  col,
4
4
  describeTables,
5
5
  schemaOf
6
- } from "./chunks/2VHESBP6.js";
7
- import "./chunks/55AX7R35.js";
6
+ } from "./chunks/QNWCYG6K.js";
7
+ import "./chunks/N6PYNICH.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/TSMB4OBX.js";
4
- import "./chunks/2VHESBP6.js";
3
+ } from "./chunks/QHPLAVFD.js";
4
+ import "./chunks/QNWCYG6K.js";
5
5
  import {
6
6
  MethodError
7
- } from "./chunks/HOJZKDRT.js";
7
+ } from "./chunks/OXDV76VZ.js";
8
8
  import {
9
9
  ERROR_STATUS
10
- } from "./chunks/55AX7R35.js";
10
+ } from "./chunks/N6PYNICH.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/HOJZKDRT.js";
3
+ } from "./chunks/OXDV76VZ.js";
4
4
  import {
5
5
  ERROR_STATUS
6
- } from "./chunks/55AX7R35.js";
6
+ } from "./chunks/N6PYNICH.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.2",
3
+ "version": "7.0.4",
4
4
  "description": "Write a Teable app as a Drizzle schema plus methods",
5
5
  "license": "MIT",
6
6
  "repository": {