@weft-framework/server 0.0.0-stage → 0.0.1

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
@@ -0,0 +1,169 @@
1
+ import type { SqlDatabase } from "@weft-framework/data";
2
+ import { type Job, type Jobs } from "./jobs.js";
3
+ import { type Secret } from "./secret.js";
4
+ export interface WebhookEndpoint {
5
+ id: string;
6
+ owner: string;
7
+ url: string;
8
+ events: string[];
9
+ description: string;
10
+ enabled: boolean;
11
+ disabledReason: string | null;
12
+ created: number;
13
+ failures: number;
14
+ }
15
+ export interface WebhookMessage {
16
+ id: string;
17
+ owner: string;
18
+ event: string;
19
+ body: string;
20
+ created: number;
21
+ }
22
+ export interface WebhookAttempt {
23
+ at: number;
24
+ status: number | null;
25
+ durationMs: number;
26
+ error: string | null;
27
+ response: string;
28
+ }
29
+ export type DeliveryStatus = "pending" | "succeeded" | "failed";
30
+ export interface WebhookDelivery {
31
+ id: string;
32
+ owner: string;
33
+ message: string;
34
+ endpoint: string;
35
+ event: string;
36
+ status: DeliveryStatus;
37
+ attempts: WebhookAttempt[];
38
+ created: number;
39
+ updated: number;
40
+ }
41
+ export type WebhookKind = "endpoint" | "message" | "delivery";
42
+ export interface WebhookStore {
43
+ put(kind: WebhookKind, id: string, owner: string, ref: string | null, created: number, data: string): void | Promise<void>;
44
+ get(kind: WebhookKind, id: string): string | null | Promise<string | null>;
45
+ list(kind: WebhookKind, owner: string, o: {
46
+ ref?: string;
47
+ limit: number;
48
+ before?: number;
49
+ }): string[] | Promise<string[]>;
50
+ remove(kind: WebhookKind, id: string): void | Promise<void>;
51
+ sweep(kind: WebhookKind, before: number, owner?: string): number | Promise<number>;
52
+ }
53
+ export declare class MemoryWebhookStore implements WebhookStore {
54
+ #private;
55
+ put(kind: WebhookKind, id: string, owner: string, ref: string | null, created: number, data: string): void;
56
+ get(kind: WebhookKind, id: string): string | null;
57
+ list(kind: WebhookKind, owner: string, o: {
58
+ ref?: string;
59
+ limit: number;
60
+ before?: number;
61
+ }): string[];
62
+ remove(kind: WebhookKind, id: string): void;
63
+ sweep(kind: WebhookKind, before: number, owner?: string): number;
64
+ }
65
+ export declare class SqlWebhookStore implements WebhookStore {
66
+ #private;
67
+ constructor(db: SqlDatabase, table?: string);
68
+ put(kind: WebhookKind, id: string, owner: string, ref: string | null, created: number, data: string): void;
69
+ get(kind: WebhookKind, id: string): string | null;
70
+ list(kind: WebhookKind, owner: string, o: {
71
+ ref?: string;
72
+ limit: number;
73
+ before?: number;
74
+ }): string[];
75
+ remove(kind: WebhookKind, id: string): void;
76
+ sweep(kind: WebhookKind, before: number, owner?: string): number;
77
+ }
78
+ export declare function isPublicAddress(ip: string): boolean;
79
+ export declare class WebhookError extends Error {
80
+ readonly code: "invalid" | "not-found" | "limit" | "address";
81
+ constructor(code: WebhookError["code"], message: string);
82
+ }
83
+ export declare function signWebhook(secrets: readonly string[], id: string, timestamp: number, body: string): Promise<string>;
84
+ export declare function verifyWebhook(secret: string, headers: Headers | Record<string, string | undefined>, body: string, o?: {
85
+ toleranceSec?: number;
86
+ now?: number;
87
+ }): Promise<unknown>;
88
+ export interface WebhookRequest {
89
+ url: string;
90
+ headers: Record<string, string>;
91
+ body: string;
92
+ timeoutMs: number;
93
+ }
94
+ export interface WebhookResponse {
95
+ status: number;
96
+ body: string;
97
+ }
98
+ export type WebhookTransport = (req: WebhookRequest) => Promise<WebhookResponse>;
99
+ type Lookup = (host: string) => Promise<{
100
+ address: string;
101
+ family: number;
102
+ }[]>;
103
+ export declare function nodeTransport(o?: {
104
+ allowPrivateNetworks?: boolean;
105
+ lookup?: Lookup;
106
+ }): WebhookTransport;
107
+ export interface WebhooksOptions<E extends string> {
108
+ events: readonly E[];
109
+ key: string | Secret;
110
+ store?: WebhookStore;
111
+ jobs: () => Jobs;
112
+ transport?: WebhookTransport;
113
+ lookup?: Lookup;
114
+ retrySchedule?: readonly number[];
115
+ timeoutMs?: number;
116
+ disableAfter?: number;
117
+ maxEndpoints?: number;
118
+ maxBytes?: number;
119
+ keepMs?: number;
120
+ allowInsecure?: boolean;
121
+ allowPrivateNetworks?: boolean;
122
+ jobName?: string;
123
+ onError?(err: unknown): void;
124
+ now?(): number;
125
+ }
126
+ export interface EndpointInput<E extends string> {
127
+ url: string;
128
+ events: readonly (E | "*")[];
129
+ description?: string;
130
+ }
131
+ export declare class Webhooks<E extends string = string> {
132
+ #private;
133
+ readonly job: Job<[string]>;
134
+ readonly events: readonly E[];
135
+ constructor(o: WebhooksOptions<E>);
136
+ checkUrl(url: unknown): Promise<string>;
137
+ createEndpoint(owner: string, input: EndpointInput<E>): Promise<{
138
+ endpoint: WebhookEndpoint;
139
+ secret: string;
140
+ }>;
141
+ endpoints(owner: string): Promise<WebhookEndpoint[]>;
142
+ endpoint(owner: string, id: string): Promise<WebhookEndpoint | null>;
143
+ updateEndpoint(owner: string, id: string, patch: {
144
+ url?: string;
145
+ events?: readonly (E | "*")[];
146
+ description?: string;
147
+ enabled?: boolean;
148
+ }): Promise<WebhookEndpoint>;
149
+ revealSecret(owner: string, id: string): Promise<string>;
150
+ rotateSecret(owner: string, id: string, o?: {
151
+ keepOldMs?: number;
152
+ }): Promise<string>;
153
+ removeEndpoint(owner: string, id: string): Promise<boolean>;
154
+ emit(owner: string, event: E, data: unknown): Promise<string | null>;
155
+ deliveries(owner: string, f?: {
156
+ endpoint?: string;
157
+ status?: DeliveryStatus;
158
+ limit?: number;
159
+ before?: number;
160
+ }): Promise<WebhookDelivery[]>;
161
+ delivery(owner: string, id: string): Promise<(WebhookDelivery & {
162
+ body: string | null;
163
+ }) | null>;
164
+ replay(owner: string, id: string): Promise<boolean>;
165
+ prune(owner?: string): Promise<number>;
166
+ forget(owner: string): Promise<number>;
167
+ }
168
+ export declare function defineWebhooks<const E extends string>(o: WebhooksOptions<E>): Webhooks<E>;
169
+ export {};