@teable/app 6.1.3 → 6.1.5

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/H3YCXVRL.js";
6
- import "../chunks/RJHLCJUX.js";
5
+ } from "../chunks/QFBJVTKN.js";
6
+ import "../chunks/X7RU6GWG.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/H3YCXVRL.js";
7
- import "../chunks/RJHLCJUX.js";
6
+ } from "../chunks/QFBJVTKN.js";
7
+ import "../chunks/X7RU6GWG.js";
8
8
  export {
9
9
  buildServer,
10
10
  buildWorker,
@@ -4,7 +4,7 @@ import {
4
4
  FILE_NAME_HEADER,
5
5
  SESSION_PATH,
6
6
  fileKeyPath
7
- } from "./RJHLCJUX.js";
7
+ } from "./X7RU6GWG.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 "./TN5GZDH5.js";
3
+ } from "./YKGJK354.js";
4
4
  import {
5
5
  CAPABILITIES,
6
6
  PROTOCOL_VERSION,
7
7
  admit,
8
8
  isPageAccess
9
- } from "./RJHLCJUX.js";
9
+ } from "./X7RU6GWG.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
- } from "./RJHLCJUX.js";
8
+ checkAccess,
9
+ spaceRoleOf
10
+ } from "./X7RU6GWG.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();
@@ -115,6 +115,18 @@ function isExposed(method) {
115
115
  function callableMethods(manifest, caller) {
116
116
  return manifest.methods.filter((m) => isExposed(m) && checkAccess(caller, m.access) === null);
117
117
  }
118
+ function spaceRoleOf(name) {
119
+ return SPACE_ROLES.find((role) => role === name) ?? null;
120
+ }
121
+ function roleAsAsked(role, asked) {
122
+ return asked !== null && SPACE_ROLES.indexOf(asked) > SPACE_ROLES.indexOf(role) ? asked : role;
123
+ }
124
+ function signedInAsAsked(role, asked) {
125
+ return asked === null || role === asked;
126
+ }
127
+ function rolesBelow(role) {
128
+ return SPACE_ROLES.slice(SPACE_ROLES.indexOf(role) + 1);
129
+ }
118
130
 
119
131
  export {
120
132
  PROTOCOL_VERSION,
@@ -142,5 +154,9 @@ export {
142
154
  admit,
143
155
  isMember,
144
156
  isExposed,
145
- callableMethods
157
+ callableMethods,
158
+ spaceRoleOf,
159
+ roleAsAsked,
160
+ signedInAsAsked,
161
+ rolesBelow
146
162
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_CURRENCY,
3
3
  currencyDigits
4
- } from "./RJHLCJUX.js";
4
+ } from "./X7RU6GWG.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/TDLQQFGT.js";
5
- import "./chunks/RJHLCJUX.js";
4
+ } from "./chunks/7LMF3F7Z.js";
5
+ import "./chunks/X7RU6GWG.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/RJHLCJUX.js";
13
+ } from "../chunks/X7RU6GWG.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/O6KEZ2KL.js";
5
- import "./chunks/TN5GZDH5.js";
6
- import "./chunks/RJHLCJUX.js";
4
+ } from "./chunks/JX4PSLSS.js";
5
+ import "./chunks/YKGJK354.js";
6
+ import "./chunks/X7RU6GWG.js";
7
7
 
8
8
  // src/index.ts
9
9
  import { z } from "zod";
@@ -536,6 +536,18 @@ export interface AppFailure {
536
536
  attempt: number | null;
537
537
  dead: boolean | null;
538
538
  }
539
+ /**
540
+ * Whether an app is offline (ADR 0016), as `{APPS_PATH}/:appId/offline`
541
+ * says it to its creators: since when (epoch milliseconds) and who took it
542
+ * offline, or null while it is online. Offline, it answers only those who
543
+ * may publish it, until one of them brings it back.
544
+ */
545
+ export interface AppOffline {
546
+ offline: {
547
+ since: number;
548
+ by: string;
549
+ } | null;
550
+ }
539
551
  /**
540
552
  * A secret of an app (ADR 0015), as `GET {APPS_PATH}/:appId/secrets` lists
541
553
  * them for its creators: by name, never by value. The app's code writes
@@ -600,3 +612,15 @@ export declare function isMember(caller: Caller): boolean;
600
612
  export declare function isExposed(method: MethodInfo): boolean;
601
613
  /** The exposed methods this caller may call. */
602
614
  export declare function callableMethods(manifest: AppManifest, caller: Caller): MethodInfo[];
615
+ /** A space role by its name; null for anything else. */
616
+ export declare function spaceRoleOf(name: unknown): SpaceRole | null;
617
+ /**
618
+ * The role a sign-in to an app's pages gives a person who asked to be at
619
+ * most `asked` (the builder's Preview, as another role): theirs, or the
620
+ * lower one asked for, never a higher one. Null asks for theirs.
621
+ */
622
+ export declare function roleAsAsked(role: SpaceRole, asked: SpaceRole | null): SpaceRole;
623
+ /** Whether a session with `role` is what a sign-in asking for `asked` gives: none is needed. */
624
+ export declare function signedInAsAsked(role: SpaceRole, asked: SpaceRole | null): boolean;
625
+ /** The roles below `role`, highest first: those its holder may preview an app's pages as. */
626
+ export declare function rolesBelow(role: SpaceRole): SpaceRole[];
package/dist/protocol.js CHANGED
@@ -24,8 +24,12 @@ import {
24
24
  isExposed,
25
25
  isMember,
26
26
  isPageAccess,
27
- secretPlaceholder
28
- } from "./chunks/RJHLCJUX.js";
27
+ roleAsAsked,
28
+ rolesBelow,
29
+ secretPlaceholder,
30
+ signedInAsAsked,
31
+ spaceRoleOf
32
+ } from "./chunks/X7RU6GWG.js";
29
33
  export {
30
34
  APPS_PATH,
31
35
  APP_COMPATIBILITY_DATE,
@@ -52,5 +56,9 @@ export {
52
56
  isExposed,
53
57
  isMember,
54
58
  isPageAccess,
55
- secretPlaceholder
59
+ roleAsAsked,
60
+ rolesBelow,
61
+ secretPlaceholder,
62
+ signedInAsAsked,
63
+ spaceRoleOf
56
64
  };
package/dist/schema.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  col,
4
4
  describeTables,
5
5
  schemaOf
6
- } from "./chunks/TN5GZDH5.js";
7
- import "./chunks/RJHLCJUX.js";
6
+ } from "./chunks/YKGJK354.js";
7
+ import "./chunks/X7RU6GWG.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/O6KEZ2KL.js";
4
- import "./chunks/TN5GZDH5.js";
3
+ } from "./chunks/JX4PSLSS.js";
4
+ import "./chunks/YKGJK354.js";
5
5
  import {
6
6
  MethodError
7
- } from "./chunks/TDLQQFGT.js";
7
+ } from "./chunks/7LMF3F7Z.js";
8
8
  import {
9
9
  ERROR_STATUS
10
- } from "./chunks/RJHLCJUX.js";
10
+ } from "./chunks/X7RU6GWG.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/TDLQQFGT.js";
3
+ } from "./chunks/7LMF3F7Z.js";
4
4
  import {
5
5
  ERROR_STATUS
6
- } from "./chunks/RJHLCJUX.js";
6
+ } from "./chunks/X7RU6GWG.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.3",
3
+ "version": "6.1.5",
4
4
  "description": "Write a Teable app as a Drizzle schema plus methods",
5
5
  "license": "MIT",
6
6
  "repository": {