@weft-framework/server 0.0.0-stage → 0.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.
Files changed (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -2
  3. package/dist/account.d.ts +124 -0
  4. package/dist/account.js +344 -0
  5. package/dist/action.d.ts +43 -0
  6. package/dist/action.js +135 -0
  7. package/dist/admin.d.ts +99 -0
  8. package/dist/admin.js +431 -0
  9. package/dist/api.d.ts +21 -0
  10. package/dist/api.js +72 -0
  11. package/dist/app.d.ts +202 -0
  12. package/dist/app.js +3692 -0
  13. package/dist/assets.d.ts +4 -0
  14. package/dist/assets.js +91 -0
  15. package/dist/auth.d.ts +150 -0
  16. package/dist/auth.js +215 -0
  17. package/dist/backup.d.ts +46 -0
  18. package/dist/backup.js +345 -0
  19. package/dist/build.d.ts +33 -0
  20. package/dist/build.js +274 -0
  21. package/dist/bun.d.ts +30 -0
  22. package/dist/bun.js +53 -0
  23. package/dist/calendar.d.ts +161 -0
  24. package/dist/calendar.js +690 -0
  25. package/dist/compiler.d.ts +13 -0
  26. package/dist/compiler.js +58 -0
  27. package/dist/compress.d.ts +6 -0
  28. package/dist/compress.js +78 -0
  29. package/dist/config.d.ts +26 -0
  30. package/dist/config.js +317 -0
  31. package/dist/context.d.ts +9 -0
  32. package/dist/context.js +1 -0
  33. package/dist/contract.d.ts +18 -0
  34. package/dist/contract.js +171 -0
  35. package/dist/datamap.d.ts +24 -0
  36. package/dist/datamap.js +365 -0
  37. package/dist/db-backup.d.ts +27 -0
  38. package/dist/db-backup.js +115 -0
  39. package/dist/dev-events.d.ts +14 -0
  40. package/dist/dev-events.js +135 -0
  41. package/dist/dev.d.ts +1 -0
  42. package/dist/dev.js +240 -0
  43. package/dist/devtools-client.d.ts +1 -0
  44. package/dist/devtools-client.js +362 -0
  45. package/dist/devtools.d.ts +87 -0
  46. package/dist/devtools.js +68 -0
  47. package/dist/edge.d.ts +3 -0
  48. package/dist/edge.js +7 -0
  49. package/dist/email-signin.d.ts +92 -0
  50. package/dist/email-signin.js +259 -0
  51. package/dist/env.d.ts +1 -0
  52. package/dist/env.js +15 -0
  53. package/dist/explain.d.ts +12 -0
  54. package/dist/explain.js +217 -0
  55. package/dist/files.d.ts +6 -0
  56. package/dist/files.js +170 -0
  57. package/dist/grants.d.ts +69 -0
  58. package/dist/grants.js +206 -0
  59. package/dist/image/bitmap.d.ts +11 -0
  60. package/dist/image/bitmap.js +172 -0
  61. package/dist/image/jpeg.d.ts +10 -0
  62. package/dist/image/jpeg.js +697 -0
  63. package/dist/image/png.d.ts +8 -0
  64. package/dist/image/png.js +282 -0
  65. package/dist/image/transform.d.ts +20 -0
  66. package/dist/image/transform.js +52 -0
  67. package/dist/image/worker.d.ts +1 -0
  68. package/dist/image/worker.js +11 -0
  69. package/dist/images.d.ts +39 -0
  70. package/dist/images.js +283 -0
  71. package/dist/index.d.ts +64 -0
  72. package/dist/index.js +31 -0
  73. package/dist/inspect-hub.d.ts +42 -0
  74. package/dist/inspect-hub.js +14 -0
  75. package/dist/inspector.d.ts +51 -0
  76. package/dist/inspector.js +193 -0
  77. package/dist/job-admin.d.ts +55 -0
  78. package/dist/job-admin.js +89 -0
  79. package/dist/jobs.d.ts +222 -0
  80. package/dist/jobs.js +789 -0
  81. package/dist/live.d.ts +72 -0
  82. package/dist/live.js +481 -0
  83. package/dist/load-config.d.ts +2 -0
  84. package/dist/load-config.js +41 -0
  85. package/dist/log.d.ts +20 -0
  86. package/dist/log.js +143 -0
  87. package/dist/mail.d.ts +189 -0
  88. package/dist/mail.js +999 -0
  89. package/dist/media.d.ts +129 -0
  90. package/dist/media.js +470 -0
  91. package/dist/meta.d.ts +54 -0
  92. package/dist/meta.js +146 -0
  93. package/dist/middleware.d.ts +20 -0
  94. package/dist/middleware.js +101 -0
  95. package/dist/migrate.d.ts +12 -0
  96. package/dist/migrate.js +88 -0
  97. package/dist/node.d.ts +26 -0
  98. package/dist/node.js +96 -0
  99. package/dist/notice.d.ts +21 -0
  100. package/dist/notice.js +48 -0
  101. package/dist/npm.d.ts +16 -0
  102. package/dist/npm.js +347 -0
  103. package/dist/oauth.d.ts +76 -0
  104. package/dist/oauth.js +408 -0
  105. package/dist/otel.d.ts +57 -0
  106. package/dist/otel.js +293 -0
  107. package/dist/passkey.d.ts +99 -0
  108. package/dist/passkey.js +572 -0
  109. package/dist/password.d.ts +8 -0
  110. package/dist/password.js +65 -0
  111. package/dist/pdf.d.ts +46 -0
  112. package/dist/pdf.js +332 -0
  113. package/dist/personal-data.d.ts +22 -0
  114. package/dist/personal-data.js +148 -0
  115. package/dist/pointers.d.ts +9 -0
  116. package/dist/pointers.js +148 -0
  117. package/dist/postcss.d.ts +3 -0
  118. package/dist/postcss.js +89 -0
  119. package/dist/presence.d.ts +27 -0
  120. package/dist/presence.js +161 -0
  121. package/dist/preview.d.ts +25 -0
  122. package/dist/preview.js +353 -0
  123. package/dist/production.d.ts +16 -0
  124. package/dist/production.js +119 -0
  125. package/dist/project.d.ts +23 -0
  126. package/dist/project.js +536 -0
  127. package/dist/regions.d.ts +47 -0
  128. package/dist/regions.js +511 -0
  129. package/dist/replay.d.ts +44 -0
  130. package/dist/replay.js +259 -0
  131. package/dist/router.d.ts +29 -0
  132. package/dist/router.js +146 -0
  133. package/dist/rules-diff.d.ts +18 -0
  134. package/dist/rules-diff.js +165 -0
  135. package/dist/rules-test.d.ts +17 -0
  136. package/dist/rules-test.js +108 -0
  137. package/dist/saml.d.ts +160 -0
  138. package/dist/saml.js +959 -0
  139. package/dist/seal.d.ts +35 -0
  140. package/dist/seal.js +107 -0
  141. package/dist/secret.d.ts +14 -0
  142. package/dist/secret.js +110 -0
  143. package/dist/security.d.ts +53 -0
  144. package/dist/security.js +250 -0
  145. package/dist/seed.d.ts +16 -0
  146. package/dist/seed.js +94 -0
  147. package/dist/seo.d.ts +42 -0
  148. package/dist/seo.js +175 -0
  149. package/dist/settings.d.ts +79 -0
  150. package/dist/settings.js +212 -0
  151. package/dist/shared.d.ts +15 -0
  152. package/dist/shared.js +283 -0
  153. package/dist/shell.d.ts +12 -0
  154. package/dist/shell.js +118 -0
  155. package/dist/storage.d.ts +13 -0
  156. package/dist/storage.js +55 -0
  157. package/dist/support.d.ts +83 -0
  158. package/dist/support.js +236 -0
  159. package/dist/sync.d.ts +35 -0
  160. package/dist/sync.js +167 -0
  161. package/dist/tailwind.d.ts +14 -0
  162. package/dist/tailwind.js +117 -0
  163. package/dist/two-factor.d.ts +103 -0
  164. package/dist/two-factor.js +435 -0
  165. package/dist/uploads.d.ts +185 -0
  166. package/dist/uploads.js +991 -0
  167. package/dist/webhooks.d.ts +169 -0
  168. package/dist/webhooks.js +758 -0
  169. package/dist/webpush.d.ts +97 -0
  170. package/dist/webpush.js +372 -0
  171. package/dist/wizard.d.ts +141 -0
  172. package/dist/wizard.js +410 -0
  173. package/dist/workflows.d.ts +134 -0
  174. package/dist/workflows.js +511 -0
  175. package/package.json +186 -4
package/dist/app.d.ts ADDED
@@ -0,0 +1,202 @@
1
+ import { type Component } from "@weft-framework/runtime";
2
+ import { type ChangeFeed } from "@weft-framework/data";
3
+ import { type ApiHandlers } from "./api.js";
4
+ import type { PageContext } from "./context.js";
5
+ import { type AuthOptions } from "./auth.js";
6
+ import { type CompressOptions } from "./compress.js";
7
+ import { type Action } from "./action.js";
8
+ import { Redirect } from "./live.js";
9
+ import { type PageMeta } from "./meta.js";
10
+ import { type Middleware } from "./middleware.js";
11
+ import { type RobotsOptions, type SitemapOptions } from "./seo.js";
12
+ import { type Logger } from "./log.js";
13
+ import type { Telemetry } from "./otel.js";
14
+ import type { Uploads } from "./uploads.js";
15
+ import { type Regions } from "./regions.js";
16
+ import { type SharedFieldOptions } from "./shared.js";
17
+ import { type CspSources, type RateLimitOptions } from "./security.js";
18
+ import { type PdfPrinter, type PdfRouteOptions } from "./pdf.js";
19
+ import { type Images } from "./images.js";
20
+ export type { PageContext };
21
+ export declare class NotFound {
22
+ readonly notFound = true;
23
+ }
24
+ export declare function notFound(): NotFound;
25
+ export type MetaSource<D> = PageMeta | ((ctx: PageContext, data: D) => PageMeta | Promise<PageMeta>);
26
+ export interface Layout {
27
+ component: Component<never>;
28
+ meta?: MetaSource<undefined>;
29
+ }
30
+ export interface Route<P extends object = object> {
31
+ component: Component<P>;
32
+ load?(ctx: PageContext): P | Redirect | NotFound | Promise<P | Redirect | NotFound>;
33
+ meta?: MetaSource<P>;
34
+ title?: string;
35
+ layouts?: readonly Layout[];
36
+ status?: number;
37
+ cache?: "etag";
38
+ csp?: CspSources;
39
+ pdf?: true | PdfRouteOptions;
40
+ edge?: boolean;
41
+ og?: Component<never> | OgImage;
42
+ }
43
+ export interface OgImage {
44
+ component: Component<never>;
45
+ width?: number;
46
+ height?: number;
47
+ }
48
+ export declare function checkOg(raw: unknown, where: string): Component<never> | OgImage;
49
+ export declare function edgeReason(route: Route<never>, app: {
50
+ middleware?: unknown;
51
+ htmlAttributes?: unknown;
52
+ }): string | null;
53
+ export interface CspViolation {
54
+ route: string | null;
55
+ directive: string;
56
+ blocked: string;
57
+ source: string | null;
58
+ }
59
+ export interface AppOptions {
60
+ secret: string;
61
+ routes: Record<string, Route<never>>;
62
+ notFound?: Route<never>;
63
+ error?: Route<never>;
64
+ api?: Record<string, ApiHandlers>;
65
+ middleware?: Middleware | readonly Middleware[];
66
+ devtools?: boolean;
67
+ patchBudget?: number | false;
68
+ onPatchBudget?: (over: PatchOver) => void;
69
+ queryWarnings?: {
70
+ repeat?: number;
71
+ rows?: number;
72
+ } | false;
73
+ onQueryWarning?: (w: QueryWarning) => void;
74
+ shell?: string;
75
+ meta?: PageMeta;
76
+ siteUrl?: string;
77
+ sitemap?: SitemapOptions;
78
+ robots?: RobotsOptions;
79
+ files?(path: string, req: Request): Promise<Response | null> | Response | null;
80
+ clientScript?: string;
81
+ assets?: Record<string, string>;
82
+ stylesheet?: string;
83
+ htmlAttributes?: (req: Request) => Record<string, string | boolean | null | undefined>;
84
+ componentStyles?: Record<string, string>;
85
+ clientEntry?: string;
86
+ immutableAssets?: boolean;
87
+ transports?: readonly ("ws" | "sse")[];
88
+ streamTimeoutMs?: number;
89
+ instance?: string;
90
+ stickyCookie?: string;
91
+ auth?: AuthOptions;
92
+ uploads?: Uploads<string>;
93
+ regions?: Regions;
94
+ compress?: boolean | CompressOptions;
95
+ cookieName?: string;
96
+ rateLimit?: RateLimitOptions;
97
+ pageTtlMs?: number;
98
+ maxPages?: number;
99
+ maxPagesPerSession?: number;
100
+ degrade?: {
101
+ pages?: number;
102
+ heapBytes?: number;
103
+ onDegrade?(info: {
104
+ route: string;
105
+ reason: "pages" | "memory";
106
+ pages: number;
107
+ heapBytes: number | null;
108
+ }): void;
109
+ };
110
+ heartbeatMs?: number;
111
+ sync?: ChangeFeed | false;
112
+ sharedFields?: SharedFieldOptions;
113
+ offline?: {
114
+ stale?: "run" | "refuse";
115
+ };
116
+ syncDelayMs?: number;
117
+ presenceGraceMs?: number;
118
+ actions?: Record<string, Action<never[]>>;
119
+ maxActionBytes?: number;
120
+ prefetch?: false | {
121
+ links?: number;
122
+ minVisits?: number;
123
+ share?: number;
124
+ };
125
+ csp?: CspSources;
126
+ cspReport?: (violation: CspViolation) => void;
127
+ pdf?: PdfPrinter;
128
+ edge?: false | {
129
+ maxAge?: number;
130
+ stale?: number;
131
+ };
132
+ images?: Images;
133
+ maxApiBytes?: number;
134
+ ready?: Record<string, () => unknown>;
135
+ readyTimeoutMs?: number;
136
+ logger?: Logger;
137
+ trustRequestId?: boolean;
138
+ onError?(err: unknown): void;
139
+ reportError?(err: unknown, report: ErrorReport): void;
140
+ telemetry?: Telemetry;
141
+ now?(): number;
142
+ }
143
+ export interface QueryWarning {
144
+ kind: "repeat" | "rows";
145
+ route: string;
146
+ cause: string;
147
+ model: string;
148
+ reads: number;
149
+ rows: number;
150
+ }
151
+ export interface ErrorReport {
152
+ kind: "page" | "event" | "action" | "api" | "upload" | "request";
153
+ route?: string;
154
+ component?: string;
155
+ handler?: string;
156
+ actor: string | null;
157
+ requestId: string | null;
158
+ method?: string;
159
+ path?: string;
160
+ instance: string;
161
+ }
162
+ export interface DrainOptions {
163
+ delayMs?: number;
164
+ timeoutMs?: number;
165
+ handoff?: boolean;
166
+ }
167
+ export interface UpgradeServer {
168
+ upgrade(req: Request, opts: {
169
+ data: SocketData;
170
+ }): boolean;
171
+ }
172
+ export interface SocketData {
173
+ lid: string;
174
+ sid: string;
175
+ }
176
+ export interface LiveSocket {
177
+ data: SocketData;
178
+ send(data: string): unknown;
179
+ close(code?: number, reason?: string): void;
180
+ }
181
+ export interface App {
182
+ fetch(req: Request, server?: UpgradeServer): Promise<Response | undefined>;
183
+ websocket: {
184
+ open(ws: LiveSocket): void;
185
+ message(ws: LiveSocket, data: string | Uint8Array): Promise<void>;
186
+ close(ws: LiveSocket): void;
187
+ };
188
+ drain(opts?: DrainOptions): Promise<boolean>;
189
+ close(): void;
190
+ }
191
+ export interface PatchOver {
192
+ route: string;
193
+ cause: string;
194
+ bytes: number;
195
+ budget: number;
196
+ components: {
197
+ name: string;
198
+ bytes: number;
199
+ }[];
200
+ }
201
+ export declare function createApp(opts: AppOptions): App;
202
+ export declare function parseCspReports(text: string, origin: string, patternAt: (path: string) => string | undefined): CspViolation[];