@teable/app 5.0.2 → 6.0.0
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 +12 -3
- package/dist/build/index.d.ts +105 -0
- package/dist/build/index.js +8 -3
- package/dist/chunks/{EVNB2DU2.js → 33OZ5YAY.js} +16 -6
- package/dist/chunks/{323GVFSV.js → L6RROFUY.js} +14 -4
- package/dist/chunks/{LV3ZHKKL.js → N7LBNIRZ.js} +1 -1
- package/dist/chunks/TXLTJKEX.js +353 -0
- package/dist/chunks/{JQWQD45Z.js → VMIIUPHE.js} +17 -1
- package/dist/client.d.ts +24 -3
- package/dist/client.js +2 -2
- package/dist/dev/host.d.ts +74 -0
- package/dist/dev/host.js +388 -0
- package/dist/index.js +3 -3
- package/dist/protocol.d.ts +107 -4
- package/dist/protocol.js +13 -3
- package/dist/schema.js +2 -2
- package/dist/server/app.d.ts +8 -1
- package/dist/testing.js +4 -4
- package/dist/worker.d.ts +59 -0
- package/dist/worker.js +33 -0
- package/package.json +10 -1
- package/dist/chunks/5QIBCQL5.js +0 -52
package/dist/protocol.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* and starts only apps built for its own version, so a change to the contract
|
|
14
14
|
* comes with a new version, and every app is deployed again.
|
|
15
15
|
*/
|
|
16
|
-
export declare const PROTOCOL_VERSION =
|
|
16
|
+
export declare const PROTOCOL_VERSION = 6;
|
|
17
17
|
/**
|
|
18
18
|
* The workerd compatibility date every app runs with: the host loads app code
|
|
19
19
|
* with it, and the SDK's and templates' tests run with it. Bump deliberately,
|
|
@@ -23,7 +23,11 @@ export declare const APP_COMPATIBILITY_DATE = "2026-12-01";
|
|
|
23
23
|
/** Space roles, strongest first. Mirrors the old platform's space roles. */
|
|
24
24
|
export declare const SPACE_ROLES: readonly ["owner", "creator", "editor", "commenter", "viewer"];
|
|
25
25
|
export type SpaceRole = (typeof SPACE_ROLES)[number];
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Who is calling a method. Identity is verified by the platform, never by the
|
|
28
|
+
* app. The app itself calls as `system`: from a task, or from its own Worker
|
|
29
|
+
* acting as the app (`asApp`, ADR 0014).
|
|
30
|
+
*/
|
|
27
31
|
export type Caller = {
|
|
28
32
|
kind: "user";
|
|
29
33
|
userId: string;
|
|
@@ -36,6 +40,9 @@ export type Caller = {
|
|
|
36
40
|
kind: "system";
|
|
37
41
|
via: "task";
|
|
38
42
|
task: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "system";
|
|
45
|
+
via: "worker";
|
|
39
46
|
};
|
|
40
47
|
export type ExternalChannel = "web" | "api" | "mcp";
|
|
41
48
|
/**
|
|
@@ -129,6 +136,36 @@ export interface AppManifest {
|
|
|
129
136
|
tables: TableInfo[];
|
|
130
137
|
/** Platform capabilities the app declared; the host wires only these. */
|
|
131
138
|
capabilities: Capability[];
|
|
139
|
+
/** The app's pages, at its own host (ADR 0014): who may open them. */
|
|
140
|
+
pages: {
|
|
141
|
+
access: PageAccess;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Who may open an app's pages: members of its space with at least that role,
|
|
146
|
+
* or anyone (`public`). A browser's navigation by anyone below it is sent to
|
|
147
|
+
* sign in, or told what it lacks, before the app's Worker runs; data still
|
|
148
|
+
* comes only from methods, under their own access.
|
|
149
|
+
*/
|
|
150
|
+
export type PageAccess = SpaceRole | "public";
|
|
151
|
+
/**
|
|
152
|
+
* What the app's Worker gets with every request, as `ctx.props` (ADR 0014):
|
|
153
|
+
* who sent the request, as methods see callers (`via: "web"`); the app's
|
|
154
|
+
* reads and writes, called as that caller (`asCaller`) or as the app itself
|
|
155
|
+
* (`asApp`, internal methods included); and one binding per capability the
|
|
156
|
+
* app declared, but `http` (its Worker has the network of its own). Each was
|
|
157
|
+
* made by the platform for this request and this app, and works only during
|
|
158
|
+
* the request it came with.
|
|
159
|
+
*/
|
|
160
|
+
export interface WorkerProps extends Partial<Omit<Capabilities, "http">> {
|
|
161
|
+
appId: string;
|
|
162
|
+
caller: Caller;
|
|
163
|
+
asCaller: MethodCaller;
|
|
164
|
+
asApp: MethodCaller;
|
|
165
|
+
}
|
|
166
|
+
/** Calls the app's reads and writes for its Worker: a method's value, as JSON, or why not. */
|
|
167
|
+
export interface MethodCaller {
|
|
168
|
+
call(method: string, input?: JsonValue): Promise<Result<JsonValue>>;
|
|
132
169
|
}
|
|
133
170
|
/** A stored file, as apps keep it in their rows. */
|
|
134
171
|
export interface Attachment {
|
|
@@ -302,12 +339,49 @@ export interface ErrorBody {
|
|
|
302
339
|
}
|
|
303
340
|
/**
|
|
304
341
|
* `GET {APPS_PATH}/:appId/manifest`: the live version's manifest as far as the
|
|
305
|
-
* caller may see it, which version that is,
|
|
342
|
+
* caller may see it, which version that is, who the caller is to the app, and
|
|
343
|
+
* where its pages are (null while the live version has none).
|
|
306
344
|
*/
|
|
307
345
|
export interface ManifestResponse extends AppManifest {
|
|
308
346
|
appId: string;
|
|
309
347
|
version: number;
|
|
310
348
|
caller: Caller;
|
|
349
|
+
pagesUrl: string | null;
|
|
350
|
+
}
|
|
351
|
+
/** Whether a manifest's pages access is one there is: a space role, or `public`. */
|
|
352
|
+
export declare function isPageAccess(access: unknown): access is PageAccess;
|
|
353
|
+
/**
|
|
354
|
+
* How `teable()`, the Vite plugin in `@teable/app/build`, and the runtime's
|
|
355
|
+
* stand-in it runs in workerd (`@teable/app/dev-host`) talk in local
|
|
356
|
+
* development (ADR 0014): paths nothing else uses.
|
|
357
|
+
* - `deploy`: the app's server code and Worker after each build, JSON
|
|
358
|
+
* `{ server, worker }`;
|
|
359
|
+
* - `gate`: whether a navigation may see the pages, 204, or the redirect or
|
|
360
|
+
* page that says why not;
|
|
361
|
+
* - `worker`: a request for the app's own Worker, its path after this.
|
|
362
|
+
*/
|
|
363
|
+
export declare const DEV_PATHS: {
|
|
364
|
+
readonly deploy: "/__teable/deploy";
|
|
365
|
+
readonly gate: "/__teable/gate";
|
|
366
|
+
readonly worker: "/__teable/worker";
|
|
367
|
+
};
|
|
368
|
+
/** On the app's Worker's requests for its pages' files (`env.ASSETS`), in development: never sent back to it. */
|
|
369
|
+
export declare const ASSETS_HEADER = "X-Teable-Assets";
|
|
370
|
+
/**
|
|
371
|
+
* Where the runtime answers on an app's own host before its Worker (ADR
|
|
372
|
+
* 0014): `sign-in?return=<path>` (to Teable and back), `callback`,
|
|
373
|
+
* `session` (`SessionResponse`) and `sign-out` (POST). With `${APPS_PATH}/`,
|
|
374
|
+
* the app's own API there, the app's Worker never sees these paths.
|
|
375
|
+
*/
|
|
376
|
+
export declare const SESSION_PATH = "/.teable";
|
|
377
|
+
/**
|
|
378
|
+
* `GET ${SESSION_PATH}/session` on an app's host: who is signed in to its
|
|
379
|
+
* pages, as methods see them, and until when (epoch milliseconds); an
|
|
380
|
+
* anonymous caller and null when nobody is.
|
|
381
|
+
*/
|
|
382
|
+
export interface SessionResponse {
|
|
383
|
+
caller: Caller;
|
|
384
|
+
expiresAt: number | null;
|
|
311
385
|
}
|
|
312
386
|
/**
|
|
313
387
|
* Sent on `GET {APPS_PATH}/:appId/realtime`: `changes` after every call that
|
|
@@ -342,11 +416,40 @@ export declare const DEPLOY_HEADERS: {
|
|
|
342
416
|
readonly commit: "X-Teable-Commit";
|
|
343
417
|
readonly message: "X-Teable-Message";
|
|
344
418
|
};
|
|
345
|
-
/**
|
|
419
|
+
/**
|
|
420
|
+
* A deploy's answer (201): the version the bundle went live as, its
|
|
421
|
+
* manifest, and where its pages are (null without pages).
|
|
422
|
+
*/
|
|
346
423
|
export interface DeployResponse {
|
|
347
424
|
version: number;
|
|
348
425
|
manifest: AppManifest;
|
|
426
|
+
pagesUrl: string | null;
|
|
349
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* The files of an app's pages (ADR 0014), as `dist/pages` holds them: each
|
|
430
|
+
* path (`/index.html`) with its bytes' SHA-256, in hex, and its size.
|
|
431
|
+
* `_headers`, `_redirects` and `_routes.json` among them are settings.
|
|
432
|
+
*/
|
|
433
|
+
export type PageFiles = Record<string, {
|
|
434
|
+
sha256: string;
|
|
435
|
+
size: number;
|
|
436
|
+
}>;
|
|
437
|
+
/**
|
|
438
|
+
* Publishing pages (ADR 0014): `POST {APPS_PATH}/:appId/pages` with
|
|
439
|
+
* `{ files: PageFiles }` answers which of them the runtime lacks, by SHA-256;
|
|
440
|
+
* `POST {APPS_PATH}/:appId/pages/files`, multipart, each part one of them
|
|
441
|
+
* named by its SHA-256, keeps them; then a deploy sends these parts
|
|
442
|
+
* (multipart/form-data): the server bundle, the app's Worker if it has one,
|
|
443
|
+
* and the pages' files again, as JSON.
|
|
444
|
+
*/
|
|
445
|
+
export interface PagesCheckResponse {
|
|
446
|
+
missing: string[];
|
|
447
|
+
}
|
|
448
|
+
export declare const DEPLOY_PARTS: {
|
|
449
|
+
readonly server: "server";
|
|
450
|
+
readonly worker: "worker";
|
|
451
|
+
readonly pages: "pages";
|
|
452
|
+
};
|
|
350
453
|
/**
|
|
351
454
|
* `POST {APPS_PATH}/:appId/rollback` with `{ "to": <version> }` deploys that
|
|
352
455
|
* version's bundle again, as a new version. Its answer (201) is a deploy's,
|
package/dist/protocol.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
APPS_PATH,
|
|
3
3
|
APP_COMPATIBILITY_DATE,
|
|
4
|
+
ASSETS_HEADER,
|
|
4
5
|
CAPABILITIES,
|
|
5
6
|
DEFAULT_CURRENCY,
|
|
6
7
|
DEPLOY_HEADERS,
|
|
8
|
+
DEPLOY_PARTS,
|
|
9
|
+
DEV_PATHS,
|
|
7
10
|
ERROR_CODES,
|
|
8
11
|
ERROR_STATUS,
|
|
9
12
|
FILE_NAME_HEADER,
|
|
10
13
|
PROTOCOL_VERSION,
|
|
14
|
+
SESSION_PATH,
|
|
11
15
|
SPACE_ROLES,
|
|
12
16
|
admit,
|
|
13
17
|
callableMethods,
|
|
@@ -15,18 +19,23 @@ import {
|
|
|
15
19
|
currencyDigits,
|
|
16
20
|
fileKeyPath,
|
|
17
21
|
isExposed,
|
|
18
|
-
isMember
|
|
19
|
-
|
|
22
|
+
isMember,
|
|
23
|
+
isPageAccess
|
|
24
|
+
} from "./chunks/VMIIUPHE.js";
|
|
20
25
|
export {
|
|
21
26
|
APPS_PATH,
|
|
22
27
|
APP_COMPATIBILITY_DATE,
|
|
28
|
+
ASSETS_HEADER,
|
|
23
29
|
CAPABILITIES,
|
|
24
30
|
DEFAULT_CURRENCY,
|
|
25
31
|
DEPLOY_HEADERS,
|
|
32
|
+
DEPLOY_PARTS,
|
|
33
|
+
DEV_PATHS,
|
|
26
34
|
ERROR_CODES,
|
|
27
35
|
ERROR_STATUS,
|
|
28
36
|
FILE_NAME_HEADER,
|
|
29
37
|
PROTOCOL_VERSION,
|
|
38
|
+
SESSION_PATH,
|
|
30
39
|
SPACE_ROLES,
|
|
31
40
|
admit,
|
|
32
41
|
callableMethods,
|
|
@@ -34,5 +43,6 @@ export {
|
|
|
34
43
|
currencyDigits,
|
|
35
44
|
fileKeyPath,
|
|
36
45
|
isExposed,
|
|
37
|
-
isMember
|
|
46
|
+
isMember,
|
|
47
|
+
isPageAccess
|
|
38
48
|
};
|
package/dist/schema.js
CHANGED
package/dist/server/app.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DurableObject } from "cloudflare:workers";
|
|
2
2
|
import { type DrizzleSqliteDODatabase } from "drizzle-orm/durable-sqlite";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { type Access, type AppFacet, type AppManifest, type Caller, type Capabilities, type Capability } from "../protocol.js";
|
|
4
|
+
import { type Access, type AppFacet, type AppManifest, type Caller, type Capabilities, type Capability, type PageAccess } from "../protocol.js";
|
|
5
5
|
import { type Migrations } from "./migrations.js";
|
|
6
6
|
type Schema = Record<string, unknown>;
|
|
7
7
|
/** The Drizzle database handed to read and write handlers. */
|
|
@@ -100,6 +100,13 @@ export declare function createApp<S extends Schema>(options: {
|
|
|
100
100
|
migrations: Migrations;
|
|
101
101
|
/** Platform capabilities tasks may use; the host wires only these. */
|
|
102
102
|
capabilities?: readonly Capability[];
|
|
103
|
+
/**
|
|
104
|
+
* The app's pages, at its own host: who may open them. Members of the
|
|
105
|
+
* app's space with at least `viewer` unless said; `public` for anyone.
|
|
106
|
+
*/
|
|
107
|
+
pages?: {
|
|
108
|
+
access?: PageAccess;
|
|
109
|
+
};
|
|
103
110
|
}): {
|
|
104
111
|
/** Read data. Synchronous and read-only: a read that writes is rolled back and fails. */
|
|
105
112
|
read<R, In extends InputSchema = typeof emptyInput, A extends Access = "viewer", Out extends OutputSchema | undefined = undefined>(def: Common<In> & MethodOptions<ReadContext<S, z.output<In>>, R, A, Out> & MustBeSync<R>): ReadMethod<In, Given<Out, R>, A>;
|
package/dist/testing.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
methodName
|
|
3
|
-
} from "./chunks/
|
|
4
|
-
import "./chunks/
|
|
3
|
+
} from "./chunks/33OZ5YAY.js";
|
|
4
|
+
import "./chunks/N7LBNIRZ.js";
|
|
5
5
|
import {
|
|
6
6
|
MethodError
|
|
7
|
-
} from "./chunks/
|
|
7
|
+
} from "./chunks/L6RROFUY.js";
|
|
8
8
|
import {
|
|
9
9
|
ERROR_STATUS
|
|
10
|
-
} from "./chunks/
|
|
10
|
+
} from "./chunks/VMIIUPHE.js";
|
|
11
11
|
|
|
12
12
|
// src/testing.ts
|
|
13
13
|
var OWNER = { kind: "user", userId: "test-owner", role: "owner", via: "api" };
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @teable/app/worker — the app's own Worker (ADR 0014): HTTP of its own beside
|
|
3
|
+
* its pages, at the app's host. Write it in `src/worker/index.ts`, and
|
|
4
|
+
* `teable-app build` bundles it; without one, the platform serves the pages.
|
|
5
|
+
*
|
|
6
|
+
* import { appOf, type WorkerEnv } from "@teable/app/worker";
|
|
7
|
+
* import type * as server from "../server";
|
|
8
|
+
*
|
|
9
|
+
* export default {
|
|
10
|
+
* async fetch(request, env, ctx) {
|
|
11
|
+
* const app = appOf<typeof server>(ctx);
|
|
12
|
+
* if (new URL(request.url).pathname === "/hooks/paid" && request.method === "POST") {
|
|
13
|
+
* // Check the sender's signature first: the app acts as itself here.
|
|
14
|
+
* await app.asApp.call("markPaid", await request.json());
|
|
15
|
+
* return new Response(null, { status: 204 });
|
|
16
|
+
* }
|
|
17
|
+
* return env.ASSETS.fetch(request);
|
|
18
|
+
* },
|
|
19
|
+
* } satisfies ExportedHandler<WorkerEnv>;
|
|
20
|
+
*
|
|
21
|
+
* The pages' files are served before the Worker runs. It gets what no file
|
|
22
|
+
* answers and is not a page's navigation (webhooks, fetches, feeds), and the
|
|
23
|
+
* paths `_routes.json` in the pages includes, before any file; `env.ASSETS`
|
|
24
|
+
* serves the pages. It keeps no data of its own: the app's data is reached
|
|
25
|
+
* through its methods, as the visitor (`asCaller`, under the method's access)
|
|
26
|
+
* or as the app (`asApp`, internal methods too). Never change data on GET.
|
|
27
|
+
*/
|
|
28
|
+
import { type AppMethodName, type MethodInput, type MethodName, type MethodOutput, type ServerModule, type Untyped } from "./client.js";
|
|
29
|
+
import { type Caller, type FilesCapability } from "./protocol.js";
|
|
30
|
+
/** The Worker's env: its pages' files, and nothing else. */
|
|
31
|
+
export interface WorkerEnv {
|
|
32
|
+
ASSETS: {
|
|
33
|
+
fetch(request: Request | string): Promise<Response>;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** The app as its Worker reaches it during one request. */
|
|
37
|
+
export interface AppWorker<S> {
|
|
38
|
+
readonly appId: string;
|
|
39
|
+
/** Who sent the request, as methods see callers: anonymous unless signed in to the pages. */
|
|
40
|
+
readonly caller: Caller;
|
|
41
|
+
/** The app's reads and writes, called as the visitor, under each method's access. */
|
|
42
|
+
readonly asCaller: {
|
|
43
|
+
call<K extends MethodName<S>>(method: K, input?: MethodInput<S, K>): Promise<MethodOutput<S, K>>;
|
|
44
|
+
};
|
|
45
|
+
/** The app's reads and writes, internal ones too, called as the app itself. */
|
|
46
|
+
readonly asApp: {
|
|
47
|
+
call<K extends AppMethodName<S>>(method: K, input?: MethodInput<S, K>): Promise<MethodOutput<S, K>>;
|
|
48
|
+
};
|
|
49
|
+
/** The app's files, when it declares `capabilities: ["files"]`. */
|
|
50
|
+
readonly files: FilesCapability;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The app as this request's Worker reaches it, typed from the app's server
|
|
54
|
+
* code (`import type * as server from "../server"`), as the client is. What
|
|
55
|
+
* it holds works only during this request.
|
|
56
|
+
*/
|
|
57
|
+
export declare function appOf<S extends ServerModule | Untyped = Untyped>(ctx: {
|
|
58
|
+
props: unknown;
|
|
59
|
+
}): AppWorker<S>;
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MethodError
|
|
3
|
+
} from "./chunks/L6RROFUY.js";
|
|
4
|
+
import {
|
|
5
|
+
ERROR_STATUS
|
|
6
|
+
} from "./chunks/VMIIUPHE.js";
|
|
7
|
+
|
|
8
|
+
// src/worker.ts
|
|
9
|
+
function thrower(caller) {
|
|
10
|
+
return {
|
|
11
|
+
async call(method, input) {
|
|
12
|
+
const result = await caller.call(method, input);
|
|
13
|
+
if (!result.ok) throw new MethodError(result.error, ERROR_STATUS[result.error.code]);
|
|
14
|
+
return result.value;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var undeclared = new Proxy({}, {
|
|
19
|
+
get: () => () => Promise.reject(new Error('Declare capabilities: ["files"] in createApp to use files'))
|
|
20
|
+
});
|
|
21
|
+
function appOf(ctx) {
|
|
22
|
+
const props = ctx.props;
|
|
23
|
+
return {
|
|
24
|
+
appId: props.appId,
|
|
25
|
+
caller: props.caller,
|
|
26
|
+
asCaller: thrower(props.asCaller),
|
|
27
|
+
asApp: thrower(props.asApp),
|
|
28
|
+
files: props.files ?? undeclared
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
appOf
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teable/app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Write a Teable app as a Drizzle schema plus methods",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,6 +26,14 @@
|
|
|
26
26
|
"types": "./dist/client.d.ts",
|
|
27
27
|
"default": "./dist/client.js"
|
|
28
28
|
},
|
|
29
|
+
"./worker": {
|
|
30
|
+
"types": "./dist/worker.d.ts",
|
|
31
|
+
"default": "./dist/worker.js"
|
|
32
|
+
},
|
|
33
|
+
"./dev-host": {
|
|
34
|
+
"types": "./dist/dev/host.d.ts",
|
|
35
|
+
"default": "./dist/dev/host.js"
|
|
36
|
+
},
|
|
29
37
|
"./testing": {
|
|
30
38
|
"types": "./dist/testing.d.ts",
|
|
31
39
|
"default": "./dist/testing.js"
|
|
@@ -52,6 +60,7 @@
|
|
|
52
60
|
"dependencies": {
|
|
53
61
|
"drizzle-orm": "0.45.4",
|
|
54
62
|
"esbuild": "0.28.2",
|
|
63
|
+
"miniflare": "5.20261129.0-beta",
|
|
55
64
|
"zod": "4.6.7"
|
|
56
65
|
}
|
|
57
66
|
}
|
package/dist/chunks/5QIBCQL5.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// src/build/index.ts
|
|
2
|
-
import { build } from "esbuild";
|
|
3
|
-
var SERVER_ENTRY = "src/server/index.ts";
|
|
4
|
-
async function buildServer(options) {
|
|
5
|
-
const entry = options.entry ?? SERVER_ENTRY;
|
|
6
|
-
const result = await build({
|
|
7
|
-
absWorkingDir: options.root,
|
|
8
|
-
stdin: {
|
|
9
|
-
contents: `export { App } from ${JSON.stringify(`./${entry}`)};`,
|
|
10
|
-
resolveDir: options.root,
|
|
11
|
-
sourcefile: "teable-app-entry.js",
|
|
12
|
-
loader: "js"
|
|
13
|
-
},
|
|
14
|
-
define: options.define ?? {},
|
|
15
|
-
bundle: true,
|
|
16
|
-
format: "esm",
|
|
17
|
-
platform: "neutral",
|
|
18
|
-
target: "es2024",
|
|
19
|
-
conditions: ["workerd", "worker", "browser"],
|
|
20
|
-
mainFields: ["module", "main"],
|
|
21
|
-
external: ["cloudflare:*"],
|
|
22
|
-
loader: { ".sql": "text" },
|
|
23
|
-
minify: options.minify ?? true,
|
|
24
|
-
legalComments: "none",
|
|
25
|
-
write: false,
|
|
26
|
-
logLevel: "silent"
|
|
27
|
-
}).catch((error) => {
|
|
28
|
-
const reasons = error.errors?.map((e) => e.text) ?? [String(error)];
|
|
29
|
-
if (reasons.some((r) => r.includes("No matching export") && r.includes('"App"'))) {
|
|
30
|
-
throw new Error(`${entry} must export the class from define() as "App"`);
|
|
31
|
-
}
|
|
32
|
-
throw new Error(`Could not build ${entry}: ${reasons.join("; ")}`);
|
|
33
|
-
});
|
|
34
|
-
const [output] = result.outputFiles;
|
|
35
|
-
if (output === void 0) throw new Error("esbuild produced no output");
|
|
36
|
-
return { code: output.text, bytes: output.contents.byteLength };
|
|
37
|
-
}
|
|
38
|
-
function sqlAsText() {
|
|
39
|
-
return {
|
|
40
|
-
name: "teable:sql-as-text",
|
|
41
|
-
enforce: "pre",
|
|
42
|
-
transform(code, id) {
|
|
43
|
-
if (!id.endsWith(".sql")) return void 0;
|
|
44
|
-
return { code: `export default ${JSON.stringify(code)};`, map: null };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
buildServer,
|
|
51
|
-
sqlAsText
|
|
52
|
-
};
|