palbase 0.0.0-stage → 0.1.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/LICENSE +27 -0
- package/README.md +2 -2
- package/dist/ai/index.js +17 -0
- package/dist/backend/engine.js +2 -0
- package/dist/backend/env.js +1 -0
- package/dist/backend/index.js +12 -0
- package/dist/backend/stack.js +1 -0
- package/dist/backend/test.js +2 -0
- package/dist/chunks/3OGEBGYZ.js +20 -0
- package/dist/chunks/3VASGTIN.js +2 -0
- package/dist/chunks/3XT4L2XV.js +2 -0
- package/dist/chunks/45J7YXRB.js +2 -0
- package/dist/chunks/6FWCNTAM.js +2 -0
- package/dist/chunks/DAOLIUNZ.js +2 -0
- package/dist/chunks/E5Q4VTW4.js +2 -0
- package/dist/chunks/HKJU2FKE.js +2 -0
- package/dist/chunks/IKVOXHEE.js +2 -0
- package/dist/chunks/JAWWIVZH.js +2 -0
- package/dist/chunks/LYEFPLJZ.js +4 -0
- package/dist/chunks/QXUMLO7O.js +13 -0
- package/dist/chunks/UAY56IQR.js +6 -0
- package/dist/cli.js +815 -0
- package/dist/refuse/ai.js +2 -0
- package/dist/refuse/backend.js +2 -0
- package/dist/refuse/server.js +2 -0
- package/dist/server/index.js +2 -0
- package/dist/server/testing.js +2 -0
- package/dist/web/index.js +2 -0
- package/dist/web/palbe.js +2 -0
- package/dist/web/vite.js +3 -0
- package/package.json +107 -4
- package/types/ai/src/ai.d.ts +178 -0
- package/types/ai/src/index.d.ts +5 -0
- package/types/ai/src/partial.d.ts +1 -0
- package/types/ai/src/schema.d.ts +47 -0
- package/types/backend/src/bootstrap.d.ts +72 -0
- package/types/backend/src/cache.d.ts +32 -0
- package/types/backend/src/container.d.ts +49 -0
- package/types/backend/src/database.d.ts +148 -0
- package/types/backend/src/db-env.d.ts +4 -0
- package/types/backend/src/decorators.d.ts +293 -0
- package/types/backend/src/engine-db.d.ts +24 -0
- package/types/backend/src/engine-exports.d.ts +3 -0
- package/types/backend/src/engine.d.ts +124 -0
- package/types/backend/src/env.d.ts +27 -0
- package/types/backend/src/errors.d.ts +70 -0
- package/types/backend/src/i18n.d.ts +21 -0
- package/types/backend/src/index.d.ts +23 -0
- package/types/backend/src/openapi.d.ts +73 -0
- package/types/backend/src/platform-calls.d.ts +41 -0
- package/types/backend/src/requests.d.ts +81 -0
- package/types/backend/src/rooms.d.ts +168 -0
- package/types/backend/src/router.d.ts +22 -0
- package/types/backend/src/runtime.d.ts +56 -0
- package/types/backend/src/services.d.ts +262 -0
- package/types/backend/src/stack.d.ts +20 -0
- package/types/backend/src/strings-files.d.ts +3 -0
- package/types/backend/src/testing/index.d.ts +3 -0
- package/types/backend/src/testing/unit.d.ts +66 -0
- package/types/backend/src/upload.d.ts +125 -0
- package/types/backend/src/webhooks.d.ts +113 -0
- package/types/internal/src/event.d.ts +9 -0
- package/types/internal/src/modules/ai.d.ts +678 -0
- package/types/internal/src/modules/analytics.d.ts +1414 -0
- package/types/internal/src/modules/auth.d.ts +5660 -0
- package/types/internal/src/modules/cache.d.ts +158 -0
- package/types/internal/src/modules/events.d.ts +19 -0
- package/types/internal/src/modules/flags.d.ts +957 -0
- package/types/internal/src/modules/index.d.ts +13 -0
- package/types/internal/src/modules/machines.d.ts +1584 -0
- package/types/internal/src/modules/notify.d.ts +1450 -0
- package/types/internal/src/modules/purchases.d.ts +2944 -0
- package/types/internal/src/modules/realtime.d.ts +326 -0
- package/types/internal/src/modules/secrets.d.ts +275 -0
- package/types/internal/src/modules/storage.d.ts +691 -0
- package/types/internal/src/modules/stores.d.ts +1516 -0
- package/types/internal/src/retry.d.ts +14 -0
- package/types/internal/src/transport.d.ts +106 -0
- package/types/server/src/auth/dpop.d.ts +47 -0
- package/types/server/src/auth/jwt.d.ts +115 -0
- package/types/server/src/index.d.ts +9 -0
- package/types/server/src/pages.d.ts +4 -0
- package/types/server/src/purchases.d.ts +51 -0
- package/types/server/src/secrets-env.d.ts +22 -0
- package/types/server/src/server.d.ts +40 -0
- package/types/server/src/testing.d.ts +91 -0
- package/types/server/src/webhooks.d.ts +72 -0
- package/types/web/src/analytics.d.ts +87 -0
- package/types/web/src/auth.d.ts +155 -0
- package/types/web/src/backend-error.d.ts +38 -0
- package/types/web/src/backend-names.d.ts +25 -0
- package/types/web/src/backends.d.ts +84 -0
- package/types/web/src/client.d.ts +51 -0
- package/types/web/src/index.d.ts +11 -0
- package/types/web/src/palbe.d.ts +2 -0
- package/types/web/src/purchases.d.ts +73 -0
- package/types/web/src/rooms.d.ts +61 -0
- package/types/web/src/session.d.ts +91 -0
- package/types/web/src/socket.d.ts +87 -0
- package/types/web/src/vite.d.ts +49 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export type Frame = [joinRef: string | null, ref: string | null, topic: string, event: string, payload: Record<string, unknown>];
|
|
2
|
+
export interface SocketOptions {
|
|
3
|
+
/** https://<ref>.<domain> */
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
publishableKey: string;
|
|
6
|
+
accessToken: () => Promise<string | undefined>;
|
|
7
|
+
/** The WebSocket constructor (globalThis.WebSocket by default). */
|
|
8
|
+
webSocket?: typeof WebSocket;
|
|
9
|
+
/** Pauses before each reconnection attempt, in ms; the last repeats. Jittered ±20%. */
|
|
10
|
+
backoff?: number[];
|
|
11
|
+
heartbeatMs?: number;
|
|
12
|
+
replyTimeoutMs?: number;
|
|
13
|
+
}
|
|
14
|
+
export type ChannelState = 'closed' | 'joining' | 'joined' | 'refused';
|
|
15
|
+
/**
|
|
16
|
+
* What became of a push: the server's answer — `ok` with its response, or
|
|
17
|
+
* `error` with `{ reason }` — or, when none came, `timeout` (`no reply`: the
|
|
18
|
+
* server may have taken it) or `error` with `socket closed` or `not joined`.
|
|
19
|
+
*/
|
|
20
|
+
export interface PushReply {
|
|
21
|
+
status: string;
|
|
22
|
+
response: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
type Listener = (payload: Record<string, unknown>) => void;
|
|
25
|
+
export declare class Channel {
|
|
26
|
+
state: ChannelState;
|
|
27
|
+
/** Why the server refused the last join, when it did. */
|
|
28
|
+
refusal?: Record<string, unknown>;
|
|
29
|
+
joinRef: string | null;
|
|
30
|
+
private listeners;
|
|
31
|
+
private closers;
|
|
32
|
+
private joinWaiters;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
private socket;
|
|
35
|
+
constructor(name: string, socket: RealtimeSocket);
|
|
36
|
+
get topic(): string;
|
|
37
|
+
/** Resolves once joined; rejects with the server's reason when refused. */
|
|
38
|
+
join(): Promise<void>;
|
|
39
|
+
leave(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Sends one event on the joined channel and resolves with what became of it
|
|
42
|
+
* (PushReply) — never rejects for an answer, whatever it says. A channel
|
|
43
|
+
* that is not joined sends nothing. The server answers what it takes or
|
|
44
|
+
* refuses of a room's message and what it refuses of any other; a broadcast
|
|
45
|
+
* it took on a channel that is no room is answered by no one.
|
|
46
|
+
*/
|
|
47
|
+
push(event: string, payload: Record<string, unknown>): Promise<PushReply>;
|
|
48
|
+
/** Listens to an event on this channel (a broadcast is the event "broadcast"); returns the unsubscribe. */
|
|
49
|
+
on(event: string, listener: Listener): () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Listens for the end of what was joined here as the socket's user: the
|
|
52
|
+
* socket closed for good (the user signed out, or someone signed in) — not a
|
|
53
|
+
* drop, after which the channel is joined again. Returns the unsubscribe.
|
|
54
|
+
*/
|
|
55
|
+
onClosed(listener: () => void): () => void;
|
|
56
|
+
}
|
|
57
|
+
export declare class RealtimeSocket {
|
|
58
|
+
private ws;
|
|
59
|
+
private opening;
|
|
60
|
+
private ref;
|
|
61
|
+
private channels;
|
|
62
|
+
private replies;
|
|
63
|
+
private heartbeat;
|
|
64
|
+
private heartbeatRef;
|
|
65
|
+
private reconnectTimer;
|
|
66
|
+
private attempts;
|
|
67
|
+
private closedByUs;
|
|
68
|
+
/** Counted for the app's own diagnostics: how many times the socket was opened again after a drop. */
|
|
69
|
+
reconnects: number;
|
|
70
|
+
private opts;
|
|
71
|
+
constructor(opts: SocketOptions);
|
|
72
|
+
channel(name: string): Channel;
|
|
73
|
+
/** Closes the socket; every channel is closed (the app joins again — as the next user, if one signs in). */
|
|
74
|
+
disconnect(): void;
|
|
75
|
+
/** A new token for every joined channel (the session was refreshed). */
|
|
76
|
+
tokenChanged(): Promise<void>;
|
|
77
|
+
private open;
|
|
78
|
+
private dropped;
|
|
79
|
+
private sendJoin;
|
|
80
|
+
private awaitReply;
|
|
81
|
+
private receive;
|
|
82
|
+
private push;
|
|
83
|
+
private nextRef;
|
|
84
|
+
private startHeartbeat;
|
|
85
|
+
private stopHeartbeat;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface PalbaseViteOptions {
|
|
2
|
+
/** The app's slug (palbase apps:list): its file in palbase/. */
|
|
3
|
+
app: string;
|
|
4
|
+
/** Each mode the app is built in (vite --mode), and the environment it is built against. */
|
|
5
|
+
environments: Record<string, string>;
|
|
6
|
+
/** Where palbase apps:sync writes; palbase by default. */
|
|
7
|
+
dir?: string;
|
|
8
|
+
/** The app's tsconfig, from its root: tsconfig.app.json where there is one, else tsconfig.json. */
|
|
9
|
+
tsconfig?: string;
|
|
10
|
+
/** Type-check the app against its environment before a build (true). */
|
|
11
|
+
typecheck?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface Warning {
|
|
14
|
+
code?: string;
|
|
15
|
+
exporter?: string;
|
|
16
|
+
id?: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
type Warn = (w: Warning) => void;
|
|
20
|
+
/** What a hook may ask of the bundler: to resolve an import as from another file. */
|
|
21
|
+
interface ResolveContext {
|
|
22
|
+
resolve(source: string, importer: string, options: {
|
|
23
|
+
skipSelf: boolean;
|
|
24
|
+
}): Promise<unknown>;
|
|
25
|
+
}
|
|
26
|
+
/** What the plugin is to Vite: its hooks, typed here so the package needs no Vite of its own. */
|
|
27
|
+
export interface PalbaseVitePlugin {
|
|
28
|
+
name: string;
|
|
29
|
+
enforce: 'pre';
|
|
30
|
+
config(user: {
|
|
31
|
+
build?: {
|
|
32
|
+
rollupOptions?: {
|
|
33
|
+
onwarn?: (w: Warning, warn: Warn) => void;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}, env: {
|
|
37
|
+
mode: string;
|
|
38
|
+
command?: string;
|
|
39
|
+
}): unknown;
|
|
40
|
+
configResolved(config: {
|
|
41
|
+
root: string;
|
|
42
|
+
mode: string;
|
|
43
|
+
command?: string;
|
|
44
|
+
}): void;
|
|
45
|
+
buildStart(): Promise<void>;
|
|
46
|
+
resolveId(this: ResolveContext, source: string, importer?: string): string | null | Promise<unknown>;
|
|
47
|
+
}
|
|
48
|
+
export declare function palbase(options: PalbaseViteOptions): PalbaseVitePlugin;
|
|
49
|
+
export {};
|