alepha 0.20.2 → 0.20.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 (208) hide show
  1. package/README.md +0 -1
  2. package/assets/swagger-ui/swagger-ui-bundle.js +1 -1
  3. package/assets/swagger-ui/swagger-ui.css +1 -1
  4. package/dist/api/audits/index.browser.js +49 -0
  5. package/dist/api/audits/index.browser.js.map +1 -1
  6. package/dist/api/audits/index.d.ts.map +1 -1
  7. package/dist/api/audits/index.js +49 -0
  8. package/dist/api/audits/index.js.map +1 -1
  9. package/dist/api/files/index.d.ts.map +1 -1
  10. package/dist/api/files/index.js.map +1 -1
  11. package/dist/api/jobs/index.d.ts +16 -75
  12. package/dist/api/jobs/index.d.ts.map +1 -1
  13. package/dist/api/jobs/index.js.map +1 -1
  14. package/dist/api/keys/index.js.map +1 -1
  15. package/dist/api/notifications/index.d.ts +1 -10
  16. package/dist/api/notifications/index.d.ts.map +1 -1
  17. package/dist/api/organizations/index.d.ts.map +1 -1
  18. package/dist/api/parameters/index.browser.js +37 -0
  19. package/dist/api/parameters/index.browser.js.map +1 -1
  20. package/dist/api/parameters/index.d.ts +4 -65
  21. package/dist/api/parameters/index.d.ts.map +1 -1
  22. package/dist/api/parameters/index.js +37 -0
  23. package/dist/api/parameters/index.js.map +1 -1
  24. package/dist/api/payments/index.d.ts.map +1 -1
  25. package/dist/api/payments/index.js.map +1 -1
  26. package/dist/api/users/index.d.ts +207 -5184
  27. package/dist/api/users/index.d.ts.map +1 -1
  28. package/dist/api/users/index.js +2 -4
  29. package/dist/api/users/index.js.map +1 -1
  30. package/dist/api/verifications/index.d.ts.map +1 -1
  31. package/dist/api/verifications/index.js +2 -1
  32. package/dist/api/verifications/index.js.map +1 -1
  33. package/dist/bucket/index.js +5 -1
  34. package/dist/bucket/index.js.map +1 -1
  35. package/dist/bucket/index.workerd.js +5 -1
  36. package/dist/bucket/index.workerd.js.map +1 -1
  37. package/dist/cache/core/index.js.map +1 -1
  38. package/dist/cache/core/index.workerd.js.map +1 -1
  39. package/dist/captcha/index.js.map +1 -1
  40. package/dist/cli/core/index.d.ts +217 -11647
  41. package/dist/cli/core/index.d.ts.map +1 -1
  42. package/dist/cli/core/index.js +706 -42
  43. package/dist/cli/core/index.js.map +1 -1
  44. package/dist/cli/devtools/index.js +7 -1
  45. package/dist/cli/devtools/index.js.map +1 -1
  46. package/dist/cli/platform/index.d.ts +41 -64
  47. package/dist/cli/platform/index.d.ts.map +1 -1
  48. package/dist/cli/platform/index.js +47 -0
  49. package/dist/cli/platform/index.js.map +1 -1
  50. package/dist/cli/vendor/index.js +15 -0
  51. package/dist/cli/vendor/index.js.map +1 -1
  52. package/dist/command/index.js +1 -1
  53. package/dist/command/index.js.map +1 -1
  54. package/dist/core/index.browser.js.map +1 -1
  55. package/dist/core/index.d.ts +2 -8
  56. package/dist/core/index.d.ts.map +1 -1
  57. package/dist/core/index.js.map +1 -1
  58. package/dist/core/index.native.js.map +1 -1
  59. package/dist/core/index.workerd.js.map +1 -1
  60. package/dist/crypto/index.js.map +1 -1
  61. package/dist/datetime/index.js.map +1 -1
  62. package/dist/email/core/index.js.map +1 -1
  63. package/dist/email/smtp/index.js +2 -10522
  64. package/dist/email/smtp/index.js.map +1 -1
  65. package/dist/fake/index.d.ts +4 -8085
  66. package/dist/fake/index.d.ts.map +1 -1
  67. package/dist/fake/index.js +3 -33554
  68. package/dist/fake/index.js.map +1 -1
  69. package/dist/lock/core/index.js.map +1 -1
  70. package/dist/lock/redis/index.js.map +1 -1
  71. package/dist/logger/index.js +32 -1
  72. package/dist/logger/index.js.map +1 -1
  73. package/dist/mcp/index.js +5 -1
  74. package/dist/mcp/index.js.map +1 -1
  75. package/dist/orm/core/index.browser.js +1 -361
  76. package/dist/orm/core/index.browser.js.map +1 -1
  77. package/dist/orm/core/index.bun.js +14 -406
  78. package/dist/orm/core/index.bun.js.map +1 -1
  79. package/dist/orm/core/index.d.ts +96 -5117
  80. package/dist/orm/core/index.d.ts.map +1 -1
  81. package/dist/orm/core/index.js +23 -419
  82. package/dist/orm/core/index.js.map +1 -1
  83. package/dist/orm/postgres/index.bun.js +17 -20
  84. package/dist/orm/postgres/index.bun.js.map +1 -1
  85. package/dist/orm/postgres/index.d.ts +2 -613
  86. package/dist/orm/postgres/index.d.ts.map +1 -1
  87. package/dist/orm/postgres/index.js +17 -20
  88. package/dist/orm/postgres/index.js.map +1 -1
  89. package/dist/react/core/index.js.map +1 -1
  90. package/dist/react/i18n/index.js.map +1 -1
  91. package/dist/react/intro/index.js +22 -17
  92. package/dist/react/intro/index.js.map +1 -1
  93. package/dist/react/router/index.browser.js +78 -2
  94. package/dist/react/router/index.browser.js.map +1 -1
  95. package/dist/react/router/index.d.ts +22 -1
  96. package/dist/react/router/index.d.ts.map +1 -1
  97. package/dist/react/router/index.js +102 -4
  98. package/dist/react/router/index.js.map +1 -1
  99. package/dist/react/testing/index.d.ts +1 -411
  100. package/dist/react/testing/index.d.ts.map +1 -1
  101. package/dist/react/testing/index.js +13 -12293
  102. package/dist/react/testing/index.js.map +1 -1
  103. package/dist/react/ui/index.js +3 -0
  104. package/dist/react/ui/index.js.map +1 -1
  105. package/dist/react/websocket/index.js.map +1 -1
  106. package/dist/redis/index.js.map +1 -1
  107. package/dist/scheduler/index.d.ts +1 -83
  108. package/dist/scheduler/index.d.ts.map +1 -1
  109. package/dist/scheduler/index.js +2 -391
  110. package/dist/scheduler/index.js.map +1 -1
  111. package/dist/scheduler/index.workerd.js +2 -391
  112. package/dist/scheduler/index.workerd.js.map +1 -1
  113. package/dist/security/index.browser.js.map +1 -1
  114. package/dist/security/index.d.ts +2 -325
  115. package/dist/security/index.d.ts.map +1 -1
  116. package/dist/security/index.js +3 -1362
  117. package/dist/security/index.js.map +1 -1
  118. package/dist/server/auth/index.d.ts +1 -1054
  119. package/dist/server/auth/index.d.ts.map +1 -1
  120. package/dist/server/auth/index.js +16 -1224
  121. package/dist/server/auth/index.js.map +1 -1
  122. package/dist/server/cookies/index.js.map +1 -1
  123. package/dist/server/core/index.browser.js.map +1 -1
  124. package/dist/server/core/index.d.ts +1 -4
  125. package/dist/server/core/index.d.ts.map +1 -1
  126. package/dist/server/core/index.js +19 -4
  127. package/dist/server/core/index.js.map +1 -1
  128. package/dist/server/links/index.browser.js.map +1 -1
  129. package/dist/server/links/index.js.map +1 -1
  130. package/dist/server/metrics/index.d.ts +1 -514
  131. package/dist/server/metrics/index.d.ts.map +1 -1
  132. package/dist/server/metrics/index.js +4 -4356
  133. package/dist/server/metrics/index.js.map +1 -1
  134. package/dist/server/rate-limit/index.js.map +1 -1
  135. package/dist/server/static/index.js.map +1 -1
  136. package/dist/server/swagger/index.js +1 -1
  137. package/dist/server/swagger/index.js.map +1 -1
  138. package/dist/sms/index.js.map +1 -1
  139. package/dist/system/index.browser.js.map +1 -1
  140. package/dist/system/index.js.map +1 -1
  141. package/dist/system/index.workerd.js.map +1 -1
  142. package/dist/topic/core/index.js.map +1 -1
  143. package/dist/websocket/index.browser.js +21 -0
  144. package/dist/websocket/index.browser.js.map +1 -1
  145. package/dist/websocket/index.js +21 -0
  146. package/dist/websocket/index.js.map +1 -1
  147. package/package.json +18 -15
  148. package/src/api/files/__tests__/FileController.spec.ts +1 -1
  149. package/src/api/jobs/__tests__/$job.spec.ts +5 -1
  150. package/src/api/users/schemas/userQuerySchema.ts +0 -1
  151. package/src/api/users/services/UserService.ts +1 -5
  152. package/src/api/verifications/__tests__/CodeVerification.spec.ts +14 -0
  153. package/src/api/verifications/__tests__/LinkVerification.spec.ts +14 -0
  154. package/src/api/verifications/services/VerificationService.ts +1 -0
  155. package/src/cli/core/__tests__/init.spec.ts +208 -0
  156. package/src/cli/core/commands/init.ts +12 -0
  157. package/src/cli/core/services/PackageManagerUtils.ts +23 -6
  158. package/src/cli/core/services/ProjectScaffolder.ts +298 -20
  159. package/src/cli/core/tasks/BuildDockerTask.ts +9 -10
  160. package/src/cli/core/tasks/BuildServerTask.ts +8 -0
  161. package/src/cli/core/templates/apiIndexTs.ts +23 -1
  162. package/src/cli/core/templates/componentsJsonTs.ts +39 -0
  163. package/src/cli/core/templates/mainCss.ts +1 -0
  164. package/src/cli/core/templates/saasAdminLayoutTsx.ts +77 -0
  165. package/src/cli/core/templates/saasAdminPagesTsx.ts +26 -0
  166. package/src/cli/core/templates/saasAuthLayoutTsx.ts +20 -0
  167. package/src/cli/core/templates/saasAuthPagesTsx.ts +62 -0
  168. package/src/cli/core/templates/saasRealmProviderTs.ts +46 -0
  169. package/src/cli/core/templates/webAppRouterTs.ts +104 -1
  170. package/src/cli/core/templates/webIndexTs.ts +23 -1
  171. package/src/cli/platform/__tests__/SecretsCommand.spec.ts +2 -0
  172. package/src/command/providers/CliProvider.ts +1 -1
  173. package/src/core/interfaces/Service.ts +3 -1
  174. package/src/core/providers/TypeProvider.ts +1 -1
  175. package/src/logger/services/Logger.ts +1 -1
  176. package/src/mcp/__tests__/$resource.spec.ts +1 -1
  177. package/src/mcp/__tests__/$tool.spec.ts +1 -1
  178. package/src/mcp/__tests__/McpServerProvider.spec.ts +1 -1
  179. package/src/orm/__tests__/$repository-tests.ts +1 -0
  180. package/src/orm/__tests__/orm-next-tests.ts +2 -67
  181. package/src/orm/__tests__/orm-next.spec.ts +0 -21
  182. package/src/orm/core/index.shared.ts +0 -2
  183. package/src/orm/core/index.ts +1 -2
  184. package/src/orm/core/primitives/$repository.ts +3 -6
  185. package/src/orm/core/providers/drivers/DatabaseProvider.ts +0 -5
  186. package/src/orm/core/providers/drivers/NodeSqliteProvider.ts +11 -13
  187. package/src/orm/core/services/ModelBuilder.ts +1 -13
  188. package/src/orm/core/services/Repository.ts +1 -42
  189. package/src/orm/core/services/SqliteModelBuilder.ts +2 -33
  190. package/src/orm/postgres/services/PostgresModelBuilder.ts +10 -45
  191. package/src/react/intro/components/GettingStartedAuthSlide.tsx +11 -4
  192. package/src/react/router/__tests__/ReactBrowserProvider.browser.spec.ts +213 -2
  193. package/src/react/router/providers/ReactBrowserProvider.ts +73 -0
  194. package/src/react/router/providers/ReactBrowserRouterProvider.ts +1 -1
  195. package/src/react/router/providers/ReactPreloadProvider.ts +1 -1
  196. package/src/react/router/providers/ReactServerProvider.ts +1 -0
  197. package/src/scheduler/providers/CronProvider.ts +1 -1
  198. package/src/security/primitives/$basicAuth.ts +1 -1
  199. package/src/server/auth/providers/ServerAuthProvider.ts +5 -1
  200. package/src/server/core/interfaces/ServerRequest.ts +1 -0
  201. package/src/server/core/providers/ServerProvider.ts +1 -1
  202. package/src/server/core/providers/ServerRouterProvider.ts +2 -2
  203. package/src/server/core/services/HttpClient.ts +1 -1
  204. package/src/server/swagger/providers/ServerSwaggerProvider.ts +1 -1
  205. package/dist/react/testing/chunk-DBEY4PJZ.js +0 -16
  206. package/src/orm/core/__tests__/parseQueryString.spec.ts +0 -196
  207. package/src/orm/core/helpers/parseQueryString.ts +0 -502
  208. package/src/orm/core/primitives/$view.ts +0 -88
@@ -1,6 +1,6 @@
1
1
  import * as _$alepha from "alepha";
2
2
  import { Static, TObject, TSchema } from "alepha";
3
- import { DatabaseProvider, EntityPrimitive, FromSchema, ModelBuilder, SQLLike, SequencePrimitive, ViewPrimitive } from "alepha/orm";
3
+ import { DatabaseProvider, EntityPrimitive, FromSchema, ModelBuilder, SQLLike, SequencePrimitive } from "alepha/orm";
4
4
  import * as _$drizzle_orm0 from "drizzle-orm";
5
5
  import { BuildExtraConfigColumns } from "drizzle-orm";
6
6
  import * as pg from "drizzle-orm/pg-core";
@@ -8,6 +8,7 @@ import { PgDatabase, PgSchema, PgTableExtraConfigValue } from "drizzle-orm/pg-co
8
8
  import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
9
9
  import postgres from "postgres";
10
10
  import { BunSQLDatabase } from "drizzle-orm/bun-sql";
11
+ import { PGlite } from "@electric-sql/pglite";
11
12
  import { PgliteDatabase } from "drizzle-orm/pglite";
12
13
 
13
14
  //#region ../../src/orm/postgres/services/PostgresModelBuilder.d.ts
@@ -24,10 +25,6 @@ declare class PostgresModelBuilder extends ModelBuilder {
24
25
  schemas: Map<string, unknown>;
25
26
  schema: string;
26
27
  }): void;
27
- buildView(view: ViewPrimitive, options: {
28
- tables: Map<string, unknown>;
29
- schema: string;
30
- }): void;
31
28
  buildSequence(sequence: SequencePrimitive, options: {
32
29
  sequences: Map<string, unknown>;
33
30
  schema: string;
@@ -217,614 +214,6 @@ declare class NodePostgresProvider extends PostgresProvider {
217
214
  protected ssl(url: URL): "require" | "allow" | "prefer" | "verify-full" | undefined;
218
215
  }
219
216
  //#endregion
220
- //#region ../../../../node_modules/@electric-sql/pglite/dist/pglite-BZlQ7pL-.d.ts
221
- type MessageName = 'parseComplete' | 'bindComplete' | 'closeComplete' | 'noData' | 'portalSuspended' | 'replicationStart' | 'emptyQuery' | 'copyDone' | 'copyData' | 'rowDescription' | 'parameterDescription' | 'parameterStatus' | 'backendKeyData' | 'notification' | 'readyForQuery' | 'commandComplete' | 'dataRow' | 'copyInResponse' | 'copyOutResponse' | 'authenticationOk' | 'authenticationMD5Password' | 'authenticationCleartextPassword' | 'authenticationSASL' | 'authenticationSASLContinue' | 'authenticationSASLFinal' | 'error' | 'notice';
222
- type BackendMessage = {
223
- name: MessageName;
224
- length: number;
225
- };
226
- interface NoticeOrError {
227
- message: string | undefined;
228
- severity: string | undefined;
229
- code: string | undefined;
230
- detail: string | undefined;
231
- hint: string | undefined;
232
- position: string | undefined;
233
- internalPosition: string | undefined;
234
- internalQuery: string | undefined;
235
- where: string | undefined;
236
- schema: string | undefined;
237
- table: string | undefined;
238
- column: string | undefined;
239
- dataType: string | undefined;
240
- constraint: string | undefined;
241
- file: string | undefined;
242
- line: string | undefined;
243
- routine: string | undefined;
244
- }
245
- declare class NoticeMessage implements BackendMessage, NoticeOrError {
246
- readonly length: number;
247
- readonly message: string | undefined;
248
- constructor(length: number, message: string | undefined);
249
- readonly name = "notice";
250
- severity: string | undefined;
251
- code: string | undefined;
252
- detail: string | undefined;
253
- hint: string | undefined;
254
- position: string | undefined;
255
- internalPosition: string | undefined;
256
- internalQuery: string | undefined;
257
- where: string | undefined;
258
- schema: string | undefined;
259
- table: string | undefined;
260
- column: string | undefined;
261
- dataType: string | undefined;
262
- constraint: string | undefined;
263
- file: string | undefined;
264
- line: string | undefined;
265
- routine: string | undefined;
266
- }
267
- type IDBFS = Emscripten.FileSystemType & {
268
- quit: () => void;
269
- dbs: Record<string, IDBDatabase>;
270
- };
271
- type FS = typeof FS & {
272
- filesystems: {
273
- MEMFS: Emscripten.FileSystemType;
274
- NODEFS: Emscripten.FileSystemType;
275
- IDBFS: IDBFS;
276
- };
277
- quit: () => void;
278
- };
279
- interface PostgresMod extends Omit<EmscriptenModule, 'preInit' | 'preRun' | 'postRun'> {
280
- preInit: Array<{
281
- (mod: PostgresMod): void;
282
- }>;
283
- preRun: Array<{
284
- (mod: PostgresMod): void;
285
- }>;
286
- postRun: Array<{
287
- (mod: PostgresMod): void;
288
- }>;
289
- thisProgram: string;
290
- stdin: (() => number | null) | null;
291
- FS: FS;
292
- wasmMemory: WebAssembly.Memory;
293
- PROXYFS: Emscripten.FileSystemType;
294
- WASM_PREFIX: string;
295
- pg_extensions: Record<string, Promise<Blob | null>>;
296
- UTF8ToString: (ptr: number, maxBytesToRead?: number) => string;
297
- stringToUTF8OnStack: (s: string) => number;
298
- _pgl_set_system_fn: (system_fn: number) => void;
299
- _pgl_set_popen_fn: (popen_fn: number) => void;
300
- _pgl_set_pclose_fn: (pclose_fn: number) => void;
301
- _pgl_set_rw_cbs: (read_cb: number, write_cb: number) => void;
302
- _pgl_set_pipe_fn: (pipe_fn: number) => number;
303
- _pgl_freopen: (filepath: number, mode: number, stream: number) => number;
304
- _pgl_pq_flush: () => void;
305
- _fopen: (path: number, mode: number) => number;
306
- _fclose: (stream: number) => number;
307
- _fflush: (stream: number) => void;
308
- _pgl_proc_exit: (code: number) => number;
309
- addFunction: (cb: (ptr: any, length: number) => void, signature: string) => number;
310
- removeFunction: (f: number) => void;
311
- callMain: (args?: string[]) => number;
312
- _PostgresMainLoopOnce: () => void;
313
- _PostgresMainLongJmp: () => void;
314
- _PostgresSendReadyForQueryIfNecessary: () => void;
315
- _ProcessStartupPacket: (Port: number, ssl_done: boolean, gss_done: boolean) => number;
316
- _IsTransactionBlock: () => number;
317
- _pgl_setPGliteActive: (newValue: number) => number;
318
- _pgl_startPGlite: () => void;
319
- _pgl_getMyProcPort: () => number;
320
- _pgl_sendConnData: () => void;
321
- ENV: any;
322
- _emscripten_force_exit: (status: number) => void;
323
- _pgl_run_atexit_funcs: () => void;
324
- _pq_buffer_remaining_data: () => number;
325
- }
326
- type DumpTarCompressionOptions = 'none' | 'gzip' | 'auto';
327
- /**
328
- * Filesystem interface.
329
- * All virtual filesystems that are compatible with PGlite must implement
330
- * this interface.
331
- */
332
- interface Filesystem {
333
- /**
334
- * Initiate the filesystem and return the options to pass to the emscripten module.
335
- */
336
- init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{
337
- emscriptenOpts: Partial<PostgresMod>;
338
- }>;
339
- /**
340
- * Sync the filesystem to any underlying storage.
341
- */
342
- syncToFs(relaxedDurability?: boolean): Promise<void>;
343
- /**
344
- * Sync the filesystem from any underlying storage.
345
- */
346
- initialSyncFs(): Promise<void>;
347
- /**
348
- * Dump the PGDATA dir from the filesystem to a gzipped tarball.
349
- */
350
- dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<File | Blob>;
351
- /**
352
- * Close the filesystem.
353
- */
354
- closeFs(): Promise<void>;
355
- }
356
- /**
357
- * Base class for all emscripten built-in filesystems.
358
- */
359
- type DebugLevel = 0 | 1 | 2 | 3 | 4 | 5;
360
- type RowMode = 'array' | 'object';
361
- interface ParserOptions {
362
- [pgType: number]: (value: string) => any;
363
- }
364
- interface SerializerOptions {
365
- [pgType: number]: (value: any) => string;
366
- }
367
- interface QueryOptions {
368
- rowMode?: RowMode;
369
- parsers?: ParserOptions;
370
- serializers?: SerializerOptions;
371
- blob?: Blob | File;
372
- onNotice?: (notice: NoticeMessage) => void;
373
- paramTypes?: number[];
374
- }
375
- interface ExecProtocolOptions {
376
- syncToFs?: boolean;
377
- throwOnError?: boolean;
378
- onNotice?: (notice: NoticeMessage) => void;
379
- }
380
- interface ExecProtocolOptionsStream {
381
- syncToFs?: boolean;
382
- onRawData: (data: Uint8Array) => void;
383
- }
384
- interface ExtensionSetupResult<TNamespace = any> {
385
- emscriptenOpts?: any;
386
- namespaceObj?: TNamespace;
387
- bundlePath?: URL;
388
- init?: () => Promise<void>;
389
- close?: () => Promise<void>;
390
- }
391
- type ExtensionSetup<TNamespace = any> = (pg: PGliteInterface, emscriptenOpts: any, clientOnly?: boolean) => Promise<ExtensionSetupResult<TNamespace>>;
392
- interface Extension<TNamespace = any> {
393
- name: string;
394
- setup: ExtensionSetup<TNamespace>;
395
- }
396
- type ExtensionNamespace<T> = T extends Extension<infer TNamespace> ? TNamespace : any;
397
- type Extensions = {
398
- [namespace: string]: Extension | URL;
399
- };
400
- type InitializedExtensions<TExtensions extends Extensions = Extensions> = { [K in keyof TExtensions]: ExtensionNamespace<TExtensions[K]> };
401
- interface ExecProtocolResult {
402
- messages: BackendMessage[];
403
- data: Uint8Array;
404
- }
405
- interface PGliteOptions<TExtensions extends Extensions = Extensions> {
406
- noInitDb?: boolean;
407
- dataDir?: string;
408
- username?: string;
409
- database?: string;
410
- fs?: Filesystem;
411
- debug?: DebugLevel;
412
- relaxedDurability?: boolean;
413
- extensions?: TExtensions;
414
- loadDataDir?: Blob | File;
415
- initialMemory?: number;
416
- pgliteWasmModule?: WebAssembly.Module;
417
- initdbWasmModule?: WebAssembly.Module;
418
- fsBundle?: Blob | File;
419
- parsers?: ParserOptions;
420
- serializers?: SerializerOptions;
421
- startParams?: string[];
422
- }
423
- type PGliteInterface<T extends Extensions = Extensions> = InitializedExtensions<T> & {
424
- readonly waitReady: Promise<void>;
425
- readonly debug: DebugLevel;
426
- readonly ready: boolean;
427
- readonly closed: boolean;
428
- close(): Promise<void>;
429
- query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>;
430
- sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>;
431
- exec(query: string, options?: QueryOptions): Promise<Array<Results>>;
432
- describeQuery(query: string): Promise<DescribeQueryResult>;
433
- transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>;
434
- execProtocolRaw(message: Uint8Array, options?: ExecProtocolOptions): Promise<Uint8Array>;
435
- execProtocolRawStream(message: Uint8Array, options?: ExecProtocolOptionsStream): Promise<void>;
436
- execProtocol(message: Uint8Array, options?: ExecProtocolOptions): Promise<ExecProtocolResult>;
437
- runExclusive<T>(fn: () => Promise<T>): Promise<T>;
438
- listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>;
439
- unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>;
440
- onNotification(callback: (channel: string, payload: string) => void): () => void;
441
- offNotification(callback: (channel: string, payload: string) => void): void;
442
- dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>;
443
- refreshArrayTypes(): Promise<void>;
444
- };
445
- type PGliteInterfaceExtensions<E> = E extends Extensions ? { [K in keyof E]: E[K] extends Extension ? Awaited<ReturnType<E[K]['setup']>>['namespaceObj'] extends infer N ? N extends undefined | null | void ? never : N : never : never } : Record<string, never>;
446
- type Row<T = {
447
- [key: string]: any;
448
- }> = T;
449
- type Results<T = {
450
- [key: string]: any;
451
- }> = {
452
- rows: Row<T>[];
453
- affectedRows?: number;
454
- fields: {
455
- name: string;
456
- dataTypeID: number;
457
- }[];
458
- blob?: Blob;
459
- };
460
- interface Transaction {
461
- query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>;
462
- sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>;
463
- exec(query: string, options?: QueryOptions): Promise<Array<Results>>;
464
- rollback(): Promise<void>;
465
- listen(channel: string, callback: (payload: string) => void): Promise<(tx?: Transaction) => Promise<void>>;
466
- get closed(): boolean;
467
- }
468
- type DescribeQueryResult = {
469
- queryParams: {
470
- dataTypeID: number;
471
- serializer: Serializer;
472
- }[];
473
- resultFields: {
474
- name: string;
475
- dataTypeID: number;
476
- parser: Parser;
477
- }[];
478
- };
479
- type Parser = (x: string, typeId?: number) => any;
480
- type Serializer = (x: any) => string;
481
- declare abstract class BasePGlite implements Pick<PGliteInterface, 'query' | 'sql' | 'exec' | 'transaction'> {
482
- #private;
483
- serializers: Record<number | string, Serializer>;
484
- parsers: Record<number | string, Parser>;
485
- abstract debug: DebugLevel;
486
- /**
487
- * Execute a postgres wire protocol message
488
- * @param message The postgres wire protocol message to execute
489
- * @returns The result of the query
490
- */
491
- abstract execProtocol(message: Uint8Array, {
492
- syncToFs,
493
- onNotice
494
- }: ExecProtocolOptions): Promise<ExecProtocolResult>;
495
- /**
496
- * Execute a postgres wire protocol message
497
- * @param message The postgres wire protocol message to execute
498
- * @returns The parsed results of the query
499
- */
500
- abstract execProtocolStream(message: Uint8Array, {
501
- syncToFs,
502
- onNotice
503
- }: ExecProtocolOptions): Promise<BackendMessage[]>;
504
- /**
505
- * Execute a postgres wire protocol message directly without wrapping the response.
506
- * Only use if `execProtocol()` doesn't suite your needs.
507
- *
508
- * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages,
509
- * transactions, and notification listeners. Only use if you need to bypass these wrappers and
510
- * don't intend to use the above features.
511
- *
512
- * @param message The postgres wire protocol message to execute
513
- * @returns The direct message data response produced by Postgres
514
- */
515
- abstract execProtocolRaw(message: Uint8Array, {
516
- syncToFs
517
- }: ExecProtocolOptions): Promise<Uint8Array>;
518
- /**
519
- * Execute a postgres wire protocol message directly without wrapping the response.
520
- * Only use if `execProtocol()` doesn't suite your needs.
521
- *
522
- * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages,
523
- * transactions, and notification listeners. Only use if you need to bypass these wrappers and
524
- * don't intend to use the above features.
525
- *
526
- * @param message The postgres wire protocol message to execute
527
- * @param options.onRawData Callback to receive streaming data
528
- */
529
- abstract execProtocolRawStream(message: Uint8Array, {
530
- syncToFs,
531
- onRawData
532
- }: ExecProtocolOptionsStream): Promise<void>;
533
- /**
534
- * Sync the database to the filesystem
535
- * @returns Promise that resolves when the database is synced to the filesystem
536
- */
537
- abstract syncToFs(): Promise<void>;
538
- /**
539
- * Handle a file attached to the current query
540
- * @param file The file to handle
541
- */
542
- abstract _handleBlob(blob?: File | Blob): Promise<void>;
543
- /**
544
- * Get the written file
545
- */
546
- abstract _getWrittenBlob(): Promise<File | Blob | undefined>;
547
- /**
548
- * Cleanup the current file
549
- */
550
- abstract _cleanupBlob(): Promise<void>;
551
- abstract _checkReady(): Promise<void>;
552
- abstract _runExclusiveQuery<T>(fn: () => Promise<T>): Promise<T>;
553
- abstract _runExclusiveTransaction<T>(fn: () => Promise<T>): Promise<T>;
554
- /**
555
- * Listen for notifications on a channel
556
- */
557
- abstract listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>;
558
- /**
559
- * Initialize the array types
560
- * The oid if the type of an element and the typarray is the oid of the type of the
561
- * array.
562
- * We extract these from the database then create the serializers/parsers for
563
- * each type.
564
- * This should be called at the end of #init() in the implementing class.
565
- */
566
- _initArrayTypes({
567
- force
568
- }?: {
569
- force?: boolean | undefined;
570
- }): Promise<void>;
571
- /**
572
- * Re-syncs the array types from the database
573
- * This is useful if you add a new type to the database and want to use it, otherwise pglite won't recognize it.
574
- */
575
- refreshArrayTypes(): Promise<void>;
576
- /**
577
- * Execute a single SQL statement
578
- * This uses the "Extended Query" postgres wire protocol message.
579
- * @param query The query to execute
580
- * @param params Optional parameters for the query
581
- * @returns The result of the query
582
- */
583
- query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>;
584
- /**
585
- * Execute a single SQL statement like with {@link PGlite.query}, but with a
586
- * templated statement where template values will be treated as parameters.
587
- *
588
- * You can use helpers from `/template` to further format the query with
589
- * identifiers, raw SQL, and nested statements.
590
- *
591
- * This uses the "Extended Query" postgres wire protocol message.
592
- *
593
- * @param query The query to execute with parameters as template values
594
- * @returns The result of the query
595
- *
596
- * @example
597
- * ```ts
598
- * const results = await db.sql`SELECT * FROM ${identifier`foo`} WHERE id = ${id}`
599
- * ```
600
- */
601
- sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>;
602
- /**
603
- * Execute a SQL query, this can have multiple statements.
604
- * This uses the "Simple Query" postgres wire protocol message.
605
- * @param query The query to execute
606
- * @returns The result of the query
607
- */
608
- exec(query: string, options?: QueryOptions): Promise<Array<Results>>;
609
- /**
610
- * Describe a query
611
- * @param query The query to describe
612
- * @returns A description of the result types for the query
613
- */
614
- describeQuery(query: string, options?: QueryOptions): Promise<DescribeQueryResult>;
615
- /**
616
- * Execute a transaction
617
- * @param callback A callback function that takes a transaction object
618
- * @returns The result of the transaction
619
- */
620
- transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>;
621
- /**
622
- * Run a function exclusively, no other transactions or queries will be allowed
623
- * while the function is running.
624
- * This is useful when working with the execProtocol methods as they are not blocked,
625
- * and do not block the locks used by transactions and queries.
626
- * @param fn The function to run
627
- * @returns The result of the function
628
- */
629
- runExclusive<T>(fn: () => Promise<T>): Promise<T>;
630
- }
631
- declare class PGlite extends BasePGlite implements PGliteInterface, AsyncDisposable {
632
- #private;
633
- fs?: Filesystem;
634
- protected mod?: PostgresMod;
635
- private readonly POSTGRES_MAIN_LONGJMP;
636
- get ENV(): any;
637
- readonly dataDir?: string;
638
- readonly waitReady: Promise<void>;
639
- readonly debug: DebugLevel;
640
- static readonly DEFAULT_RECV_BUF_SIZE: number;
641
- static readonly MAX_BUFFER_SIZE: number;
642
- externalCommandStreamFd: number | null;
643
- static readonly defaultStartParams: string[];
644
- /**
645
- * Create a new PGlite instance
646
- * @param dataDir The directory to store the database files
647
- * Prefix with idb:// to use indexeddb filesystem in the browser
648
- * Use memory:// to use in-memory filesystem
649
- * @param options PGlite options
650
- */
651
- constructor(dataDir?: string, options?: PGliteOptions);
652
- /**
653
- * Create a new PGlite instance
654
- * @param options PGlite options including the data directory
655
- */
656
- constructor(options?: PGliteOptions);
657
- /**
658
- * Create a new PGlite instance with extensions on the Typescript interface
659
- * (The main constructor does enable extensions, however due to the limitations
660
- * of Typescript, the extensions are not available on the instance interface)
661
- * @param options PGlite options including the data directory
662
- * @returns A promise that resolves to the PGlite instance when it's ready.
663
- */
664
- static create<O extends PGliteOptions>(options?: O): Promise<PGlite & PGliteInterfaceExtensions<O['extensions']>>;
665
- /**
666
- * Create a new PGlite instance with extensions on the Typescript interface
667
- * (The main constructor does enable extensions, however due to the limitations
668
- * of Typescript, the extensions are not available on the instance interface)
669
- * @param dataDir The directory to store the database files
670
- * Prefix with idb:// to use indexeddb filesystem in the browser
671
- * Use memory:// to use in-memory filesystem
672
- * @param options PGlite options
673
- * @returns A promise that resolves to the PGlite instance when it's ready.
674
- */
675
- static create<O extends PGliteOptions>(dataDir?: string, options?: O): Promise<PGlite & PGliteInterfaceExtensions<O['extensions']>>;
676
- handleExternalCmd(cmd: string, mode: string): number;
677
- /**
678
- * The Postgres Emscripten Module
679
- */
680
- get Module(): PostgresMod;
681
- /**
682
- * The ready state of the database
683
- */
684
- get ready(): boolean;
685
- /**
686
- * The closed state of the database
687
- */
688
- get closed(): boolean;
689
- /**
690
- * Close the database
691
- * @returns A promise that resolves when the database is closed
692
- */
693
- close(): Promise<void>;
694
- /**
695
- * Close the database when the object exits scope
696
- * Stage 3 ECMAScript Explicit Resource Management
697
- * https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management
698
- */
699
- [Symbol.asyncDispose](): Promise<void>;
700
- /**
701
- * Handle a file attached to the current query
702
- * @param file The file to handle
703
- */
704
- _handleBlob(blob?: File | Blob): Promise<void>;
705
- /**
706
- * Cleanup the current file
707
- */
708
- _cleanupBlob(): Promise<void>;
709
- /**
710
- * Get the written blob from the current query
711
- * @returns The written blob
712
- */
713
- _getWrittenBlob(): Promise<Blob | undefined>;
714
- /**
715
- * Wait for the database to be ready
716
- */
717
- _checkReady(): Promise<void>;
718
- /**
719
- * Execute a postgres wire protocol synchronously
720
- * @param message The postgres wire protocol message to execute
721
- * @returns The direct message data response produced by Postgres
722
- */
723
- execProtocolRawSync(message: Uint8Array): Uint8Array;
724
- /**
725
- * Execute a postgres wire protocol message directly without wrapping the response.
726
- * Only use if `execProtocol()` doesn't suite your needs.
727
- *
728
- * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages,
729
- * transactions, and notification listeners. Only use if you need to bypass these wrappers and
730
- * don't intend to use the above features.
731
- *
732
- * @param message The postgres wire protocol message to execute
733
- * @returns The direct message data response produced by Postgres
734
- */
735
- execProtocolRaw(message: Uint8Array, {
736
- syncToFs
737
- }?: ExecProtocolOptions): Promise<Uint8Array>;
738
- /**
739
- * Execute a postgres wire protocol message directly without wrapping the response.
740
- * Only use if `execProtocol()` doesn't suite your needs.
741
- *
742
- * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages,
743
- * transactions, and notification listeners. Only use if you need to bypass these wrappers and
744
- * don't intend to use the above features.
745
- *
746
- * @param message The postgres wire protocol message to execute
747
- * @param options.onRawData Callback to receive results as streaming data
748
- */
749
- execProtocolRawStream(message: Uint8Array, {
750
- syncToFs,
751
- onRawData
752
- }: ExecProtocolOptionsStream): Promise<void>;
753
- /**
754
- * Execute a postgres wire protocol message
755
- * @param message The postgres wire protocol message to execute
756
- * @returns The result of the query
757
- */
758
- execProtocol(message: Uint8Array, {
759
- syncToFs,
760
- throwOnError,
761
- onNotice
762
- }?: ExecProtocolOptions): Promise<ExecProtocolResult>;
763
- /**
764
- * Execute a postgres wire protocol message
765
- * @param message The postgres wire protocol message to execute
766
- * @returns The parsed results of the query
767
- */
768
- execProtocolStream(message: Uint8Array, {
769
- syncToFs,
770
- throwOnError,
771
- onNotice
772
- }?: ExecProtocolOptions): Promise<BackendMessage[]>;
773
- /**
774
- * Check if the database is in a transaction
775
- * @returns True if the database is in a transaction, false otherwise
776
- */
777
- isInTransaction(): boolean;
778
- /**
779
- * Perform any sync operations implemented by the filesystem, this is
780
- * run after every query to ensure that the filesystem is synced.
781
- */
782
- syncToFs(): Promise<void>;
783
- /**
784
- * Listen for a notification
785
- * @param channel The channel to listen on
786
- * @param callback The callback to call when a notification is received
787
- */
788
- listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>;
789
- /**
790
- * Stop listening for a notification
791
- * @param channel The channel to stop listening on
792
- * @param callback The callback to remove
793
- */
794
- unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>;
795
- /**
796
- * Listen to notifications
797
- * @param callback The callback to call when a notification is received
798
- */
799
- onNotification(callback: (channel: string, payload: string) => void): () => void;
800
- /**
801
- * Stop listening to notifications
802
- * @param callback The callback to remove
803
- */
804
- offNotification(callback: (channel: string, payload: string) => void): void;
805
- /**
806
- * Dump the PGDATA dir from the filesystem to a gzipped tarball.
807
- * @param compression The compression options to use - 'gzip', 'auto', 'none'
808
- * @returns The tarball as a File object where available, and fallback to a Blob
809
- */
810
- dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>;
811
- /**
812
- * Run a function in a mutex that's exclusive to queries
813
- * @param fn The query to run
814
- * @returns The result of the query
815
- */
816
- _runExclusiveQuery<T>(fn: () => Promise<T>): Promise<T>;
817
- /**
818
- * Run a function in a mutex that's exclusive to transactions
819
- * @param fn The function to run
820
- * @returns The result of the function
821
- */
822
- _runExclusiveTransaction<T>(fn: () => Promise<T>): Promise<T>;
823
- clone(): Promise<PGliteInterface>;
824
- _runExclusiveListen<T>(fn: () => Promise<T>): Promise<T>;
825
- callMain(args: string[]): number;
826
- }
827
- //#endregion
828
217
  //#region ../../src/orm/postgres/providers/PglitePostgresProvider.d.ts
829
218
  interface PgLiteModule {
830
219
  PGlite: typeof PGlite;