o134 commited on
Commit
b3b8f74
·
verified ·
1 Parent(s): 4e8727c

Grouping tasks by day and monthly drafts (Python Upload)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. artifacts/design-studio/src/pages/clients.tsx +29 -3
  3. artifacts/design-studio/src/pages/dashboard.tsx +120 -79
  4. backups/local_20260510_155124.db +0 -0
  5. node_modules/.bin/prettier +22 -0
  6. node_modules/.bin/prettier.CMD +12 -0
  7. node_modules/.bin/prettier.ps1 +41 -0
  8. node_modules/.bin/tsc +22 -0
  9. node_modules/.bin/tsc.CMD +12 -0
  10. node_modules/.bin/tsc.ps1 +41 -0
  11. node_modules/.bin/tsserver +22 -0
  12. node_modules/.bin/tsserver.CMD +12 -0
  13. node_modules/.bin/tsserver.ps1 +41 -0
  14. node_modules/.modules.yaml +1478 -0
  15. node_modules/.pnpm-workspace-state-v1.json +183 -0
  16. node_modules/.pnpm/lock.yaml +0 -0
  17. node_modules/@rollup/rollup-win32-x64-msvc/README.md +3 -0
  18. node_modules/@rollup/rollup-win32-x64-msvc/package.json +22 -0
  19. node_modules/@rollup/rollup-win32-x64-msvc/rollup.win32-x64-msvc.node +3 -0
  20. node_modules/@tailwindcss/oxide-win32-x64-msvc/LICENSE +21 -0
  21. node_modules/@tailwindcss/oxide-win32-x64-msvc/README.md +3 -0
  22. node_modules/@tailwindcss/oxide-win32-x64-msvc/package.json +27 -0
  23. node_modules/@tailwindcss/oxide-win32-x64-msvc/tailwindcss-oxide.win32-x64-msvc.node +3 -0
  24. node_modules/lightningcss-win32-x64-msvc/LICENSE +373 -0
  25. node_modules/lightningcss-win32-x64-msvc/README.md +1 -0
  26. node_modules/lightningcss-win32-x64-msvc/lightningcss.win32-x64-msvc.node +3 -0
  27. node_modules/lightningcss-win32-x64-msvc/package.json +34 -0
  28. node_modules/postgres/README.md +1392 -0
  29. node_modules/postgres/cf/polyfills.js +233 -0
  30. node_modules/postgres/cf/src/bytes.js +79 -0
  31. node_modules/postgres/cf/src/connection.js +1064 -0
  32. node_modules/postgres/cf/src/errors.js +53 -0
  33. node_modules/postgres/cf/src/index.js +568 -0
  34. node_modules/postgres/cf/src/large.js +70 -0
  35. node_modules/postgres/cf/src/query.js +173 -0
  36. node_modules/postgres/cf/src/queue.js +31 -0
  37. node_modules/postgres/cf/src/result.js +16 -0
  38. node_modules/postgres/cf/src/subscribe.js +278 -0
  39. node_modules/postgres/cf/src/types.js +368 -0
  40. node_modules/postgres/cjs/package.json +1 -0
  41. node_modules/postgres/cjs/src/bytes.js +78 -0
  42. node_modules/postgres/cjs/src/connection.js +1062 -0
  43. node_modules/postgres/cjs/src/errors.js +53 -0
  44. node_modules/postgres/cjs/src/index.js +567 -0
  45. node_modules/postgres/cjs/src/large.js +70 -0
  46. node_modules/postgres/cjs/src/query.js +173 -0
  47. node_modules/postgres/cjs/src/queue.js +31 -0
  48. node_modules/postgres/cjs/src/result.js +16 -0
  49. node_modules/postgres/cjs/src/subscribe.js +277 -0
  50. node_modules/postgres/cjs/src/types.js +367 -0
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ node_modules/@rollup/rollup-win32-x64-msvc/rollup.win32-x64-msvc.node filter=lfs diff=lfs merge=lfs -text
37
+ node_modules/@tailwindcss/oxide-win32-x64-msvc/tailwindcss-oxide.win32-x64-msvc.node filter=lfs diff=lfs merge=lfs -text
38
+ node_modules/lightningcss-win32-x64-msvc/lightningcss.win32-x64-msvc.node filter=lfs diff=lfs merge=lfs -text
artifacts/design-studio/src/pages/clients.tsx CHANGED
@@ -1,7 +1,7 @@
1
  import { useState } from "react";
2
  import { useListClients, useCreateClient, useDeleteClient, getListClientsQueryKey } from "@workspace/api-client-react";
3
  import { useQueryClient } from "@tanstack/react-query";
4
- import { Plus, Building2, Mail, Phone, Trash2, Link } from "lucide-react";
5
  import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
6
  import { Button } from "@/components/ui/button";
7
  import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
@@ -65,7 +65,33 @@ export default function Clients() {
65
  <div className="space-y-2"><Label>الشركة</Label><Input value={formData.company} onChange={e => setFormData({ ...formData, company: e.target.value })} /></div>
66
  <div className="space-y-2"><Label>البريد الإلكتروني</Label><Input type="email" value={formData.email} onChange={e => setFormData({ ...formData, email: e.target.value })} /></div>
67
  <div className="space-y-2"><Label>رقم الهاتف</Label><Input value={formData.phone} onChange={e => setFormData({ ...formData, phone: e.target.value })} /></div>
68
- <div className="space-y-2"><Label>شيت التاسكات</Label><Input type="url" placeholder="رابط شيت الإكسيل..." dir="ltr" value={formData.notes} onChange={e => setFormData({ ...formData, notes: e.target.value })} /></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  </div>
70
  <div className="flex justify-end gap-2">
71
  <Button variant="outline" onClick={() => setIsOpen(false)}>إلغاء</Button>
@@ -116,7 +142,7 @@ export default function Clients() {
116
  )}
117
  {client.notes && (
118
  <div className="flex items-center gap-3 text-muted-foreground">
119
- <Link className="w-4 h-4" />
120
  <a href={client.notes} target="_blank" rel="noopener noreferrer" className="hover:underline truncate" title={client.notes}>
121
  شيت التاسكات
122
  </a>
 
1
  import { useState } from "react";
2
  import { useListClients, useCreateClient, useDeleteClient, getListClientsQueryKey } from "@workspace/api-client-react";
3
  import { useQueryClient } from "@tanstack/react-query";
4
+ import { Plus, Building2, Mail, Phone, Trash2, Link, ExternalLink, Link2 } from "lucide-react";
5
  import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
6
  import { Button } from "@/components/ui/button";
7
  import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
 
65
  <div className="space-y-2"><Label>الشركة</Label><Input value={formData.company} onChange={e => setFormData({ ...formData, company: e.target.value })} /></div>
66
  <div className="space-y-2"><Label>البريد الإلكتروني</Label><Input type="email" value={formData.email} onChange={e => setFormData({ ...formData, email: e.target.value })} /></div>
67
  <div className="space-y-2"><Label>رقم الهاتف</Label><Input value={formData.phone} onChange={e => setFormData({ ...formData, phone: e.target.value })} /></div>
68
+ <div className="space-y-2">
69
+ <Label className="flex items-center gap-2">
70
+ <Link2 className="w-4 h-4 text-muted-foreground" />
71
+ شيت التاسكات
72
+ </Label>
73
+ <div className="flex gap-2">
74
+ <Input
75
+ type="url"
76
+ placeholder="رابط شيت الإكسيل..."
77
+ dir="ltr"
78
+ value={formData.notes}
79
+ onChange={e => setFormData({ ...formData, notes: e.target.value })}
80
+ />
81
+ {formData.notes && (
82
+ <Button
83
+ type="button"
84
+ variant="outline"
85
+ size="icon"
86
+ className="shrink-0"
87
+ onClick={() => window.open(formData.notes, '_blank')}
88
+ title="فتح الرابط"
89
+ >
90
+ <ExternalLink className="w-4 h-4" />
91
+ </Button>
92
+ )}
93
+ </div>
94
+ </div>
95
  </div>
96
  <div className="flex justify-end gap-2">
97
  <Button variant="outline" onClick={() => setIsOpen(false)}>إلغاء</Button>
 
142
  )}
143
  {client.notes && (
144
  <div className="flex items-center gap-3 text-muted-foreground">
145
+ <Link2 className="w-4 h-4" />
146
  <a href={client.notes} target="_blank" rel="noopener noreferrer" className="hover:underline truncate" title={client.notes}>
147
  شيت التاسكات
148
  </a>
artifacts/design-studio/src/pages/dashboard.tsx CHANGED
@@ -11,7 +11,7 @@ import {
11
  getGetDashboardStatsQueryKey,
12
  } from "@workspace/api-client-react";
13
  import { useQueryClient } from "@tanstack/react-query";
14
- import { format, differenceInDays } from "date-fns";
15
  import { ar } from "date-fns/locale";
16
  import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
17
  import { Skeleton } from "@/components/ui/skeleton";
@@ -225,35 +225,39 @@ export default function Dashboard() {
225
  };
226
 
227
  const now = new Date();
228
-
229
- // Tasks from current month
230
- const currentMonthTasks = tasks.filter(t => {
231
- const d = new Date(t.createdAt);
232
- return d.getMonth() === now.getMonth() && d.getFullYear() === now.getFullYear();
233
- });
234
- const currentMonthDoneTasks = doneTasks.filter(t => {
235
- const d = new Date(t.createdAt);
236
- return d.getMonth() === now.getMonth() && d.getFullYear() === now.getFullYear();
237
- });
238
-
239
- // Tasks from previous months
240
- const previousTasks = [
241
- ...tasks.filter(t => {
242
- const d = new Date(t.createdAt);
243
- return d.getMonth() !== now.getMonth() || d.getFullYear() !== now.getFullYear();
244
- }),
245
- ...doneTasks.filter(t => {
246
- const d = new Date(t.createdAt);
247
- return d.getMonth() !== now.getMonth() || d.getFullYear() !== now.getFullYear();
248
- })
249
- ].sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()); // Sort newest first
250
-
251
- const groupedPreviousTasks = previousTasks.reduce((acc, task) => {
252
- const monthYear = format(new Date(task.createdAt), "MMMM yyyy", { locale: ar });
253
- if (!acc[monthYear]) acc[monthYear] = [];
254
- acc[monthYear].push(task);
255
  return acc;
256
- }, {} as Record<string, typeof tasks>);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
  return (
259
  <div className="p-6 md:p-8 lg:p-10 max-w-7xl mx-auto w-full flex-1 overflow-y-auto" dir="rtl">
@@ -280,15 +284,16 @@ export default function Dashboard() {
280
  </CardTitle>
281
  </CardHeader>
282
  <CardContent>
 
283
  {tasksLoading ? (
284
  <div className="space-y-3">
285
  {[1, 2, 3].map((i) => <Skeleton key={i} className="h-12 w-full" />)}
286
  </div>
287
- ) : currentMonthTasks?.length === 0 ? (
288
- <p className="text-sm text-muted-foreground text-center py-6">لا توجد مهام معلقة لهذا الشهر</p>
289
  ) : (
290
- <div className="space-y-2 mb-4">
291
- {currentMonthTasks?.map((task) => (
292
  <div
293
  key={task.id}
294
  data-testid={`task-item-${task.id}`}
@@ -316,6 +321,8 @@ export default function Dashboard() {
316
  ))}
317
  </div>
318
  )}
 
 
319
  <form onSubmit={handleAddTask} className="flex gap-2 mt-2 border-t pt-4">
320
  <Input
321
  placeholder="إضافة مهمة جديدة..."
@@ -341,68 +348,102 @@ export default function Dashboard() {
341
  </Button>
342
  </form>
343
 
344
- {currentMonthDoneTasks.length > 0 && (
345
- <div className="mt-4 space-y-2 border-t pt-4">
346
- {currentMonthDoneTasks.map((task) => (
347
- <div
348
- key={task.id}
349
- data-testid={`task-done-item-${task.id}`}
350
- className="flex items-center gap-3 p-3 rounded-lg border border-border/50 bg-secondary/10 transition-colors opacity-70 group"
351
- >
352
- <Checkbox
353
- data-testid={`task-done-check-${task.id}`}
354
- checked={task.done}
355
- onCheckedChange={(checked) => handleToggleTask(task.id, !!checked)}
356
- className="data-[state=checked]:bg-[#D98A1A] data-[state=checked]:border-[#D98A1A] text-white"
357
- />
358
- <div className="flex-1 min-w-0 flex items-center gap-2">
359
- <p className="text-sm truncate line-through text-muted-foreground">{task.title}</p>
360
- <Check className="w-4 h-4 text-green-500 shrink-0" />
361
- </div>
362
- {getProjectName(task.projectId) && (
363
- <span className="text-xs text-muted-foreground mt-0.5 truncate shrink-0">
364
- {getProjectName(task.projectId)}
365
  </span>
366
- )}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  </div>
368
  ))}
369
  </div>
370
  )}
371
 
372
- {Object.keys(groupedPreviousTasks).length > 0 && (
 
373
  <div className="mt-8 border-t pt-6">
374
- <h3 className="text-sm font-medium text-muted-foreground mb-4">مسودة الشهور السابقة</h3>
375
- <Accordion type="multiple" className="space-y-4">
376
- {Object.entries(groupedPreviousTasks).map(([monthYear, monthTasks]) => (
 
 
377
  <AccordionItem key={monthYear} value={monthYear} className="border rounded-lg px-4 bg-card/50">
378
  <AccordionTrigger className="hover:no-underline py-3">
379
  <div className="flex items-center gap-2">
380
  <span className="font-semibold">{monthYear}</span>
381
  <span className="text-xs text-muted-foreground bg-secondary px-2 py-0.5 rounded-full">
382
- {monthTasks.length} مهام
383
  </span>
384
  </div>
385
  </AccordionTrigger>
386
  <AccordionContent className="pt-2 pb-4 space-y-2 border-t">
387
- {monthTasks.map((task) => (
388
- <div
389
- key={task.id}
390
- className={`flex items-center gap-3 p-3 rounded-lg border transition-colors group ${task.done ? 'border-border/50 bg-secondary/10 opacity-70' : 'bg-card hover:bg-secondary/20'}`}
391
- >
392
- <Checkbox
393
- checked={task.done}
394
- onCheckedChange={(checked) => handleToggleTask(task.id, !!checked)}
395
- className={task.done ? "data-[state=checked]:bg-[#D98A1A] data-[state=checked]:border-[#D98A1A] text-white" : ""}
396
- />
397
- <div className="flex-1 min-w-0 flex items-center gap-2">
398
- <p className={`text-sm truncate ${task.done ? 'line-through text-muted-foreground' : ''}`}>{task.title}</p>
399
- {task.done && <Check className="w-4 h-4 text-green-500 shrink-0" />}
400
- </div>
401
- {getProjectName(task.projectId) && (
402
- <span className={`text-xs truncate shrink-0 ${task.done ? 'text-muted-foreground mt-0.5' : 'text-muted-foreground'}`}>
403
- {task.done ? `(${getProjectName(task.projectId)})` : getProjectName(task.projectId)}
404
- </span>
405
- )}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  </div>
407
  ))}
408
  </AccordionContent>
 
11
  getGetDashboardStatsQueryKey,
12
  } from "@workspace/api-client-react";
13
  import { useQueryClient } from "@tanstack/react-query";
14
+ import { format, differenceInDays, isToday, isYesterday, parseISO, isSameMonth } from "date-fns";
15
  import { ar } from "date-fns/locale";
16
  import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
17
  import { Skeleton } from "@/components/ui/skeleton";
 
225
  };
226
 
227
  const now = new Date();
228
+
229
+ // ── All pending tasks (across all time) ─────────────────────────
230
+ const pendingTasks = tasks; // done: false from API
231
+
232
+ // ── Done tasks: current month grouped by completion day (updatedAt) ──
233
+ const doneThisMonth = doneTasks
234
+ .filter((t) => isSameMonth(new Date(t.updatedAt), now))
235
+ .sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime());
236
+
237
+ const groupedDoneByDay = doneThisMonth.reduce((acc, task) => {
238
+ const dayKey = format(new Date(task.updatedAt), "yyyy-MM-dd");
239
+ if (!acc[dayKey]) acc[dayKey] = [];
240
+ acc[dayKey].push(task);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  return acc;
242
+ }, {} as Record<string, any[]>);
243
+
244
+ const getDayLabel = (dayKey: string) => {
245
+ const d = parseISO(dayKey);
246
+ if (isToday(d)) return `مُنجز اليوم — ${format(d, "d MMMM", { locale: ar })}`;
247
+ if (isYesterday(d)) return `مُنجز أمس — ${format(d, "d MMMM", { locale: ar })}`;
248
+ return `مُنجز ${format(d, "EEEE d MMMM", { locale: ar })}`;
249
+ };
250
+
251
+ // ── Done tasks: previous months — grouped by month of completion (updatedAt) ──
252
+ const groupedPreviousMonthsDone = doneTasks
253
+ .filter((t) => !isSameMonth(new Date(t.updatedAt), now))
254
+ .sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime())
255
+ .reduce((acc, task) => {
256
+ const monthYear = format(new Date(task.updatedAt), "MMMM yyyy", { locale: ar });
257
+ if (!acc[monthYear]) acc[monthYear] = [];
258
+ acc[monthYear].push(task);
259
+ return acc;
260
+ }, {} as Record<string, any[]>);
261
 
262
  return (
263
  <div className="p-6 md:p-8 lg:p-10 max-w-7xl mx-auto w-full flex-1 overflow-y-auto" dir="rtl">
 
284
  </CardTitle>
285
  </CardHeader>
286
  <CardContent>
287
+ {/* ── Pending tasks (all time) ── */}
288
  {tasksLoading ? (
289
  <div className="space-y-3">
290
  {[1, 2, 3].map((i) => <Skeleton key={i} className="h-12 w-full" />)}
291
  </div>
292
+ ) : pendingTasks.length === 0 && doneThisMonth.length === 0 ? (
293
+ <p className="text-sm text-muted-foreground text-center py-6">لا توجد مهام — أضف مهمة جديدة أدناه</p>
294
  ) : (
295
+ <div className="space-y-2 mb-2">
296
+ {pendingTasks.map((task) => (
297
  <div
298
  key={task.id}
299
  data-testid={`task-item-${task.id}`}
 
321
  ))}
322
  </div>
323
  )}
324
+
325
+ {/* ── Add task form ── */}
326
  <form onSubmit={handleAddTask} className="flex gap-2 mt-2 border-t pt-4">
327
  <Input
328
  placeholder="إضافة مهمة جديدة..."
 
348
  </Button>
349
  </form>
350
 
351
+ {/* ── Done tasks — grouped by day (current month) ── */}
352
+ {Object.keys(groupedDoneByDay).length > 0 && (
353
+ <div className="mt-4 space-y-5">
354
+ {(Object.entries(groupedDoneByDay) as [string, any[]][]).map(([dayKey, dayTasks]) => (
355
+ <div key={dayKey}>
356
+ {/* Day header */}
357
+ <div className="flex items-center gap-2 mb-2">
358
+ <div className="h-px flex-1 bg-border" />
359
+ <span className="text-xs font-medium text-muted-foreground px-2 py-0.5 rounded-full bg-secondary/60 shrink-0">
360
+ {getDayLabel(dayKey)}
 
 
 
 
 
 
 
 
 
 
 
361
  </span>
362
+ <div className="h-px flex-1 bg-border" />
363
+ </div>
364
+ {/* Tasks for this day */}
365
+ <div className="space-y-2">
366
+ {(dayTasks as any[]).map((task: any) => (
367
+ <div
368
+ key={task.id}
369
+ data-testid={`task-done-item-${task.id}`}
370
+ className="flex items-center gap-3 p-3 rounded-lg border border-border/50 bg-secondary/10 opacity-75 hover:opacity-100 transition-opacity group"
371
+ >
372
+ <Checkbox
373
+ data-testid={`task-done-check-${task.id}`}
374
+ checked={task.done}
375
+ onCheckedChange={(checked) => handleToggleTask(task.id, !!checked)}
376
+ className="data-[state=checked]:bg-[#D98A1A] data-[state=checked]:border-[#D98A1A] text-white"
377
+ />
378
+ <div className="flex-1 min-w-0 flex items-center gap-2">
379
+ <p className="text-sm truncate line-through text-muted-foreground">{task.title}</p>
380
+ <Check className="w-4 h-4 text-green-500 shrink-0" />
381
+ </div>
382
+ {getProjectName(task.projectId) && (
383
+ <span className="text-xs text-muted-foreground truncate shrink-0">
384
+ {getProjectName(task.projectId)}
385
+ </span>
386
+ )}
387
+ </div>
388
+ ))}
389
+ </div>
390
  </div>
391
  ))}
392
  </div>
393
  )}
394
 
395
+ {/* ── Monthly drafts — previous months (done tasks only) ── */}
396
+ {Object.keys(groupedPreviousMonthsDone).length > 0 && (
397
  <div className="mt-8 border-t pt-6">
398
+ <h3 className="text-sm font-semibold text-muted-foreground mb-4 flex items-center gap-2">
399
+ <span className="text-base">📋</span> مسودات الشهور السابقة
400
+ </h3>
401
+ <Accordion type="multiple" className="space-y-3">
402
+ {(Object.entries(groupedPreviousMonthsDone) as [string, any[]][]).map(([monthYear, monthTasks]) => (
403
  <AccordionItem key={monthYear} value={monthYear} className="border rounded-lg px-4 bg-card/50">
404
  <AccordionTrigger className="hover:no-underline py-3">
405
  <div className="flex items-center gap-2">
406
  <span className="font-semibold">{monthYear}</span>
407
  <span className="text-xs text-muted-foreground bg-secondary px-2 py-0.5 rounded-full">
408
+ {monthTasks.length} مهام منجزة
409
  </span>
410
  </div>
411
  </AccordionTrigger>
412
  <AccordionContent className="pt-2 pb-4 space-y-2 border-t">
413
+ {/* Group by day within month */}
414
+ {Object.entries(
415
+ (monthTasks as any[]).reduce((acc: Record<string, any[]>, t: any) => {
416
+ const dk = format(new Date(t.updatedAt), "yyyy-MM-dd");
417
+ if (!acc[dk]) acc[dk] = [];
418
+ acc[dk].push(t);
419
+ return acc;
420
+ }, {} as Record<string, any[]>)
421
+ ).map(([dk, dayItems]) => (
422
+ <div key={dk}>
423
+ <p className="text-xs text-muted-foreground mb-1.5 mt-2">
424
+ {format(parseISO(dk), "EEEE d MMMM", { locale: ar })}
425
+ </p>
426
+ {(dayItems as any[]).map((task: any) => (
427
+ <div
428
+ key={task.id}
429
+ className="flex items-center gap-3 p-3 rounded-lg border border-border/50 bg-secondary/10 opacity-70 mb-1.5"
430
+ >
431
+ <Checkbox
432
+ checked={task.done}
433
+ onCheckedChange={(checked) => handleToggleTask(task.id, !!checked)}
434
+ className="data-[state=checked]:bg-[#D98A1A] data-[state=checked]:border-[#D98A1A] text-white"
435
+ />
436
+ <div className="flex-1 min-w-0 flex items-center gap-2">
437
+ <p className="text-sm truncate line-through text-muted-foreground">{task.title}</p>
438
+ <Check className="w-4 h-4 text-green-500 shrink-0" />
439
+ </div>
440
+ {getProjectName(task.projectId) && (
441
+ <span className="text-xs text-muted-foreground truncate shrink-0">
442
+ ({getProjectName(task.projectId)})
443
+ </span>
444
+ )}
445
+ </div>
446
+ ))}
447
  </div>
448
  ))}
449
  </AccordionContent>
backups/local_20260510_155124.db ADDED
Binary file (36.9 kB). View file
 
node_modules/.bin/prettier ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/prettier@3.8.3/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/prettier@3.8.3/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../prettier/bin/prettier.cjs" "$@"
19
+ else
20
+ exec node "$basedir/../prettier/bin/prettier.cjs" "$@"
21
+ fi
22
+ # cmd-shim-target=D:/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/prettier/bin/prettier.cjs
node_modules/.bin/prettier.CMD ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @SETLOCAL
2
+ @IF NOT DEFINED NODE_PATH (
3
+ @SET "NODE_PATH=D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\prettier@3.8.3\node_modules\prettier\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\prettier@3.8.3\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\node_modules"
4
+ ) ELSE (
5
+ @SET "NODE_PATH=D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\prettier@3.8.3\node_modules\prettier\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\prettier@3.8.3\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\node_modules;%NODE_PATH%"
6
+ )
7
+ @IF EXIST "%~dp0\node.exe" (
8
+ "%~dp0\node.exe" "%~dp0\..\prettier\bin\prettier.cjs" %*
9
+ ) ELSE (
10
+ @SET PATHEXT=%PATHEXT:;.JS;=;%
11
+ node "%~dp0\..\prettier\bin\prettier.cjs" %*
12
+ )
node_modules/.bin/prettier.ps1 ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env pwsh
2
+ $basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+ $exe=""
5
+ $pathsep=":"
6
+ $env_node_path=$env:NODE_PATH
7
+ $new_node_path="D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\prettier@3.8.3\node_modules\prettier\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\prettier@3.8.3\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\node_modules"
8
+ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
9
+ # Fix case when both the Windows and Linux builds of Node
10
+ # are installed in the same directory
11
+ $exe=".exe"
12
+ $pathsep=";"
13
+ } else {
14
+ $new_node_path="/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/prettier@3.8.3/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/node_modules"
15
+ }
16
+ if ([string]::IsNullOrEmpty($env_node_path)) {
17
+ $env:NODE_PATH=$new_node_path
18
+ } else {
19
+ $env:NODE_PATH="$new_node_path$pathsep$env_node_path"
20
+ }
21
+
22
+ $ret=0
23
+ if (Test-Path "$basedir/node$exe") {
24
+ # Support pipeline input
25
+ if ($MyInvocation.ExpectingInput) {
26
+ $input | & "$basedir/node$exe" "$basedir/../prettier/bin/prettier.cjs" $args
27
+ } else {
28
+ & "$basedir/node$exe" "$basedir/../prettier/bin/prettier.cjs" $args
29
+ }
30
+ $ret=$LASTEXITCODE
31
+ } else {
32
+ # Support pipeline input
33
+ if ($MyInvocation.ExpectingInput) {
34
+ $input | & "node$exe" "$basedir/../prettier/bin/prettier.cjs" $args
35
+ } else {
36
+ & "node$exe" "$basedir/../prettier/bin/prettier.cjs" $args
37
+ }
38
+ $ret=$LASTEXITCODE
39
+ }
40
+ $env:NODE_PATH=$env_node_path
41
+ exit $ret
node_modules/.bin/tsc ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsc" "$@"
21
+ fi
22
+ # cmd-shim-target=D:/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/typescript/bin/tsc
node_modules/.bin/tsc.CMD ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @SETLOCAL
2
+ @IF NOT DEFINED NODE_PATH (
3
+ @SET "NODE_PATH=D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\node_modules"
4
+ ) ELSE (
5
+ @SET "NODE_PATH=D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\node_modules;%NODE_PATH%"
6
+ )
7
+ @IF EXIST "%~dp0\node.exe" (
8
+ "%~dp0\node.exe" "%~dp0\..\typescript\bin\tsc" %*
9
+ ) ELSE (
10
+ @SET PATHEXT=%PATHEXT:;.JS;=;%
11
+ node "%~dp0\..\typescript\bin\tsc" %*
12
+ )
node_modules/.bin/tsc.ps1 ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env pwsh
2
+ $basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+ $exe=""
5
+ $pathsep=":"
6
+ $env_node_path=$env:NODE_PATH
7
+ $new_node_path="D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\node_modules"
8
+ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
9
+ # Fix case when both the Windows and Linux builds of Node
10
+ # are installed in the same directory
11
+ $exe=".exe"
12
+ $pathsep=";"
13
+ } else {
14
+ $new_node_path="/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/node_modules"
15
+ }
16
+ if ([string]::IsNullOrEmpty($env_node_path)) {
17
+ $env:NODE_PATH=$new_node_path
18
+ } else {
19
+ $env:NODE_PATH="$new_node_path$pathsep$env_node_path"
20
+ }
21
+
22
+ $ret=0
23
+ if (Test-Path "$basedir/node$exe") {
24
+ # Support pipeline input
25
+ if ($MyInvocation.ExpectingInput) {
26
+ $input | & "$basedir/node$exe" "$basedir/../typescript/bin/tsc" $args
27
+ } else {
28
+ & "$basedir/node$exe" "$basedir/../typescript/bin/tsc" $args
29
+ }
30
+ $ret=$LASTEXITCODE
31
+ } else {
32
+ # Support pipeline input
33
+ if ($MyInvocation.ExpectingInput) {
34
+ $input | & "node$exe" "$basedir/../typescript/bin/tsc" $args
35
+ } else {
36
+ & "node$exe" "$basedir/../typescript/bin/tsc" $args
37
+ }
38
+ $ret=$LASTEXITCODE
39
+ }
40
+ $env:NODE_PATH=$env_node_path
41
+ exit $ret
node_modules/.bin/tsserver ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsserver" "$@"
21
+ fi
22
+ # cmd-shim-target=D:/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/typescript/bin/tsserver
node_modules/.bin/tsserver.CMD ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @SETLOCAL
2
+ @IF NOT DEFINED NODE_PATH (
3
+ @SET "NODE_PATH=D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\node_modules"
4
+ ) ELSE (
5
+ @SET "NODE_PATH=D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\node_modules;%NODE_PATH%"
6
+ )
7
+ @IF EXIST "%~dp0\node.exe" (
8
+ "%~dp0\node.exe" "%~dp0\..\typescript\bin\tsserver" %*
9
+ ) ELSE (
10
+ @SET PATHEXT=%PATHEXT:;.JS;=;%
11
+ node "%~dp0\..\typescript\bin\tsserver" %*
12
+ )
node_modules/.bin/tsserver.ps1 ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env pwsh
2
+ $basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+ $exe=""
5
+ $pathsep=":"
6
+ $env_node_path=$env:NODE_PATH
7
+ $new_node_path="D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\typescript@5.9.3\node_modules;D:\design-studio-latest (3)\design-studio-latest\design-studio-latest\node_modules\.pnpm\node_modules"
8
+ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
9
+ # Fix case when both the Windows and Linux builds of Node
10
+ # are installed in the same directory
11
+ $exe=".exe"
12
+ $pathsep=";"
13
+ } else {
14
+ $new_node_path="/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/typescript@5.9.3/node_modules:/mnt/d/design-studio-latest (3)/design-studio-latest/design-studio-latest/node_modules/.pnpm/node_modules"
15
+ }
16
+ if ([string]::IsNullOrEmpty($env_node_path)) {
17
+ $env:NODE_PATH=$new_node_path
18
+ } else {
19
+ $env:NODE_PATH="$new_node_path$pathsep$env_node_path"
20
+ }
21
+
22
+ $ret=0
23
+ if (Test-Path "$basedir/node$exe") {
24
+ # Support pipeline input
25
+ if ($MyInvocation.ExpectingInput) {
26
+ $input | & "$basedir/node$exe" "$basedir/../typescript/bin/tsserver" $args
27
+ } else {
28
+ & "$basedir/node$exe" "$basedir/../typescript/bin/tsserver" $args
29
+ }
30
+ $ret=$LASTEXITCODE
31
+ } else {
32
+ # Support pipeline input
33
+ if ($MyInvocation.ExpectingInput) {
34
+ $input | & "node$exe" "$basedir/../typescript/bin/tsserver" $args
35
+ } else {
36
+ & "node$exe" "$basedir/../typescript/bin/tsserver" $args
37
+ }
38
+ $ret=$LASTEXITCODE
39
+ }
40
+ $env:NODE_PATH=$env_node_path
41
+ exit $ret
node_modules/.modules.yaml ADDED
@@ -0,0 +1,1478 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "hoistedDependencies": {
3
+ "@types/cookie-parser@1.4.10(@types/express@5.0.6)": {
4
+ "@types/cookie-parser": "private"
5
+ },
6
+ "@types/cors@2.8.19": {
7
+ "@types/cors": "private"
8
+ },
9
+ "@types/express@5.0.6": {
10
+ "@types/express": "private"
11
+ },
12
+ "@types/node@25.6.0": {
13
+ "@types/node": "private"
14
+ },
15
+ "esbuild@0.27.3": {
16
+ "esbuild": "private"
17
+ },
18
+ "esbuild-plugin-pino@2.3.3(esbuild@0.27.3)(pino-pretty@13.1.3)(pino@9.14.0)(thread-stream@3.1.0)": {
19
+ "esbuild-plugin-pino": "private"
20
+ },
21
+ "pino-pretty@13.1.3": {
22
+ "pino-pretty": "private"
23
+ },
24
+ "thread-stream@3.1.0": {
25
+ "thread-stream": "private"
26
+ },
27
+ "@libsql/client@0.17.3": {
28
+ "@libsql/client": "private"
29
+ },
30
+ "cookie-parser@1.4.7": {
31
+ "cookie-parser": "private"
32
+ },
33
+ "cors@2.8.6": {
34
+ "cors": "private"
35
+ },
36
+ "express@5.2.1": {
37
+ "express": "private"
38
+ },
39
+ "pino@9.14.0": {
40
+ "pino": "private"
41
+ },
42
+ "pino-http@10.5.0": {
43
+ "pino-http": "private"
44
+ },
45
+ "@dnd-kit/core@6.3.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
46
+ "@dnd-kit/core": "private"
47
+ },
48
+ "@dnd-kit/sortable@10.0.0(@dnd-kit/core@6.3.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react@19.1.0)": {
49
+ "@dnd-kit/sortable": "private"
50
+ },
51
+ "@dnd-kit/utilities@3.2.2(react@19.1.0)": {
52
+ "@dnd-kit/utilities": "private"
53
+ },
54
+ "@hookform/resolvers@3.10.0(react-hook-form@7.75.0(react@19.1.0))": {
55
+ "@hookform/resolvers": "private"
56
+ },
57
+ "@radix-ui/react-accordion@1.2.12(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
58
+ "@radix-ui/react-accordion": "private"
59
+ },
60
+ "@radix-ui/react-alert-dialog@1.1.15(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
61
+ "@radix-ui/react-alert-dialog": "private"
62
+ },
63
+ "@radix-ui/react-aspect-ratio@1.1.8(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
64
+ "@radix-ui/react-aspect-ratio": "private"
65
+ },
66
+ "@radix-ui/react-avatar@1.1.11(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
67
+ "@radix-ui/react-avatar": "private"
68
+ },
69
+ "@radix-ui/react-checkbox@1.3.3(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
70
+ "@radix-ui/react-checkbox": "private"
71
+ },
72
+ "@radix-ui/react-collapsible@1.1.12(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
73
+ "@radix-ui/react-collapsible": "private"
74
+ },
75
+ "@radix-ui/react-context-menu@2.2.16(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
76
+ "@radix-ui/react-context-menu": "private"
77
+ },
78
+ "@radix-ui/react-dialog@1.1.15(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
79
+ "@radix-ui/react-dialog": "private"
80
+ },
81
+ "@radix-ui/react-dropdown-menu@2.1.16(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
82
+ "@radix-ui/react-dropdown-menu": "private"
83
+ },
84
+ "@radix-ui/react-hover-card@1.1.15(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
85
+ "@radix-ui/react-hover-card": "private"
86
+ },
87
+ "@radix-ui/react-label@2.1.8(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
88
+ "@radix-ui/react-label": "private"
89
+ },
90
+ "@radix-ui/react-menubar@1.1.16(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
91
+ "@radix-ui/react-menubar": "private"
92
+ },
93
+ "@radix-ui/react-navigation-menu@1.2.14(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
94
+ "@radix-ui/react-navigation-menu": "private"
95
+ },
96
+ "@radix-ui/react-popover@1.1.15(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
97
+ "@radix-ui/react-popover": "private"
98
+ },
99
+ "@radix-ui/react-progress@1.1.8(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
100
+ "@radix-ui/react-progress": "private"
101
+ },
102
+ "@radix-ui/react-radio-group@1.3.8(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
103
+ "@radix-ui/react-radio-group": "private"
104
+ },
105
+ "@radix-ui/react-scroll-area@1.2.10(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
106
+ "@radix-ui/react-scroll-area": "private"
107
+ },
108
+ "@radix-ui/react-select@2.2.6(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
109
+ "@radix-ui/react-select": "private"
110
+ },
111
+ "@radix-ui/react-separator@1.1.8(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
112
+ "@radix-ui/react-separator": "private"
113
+ },
114
+ "@radix-ui/react-slider@1.3.6(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
115
+ "@radix-ui/react-slider": "private"
116
+ },
117
+ "@radix-ui/react-slot@1.2.4(@types/react@19.2.14)(react@19.1.0)": {
118
+ "@radix-ui/react-slot": "private"
119
+ },
120
+ "@radix-ui/react-switch@1.2.6(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
121
+ "@radix-ui/react-switch": "private"
122
+ },
123
+ "@radix-ui/react-tabs@1.1.13(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
124
+ "@radix-ui/react-tabs": "private"
125
+ },
126
+ "@radix-ui/react-toast@1.2.15(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
127
+ "@radix-ui/react-toast": "private"
128
+ },
129
+ "@radix-ui/react-toggle@1.1.10(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
130
+ "@radix-ui/react-toggle": "private"
131
+ },
132
+ "@radix-ui/react-toggle-group@1.1.11(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
133
+ "@radix-ui/react-toggle-group": "private"
134
+ },
135
+ "@radix-ui/react-tooltip@1.2.8(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
136
+ "@radix-ui/react-tooltip": "private"
137
+ },
138
+ "@replit/vite-plugin-cartographer@0.5.5": {
139
+ "@replit/vite-plugin-cartographer": "private"
140
+ },
141
+ "@replit/vite-plugin-dev-banner@0.1.2": {
142
+ "@replit/vite-plugin-dev-banner": "private"
143
+ },
144
+ "@replit/vite-plugin-runtime-error-modal@0.0.6": {
145
+ "@replit/vite-plugin-runtime-error-modal": "private"
146
+ },
147
+ "@tailwindcss/typography@0.5.19(tailwindcss@4.2.4)": {
148
+ "@tailwindcss/typography": "private"
149
+ },
150
+ "@tailwindcss/vite@4.2.4(vite@7.3.2(@types/node@25.6.0)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.21.0)(yaml@2.8.4))": {
151
+ "@tailwindcss/vite": "private"
152
+ },
153
+ "@tanstack/react-query@5.100.9(react@19.1.0)": {
154
+ "@tanstack/react-query": "private"
155
+ },
156
+ "@types/react@19.2.14": {
157
+ "@types/react": "private"
158
+ },
159
+ "@types/react-dom@19.2.3(@types/react@19.2.14)": {
160
+ "@types/react-dom": "private"
161
+ },
162
+ "@vitejs/plugin-react@5.2.0(vite@7.3.2(@types/node@25.6.0)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.21.0)(yaml@2.8.4))": {
163
+ "@vitejs/plugin-react": "private"
164
+ },
165
+ "class-variance-authority@0.7.1": {
166
+ "class-variance-authority": "private"
167
+ },
168
+ "clsx@2.1.1": {
169
+ "clsx": "private"
170
+ },
171
+ "cmdk@1.1.1(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
172
+ "cmdk": "private"
173
+ },
174
+ "date-fns@3.6.0": {
175
+ "date-fns": "private"
176
+ },
177
+ "embla-carousel-react@8.6.0(react@19.1.0)": {
178
+ "embla-carousel-react": "private"
179
+ },
180
+ "framer-motion@12.38.0(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
181
+ "framer-motion": "private"
182
+ },
183
+ "input-otp@1.4.2(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
184
+ "input-otp": "private"
185
+ },
186
+ "lucide-react@0.545.0(react@19.1.0)": {
187
+ "lucide-react": "private"
188
+ },
189
+ "next-themes@0.4.6(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
190
+ "next-themes": "private"
191
+ },
192
+ "react@19.1.0": {
193
+ "react": "private"
194
+ },
195
+ "react-day-picker@9.14.0(react@19.1.0)": {
196
+ "react-day-picker": "private"
197
+ },
198
+ "react-dom@19.1.0(react@19.1.0)": {
199
+ "react-dom": "private"
200
+ },
201
+ "react-hook-form@7.75.0(react@19.1.0)": {
202
+ "react-hook-form": "private"
203
+ },
204
+ "react-icons@5.6.0(react@19.1.0)": {
205
+ "react-icons": "private"
206
+ },
207
+ "react-resizable-panels@2.1.9(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
208
+ "react-resizable-panels": "private"
209
+ },
210
+ "recharts@2.15.4(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
211
+ "recharts": "private"
212
+ },
213
+ "sonner@2.0.7(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
214
+ "sonner": "private"
215
+ },
216
+ "tailwind-merge@3.5.0": {
217
+ "tailwind-merge": "private"
218
+ },
219
+ "tailwindcss@4.2.4": {
220
+ "tailwindcss": "private"
221
+ },
222
+ "tw-animate-css@1.4.0": {
223
+ "tw-animate-css": "private"
224
+ },
225
+ "vaul@1.1.2(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
226
+ "vaul": "private"
227
+ },
228
+ "vite@7.3.2(@types/node@25.6.0)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.21.0)(yaml@2.8.4)": {
229
+ "vite": "private"
230
+ },
231
+ "wouter@3.9.0(react@19.1.0)": {
232
+ "wouter": "private"
233
+ },
234
+ "zod@3.25.76": {
235
+ "zod": "private"
236
+ },
237
+ "chokidar@4.0.3": {
238
+ "chokidar": "private"
239
+ },
240
+ "fast-glob@3.3.3": {
241
+ "fast-glob": "private"
242
+ },
243
+ "tailwindcss-animate@1.0.7(tailwindcss@4.2.4)": {
244
+ "tailwindcss-animate": "private"
245
+ },
246
+ "orval@8.9.1(prettier@3.8.3)(typescript@5.9.3)": {
247
+ "orval": "private"
248
+ },
249
+ "drizzle-kit@0.31.10": {
250
+ "drizzle-kit": "private"
251
+ },
252
+ "tsx@4.21.0": {
253
+ "tsx": "private",
254
+ "@esbuild-kit/esm-loader": "private"
255
+ },
256
+ "@dnd-kit/accessibility@3.1.1(react@19.1.0)": {
257
+ "@dnd-kit/accessibility": "private"
258
+ },
259
+ "tslib@2.8.1": {
260
+ "tslib": "private"
261
+ },
262
+ "@libsql/core@0.17.3": {
263
+ "@libsql/core": "private"
264
+ },
265
+ "@libsql/hrana-client@0.10.0": {
266
+ "@libsql/hrana-client": "private"
267
+ },
268
+ "js-base64@3.7.8": {
269
+ "js-base64": "private"
270
+ },
271
+ "libsql@0.5.29": {
272
+ "libsql": "private"
273
+ },
274
+ "promise-limit@2.7.0": {
275
+ "promise-limit": "private"
276
+ },
277
+ "@radix-ui/primitive@1.1.3": {
278
+ "@radix-ui/primitive": "private"
279
+ },
280
+ "@radix-ui/react-collection@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
281
+ "@radix-ui/react-collection": "private"
282
+ },
283
+ "@radix-ui/react-compose-refs@1.1.2(@types/react@19.2.14)(react@19.1.0)": {
284
+ "@radix-ui/react-compose-refs": "private"
285
+ },
286
+ "@radix-ui/react-context@1.1.2(@types/react@19.2.14)(react@19.1.0)": {
287
+ "@radix-ui/react-context": "private"
288
+ },
289
+ "@radix-ui/react-direction@1.1.1(@types/react@19.2.14)(react@19.1.0)": {
290
+ "@radix-ui/react-direction": "private"
291
+ },
292
+ "@radix-ui/react-id@1.1.1(@types/react@19.2.14)(react@19.1.0)": {
293
+ "@radix-ui/react-id": "private"
294
+ },
295
+ "@radix-ui/react-primitive@2.1.3(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
296
+ "@radix-ui/react-primitive": "private"
297
+ },
298
+ "@radix-ui/react-use-controllable-state@1.2.2(@types/react@19.2.14)(react@19.1.0)": {
299
+ "@radix-ui/react-use-controllable-state": "private"
300
+ },
301
+ "@radix-ui/react-use-callback-ref@1.1.1(@types/react@19.2.14)(react@19.1.0)": {
302
+ "@radix-ui/react-use-callback-ref": "private"
303
+ },
304
+ "@radix-ui/react-use-is-hydrated@0.1.0(@types/react@19.2.14)(react@19.1.0)": {
305
+ "@radix-ui/react-use-is-hydrated": "private"
306
+ },
307
+ "@radix-ui/react-use-layout-effect@1.1.1(@types/react@19.2.14)(react@19.1.0)": {
308
+ "@radix-ui/react-use-layout-effect": "private"
309
+ },
310
+ "@radix-ui/react-presence@1.1.5(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
311
+ "@radix-ui/react-presence": "private"
312
+ },
313
+ "@radix-ui/react-use-previous@1.1.1(@types/react@19.2.14)(react@19.1.0)": {
314
+ "@radix-ui/react-use-previous": "private"
315
+ },
316
+ "@radix-ui/react-use-size@1.1.1(@types/react@19.2.14)(react@19.1.0)": {
317
+ "@radix-ui/react-use-size": "private"
318
+ },
319
+ "@radix-ui/react-menu@2.1.16(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
320
+ "@radix-ui/react-menu": "private"
321
+ },
322
+ "@radix-ui/react-dismissable-layer@1.1.11(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
323
+ "@radix-ui/react-dismissable-layer": "private"
324
+ },
325
+ "@radix-ui/react-focus-guards@1.1.3(@types/react@19.2.14)(react@19.1.0)": {
326
+ "@radix-ui/react-focus-guards": "private"
327
+ },
328
+ "@radix-ui/react-focus-scope@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
329
+ "@radix-ui/react-focus-scope": "private"
330
+ },
331
+ "@radix-ui/react-portal@1.1.9(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
332
+ "@radix-ui/react-portal": "private"
333
+ },
334
+ "aria-hidden@1.2.6": {
335
+ "aria-hidden": "private"
336
+ },
337
+ "react-remove-scroll@2.7.2(@types/react@19.2.14)(react@19.1.0)": {
338
+ "react-remove-scroll": "private"
339
+ },
340
+ "@radix-ui/react-popper@1.2.8(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
341
+ "@radix-ui/react-popper": "private"
342
+ },
343
+ "@radix-ui/react-roving-focus@1.1.11(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
344
+ "@radix-ui/react-roving-focus": "private"
345
+ },
346
+ "@radix-ui/react-visually-hidden@1.2.3(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
347
+ "@radix-ui/react-visually-hidden": "private"
348
+ },
349
+ "@radix-ui/number@1.1.1": {
350
+ "@radix-ui/number": "private"
351
+ },
352
+ "@babel/parser@7.29.3": {
353
+ "@babel/parser": "private"
354
+ },
355
+ "@babel/traverse@7.29.0": {
356
+ "@babel/traverse": "private"
357
+ },
358
+ "@babel/types@7.29.0": {
359
+ "@babel/types": "private"
360
+ },
361
+ "magic-string@0.30.21": {
362
+ "magic-string": "private"
363
+ },
364
+ "modern-screenshot@4.7.0": {
365
+ "modern-screenshot": "private"
366
+ },
367
+ "@jridgewell/trace-mapping@0.3.31": {
368
+ "@jridgewell/trace-mapping": "private"
369
+ },
370
+ "postcss-selector-parser@6.0.10": {
371
+ "postcss-selector-parser": "private"
372
+ },
373
+ "@tailwindcss/node@4.2.4": {
374
+ "@tailwindcss/node": "private"
375
+ },
376
+ "@tailwindcss/oxide@4.2.4": {
377
+ "@tailwindcss/oxide": "private"
378
+ },
379
+ "@tanstack/query-core@5.100.9": {
380
+ "@tanstack/query-core": "private"
381
+ },
382
+ "@types/body-parser@1.19.6": {
383
+ "@types/body-parser": "private"
384
+ },
385
+ "@types/express-serve-static-core@5.1.1": {
386
+ "@types/express-serve-static-core": "private"
387
+ },
388
+ "@types/serve-static@2.2.0": {
389
+ "@types/serve-static": "private"
390
+ },
391
+ "undici-types@7.19.2": {
392
+ "undici-types": "private"
393
+ },
394
+ "csstype@3.2.3": {
395
+ "csstype": "private"
396
+ },
397
+ "@babel/core@7.29.0": {
398
+ "@babel/core": "private"
399
+ },
400
+ "@babel/plugin-transform-react-jsx-self@7.27.1(@babel/core@7.29.0)": {
401
+ "@babel/plugin-transform-react-jsx-self": "private"
402
+ },
403
+ "@babel/plugin-transform-react-jsx-source@7.27.1(@babel/core@7.29.0)": {
404
+ "@babel/plugin-transform-react-jsx-source": "private"
405
+ },
406
+ "@rolldown/pluginutils@1.0.0-rc.3": {
407
+ "@rolldown/pluginutils": "private"
408
+ },
409
+ "@types/babel__core@7.20.5": {
410
+ "@types/babel__core": "private"
411
+ },
412
+ "react-refresh@0.18.0": {
413
+ "react-refresh": "private"
414
+ },
415
+ "readdirp@4.1.2": {
416
+ "readdirp": "private"
417
+ },
418
+ "cookie@0.7.2": {
419
+ "cookie": "private"
420
+ },
421
+ "cookie-signature@1.0.6": {
422
+ "cookie-signature": "private"
423
+ },
424
+ "object-assign@4.1.1": {
425
+ "object-assign": "private"
426
+ },
427
+ "vary@1.1.2": {
428
+ "vary": "private"
429
+ },
430
+ "@drizzle-team/brocli@0.10.2": {
431
+ "@drizzle-team/brocli": "private"
432
+ },
433
+ "embla-carousel@8.6.0": {
434
+ "embla-carousel": "private"
435
+ },
436
+ "embla-carousel-reactive-utils@8.6.0(embla-carousel@8.6.0)": {
437
+ "embla-carousel-reactive-utils": "private"
438
+ },
439
+ "accepts@2.0.0": {
440
+ "accepts": "private"
441
+ },
442
+ "body-parser@2.2.2": {
443
+ "body-parser": "private"
444
+ },
445
+ "content-disposition@1.1.0": {
446
+ "content-disposition": "private"
447
+ },
448
+ "content-type@1.0.5": {
449
+ "content-type": "private"
450
+ },
451
+ "debug@4.4.3": {
452
+ "debug": "private"
453
+ },
454
+ "depd@2.0.0": {
455
+ "depd": "private"
456
+ },
457
+ "encodeurl@2.0.0": {
458
+ "encodeurl": "private"
459
+ },
460
+ "escape-html@1.0.3": {
461
+ "escape-html": "private"
462
+ },
463
+ "etag@1.8.1": {
464
+ "etag": "private"
465
+ },
466
+ "finalhandler@2.1.1": {
467
+ "finalhandler": "private"
468
+ },
469
+ "fresh@2.0.0": {
470
+ "fresh": "private"
471
+ },
472
+ "http-errors@2.0.1": {
473
+ "http-errors": "private"
474
+ },
475
+ "merge-descriptors@2.0.0": {
476
+ "merge-descriptors": "private"
477
+ },
478
+ "mime-types@3.0.2": {
479
+ "mime-types": "private"
480
+ },
481
+ "on-finished@2.4.1": {
482
+ "on-finished": "private"
483
+ },
484
+ "once@1.4.0": {
485
+ "once": "private"
486
+ },
487
+ "parseurl@1.3.3": {
488
+ "parseurl": "private"
489
+ },
490
+ "proxy-addr@2.0.7": {
491
+ "proxy-addr": "private"
492
+ },
493
+ "qs@6.15.1": {
494
+ "qs": "private"
495
+ },
496
+ "range-parser@1.2.1": {
497
+ "range-parser": "private"
498
+ },
499
+ "router@2.2.0": {
500
+ "router": "private"
501
+ },
502
+ "send@1.2.1": {
503
+ "send": "private"
504
+ },
505
+ "serve-static@2.2.1": {
506
+ "serve-static": "private"
507
+ },
508
+ "statuses@2.0.2": {
509
+ "statuses": "private"
510
+ },
511
+ "type-is@2.0.1": {
512
+ "type-is": "private"
513
+ },
514
+ "@nodelib/fs.stat@2.0.5": {
515
+ "@nodelib/fs.stat": "private"
516
+ },
517
+ "@nodelib/fs.walk@1.2.8": {
518
+ "@nodelib/fs.walk": "private"
519
+ },
520
+ "glob-parent@5.1.2": {
521
+ "glob-parent": "private"
522
+ },
523
+ "merge2@1.4.1": {
524
+ "merge2": "private"
525
+ },
526
+ "micromatch@4.0.8": {
527
+ "micromatch": "private"
528
+ },
529
+ "motion-dom@12.38.0": {
530
+ "motion-dom": "private"
531
+ },
532
+ "motion-utils@12.36.0": {
533
+ "motion-utils": "private"
534
+ },
535
+ "@commander-js/extra-typings@14.0.0(commander@14.0.3)": {
536
+ "@commander-js/extra-typings": "private"
537
+ },
538
+ "@orval/angular@8.9.1(typescript@5.9.3)": {
539
+ "@orval/angular": "private"
540
+ },
541
+ "@orval/axios@8.9.1(typescript@5.9.3)": {
542
+ "@orval/axios": "private"
543
+ },
544
+ "@orval/core@8.9.1(typescript@5.9.3)": {
545
+ "@orval/core": "private"
546
+ },
547
+ "@orval/fetch@8.9.1(typescript@5.9.3)": {
548
+ "@orval/fetch": "private"
549
+ },
550
+ "@orval/hono@8.9.1(typescript@5.9.3)": {
551
+ "@orval/hono": "private"
552
+ },
553
+ "@orval/mcp@8.9.1(typescript@5.9.3)": {
554
+ "@orval/mcp": "private"
555
+ },
556
+ "@orval/mock@8.9.1(typescript@5.9.3)": {
557
+ "@orval/mock": "private"
558
+ },
559
+ "@orval/query@8.9.1(typescript@5.9.3)": {
560
+ "@orval/query": "private"
561
+ },
562
+ "@orval/solid-start@8.9.1(typescript@5.9.3)": {
563
+ "@orval/solid-start": "private"
564
+ },
565
+ "@orval/swr@8.9.1(typescript@5.9.3)": {
566
+ "@orval/swr": "private"
567
+ },
568
+ "@orval/zod@8.9.1(typescript@5.9.3)": {
569
+ "@orval/zod": "private"
570
+ },
571
+ "@scalar/json-magic@0.12.12": {
572
+ "@scalar/json-magic": "private"
573
+ },
574
+ "@scalar/openapi-parser@0.25.12": {
575
+ "@scalar/openapi-parser": "private"
576
+ },
577
+ "@scalar/openapi-types@0.8.0": {
578
+ "@scalar/openapi-types": "private"
579
+ },
580
+ "commander@14.0.3": {
581
+ "commander": "private"
582
+ },
583
+ "enquirer@2.4.1": {
584
+ "enquirer": "private"
585
+ },
586
+ "execa@9.6.1": {
587
+ "execa": "private"
588
+ },
589
+ "find-up@8.0.0": {
590
+ "find-up": "private"
591
+ },
592
+ "fs-extra@11.3.5": {
593
+ "fs-extra": "private"
594
+ },
595
+ "jiti@2.7.0": {
596
+ "jiti": "private"
597
+ },
598
+ "js-yaml@4.1.1": {
599
+ "js-yaml": "private"
600
+ },
601
+ "remeda@2.34.0": {
602
+ "remeda": "private"
603
+ },
604
+ "string-argv@0.3.2": {
605
+ "string-argv": "private"
606
+ },
607
+ "tsconfck@3.1.6(typescript@5.9.3)": {
608
+ "tsconfck": "private"
609
+ },
610
+ "typedoc@0.28.19(typescript@5.9.3)": {
611
+ "typedoc": "private"
612
+ },
613
+ "typedoc-plugin-coverage@4.0.3(typedoc@0.28.19(typescript@5.9.3))": {
614
+ "typedoc-plugin-coverage": "private"
615
+ },
616
+ "typedoc-plugin-markdown@4.11.0(typedoc@0.28.19(typescript@5.9.3))": {
617
+ "typedoc-plugin-markdown": "private"
618
+ },
619
+ "get-caller-file@2.0.5": {
620
+ "get-caller-file": "private"
621
+ },
622
+ "pino-std-serializers@7.1.0": {
623
+ "pino-std-serializers": "private"
624
+ },
625
+ "process-warning@5.0.0": {
626
+ "process-warning": "private"
627
+ },
628
+ "colorette@2.0.20": {
629
+ "colorette": "private"
630
+ },
631
+ "dateformat@4.6.3": {
632
+ "dateformat": "private"
633
+ },
634
+ "fast-copy@4.0.3": {
635
+ "fast-copy": "private"
636
+ },
637
+ "fast-safe-stringify@2.1.1": {
638
+ "fast-safe-stringify": "private"
639
+ },
640
+ "help-me@5.0.0": {
641
+ "help-me": "private"
642
+ },
643
+ "joycon@3.1.1": {
644
+ "joycon": "private"
645
+ },
646
+ "minimist@1.2.8": {
647
+ "minimist": "private"
648
+ },
649
+ "on-exit-leak-free@2.1.2": {
650
+ "on-exit-leak-free": "private"
651
+ },
652
+ "pino-abstract-transport@3.0.0": {
653
+ "pino-abstract-transport": "private"
654
+ },
655
+ "pump@3.0.4": {
656
+ "pump": "private"
657
+ },
658
+ "secure-json-parse@4.1.0": {
659
+ "secure-json-parse": "private"
660
+ },
661
+ "sonic-boom@4.2.1": {
662
+ "sonic-boom": "private"
663
+ },
664
+ "strip-json-comments@5.0.3": {
665
+ "strip-json-comments": "private"
666
+ },
667
+ "@pinojs/redact@0.4.0": {
668
+ "@pinojs/redact": "private"
669
+ },
670
+ "atomic-sleep@1.0.0": {
671
+ "atomic-sleep": "private"
672
+ },
673
+ "quick-format-unescaped@4.0.4": {
674
+ "quick-format-unescaped": "private"
675
+ },
676
+ "real-require@0.2.0": {
677
+ "real-require": "private"
678
+ },
679
+ "safe-stable-stringify@2.5.0": {
680
+ "safe-stable-stringify": "private"
681
+ },
682
+ "@date-fns/tz@1.4.1": {
683
+ "@date-fns/tz": "private"
684
+ },
685
+ "@tabby_ai/hijri-converter@1.0.5": {
686
+ "@tabby_ai/hijri-converter": "private"
687
+ },
688
+ "date-fns-jalali@4.1.0-0": {
689
+ "date-fns-jalali": "private"
690
+ },
691
+ "scheduler@0.26.0": {
692
+ "scheduler": "private"
693
+ },
694
+ "eventemitter3@4.0.7": {
695
+ "eventemitter3": "private"
696
+ },
697
+ "lodash@4.18.1": {
698
+ "lodash": "private"
699
+ },
700
+ "react-is@18.3.1": {
701
+ "react-is": "private"
702
+ },
703
+ "react-smooth@4.0.4(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
704
+ "react-smooth": "private"
705
+ },
706
+ "recharts-scale@0.4.5": {
707
+ "recharts-scale": "private"
708
+ },
709
+ "tiny-invariant@1.3.3": {
710
+ "tiny-invariant": "private"
711
+ },
712
+ "victory-vendor@36.9.2": {
713
+ "victory-vendor": "private"
714
+ },
715
+ "get-tsconfig@4.14.0": {
716
+ "get-tsconfig": "private"
717
+ },
718
+ "fdir@6.5.0(picomatch@4.0.4)": {
719
+ "fdir": "private"
720
+ },
721
+ "picomatch@4.0.4": {
722
+ "picomatch": "private"
723
+ },
724
+ "postcss@8.5.14": {
725
+ "postcss": "private"
726
+ },
727
+ "rollup@4.60.3": {
728
+ "rollup": "private"
729
+ },
730
+ "tinyglobby@0.2.16": {
731
+ "tinyglobby": "private"
732
+ },
733
+ "lightningcss@1.32.0": {
734
+ "lightningcss": "private"
735
+ },
736
+ "yaml@2.8.4": {
737
+ "yaml": "private"
738
+ },
739
+ "mitt@3.0.1": {
740
+ "mitt": "private"
741
+ },
742
+ "regexparam@3.0.0": {
743
+ "regexparam": "private"
744
+ },
745
+ "use-sync-external-store@1.6.0(react@19.1.0)": {
746
+ "use-sync-external-store": "private"
747
+ },
748
+ "@babel/code-frame@7.29.0": {
749
+ "@babel/code-frame": "private"
750
+ },
751
+ "@babel/generator@7.29.1": {
752
+ "@babel/generator": "private"
753
+ },
754
+ "@babel/helper-compilation-targets@7.28.6": {
755
+ "@babel/helper-compilation-targets": "private"
756
+ },
757
+ "@babel/helper-module-transforms@7.28.6(@babel/core@7.29.0)": {
758
+ "@babel/helper-module-transforms": "private"
759
+ },
760
+ "@babel/helpers@7.29.2": {
761
+ "@babel/helpers": "private"
762
+ },
763
+ "@babel/template@7.28.6": {
764
+ "@babel/template": "private"
765
+ },
766
+ "@jridgewell/remapping@2.3.5": {
767
+ "@jridgewell/remapping": "private"
768
+ },
769
+ "convert-source-map@2.0.0": {
770
+ "convert-source-map": "private"
771
+ },
772
+ "gensync@1.0.0-beta.2": {
773
+ "gensync": "private"
774
+ },
775
+ "json5@2.2.3": {
776
+ "json5": "private"
777
+ },
778
+ "semver@6.3.1": {
779
+ "semver": "private"
780
+ },
781
+ "@babel/helper-plugin-utils@7.28.6": {
782
+ "@babel/helper-plugin-utils": "private"
783
+ },
784
+ "@babel/helper-globals@7.28.0": {
785
+ "@babel/helper-globals": "private"
786
+ },
787
+ "@babel/helper-string-parser@7.27.1": {
788
+ "@babel/helper-string-parser": "private"
789
+ },
790
+ "@babel/helper-validator-identifier@7.28.5": {
791
+ "@babel/helper-validator-identifier": "private"
792
+ },
793
+ "@jridgewell/resolve-uri@3.1.2": {
794
+ "@jridgewell/resolve-uri": "private"
795
+ },
796
+ "@jridgewell/sourcemap-codec@1.5.5": {
797
+ "@jridgewell/sourcemap-codec": "private"
798
+ },
799
+ "@libsql/isomorphic-ws@0.1.5": {
800
+ "@libsql/isomorphic-ws": "private"
801
+ },
802
+ "@nodelib/fs.scandir@2.1.5": {
803
+ "@nodelib/fs.scandir": "private"
804
+ },
805
+ "fastq@1.20.1": {
806
+ "fastq": "private"
807
+ },
808
+ "acorn@8.16.0": {
809
+ "acorn": "private"
810
+ },
811
+ "compare-versions@6.1.1": {
812
+ "compare-versions": "private"
813
+ },
814
+ "esutils@2.0.3": {
815
+ "esutils": "private"
816
+ },
817
+ "globby@16.1.0": {
818
+ "globby": "private"
819
+ },
820
+ "@radix-ui/react-use-escape-keydown@1.1.1(@types/react@19.2.14)(react@19.1.0)": {
821
+ "@radix-ui/react-use-escape-keydown": "private"
822
+ },
823
+ "@floating-ui/react-dom@2.1.8(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
824
+ "@floating-ui/react-dom": "private"
825
+ },
826
+ "@radix-ui/react-arrow@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
827
+ "@radix-ui/react-arrow": "private"
828
+ },
829
+ "@radix-ui/react-use-rect@1.1.1(@types/react@19.2.14)(react@19.1.0)": {
830
+ "@radix-ui/react-use-rect": "private"
831
+ },
832
+ "@radix-ui/rect@1.1.1": {
833
+ "@radix-ui/rect": "private"
834
+ },
835
+ "@radix-ui/react-use-effect-event@0.0.2(@types/react@19.2.14)(react@19.1.0)": {
836
+ "@radix-ui/react-use-effect-event": "private"
837
+ },
838
+ "@scalar/helpers@0.6.0": {
839
+ "@scalar/helpers": "private"
840
+ },
841
+ "pathe@2.0.3": {
842
+ "pathe": "private"
843
+ },
844
+ "@scalar/openapi-upgrader@0.2.6": {
845
+ "@scalar/openapi-upgrader": "private"
846
+ },
847
+ "ajv@8.20.0": {
848
+ "ajv": "private"
849
+ },
850
+ "ajv-draft-04@1.0.0(ajv@8.20.0)": {
851
+ "ajv-draft-04": "private"
852
+ },
853
+ "ajv-formats@3.0.1": {
854
+ "ajv-formats": "private"
855
+ },
856
+ "jsonpointer@5.0.1": {
857
+ "jsonpointer": "private"
858
+ },
859
+ "leven@4.1.0": {
860
+ "leven": "private"
861
+ },
862
+ "enhanced-resolve@5.21.0": {
863
+ "enhanced-resolve": "private"
864
+ },
865
+ "source-map-js@1.2.1": {
866
+ "source-map-js": "private"
867
+ },
868
+ "@types/babel__generator@7.27.0": {
869
+ "@types/babel__generator": "private"
870
+ },
871
+ "@types/babel__template@7.4.4": {
872
+ "@types/babel__template": "private"
873
+ },
874
+ "@types/babel__traverse@7.28.0": {
875
+ "@types/babel__traverse": "private"
876
+ },
877
+ "@types/connect@3.4.38": {
878
+ "@types/connect": "private"
879
+ },
880
+ "@types/qs@6.15.0": {
881
+ "@types/qs": "private"
882
+ },
883
+ "@types/range-parser@1.2.7": {
884
+ "@types/range-parser": "private"
885
+ },
886
+ "@types/send@1.2.1": {
887
+ "@types/send": "private"
888
+ },
889
+ "@types/http-errors@2.0.5": {
890
+ "@types/http-errors": "private"
891
+ },
892
+ "negotiator@1.0.0": {
893
+ "negotiator": "private"
894
+ },
895
+ "bytes@3.1.2": {
896
+ "bytes": "private"
897
+ },
898
+ "iconv-lite@0.7.2": {
899
+ "iconv-lite": "private"
900
+ },
901
+ "raw-body@3.0.2": {
902
+ "raw-body": "private"
903
+ },
904
+ "ms@2.1.3": {
905
+ "ms": "private"
906
+ },
907
+ "ansi-colors@4.1.3": {
908
+ "ansi-colors": "private"
909
+ },
910
+ "strip-ansi@6.0.1": {
911
+ "strip-ansi": "private"
912
+ },
913
+ "@sindresorhus/merge-streams@4.0.0": {
914
+ "@sindresorhus/merge-streams": "private"
915
+ },
916
+ "cross-spawn@7.0.6": {
917
+ "cross-spawn": "private"
918
+ },
919
+ "figures@6.1.0": {
920
+ "figures": "private"
921
+ },
922
+ "get-stream@9.0.1": {
923
+ "get-stream": "private"
924
+ },
925
+ "human-signals@8.0.1": {
926
+ "human-signals": "private"
927
+ },
928
+ "is-plain-obj@4.1.0": {
929
+ "is-plain-obj": "private"
930
+ },
931
+ "is-stream@4.0.1": {
932
+ "is-stream": "private"
933
+ },
934
+ "npm-run-path@6.0.0": {
935
+ "npm-run-path": "private"
936
+ },
937
+ "pretty-ms@9.3.0": {
938
+ "pretty-ms": "private"
939
+ },
940
+ "signal-exit@4.1.0": {
941
+ "signal-exit": "private"
942
+ },
943
+ "strip-final-newline@4.0.0": {
944
+ "strip-final-newline": "private"
945
+ },
946
+ "yoctocolors@2.1.2": {
947
+ "yoctocolors": "private"
948
+ },
949
+ "locate-path@8.0.0": {
950
+ "locate-path": "private"
951
+ },
952
+ "unicorn-magic@0.3.0": {
953
+ "unicorn-magic": "private"
954
+ },
955
+ "graceful-fs@4.2.11": {
956
+ "graceful-fs": "private"
957
+ },
958
+ "jsonfile@6.2.1": {
959
+ "jsonfile": "private"
960
+ },
961
+ "universalify@2.0.1": {
962
+ "universalify": "private"
963
+ },
964
+ "resolve-pkg-maps@1.0.0": {
965
+ "resolve-pkg-maps": "private"
966
+ },
967
+ "is-glob@4.0.3": {
968
+ "is-glob": "private"
969
+ },
970
+ "inherits@2.0.4": {
971
+ "inherits": "private"
972
+ },
973
+ "setprototypeof@1.2.0": {
974
+ "setprototypeof": "private"
975
+ },
976
+ "toidentifier@1.0.1": {
977
+ "toidentifier": "private"
978
+ },
979
+ "argparse@2.0.1": {
980
+ "argparse": "private"
981
+ },
982
+ "@neon-rs/load@0.0.4": {
983
+ "@neon-rs/load": "private"
984
+ },
985
+ "detect-libc@2.0.2": {
986
+ "detect-libc": "private"
987
+ },
988
+ "@libsql/win32-x64-msvc@0.5.29": {
989
+ "@libsql/win32-x64-msvc": "private"
990
+ },
991
+ "braces@3.0.3": {
992
+ "braces": "private"
993
+ },
994
+ "mime-db@1.54.0": {
995
+ "mime-db": "private"
996
+ },
997
+ "ee-first@1.1.1": {
998
+ "ee-first": "private"
999
+ },
1000
+ "wrappy@1.0.2": {
1001
+ "wrappy": "private"
1002
+ },
1003
+ "split2@4.2.0": {
1004
+ "split2": "private"
1005
+ },
1006
+ "cssesc@3.0.0": {
1007
+ "cssesc": "private"
1008
+ },
1009
+ "util-deprecate@1.0.2": {
1010
+ "util-deprecate": "private"
1011
+ },
1012
+ "nanoid@3.3.12": {
1013
+ "nanoid": "private"
1014
+ },
1015
+ "picocolors@1.1.1": {
1016
+ "picocolors": "private"
1017
+ },
1018
+ "forwarded@0.2.0": {
1019
+ "forwarded": "private"
1020
+ },
1021
+ "ipaddr.js@1.9.1": {
1022
+ "ipaddr.js": "private"
1023
+ },
1024
+ "end-of-stream@1.4.5": {
1025
+ "end-of-stream": "private"
1026
+ },
1027
+ "side-channel@1.1.0": {
1028
+ "side-channel": "private"
1029
+ },
1030
+ "react-remove-scroll-bar@2.3.8(@types/react@19.2.14)(react@19.1.0)": {
1031
+ "react-remove-scroll-bar": "private"
1032
+ },
1033
+ "react-style-singleton@2.2.3(@types/react@19.2.14)(react@19.1.0)": {
1034
+ "react-style-singleton": "private"
1035
+ },
1036
+ "use-callback-ref@1.3.3(@types/react@19.2.14)(react@19.1.0)": {
1037
+ "use-callback-ref": "private"
1038
+ },
1039
+ "use-sidecar@1.1.3(@types/react@19.2.14)(react@19.1.0)": {
1040
+ "use-sidecar": "private"
1041
+ },
1042
+ "fast-equals@5.4.0": {
1043
+ "fast-equals": "private"
1044
+ },
1045
+ "prop-types@15.8.1": {
1046
+ "prop-types": "private"
1047
+ },
1048
+ "react-transition-group@4.4.5(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
1049
+ "react-transition-group": "private"
1050
+ },
1051
+ "decimal.js-light@2.5.1": {
1052
+ "decimal.js-light": "private"
1053
+ },
1054
+ "@types/estree@1.0.8": {
1055
+ "@types/estree": "private"
1056
+ },
1057
+ "is-promise@4.0.0": {
1058
+ "is-promise": "private"
1059
+ },
1060
+ "path-to-regexp@8.4.2": {
1061
+ "path-to-regexp": "private"
1062
+ },
1063
+ "media-typer@1.1.0": {
1064
+ "media-typer": "private"
1065
+ },
1066
+ "@gerrit0/mini-shiki@3.23.0": {
1067
+ "@gerrit0/mini-shiki": "private"
1068
+ },
1069
+ "lunr@2.3.9": {
1070
+ "lunr": "private"
1071
+ },
1072
+ "markdown-it@14.1.1": {
1073
+ "markdown-it": "private"
1074
+ },
1075
+ "minimatch@10.2.5": {
1076
+ "minimatch": "private"
1077
+ },
1078
+ "@types/d3-array@3.2.2": {
1079
+ "@types/d3-array": "private"
1080
+ },
1081
+ "@types/d3-ease@3.0.2": {
1082
+ "@types/d3-ease": "private"
1083
+ },
1084
+ "@types/d3-interpolate@3.0.4": {
1085
+ "@types/d3-interpolate": "private"
1086
+ },
1087
+ "@types/d3-scale@4.0.9": {
1088
+ "@types/d3-scale": "private"
1089
+ },
1090
+ "@types/d3-shape@3.1.8": {
1091
+ "@types/d3-shape": "private"
1092
+ },
1093
+ "@types/d3-time@3.0.4": {
1094
+ "@types/d3-time": "private"
1095
+ },
1096
+ "@types/d3-timer@3.0.2": {
1097
+ "@types/d3-timer": "private"
1098
+ },
1099
+ "d3-array@3.2.4": {
1100
+ "d3-array": "private"
1101
+ },
1102
+ "d3-ease@3.0.1": {
1103
+ "d3-ease": "private"
1104
+ },
1105
+ "d3-interpolate@3.0.1": {
1106
+ "d3-interpolate": "private"
1107
+ },
1108
+ "d3-scale@4.0.2": {
1109
+ "d3-scale": "private"
1110
+ },
1111
+ "d3-shape@3.2.0": {
1112
+ "d3-shape": "private"
1113
+ },
1114
+ "d3-time@3.1.0": {
1115
+ "d3-time": "private"
1116
+ },
1117
+ "d3-timer@3.0.1": {
1118
+ "d3-timer": "private"
1119
+ },
1120
+ "js-tokens@4.0.0": {
1121
+ "js-tokens": "private"
1122
+ },
1123
+ "@jridgewell/gen-mapping@0.3.13": {
1124
+ "@jridgewell/gen-mapping": "private"
1125
+ },
1126
+ "jsesc@3.1.0": {
1127
+ "jsesc": "private"
1128
+ },
1129
+ "@babel/compat-data@7.29.3": {
1130
+ "@babel/compat-data": "private"
1131
+ },
1132
+ "@babel/helper-validator-option@7.27.1": {
1133
+ "@babel/helper-validator-option": "private"
1134
+ },
1135
+ "browserslist@4.28.2": {
1136
+ "browserslist": "private"
1137
+ },
1138
+ "lru-cache@5.1.1": {
1139
+ "lru-cache": "private"
1140
+ },
1141
+ "@babel/helper-module-imports@7.28.6": {
1142
+ "@babel/helper-module-imports": "private"
1143
+ },
1144
+ "@floating-ui/dom@1.7.6": {
1145
+ "@floating-ui/dom": "private"
1146
+ },
1147
+ "@shikijs/engine-oniguruma@3.23.0": {
1148
+ "@shikijs/engine-oniguruma": "private"
1149
+ },
1150
+ "@shikijs/langs@3.23.0": {
1151
+ "@shikijs/langs": "private"
1152
+ },
1153
+ "@shikijs/themes@3.23.0": {
1154
+ "@shikijs/themes": "private"
1155
+ },
1156
+ "@shikijs/types@3.23.0": {
1157
+ "@shikijs/types": "private"
1158
+ },
1159
+ "@shikijs/vscode-textmate@10.0.2": {
1160
+ "@shikijs/vscode-textmate": "private"
1161
+ },
1162
+ "@types/ws@8.18.1": {
1163
+ "@types/ws": "private"
1164
+ },
1165
+ "ws@8.20.0": {
1166
+ "ws": "private"
1167
+ },
1168
+ "run-parallel@1.2.0": {
1169
+ "run-parallel": "private"
1170
+ },
1171
+ "@types/d3-color@3.1.3": {
1172
+ "@types/d3-color": "private"
1173
+ },
1174
+ "@types/d3-path@3.1.1": {
1175
+ "@types/d3-path": "private"
1176
+ },
1177
+ "fast-deep-equal@3.1.3": {
1178
+ "fast-deep-equal": "private"
1179
+ },
1180
+ "fast-uri@3.1.2": {
1181
+ "fast-uri": "private"
1182
+ },
1183
+ "json-schema-traverse@1.0.0": {
1184
+ "json-schema-traverse": "private"
1185
+ },
1186
+ "require-from-string@2.0.2": {
1187
+ "require-from-string": "private"
1188
+ },
1189
+ "fill-range@7.1.1": {
1190
+ "fill-range": "private"
1191
+ },
1192
+ "path-key@3.1.1": {
1193
+ "path-key": "private"
1194
+ },
1195
+ "shebang-command@2.0.0": {
1196
+ "shebang-command": "private"
1197
+ },
1198
+ "which@2.0.2": {
1199
+ "which": "private"
1200
+ },
1201
+ "internmap@2.0.3": {
1202
+ "internmap": "private"
1203
+ },
1204
+ "d3-color@3.1.0": {
1205
+ "d3-color": "private"
1206
+ },
1207
+ "d3-format@3.1.2": {
1208
+ "d3-format": "private"
1209
+ },
1210
+ "d3-time-format@4.1.0": {
1211
+ "d3-time-format": "private"
1212
+ },
1213
+ "d3-path@3.1.0": {
1214
+ "d3-path": "private"
1215
+ },
1216
+ "tapable@2.3.3": {
1217
+ "tapable": "private"
1218
+ },
1219
+ "reusify@1.1.0": {
1220
+ "reusify": "private"
1221
+ },
1222
+ "is-unicode-supported@2.1.0": {
1223
+ "is-unicode-supported": "private"
1224
+ },
1225
+ "@sec-ant/readable-stream@0.4.1": {
1226
+ "@sec-ant/readable-stream": "private"
1227
+ },
1228
+ "ignore@7.0.5": {
1229
+ "ignore": "private"
1230
+ },
1231
+ "is-path-inside@4.0.0": {
1232
+ "is-path-inside": "private"
1233
+ },
1234
+ "slash@5.1.0": {
1235
+ "slash": "private"
1236
+ },
1237
+ "safer-buffer@2.1.2": {
1238
+ "safer-buffer": "private"
1239
+ },
1240
+ "is-extglob@2.1.1": {
1241
+ "is-extglob": "private"
1242
+ },
1243
+ "p-locate@6.0.0": {
1244
+ "p-locate": "private"
1245
+ },
1246
+ "entities@4.5.0": {
1247
+ "entities": "private"
1248
+ },
1249
+ "linkify-it@5.0.0": {
1250
+ "linkify-it": "private"
1251
+ },
1252
+ "mdurl@2.0.0": {
1253
+ "mdurl": "private"
1254
+ },
1255
+ "punycode.js@2.3.1": {
1256
+ "punycode.js": "private"
1257
+ },
1258
+ "uc.micro@2.1.0": {
1259
+ "uc.micro": "private"
1260
+ },
1261
+ "brace-expansion@5.0.5": {
1262
+ "brace-expansion": "private"
1263
+ },
1264
+ "parse-ms@4.0.0": {
1265
+ "parse-ms": "private"
1266
+ },
1267
+ "loose-envify@1.4.0": {
1268
+ "loose-envify": "private"
1269
+ },
1270
+ "unpipe@1.0.0": {
1271
+ "unpipe": "private"
1272
+ },
1273
+ "get-nonce@1.0.1": {
1274
+ "get-nonce": "private"
1275
+ },
1276
+ "@babel/runtime@7.29.2": {
1277
+ "@babel/runtime": "private"
1278
+ },
1279
+ "dom-helpers@5.2.1": {
1280
+ "dom-helpers": "private"
1281
+ },
1282
+ "es-errors@1.3.0": {
1283
+ "es-errors": "private"
1284
+ },
1285
+ "object-inspect@1.13.4": {
1286
+ "object-inspect": "private"
1287
+ },
1288
+ "side-channel-list@1.0.1": {
1289
+ "side-channel-list": "private"
1290
+ },
1291
+ "side-channel-map@1.0.1": {
1292
+ "side-channel-map": "private"
1293
+ },
1294
+ "side-channel-weakmap@1.0.2": {
1295
+ "side-channel-weakmap": "private"
1296
+ },
1297
+ "ansi-regex@5.0.1": {
1298
+ "ansi-regex": "private"
1299
+ },
1300
+ "detect-node-es@1.1.0": {
1301
+ "detect-node-es": "private"
1302
+ },
1303
+ "@floating-ui/core@1.7.5": {
1304
+ "@floating-ui/core": "private"
1305
+ },
1306
+ "@floating-ui/utils@0.2.11": {
1307
+ "@floating-ui/utils": "private"
1308
+ },
1309
+ "@types/hast@3.0.4": {
1310
+ "@types/hast": "private"
1311
+ },
1312
+ "balanced-match@4.0.4": {
1313
+ "balanced-match": "private"
1314
+ },
1315
+ "baseline-browser-mapping@2.10.27": {
1316
+ "baseline-browser-mapping": "private"
1317
+ },
1318
+ "caniuse-lite@1.0.30001792": {
1319
+ "caniuse-lite": "private"
1320
+ },
1321
+ "electron-to-chromium@1.5.352": {
1322
+ "electron-to-chromium": "private"
1323
+ },
1324
+ "node-releases@2.0.38": {
1325
+ "node-releases": "private"
1326
+ },
1327
+ "update-browserslist-db@1.2.3(browserslist@4.28.2)": {
1328
+ "update-browserslist-db": "private"
1329
+ },
1330
+ "to-regex-range@5.0.1": {
1331
+ "to-regex-range": "private"
1332
+ },
1333
+ "yallist@3.1.1": {
1334
+ "yallist": "private"
1335
+ },
1336
+ "p-limit@4.0.0": {
1337
+ "p-limit": "private"
1338
+ },
1339
+ "queue-microtask@1.2.3": {
1340
+ "queue-microtask": "private"
1341
+ },
1342
+ "shebang-regex@3.0.0": {
1343
+ "shebang-regex": "private"
1344
+ },
1345
+ "call-bound@1.0.4": {
1346
+ "call-bound": "private"
1347
+ },
1348
+ "get-intrinsic@1.3.0": {
1349
+ "get-intrinsic": "private"
1350
+ },
1351
+ "isexe@2.0.0": {
1352
+ "isexe": "private"
1353
+ },
1354
+ "@types/unist@3.0.3": {
1355
+ "@types/unist": "private"
1356
+ },
1357
+ "call-bind-apply-helpers@1.0.2": {
1358
+ "call-bind-apply-helpers": "private"
1359
+ },
1360
+ "es-define-property@1.0.1": {
1361
+ "es-define-property": "private"
1362
+ },
1363
+ "es-object-atoms@1.1.1": {
1364
+ "es-object-atoms": "private"
1365
+ },
1366
+ "function-bind@1.1.2": {
1367
+ "function-bind": "private"
1368
+ },
1369
+ "get-proto@1.0.1": {
1370
+ "get-proto": "private"
1371
+ },
1372
+ "gopd@1.2.0": {
1373
+ "gopd": "private"
1374
+ },
1375
+ "has-symbols@1.1.0": {
1376
+ "has-symbols": "private"
1377
+ },
1378
+ "hasown@2.0.3": {
1379
+ "hasown": "private"
1380
+ },
1381
+ "math-intrinsics@1.1.0": {
1382
+ "math-intrinsics": "private"
1383
+ },
1384
+ "yocto-queue@1.2.2": {
1385
+ "yocto-queue": "private"
1386
+ },
1387
+ "is-number@7.0.0": {
1388
+ "is-number": "private"
1389
+ },
1390
+ "escalade@3.2.0": {
1391
+ "escalade": "private"
1392
+ },
1393
+ "dunder-proto@1.0.1": {
1394
+ "dunder-proto": "private"
1395
+ },
1396
+ "@supabase/supabase-js@2.105.4": {
1397
+ "@supabase/supabase-js": "private"
1398
+ },
1399
+ "@supabase/postgrest-js@2.105.4": {
1400
+ "@supabase/postgrest-js": "private"
1401
+ },
1402
+ "@supabase/functions-js@2.105.4": {
1403
+ "@supabase/functions-js": "private"
1404
+ },
1405
+ "@supabase/storage-js@2.105.4": {
1406
+ "@supabase/storage-js": "private"
1407
+ },
1408
+ "@supabase/realtime-js@2.105.4": {
1409
+ "@supabase/realtime-js": "private"
1410
+ },
1411
+ "@supabase/auth-js@2.105.4": {
1412
+ "@supabase/auth-js": "private"
1413
+ },
1414
+ "@supabase/phoenix@0.4.2": {
1415
+ "@supabase/phoenix": "private"
1416
+ },
1417
+ "iceberg-js@0.8.1": {
1418
+ "iceberg-js": "private"
1419
+ },
1420
+ "dotenv@17.4.2": {
1421
+ "dotenv": "private"
1422
+ },
1423
+ "drizzle-orm@0.45.2(@libsql/client@0.17.3)(postgres@3.4.9)": {
1424
+ "drizzle-orm": "private"
1425
+ },
1426
+ "postgres@3.4.9": {
1427
+ "postgres": "private"
1428
+ },
1429
+ "drizzle-zod@0.8.3(drizzle-orm@0.45.2(@libsql/client@0.17.3)(postgres@3.4.9))(zod@3.25.76)": {
1430
+ "drizzle-zod": "private"
1431
+ },
1432
+ "detect-libc@2.1.2": {
1433
+ "detect-libc": "private"
1434
+ }
1435
+ },
1436
+ "hoistPattern": [
1437
+ "*"
1438
+ ],
1439
+ "included": {
1440
+ "dependencies": true,
1441
+ "devDependencies": true,
1442
+ "optionalDependencies": true
1443
+ },
1444
+ "injectedDeps": {},
1445
+ "layoutVersion": 5,
1446
+ "nodeLinker": "isolated",
1447
+ "packageManager": "pnpm@11.0.8",
1448
+ "pendingBuilds": [],
1449
+ "publicHoistPattern": [],
1450
+ "prunedAt": "Sun, 10 May 2026 08:00:00 GMT",
1451
+ "registries": {
1452
+ "default": "https://registry.npmjs.org/",
1453
+ "@jsr": "https://npm.jsr.io/"
1454
+ },
1455
+ "skipped": [
1456
+ "@esbuild/linux-x64@0.27.3",
1457
+ "@libsql/darwin-arm64@0.5.29",
1458
+ "@libsql/darwin-x64@0.5.29",
1459
+ "@libsql/linux-arm-gnueabihf@0.5.29",
1460
+ "@libsql/linux-arm-musleabihf@0.5.29",
1461
+ "@libsql/linux-arm64-gnu@0.5.29",
1462
+ "@libsql/linux-arm64-musl@0.5.29",
1463
+ "@libsql/linux-x64-gnu@0.5.29",
1464
+ "@libsql/linux-x64-musl@0.5.29",
1465
+ "@rollup/rollup-linux-x64-gnu@4.60.3",
1466
+ "@tailwindcss/oxide-linux-x64-gnu@4.2.4",
1467
+ "@tailwindcss/oxide-wasm32-wasi@4.2.4",
1468
+ "fsevents@2.3.3",
1469
+ "lightningcss-linux-x64-gnu@1.32.0"
1470
+ ],
1471
+ "storeDir": "D:\\.pnpm-store\\v11",
1472
+ "virtualStoreDir": "D:\\design-studio-latest (3)\\design-studio-latest\\design-studio-latest\\node_modules\\.pnpm",
1473
+ "virtualStoreDirMaxLength": 60,
1474
+ "allowBuilds": {
1475
+ "better-sqlite3": "set this to true or false",
1476
+ "esbuild": true
1477
+ }
1478
+ }
node_modules/.pnpm-workspace-state-v1.json ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "lastValidatedTimestamp": 1778492210924,
3
+ "projects": {
4
+ "D:\\design-studio-latest (3)\\design-studio-latest\\design-studio-latest": {
5
+ "name": "workspace",
6
+ "version": "0.0.0"
7
+ },
8
+ "D:\\design-studio-latest (3)\\design-studio-latest\\design-studio-latest\\artifacts\\api-server": {
9
+ "name": "@workspace/api-server",
10
+ "version": "0.0.0"
11
+ },
12
+ "D:\\design-studio-latest (3)\\design-studio-latest\\design-studio-latest\\artifacts\\design-studio": {
13
+ "name": "@workspace/design-studio",
14
+ "version": "0.0.0"
15
+ },
16
+ "D:\\design-studio-latest (3)\\design-studio-latest\\design-studio-latest\\artifacts\\mockup-sandbox": {
17
+ "name": "@workspace/mockup-sandbox",
18
+ "version": "2.0.0"
19
+ },
20
+ "D:\\design-studio-latest (3)\\design-studio-latest\\design-studio-latest\\lib\\api-client-react": {
21
+ "name": "@workspace/api-client-react",
22
+ "version": "0.0.0"
23
+ },
24
+ "D:\\design-studio-latest (3)\\design-studio-latest\\design-studio-latest\\lib\\api-spec": {
25
+ "name": "@workspace/api-spec",
26
+ "version": "0.0.0"
27
+ },
28
+ "D:\\design-studio-latest (3)\\design-studio-latest\\design-studio-latest\\lib\\api-zod": {
29
+ "name": "@workspace/api-zod",
30
+ "version": "0.0.0"
31
+ },
32
+ "D:\\design-studio-latest (3)\\design-studio-latest\\design-studio-latest\\lib\\db": {
33
+ "name": "@workspace/db",
34
+ "version": "0.0.0"
35
+ },
36
+ "D:\\design-studio-latest (3)\\design-studio-latest\\design-studio-latest\\scripts": {
37
+ "name": "@workspace/scripts",
38
+ "version": "0.0.0"
39
+ }
40
+ },
41
+ "pnpmfiles": [],
42
+ "settings": {
43
+ "allowBuilds": {
44
+ "better-sqlite3": "set this to true or false",
45
+ "esbuild": true
46
+ },
47
+ "autoInstallPeers": false,
48
+ "catalogs": {
49
+ "default": {
50
+ "@replit/vite-plugin-cartographer": "^0.5.1",
51
+ "@replit/vite-plugin-dev-banner": "^0.1.1",
52
+ "@replit/vite-plugin-runtime-error-modal": "^0.0.6",
53
+ "@tailwindcss/vite": "^4.1.14",
54
+ "@tanstack/react-query": "^5.90.21",
55
+ "@types/node": "^25.3.3",
56
+ "@types/react": "^19.2.0",
57
+ "@types/react-dom": "^19.2.0",
58
+ "@vitejs/plugin-react": "^5.0.4",
59
+ "class-variance-authority": "^0.7.1",
60
+ "clsx": "^2.1.1",
61
+ "drizzle-orm": "^0.45.2",
62
+ "framer-motion": "^12.23.24",
63
+ "lucide-react": "^0.545.0",
64
+ "react": "19.1.0",
65
+ "react-dom": "19.1.0",
66
+ "tailwind-merge": "^3.3.1",
67
+ "tailwindcss": "^4.1.14",
68
+ "tsx": "^4.21.0",
69
+ "vite": "^7.3.2",
70
+ "wouter": "^3.3.5",
71
+ "zod": "^3.25.76"
72
+ }
73
+ },
74
+ "dedupeDirectDeps": false,
75
+ "dedupeInjectedDeps": true,
76
+ "dedupePeerDependents": true,
77
+ "dedupePeers": false,
78
+ "dev": true,
79
+ "excludeLinksFromLockfile": false,
80
+ "hoistPattern": [
81
+ "*"
82
+ ],
83
+ "hoistWorkspacePackages": true,
84
+ "injectWorkspacePackages": false,
85
+ "linkWorkspacePackages": false,
86
+ "nodeLinker": "isolated",
87
+ "optional": true,
88
+ "overrides": {
89
+ "esbuild>@esbuild/darwin-arm64": "-",
90
+ "esbuild>@esbuild/darwin-x64": "-",
91
+ "esbuild>@esbuild/freebsd-arm64": "-",
92
+ "esbuild>@esbuild/freebsd-x64": "-",
93
+ "esbuild>@esbuild/linux-arm": "-",
94
+ "esbuild>@esbuild/linux-arm64": "-",
95
+ "esbuild>@esbuild/linux-ia32": "-",
96
+ "esbuild>@esbuild/linux-loong64": "-",
97
+ "esbuild>@esbuild/linux-mips64el": "-",
98
+ "esbuild>@esbuild/linux-ppc64": "-",
99
+ "esbuild>@esbuild/linux-riscv64": "-",
100
+ "esbuild>@esbuild/linux-s390x": "-",
101
+ "esbuild>@esbuild/netbsd-arm64": "-",
102
+ "esbuild>@esbuild/netbsd-x64": "-",
103
+ "esbuild>@esbuild/openbsd-arm64": "-",
104
+ "esbuild>@esbuild/openbsd-x64": "-",
105
+ "esbuild>@esbuild/sunos-x64": "-",
106
+ "esbuild>@esbuild/win32-arm64": "-",
107
+ "esbuild>@esbuild/win32-ia32": "-",
108
+ "esbuild>@esbuild/win32-x64": "-",
109
+ "esbuild>@esbuild/aix-ppc64": "-",
110
+ "esbuild>@esbuild/android-arm": "-",
111
+ "esbuild>@esbuild/android-arm64": "-",
112
+ "esbuild>@esbuild/android-x64": "-",
113
+ "esbuild>@esbuild/openharmony-arm64": "-",
114
+ "lightningcss>lightningcss-android-arm64": "-",
115
+ "lightningcss>lightningcss-darwin-arm64": "-",
116
+ "lightningcss>lightningcss-darwin-x64": "-",
117
+ "lightningcss>lightningcss-freebsd-x64": "-",
118
+ "lightningcss>lightningcss-linux-arm-gnueabihf": "-",
119
+ "lightningcss>lightningcss-linux-arm64-gnu": "-",
120
+ "lightningcss>lightningcss-linux-arm64-musl": "-",
121
+ "lightningcss>lightningcss-linux-x64-musl": "-",
122
+ "lightningcss>lightningcss-win32-arm64-msvc": "-",
123
+ "lightningcss>lightningcss-win32-x64-msvc": "-",
124
+ "@tailwindcss/oxide>@tailwindcss/oxide-android-arm64": "-",
125
+ "@tailwindcss/oxide>@tailwindcss/oxide-darwin-arm64": "-",
126
+ "@tailwindcss/oxide>@tailwindcss/oxide-darwin-x64": "-",
127
+ "@tailwindcss/oxide>@tailwindcss/oxide-freebsd-x64": "-",
128
+ "@tailwindcss/oxide>@tailwindcss/oxide-linux-arm-gnueabihf": "-",
129
+ "@tailwindcss/oxide>@tailwindcss/oxide-linux-arm64-gnu": "-",
130
+ "@tailwindcss/oxide>@tailwindcss/oxide-linux-arm64-musl": "-",
131
+ "@tailwindcss/oxide>@tailwindcss/oxide-win32-arm64-msvc": "-",
132
+ "@tailwindcss/oxide>@tailwindcss/oxide-win32-x64-msvc": "-",
133
+ "@tailwindcss/oxide>@tailwindcss/oxide-linux-x64-musl": "-",
134
+ "rollup>@rollup/rollup-android-arm-eabi": "-",
135
+ "rollup>@rollup/rollup-android-arm64": "-",
136
+ "rollup>@rollup/rollup-darwin-arm64": "-",
137
+ "rollup>@rollup/rollup-darwin-x64": "-",
138
+ "rollup>@rollup/rollup-freebsd-arm64": "-",
139
+ "rollup>@rollup/rollup-freebsd-x64": "-",
140
+ "rollup>@rollup/rollup-linux-arm-gnueabihf": "-",
141
+ "rollup>@rollup/rollup-linux-arm-musleabihf": "-",
142
+ "rollup>@rollup/rollup-linux-arm64-gnu": "-",
143
+ "rollup>@rollup/rollup-linux-arm64-musl": "-",
144
+ "rollup>@rollup/rollup-linux-loong64-gnu": "-",
145
+ "rollup>@rollup/rollup-linux-loong64-musl": "-",
146
+ "rollup>@rollup/rollup-linux-ppc64-gnu": "-",
147
+ "rollup>@rollup/rollup-linux-ppc64-musl": "-",
148
+ "rollup>@rollup/rollup-linux-riscv64-gnu": "-",
149
+ "rollup>@rollup/rollup-linux-riscv64-musl": "-",
150
+ "rollup>@rollup/rollup-linux-s390x-gnu": "-",
151
+ "rollup>@rollup/rollup-linux-x64-musl": "-",
152
+ "rollup>@rollup/rollup-openbsd-x64": "-",
153
+ "rollup>@rollup/rollup-openharmony-arm64": "-",
154
+ "rollup>@rollup/rollup-win32-arm64-msvc": "-",
155
+ "rollup>@rollup/rollup-win32-ia32-msvc": "-",
156
+ "rollup>@rollup/rollup-win32-x64-gnu": "-",
157
+ "rollup>@rollup/rollup-win32-x64-msvc": "-",
158
+ "@expo/ngrok-bin>@expo/ngrok-bin-darwin-arm64": "-",
159
+ "@expo/ngrok-bin>@expo/ngrok-bin-darwin-x64": "-",
160
+ "@expo/ngrok-bin>@expo/ngrok-bin-freebsd-ia32": "-",
161
+ "@expo/ngrok-bin>@expo/ngrok-bin-freebsd-x64": "-",
162
+ "@expo/ngrok-bin>@expo/ngrok-bin-linux-arm64": "-",
163
+ "@expo/ngrok-bin>@expo/ngrok-bin-linux-arm": "-",
164
+ "@expo/ngrok-bin>@expo/ngrok-bin-linux-ia32": "-",
165
+ "@expo/ngrok-bin>@expo/ngrok-bin-sunos-x64": "-",
166
+ "@expo/ngrok-bin>@expo/ngrok-bin-win32-ia32": "-",
167
+ "@expo/ngrok-bin>@expo/ngrok-bin-win32-x64": "-",
168
+ "@esbuild-kit/esm-loader": "npm:tsx@^4.21.0",
169
+ "esbuild": "0.27.3"
170
+ },
171
+ "peersSuffixMaxLength": 1000,
172
+ "preferWorkspacePackages": false,
173
+ "production": true,
174
+ "publicHoistPattern": [],
175
+ "workspacePackagePatterns": [
176
+ "artifacts/*",
177
+ "lib/*",
178
+ "lib/integrations/*",
179
+ "scripts"
180
+ ]
181
+ },
182
+ "filteredInstall": false
183
+ }
node_modules/.pnpm/lock.yaml ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@rollup/rollup-win32-x64-msvc/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # `@rollup/rollup-win32-x64-msvc`
2
+
3
+ This is the **x86_64-pc-windows-msvc** binary for `rollup`
node_modules/@rollup/rollup-win32-x64-msvc/package.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@rollup/rollup-win32-x64-msvc",
3
+ "version": "4.60.3",
4
+ "os": [
5
+ "win32"
6
+ ],
7
+ "cpu": [
8
+ "x64"
9
+ ],
10
+ "files": [
11
+ "rollup.win32-x64-msvc.node"
12
+ ],
13
+ "description": "Native bindings for Rollup",
14
+ "author": "Lukas Taegert-Atkinson",
15
+ "homepage": "https://rollupjs.org/",
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/rollup/rollup.git"
20
+ },
21
+ "main": "./rollup.win32-x64-msvc.node"
22
+ }
node_modules/@rollup/rollup-win32-x64-msvc/rollup.win32-x64-msvc.node ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db4e0467b7584f92c3e06920f3d7e979676c1be648ad09652babac9a08718754
3
+ size 2546176
node_modules/@tailwindcss/oxide-win32-x64-msvc/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Tailwind Labs, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/@tailwindcss/oxide-win32-x64-msvc/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # `@tailwindcss/oxide-win32-x64-msvc`
2
+
3
+ This is the **x86_64-pc-windows-msvc** binary for `@tailwindcss/oxide`
node_modules/@tailwindcss/oxide-win32-x64-msvc/package.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@tailwindcss/oxide-win32-x64-msvc",
3
+ "version": "4.2.4",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/tailwindlabs/tailwindcss.git",
7
+ "directory": "crates/node/npm/win32-x64-msvc"
8
+ },
9
+ "os": [
10
+ "win32"
11
+ ],
12
+ "cpu": [
13
+ "x64"
14
+ ],
15
+ "main": "tailwindcss-oxide.win32-x64-msvc.node",
16
+ "files": [
17
+ "tailwindcss-oxide.win32-x64-msvc.node"
18
+ ],
19
+ "publishConfig": {
20
+ "provenance": true,
21
+ "access": "public"
22
+ },
23
+ "license": "MIT",
24
+ "engines": {
25
+ "node": ">= 20"
26
+ }
27
+ }
node_modules/@tailwindcss/oxide-win32-x64-msvc/tailwindcss-oxide.win32-x64-msvc.node ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:47e69fc14436ae6c620b4d3d2734d1952a07a2823b9b6a5eea1e530d681e03d5
3
+ size 3231744
node_modules/lightningcss-win32-x64-msvc/LICENSE ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Mozilla Public License Version 2.0
2
+ ==================================
3
+
4
+ 1. Definitions
5
+ --------------
6
+
7
+ 1.1. "Contributor"
8
+ means each individual or legal entity that creates, contributes to
9
+ the creation of, or owns Covered Software.
10
+
11
+ 1.2. "Contributor Version"
12
+ means the combination of the Contributions of others (if any) used
13
+ by a Contributor and that particular Contributor's Contribution.
14
+
15
+ 1.3. "Contribution"
16
+ means Covered Software of a particular Contributor.
17
+
18
+ 1.4. "Covered Software"
19
+ means Source Code Form to which the initial Contributor has attached
20
+ the notice in Exhibit A, the Executable Form of such Source Code
21
+ Form, and Modifications of such Source Code Form, in each case
22
+ including portions thereof.
23
+
24
+ 1.5. "Incompatible With Secondary Licenses"
25
+ means
26
+
27
+ (a) that the initial Contributor has attached the notice described
28
+ in Exhibit B to the Covered Software; or
29
+
30
+ (b) that the Covered Software was made available under the terms of
31
+ version 1.1 or earlier of the License, but not also under the
32
+ terms of a Secondary License.
33
+
34
+ 1.6. "Executable Form"
35
+ means any form of the work other than Source Code Form.
36
+
37
+ 1.7. "Larger Work"
38
+ means a work that combines Covered Software with other material, in
39
+ a separate file or files, that is not Covered Software.
40
+
41
+ 1.8. "License"
42
+ means this document.
43
+
44
+ 1.9. "Licensable"
45
+ means having the right to grant, to the maximum extent possible,
46
+ whether at the time of the initial grant or subsequently, any and
47
+ all of the rights conveyed by this License.
48
+
49
+ 1.10. "Modifications"
50
+ means any of the following:
51
+
52
+ (a) any file in Source Code Form that results from an addition to,
53
+ deletion from, or modification of the contents of Covered
54
+ Software; or
55
+
56
+ (b) any new file in Source Code Form that contains any Covered
57
+ Software.
58
+
59
+ 1.11. "Patent Claims" of a Contributor
60
+ means any patent claim(s), including without limitation, method,
61
+ process, and apparatus claims, in any patent Licensable by such
62
+ Contributor that would be infringed, but for the grant of the
63
+ License, by the making, using, selling, offering for sale, having
64
+ made, import, or transfer of either its Contributions or its
65
+ Contributor Version.
66
+
67
+ 1.12. "Secondary License"
68
+ means either the GNU General Public License, Version 2.0, the GNU
69
+ Lesser General Public License, Version 2.1, the GNU Affero General
70
+ Public License, Version 3.0, or any later versions of those
71
+ licenses.
72
+
73
+ 1.13. "Source Code Form"
74
+ means the form of the work preferred for making modifications.
75
+
76
+ 1.14. "You" (or "Your")
77
+ means an individual or a legal entity exercising rights under this
78
+ License. For legal entities, "You" includes any entity that
79
+ controls, is controlled by, or is under common control with You. For
80
+ purposes of this definition, "control" means (a) the power, direct
81
+ or indirect, to cause the direction or management of such entity,
82
+ whether by contract or otherwise, or (b) ownership of more than
83
+ fifty percent (50%) of the outstanding shares or beneficial
84
+ ownership of such entity.
85
+
86
+ 2. License Grants and Conditions
87
+ --------------------------------
88
+
89
+ 2.1. Grants
90
+
91
+ Each Contributor hereby grants You a world-wide, royalty-free,
92
+ non-exclusive license:
93
+
94
+ (a) under intellectual property rights (other than patent or trademark)
95
+ Licensable by such Contributor to use, reproduce, make available,
96
+ modify, display, perform, distribute, and otherwise exploit its
97
+ Contributions, either on an unmodified basis, with Modifications, or
98
+ as part of a Larger Work; and
99
+
100
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
101
+ for sale, have made, import, and otherwise transfer either its
102
+ Contributions or its Contributor Version.
103
+
104
+ 2.2. Effective Date
105
+
106
+ The licenses granted in Section 2.1 with respect to any Contribution
107
+ become effective for each Contribution on the date the Contributor first
108
+ distributes such Contribution.
109
+
110
+ 2.3. Limitations on Grant Scope
111
+
112
+ The licenses granted in this Section 2 are the only rights granted under
113
+ this License. No additional rights or licenses will be implied from the
114
+ distribution or licensing of Covered Software under this License.
115
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
116
+ Contributor:
117
+
118
+ (a) for any code that a Contributor has removed from Covered Software;
119
+ or
120
+
121
+ (b) for infringements caused by: (i) Your and any other third party's
122
+ modifications of Covered Software, or (ii) the combination of its
123
+ Contributions with other software (except as part of its Contributor
124
+ Version); or
125
+
126
+ (c) under Patent Claims infringed by Covered Software in the absence of
127
+ its Contributions.
128
+
129
+ This License does not grant any rights in the trademarks, service marks,
130
+ or logos of any Contributor (except as may be necessary to comply with
131
+ the notice requirements in Section 3.4).
132
+
133
+ 2.4. Subsequent Licenses
134
+
135
+ No Contributor makes additional grants as a result of Your choice to
136
+ distribute the Covered Software under a subsequent version of this
137
+ License (see Section 10.2) or under the terms of a Secondary License (if
138
+ permitted under the terms of Section 3.3).
139
+
140
+ 2.5. Representation
141
+
142
+ Each Contributor represents that the Contributor believes its
143
+ Contributions are its original creation(s) or it has sufficient rights
144
+ to grant the rights to its Contributions conveyed by this License.
145
+
146
+ 2.6. Fair Use
147
+
148
+ This License is not intended to limit any rights You have under
149
+ applicable copyright doctrines of fair use, fair dealing, or other
150
+ equivalents.
151
+
152
+ 2.7. Conditions
153
+
154
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155
+ in Section 2.1.
156
+
157
+ 3. Responsibilities
158
+ -------------------
159
+
160
+ 3.1. Distribution of Source Form
161
+
162
+ All distribution of Covered Software in Source Code Form, including any
163
+ Modifications that You create or to which You contribute, must be under
164
+ the terms of this License. You must inform recipients that the Source
165
+ Code Form of the Covered Software is governed by the terms of this
166
+ License, and how they can obtain a copy of this License. You may not
167
+ attempt to alter or restrict the recipients' rights in the Source Code
168
+ Form.
169
+
170
+ 3.2. Distribution of Executable Form
171
+
172
+ If You distribute Covered Software in Executable Form then:
173
+
174
+ (a) such Covered Software must also be made available in Source Code
175
+ Form, as described in Section 3.1, and You must inform recipients of
176
+ the Executable Form how they can obtain a copy of such Source Code
177
+ Form by reasonable means in a timely manner, at a charge no more
178
+ than the cost of distribution to the recipient; and
179
+
180
+ (b) You may distribute such Executable Form under the terms of this
181
+ License, or sublicense it under different terms, provided that the
182
+ license for the Executable Form does not attempt to limit or alter
183
+ the recipients' rights in the Source Code Form under this License.
184
+
185
+ 3.3. Distribution of a Larger Work
186
+
187
+ You may create and distribute a Larger Work under terms of Your choice,
188
+ provided that You also comply with the requirements of this License for
189
+ the Covered Software. If the Larger Work is a combination of Covered
190
+ Software with a work governed by one or more Secondary Licenses, and the
191
+ Covered Software is not Incompatible With Secondary Licenses, this
192
+ License permits You to additionally distribute such Covered Software
193
+ under the terms of such Secondary License(s), so that the recipient of
194
+ the Larger Work may, at their option, further distribute the Covered
195
+ Software under the terms of either this License or such Secondary
196
+ License(s).
197
+
198
+ 3.4. Notices
199
+
200
+ You may not remove or alter the substance of any license notices
201
+ (including copyright notices, patent notices, disclaimers of warranty,
202
+ or limitations of liability) contained within the Source Code Form of
203
+ the Covered Software, except that You may alter any license notices to
204
+ the extent required to remedy known factual inaccuracies.
205
+
206
+ 3.5. Application of Additional Terms
207
+
208
+ You may choose to offer, and to charge a fee for, warranty, support,
209
+ indemnity or liability obligations to one or more recipients of Covered
210
+ Software. However, You may do so only on Your own behalf, and not on
211
+ behalf of any Contributor. You must make it absolutely clear that any
212
+ such warranty, support, indemnity, or liability obligation is offered by
213
+ You alone, and You hereby agree to indemnify every Contributor for any
214
+ liability incurred by such Contributor as a result of warranty, support,
215
+ indemnity or liability terms You offer. You may include additional
216
+ disclaimers of warranty and limitations of liability specific to any
217
+ jurisdiction.
218
+
219
+ 4. Inability to Comply Due to Statute or Regulation
220
+ ---------------------------------------------------
221
+
222
+ If it is impossible for You to comply with any of the terms of this
223
+ License with respect to some or all of the Covered Software due to
224
+ statute, judicial order, or regulation then You must: (a) comply with
225
+ the terms of this License to the maximum extent possible; and (b)
226
+ describe the limitations and the code they affect. Such description must
227
+ be placed in a text file included with all distributions of the Covered
228
+ Software under this License. Except to the extent prohibited by statute
229
+ or regulation, such description must be sufficiently detailed for a
230
+ recipient of ordinary skill to be able to understand it.
231
+
232
+ 5. Termination
233
+ --------------
234
+
235
+ 5.1. The rights granted under this License will terminate automatically
236
+ if You fail to comply with any of its terms. However, if You become
237
+ compliant, then the rights granted under this License from a particular
238
+ Contributor are reinstated (a) provisionally, unless and until such
239
+ Contributor explicitly and finally terminates Your grants, and (b) on an
240
+ ongoing basis, if such Contributor fails to notify You of the
241
+ non-compliance by some reasonable means prior to 60 days after You have
242
+ come back into compliance. Moreover, Your grants from a particular
243
+ Contributor are reinstated on an ongoing basis if such Contributor
244
+ notifies You of the non-compliance by some reasonable means, this is the
245
+ first time You have received notice of non-compliance with this License
246
+ from such Contributor, and You become compliant prior to 30 days after
247
+ Your receipt of the notice.
248
+
249
+ 5.2. If You initiate litigation against any entity by asserting a patent
250
+ infringement claim (excluding declaratory judgment actions,
251
+ counter-claims, and cross-claims) alleging that a Contributor Version
252
+ directly or indirectly infringes any patent, then the rights granted to
253
+ You by any and all Contributors for the Covered Software under Section
254
+ 2.1 of this License shall terminate.
255
+
256
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257
+ end user license agreements (excluding distributors and resellers) which
258
+ have been validly granted by You or Your distributors under this License
259
+ prior to termination shall survive termination.
260
+
261
+ ************************************************************************
262
+ * *
263
+ * 6. Disclaimer of Warranty *
264
+ * ------------------------- *
265
+ * *
266
+ * Covered Software is provided under this License on an "as is" *
267
+ * basis, without warranty of any kind, either expressed, implied, or *
268
+ * statutory, including, without limitation, warranties that the *
269
+ * Covered Software is free of defects, merchantable, fit for a *
270
+ * particular purpose or non-infringing. The entire risk as to the *
271
+ * quality and performance of the Covered Software is with You. *
272
+ * Should any Covered Software prove defective in any respect, You *
273
+ * (not any Contributor) assume the cost of any necessary servicing, *
274
+ * repair, or correction. This disclaimer of warranty constitutes an *
275
+ * essential part of this License. No use of any Covered Software is *
276
+ * authorized under this License except under this disclaimer. *
277
+ * *
278
+ ************************************************************************
279
+
280
+ ************************************************************************
281
+ * *
282
+ * 7. Limitation of Liability *
283
+ * -------------------------- *
284
+ * *
285
+ * Under no circumstances and under no legal theory, whether tort *
286
+ * (including negligence), contract, or otherwise, shall any *
287
+ * Contributor, or anyone who distributes Covered Software as *
288
+ * permitted above, be liable to You for any direct, indirect, *
289
+ * special, incidental, or consequential damages of any character *
290
+ * including, without limitation, damages for lost profits, loss of *
291
+ * goodwill, work stoppage, computer failure or malfunction, or any *
292
+ * and all other commercial damages or losses, even if such party *
293
+ * shall have been informed of the possibility of such damages. This *
294
+ * limitation of liability shall not apply to liability for death or *
295
+ * personal injury resulting from such party's negligence to the *
296
+ * extent applicable law prohibits such limitation. Some *
297
+ * jurisdictions do not allow the exclusion or limitation of *
298
+ * incidental or consequential damages, so this exclusion and *
299
+ * limitation may not apply to You. *
300
+ * *
301
+ ************************************************************************
302
+
303
+ 8. Litigation
304
+ -------------
305
+
306
+ Any litigation relating to this License may be brought only in the
307
+ courts of a jurisdiction where the defendant maintains its principal
308
+ place of business and such litigation shall be governed by laws of that
309
+ jurisdiction, without reference to its conflict-of-law provisions.
310
+ Nothing in this Section shall prevent a party's ability to bring
311
+ cross-claims or counter-claims.
312
+
313
+ 9. Miscellaneous
314
+ ----------------
315
+
316
+ This License represents the complete agreement concerning the subject
317
+ matter hereof. If any provision of this License is held to be
318
+ unenforceable, such provision shall be reformed only to the extent
319
+ necessary to make it enforceable. Any law or regulation which provides
320
+ that the language of a contract shall be construed against the drafter
321
+ shall not be used to construe this License against a Contributor.
322
+
323
+ 10. Versions of the License
324
+ ---------------------------
325
+
326
+ 10.1. New Versions
327
+
328
+ Mozilla Foundation is the license steward. Except as provided in Section
329
+ 10.3, no one other than the license steward has the right to modify or
330
+ publish new versions of this License. Each version will be given a
331
+ distinguishing version number.
332
+
333
+ 10.2. Effect of New Versions
334
+
335
+ You may distribute the Covered Software under the terms of the version
336
+ of the License under which You originally received the Covered Software,
337
+ or under the terms of any subsequent version published by the license
338
+ steward.
339
+
340
+ 10.3. Modified Versions
341
+
342
+ If you create software not governed by this License, and you want to
343
+ create a new license for such software, you may create and use a
344
+ modified version of this License if you rename the license and remove
345
+ any references to the name of the license steward (except to note that
346
+ such modified license differs from this License).
347
+
348
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
349
+ Licenses
350
+
351
+ If You choose to distribute Source Code Form that is Incompatible With
352
+ Secondary Licenses under the terms of this version of the License, the
353
+ notice described in Exhibit B of this License must be attached.
354
+
355
+ Exhibit A - Source Code Form License Notice
356
+ -------------------------------------------
357
+
358
+ This Source Code Form is subject to the terms of the Mozilla Public
359
+ License, v. 2.0. If a copy of the MPL was not distributed with this
360
+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
361
+
362
+ If it is not possible or desirable to put the notice in a particular
363
+ file, then You may include the notice in a location (such as a LICENSE
364
+ file in a relevant directory) where a recipient would be likely to look
365
+ for such a notice.
366
+
367
+ You may add additional accurate notices of copyright ownership.
368
+
369
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
370
+ ---------------------------------------------------------
371
+
372
+ This Source Code Form is "Incompatible With Secondary Licenses", as
373
+ defined by the Mozilla Public License, v. 2.0.
node_modules/lightningcss-win32-x64-msvc/README.md ADDED
@@ -0,0 +1 @@
 
 
1
+ This is the x86_64-pc-windows-msvc build of lightningcss. See https://github.com/parcel-bundler/lightningcss for details.
node_modules/lightningcss-win32-x64-msvc/lightningcss.win32-x64-msvc.node ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83e7e838ef1bbf5454c651103574fec31a1cec0b453b999d1173365cbc6c7841
3
+ size 9497600
node_modules/lightningcss-win32-x64-msvc/package.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "lightningcss-win32-x64-msvc",
3
+ "version": "1.32.0",
4
+ "license": "MPL-2.0",
5
+ "description": "A CSS parser, transformer, and minifier written in Rust",
6
+ "main": "lightningcss.win32-x64-msvc.node",
7
+ "browserslist": "last 2 versions, not dead",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "funding": {
12
+ "type": "opencollective",
13
+ "url": "https://opencollective.com/parcel"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/parcel-bundler/lightningcss.git"
18
+ },
19
+ "engines": {
20
+ "node": ">= 12.0.0"
21
+ },
22
+ "files": [
23
+ "lightningcss.win32-x64-msvc.node"
24
+ ],
25
+ "resolutions": {
26
+ "lightningcss": "link:."
27
+ },
28
+ "os": [
29
+ "win32"
30
+ ],
31
+ "cpu": [
32
+ "x64"
33
+ ]
34
+ }
node_modules/postgres/README.md ADDED
@@ -0,0 +1,1392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <img align="left" width="440" height="180" alt="Fastest full PostgreSQL nodejs client" src="https://raw.githubusercontent.com/porsager/postgres/master/postgresjs.svg?sanitize=true">
2
+
3
+ - [🚀 Fastest full-featured node & deno client](https://github.com/porsager/postgres-benchmarks#results)
4
+ - 🏷 ES6 Tagged Template Strings at the core
5
+ - 🏄‍♀️ Simple surface API
6
+ - 🖊️ Dynamic query support
7
+ - 💬 Chat and help on [Gitter](https://gitter.im/porsager/postgres)
8
+ - 🐦 Follow on [Twitter](https://twitter.com/rporsager)
9
+
10
+ <br>
11
+
12
+ ## Getting started
13
+
14
+ <br>
15
+ <img height="220" width="458" alt="Good UX with Postgres.js" src="https://raw.githubusercontent.com/porsager/postgres/master/demo.gif">
16
+ <br>
17
+
18
+ ### Installation
19
+ ```bash
20
+ $ npm install postgres
21
+ ```
22
+
23
+ ### Usage
24
+ Create your `sql` database instance
25
+ ```js
26
+ // db.js
27
+ import postgres from 'postgres'
28
+
29
+ const sql = postgres({ /* options */ }) // will use psql environment variables
30
+
31
+ export default sql
32
+ ```
33
+
34
+ Simply import for use elsewhere
35
+ ```js
36
+ // users.js
37
+ import sql from './db.js'
38
+
39
+ async function getUsersOver(age) {
40
+ const users = await sql`
41
+ select
42
+ name,
43
+ age
44
+ from users
45
+ where age > ${ age }
46
+ `
47
+ // users = Result [{ name: "Walter", age: 80 }, { name: 'Murray', age: 68 }, ...]
48
+ return users
49
+ }
50
+
51
+
52
+ async function insertUser({ name, age }) {
53
+ const users = await sql`
54
+ insert into users
55
+ (name, age)
56
+ values
57
+ (${ name }, ${ age })
58
+ returning name, age
59
+ `
60
+ // users = Result [{ name: "Murray", age: 68 }]
61
+ return users
62
+ }
63
+ ```
64
+
65
+ #### ESM dynamic imports
66
+
67
+ The library can be used with ESM dynamic imports as well as shown here.
68
+
69
+ ```js
70
+ const { default: postgres } = await import('postgres')
71
+ ```
72
+
73
+ ## Table of Contents
74
+
75
+ * [Connection](#connection)
76
+ * [Queries](#queries)
77
+ * [Building queries](#building-queries)
78
+ * [Advanced query methods](#advanced-query-methods)
79
+ * [Transactions](#transactions)
80
+ * [Data Transformation](#data-transformation)
81
+ * [Listen & notify](#listen--notify)
82
+ * [Realtime subscribe](#realtime-subscribe)
83
+ * [Numbers, bigint, numeric](#numbers-bigint-numeric)
84
+ * [Result Array](#result-array)
85
+ * [Connection details](#connection-details)
86
+ * [Custom Types](#custom-types)
87
+ * [Teardown / Cleanup](#teardown--cleanup)
88
+ * [Error handling](#error-handling)
89
+ * [TypeScript support](#typescript-support)
90
+ * [Reserving connections](#reserving-connections)
91
+ * [Changelog](./CHANGELOG.md)
92
+
93
+
94
+ ## Connection
95
+
96
+ ### `postgres([url], [options])`
97
+
98
+ You can use either a `postgres://` url connection string or the options to define your database connection properties. Options in the object will override any present in the url. Options will fall back to the same environment variables as psql.
99
+
100
+ ```js
101
+ const sql = postgres('postgres://username:password@host:port/database', {
102
+ host : '', // Postgres ip address[s] or domain name[s]
103
+ port : 5432, // Postgres server port[s]
104
+ database : '', // Name of database to connect to
105
+ username : '', // Username of database user
106
+ password : '', // Password of database user
107
+ ...and more
108
+ })
109
+ ```
110
+
111
+ More options can be found in the [Connection details section](#connection-details).
112
+
113
+ ## Queries
114
+
115
+ ### ```await sql`...` -> Result[]```
116
+
117
+ Postgres.js utilizes [Tagged template functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates) to process query parameters **before** interpolation. Using tagged template literals benefits developers by:
118
+
119
+ 1. **Enforcing** safe query generation
120
+ 2. Giving the ` sql`` ` function powerful [utility](#dynamic-inserts) and [query building](#building-queries) features.
121
+
122
+ Any generic value will be serialized according to an inferred type, and replaced by a PostgreSQL protocol placeholder `$1, $2, ...`. The parameters are then sent separately to the database which handles escaping & casting.
123
+
124
+ All queries will return a `Result` array, with objects mapping column names to each row.
125
+
126
+ ```js
127
+ const xs = await sql`
128
+ insert into users (
129
+ name, age
130
+ ) values (
131
+ 'Murray', 68
132
+ )
133
+
134
+ returning *
135
+ `
136
+
137
+ // xs = [{ user_id: 1, name: 'Murray', age: 68 }]
138
+ ```
139
+
140
+ > Please note that queries are first executed when `awaited` – or instantly by using [`.execute()`](#execute).
141
+
142
+ ### Query parameters
143
+
144
+ Parameters are automatically extracted and handled by the database so that SQL injection isn't possible. No special handling is necessary, simply use tagged template literals as usual.
145
+
146
+ ```js
147
+ const name = 'Mur'
148
+ , age = 60
149
+
150
+ const users = await sql`
151
+ select
152
+ name,
153
+ age
154
+ from users
155
+ where
156
+ name like ${ name + '%' }
157
+ and age > ${ age }
158
+ `
159
+ // users = [{ name: 'Murray', age: 68 }]
160
+ ```
161
+
162
+ > Be careful with quotation marks here. Because Postgres infers column types, you do not need to wrap your interpolated parameters in quotes like `'${name}'`. This will cause an error because the tagged template replaces `${name}` with `$1` in the query string, leaving Postgres to do the interpolation. If you wrap that in a string, Postgres will see `'$1'` and interpret it as a string as opposed to a parameter.
163
+
164
+ ### Dynamic column selection
165
+
166
+ ```js
167
+ const columns = ['name', 'age']
168
+
169
+ await sql`
170
+ select
171
+ ${ sql(columns) }
172
+ from users
173
+ `
174
+
175
+ // Which results in:
176
+ select "name", "age" from users
177
+ ```
178
+
179
+ ### Dynamic inserts
180
+
181
+ ```js
182
+ const user = {
183
+ name: 'Murray',
184
+ age: 68
185
+ }
186
+
187
+ await sql`
188
+ insert into users ${
189
+ sql(user, 'name', 'age')
190
+ }
191
+ `
192
+
193
+ // Which results in:
194
+ insert into users ("name", "age") values ($1, $2)
195
+
196
+ // The columns can also be given with an array
197
+ const columns = ['name', 'age']
198
+
199
+ await sql`
200
+ insert into users ${
201
+ sql(user, columns)
202
+ }
203
+ `
204
+ ```
205
+
206
+ **You can omit column names and simply execute `sql(user)` to get all the fields from the object as columns**. Be careful not to allow users to supply columns that you do not want to be inserted.
207
+
208
+ #### Multiple inserts in one query
209
+ If you need to insert multiple rows at the same time it's also much faster to do it with a single `insert`. Simply pass an array of objects to `sql()`.
210
+
211
+ ```js
212
+ const users = [{
213
+ name: 'Murray',
214
+ age: 68,
215
+ garbage: 'ignore'
216
+ },
217
+ {
218
+ name: 'Walter',
219
+ age: 80
220
+ }]
221
+
222
+ await sql`insert into users ${ sql(users, 'name', 'age') }`
223
+
224
+ // Is translated to:
225
+ insert into users ("name", "age") values ($1, $2), ($3, $4)
226
+
227
+ // Here you can also omit column names which will use object keys as columns
228
+ await sql`insert into users ${ sql(users) }`
229
+
230
+ // Which results in:
231
+ insert into users ("name", "age") values ($1, $2), ($3, $4)
232
+ ```
233
+
234
+ ### Dynamic columns in updates
235
+ This is also useful for update queries
236
+ ```js
237
+ const user = {
238
+ id: 1,
239
+ name: 'Murray',
240
+ age: 68
241
+ }
242
+
243
+ await sql`
244
+ update users set ${
245
+ sql(user, 'name', 'age')
246
+ }
247
+ where user_id = ${ user.id }
248
+ `
249
+
250
+ // Which results in:
251
+ update users set "name" = $1, "age" = $2 where user_id = $3
252
+
253
+ // The columns can also be given with an array
254
+ const columns = ['name', 'age']
255
+
256
+ await sql`
257
+ update users set ${
258
+ sql(user, columns)
259
+ }
260
+ where user_id = ${ user.id }
261
+ `
262
+ ```
263
+
264
+ ### Multiple updates in one query
265
+ To create multiple updates in a single query, it is necessary to use arrays instead of objects to ensure that the order of the items correspond with the column names.
266
+ ```js
267
+ const users = [
268
+ [1, 'John', 34],
269
+ [2, 'Jane', 27],
270
+ ]
271
+
272
+ await sql`
273
+ update users set name = update_data.name, age = (update_data.age)::int
274
+ from (values ${sql(users)}) as update_data (id, name, age)
275
+ where users.id = (update_data.id)::int
276
+ returning users.id, users.name, users.age
277
+ `
278
+ ```
279
+
280
+ ### Dynamic values and `where in`
281
+ Value lists can also be created dynamically, making `where in` queries simple too.
282
+ ```js
283
+ const users = await sql`
284
+ select
285
+ *
286
+ from users
287
+ where age in ${ sql([68, 75, 23]) }
288
+ `
289
+ ```
290
+
291
+ or
292
+ ```js
293
+ const [{ a, b, c }] = await sql`
294
+ select
295
+ *
296
+ from (values ${ sql(['a', 'b', 'c']) }) as x(a, b, c)
297
+ `
298
+ ```
299
+
300
+ ## Building queries
301
+
302
+ Postgres.js features a simple dynamic query builder by conditionally appending/omitting query fragments.
303
+ It works by nesting ` sql`` ` fragments within other ` sql`` ` calls or fragments. This allows you to build dynamic queries safely without risking sql injections through usual string concatenation.
304
+
305
+ ### Partial queries
306
+ ```js
307
+ const olderThan = x => sql`and age > ${ x }`
308
+
309
+ const filterAge = true
310
+
311
+ await sql`
312
+ select
313
+ *
314
+ from users
315
+ where name is not null ${
316
+ filterAge
317
+ ? olderThan(50)
318
+ : sql``
319
+ }
320
+ `
321
+ // Which results in:
322
+ select * from users where name is not null
323
+ // Or
324
+ select * from users where name is not null and age > 50
325
+ ```
326
+
327
+ ### Dynamic filters
328
+ ```js
329
+ await sql`
330
+ select
331
+ *
332
+ from users ${
333
+ id
334
+ ? sql`where user_id = ${ id }`
335
+ : sql``
336
+ }
337
+ `
338
+
339
+ // Which results in:
340
+ select * from users
341
+ // Or
342
+ select * from users where user_id = $1
343
+ ```
344
+
345
+ ### Dynamic ordering
346
+
347
+ ```js
348
+ const id = 1
349
+ const order = {
350
+ username: 'asc'
351
+ created_at: 'desc'
352
+ }
353
+ await sql`
354
+ select
355
+ *
356
+ from ticket
357
+ where account = ${ id }
358
+ order by ${
359
+ Object.entries(order).flatMap(([column, order], i) =>
360
+ [i ? sql`,` : sql``, sql`${ sql(column) } ${ order === 'desc' ? sql`desc` : sql`asc` }`]
361
+ )
362
+ }
363
+ `
364
+ ```
365
+
366
+ ### SQL functions
367
+ Using keywords or calling functions dynamically is also possible by using ``` sql`` ``` fragments.
368
+ ```js
369
+ const date = null
370
+
371
+ await sql`
372
+ update users set updated_at = ${ date || sql`now()` }
373
+ `
374
+
375
+ // Which results in:
376
+ update users set updated_at = now()
377
+ ```
378
+
379
+ ### Table names
380
+ Dynamic identifiers like table names and column names is also supported like so:
381
+ ```js
382
+ const table = 'users'
383
+ , column = 'id'
384
+
385
+ await sql`
386
+ select ${ sql(column) } from ${ sql(table) }
387
+ `
388
+
389
+ // Which results in:
390
+ select "id" from "users"
391
+ ```
392
+
393
+ ### Quick primer on interpolation
394
+
395
+ Here's a quick oversight over all the ways to do interpolation in a query template string:
396
+
397
+ | Interpolation syntax | Usage | Example |
398
+ | ------------- | ------------- | ------------- |
399
+ | `${ sql`` }` | for keywords or sql fragments | ``await sql`SELECT * FROM users ${sql`order by age desc` }` `` |
400
+ | `${ sql(string) }` | for identifiers | ``await sql`SELECT * FROM ${sql('table_name')` `` |
401
+ | `${ sql([] or {}, ...) }` | for helpers | ``await sql`INSERT INTO users ${sql({ name: 'Peter'})}` `` |
402
+ | `${ 'somevalue' }` | for values | ``await sql`SELECT * FROM users WHERE age = ${42}` `` |
403
+
404
+ ## Advanced query methods
405
+
406
+ ### Cursors
407
+
408
+ #### ```await sql``.cursor([rows = 1], [fn])```
409
+
410
+ Use cursors if you need to throttle the amount of rows being returned from a query. You can use a cursor either as an [async iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) or with a callback function. For a callback function new results won't be requested until the promise / async callback function has resolved.
411
+
412
+ ##### callback function
413
+ ```js
414
+ await sql`
415
+ select
416
+ *
417
+ from generate_series(1,4) as x
418
+ `.cursor(async([row]) => {
419
+ // row = { x: 1 }
420
+ await http.request('https://example.com/wat', { row })
421
+ })
422
+ ```
423
+
424
+ ##### for await...of
425
+ ```js
426
+ // for await...of
427
+ const cursor = sql`select * from generate_series(1,4) as x`.cursor()
428
+
429
+ for await (const [row] of cursor) {
430
+ // row = { x: 1 }
431
+ await http.request('https://example.com/wat', { row })
432
+ }
433
+ ```
434
+
435
+ A single row will be returned by default, but you can also request batches by setting the number of rows desired in each batch as the first argument to `.cursor`:
436
+ ```js
437
+ await sql`
438
+ select
439
+ *
440
+ from generate_series(1,1000) as x
441
+ `.cursor(10, async rows => {
442
+ // rows = [{ x: 1 }, { x: 2 }, ... ]
443
+ await Promise.all(rows.map(row =>
444
+ http.request('https://example.com/wat', { row })
445
+ ))
446
+ })
447
+ ```
448
+
449
+ If an error is thrown inside the callback function no more rows will be requested and the outer promise will reject with the thrown error.
450
+
451
+ You can close the cursor early either by calling `break` in the `for await...of` loop, or by returning the token `sql.CLOSE` from the callback function.
452
+
453
+ ```js
454
+ await sql`
455
+ select * from generate_series(1,1000) as x
456
+ `.cursor(row => {
457
+ return Math.random() > 0.9 && sql.CLOSE // or sql.END
458
+ })
459
+ ```
460
+
461
+ ### Instant iteration
462
+
463
+ #### ```await sql``.forEach(fn)```
464
+
465
+ If you want to handle rows returned by a query one by one, you can use `.forEach` which returns a promise that resolves once there are no more rows.
466
+ ```js
467
+ await sql`
468
+ select created_at, name from events
469
+ `.forEach(row => {
470
+ // row = { created_at: '2019-11-22T14:22:00Z', name: 'connected' }
471
+ })
472
+
473
+ // No more rows
474
+ ```
475
+
476
+ ### Query Descriptions
477
+ #### ```await sql``.describe() -> Result[]```
478
+
479
+ Rather than executing a given query, `.describe` will return information utilized in the query process. This information can include the query identifier, column types, etc.
480
+
481
+ This is useful for debugging and analyzing your Postgres queries. Furthermore, **`.describe` will give you access to the final generated query string that would be executed.**
482
+
483
+ ### Rows as Array of Values
484
+ #### ```sql``.values()```
485
+
486
+ Using `.values` will return rows as an array of values for each column, instead of objects.
487
+
488
+ This can be useful to receive identically named columns, or for specific performance/transformation reasons. The column definitions are still included on the result array, plus access to parsers for each column.
489
+
490
+ ### Rows as Raw Array of Buffers
491
+ #### ```sql``.raw()```
492
+
493
+ Using `.raw` will return rows as an array with `Buffer` values for each column, instead of objects.
494
+
495
+ This can be useful for specific performance/transformation reasons. The column definitions are still included on the result array, plus access to parsers for each column.
496
+
497
+ ### Queries in Files
498
+ #### `await sql.file(path, [args], [options]) -> Result[]`
499
+
500
+ Using a file for a query is also supported with optional parameters to use if the file includes `$1, $2, etc`
501
+
502
+ ```js
503
+ const result = await sql.file('query.sql', ['Murray', 68])
504
+ ```
505
+
506
+ ### Multiple statements in one query
507
+ #### ```await sql``.simple()```
508
+
509
+ The postgres wire protocol supports ["simple"](https://www.postgresql.org/docs/current/protocol-flow.html#id-1.10.6.7.4) and ["extended"](https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY) queries. "simple" queries supports multiple statements, but does not support any dynamic parameters. "extended" queries support parameters but only one statement. To use "simple" queries you can use
510
+ ```sql``.simple()```. That will create it as a simple query.
511
+
512
+ ```js
513
+ await sql`select 1; select 2;`.simple()
514
+ ```
515
+
516
+ ### Copy to/from as Streams
517
+
518
+ Postgres.js supports [`COPY ...`](https://www.postgresql.org/docs/14/sql-copy.html) queries, which are exposed as [Node.js streams](https://nodejs.org/api/stream.html).
519
+
520
+ #### ```await sql`copy ... from stdin`.writable() -> Writable```
521
+
522
+ ```js
523
+ import { pipeline } from 'node:stream/promises'
524
+
525
+ // Stream of users with the default tab delimitated cells and new-line delimitated rows
526
+ const userStream = Readable.from([
527
+ 'Murray\t68\n',
528
+ 'Walter\t80\n'
529
+ ])
530
+
531
+ const query = await sql`copy users (name, age) from stdin`.writable()
532
+ await pipeline(userStream, query);
533
+ ```
534
+
535
+ #### ```await sql`copy ... to stdout`.readable() -> Readable```
536
+
537
+ ##### Using Stream Pipeline
538
+ ```js
539
+ import { pipeline } from 'node:stream/promises'
540
+ import { createWriteStream } from 'node:fs'
541
+
542
+ const readableStream = await sql`copy users (name, age) to stdout`.readable()
543
+ await pipeline(readableStream, createWriteStream('output.tsv'))
544
+ // output.tsv content: `Murray\t68\nWalter\t80\n`
545
+ ```
546
+
547
+ ##### Using `for await...of`
548
+ ```js
549
+ const readableStream = await sql`
550
+ copy (
551
+ select name, age
552
+ from users
553
+ where age = 68
554
+ ) to stdout
555
+ `.readable()
556
+ for await (const chunk of readableStream) {
557
+ // chunk.toString() === `Murray\t68\n`
558
+ }
559
+ ```
560
+
561
+ > **NOTE** This is a low-level API which does not provide any type safety. To make this work, you must match your [`copy query` parameters](https://www.postgresql.org/docs/14/sql-copy.html) correctly to your [Node.js stream read or write](https://nodejs.org/api/stream.html) code. Ensure [Node.js stream backpressure](https://nodejs.org/en/learn/modules/backpressuring-in-streams) is handled correctly to avoid memory exhaustion.
562
+
563
+ ### Canceling Queries in Progress
564
+
565
+ Postgres.js supports, [canceling queries in progress](https://www.postgresql.org/docs/7.1/protocol-protocol.html#AEN39000). It works by opening a new connection with a protocol level startup message to cancel the current query running on a specific connection. That means there is no guarantee that the query will be canceled, and due to the possible race conditions it might even result in canceling another query. This is fine for long running queries, but in the case of high load and fast queries it might be better to simply ignore results instead of canceling.
566
+
567
+ ```js
568
+ const query = sql`select pg_sleep 100`.execute()
569
+ setTimeout(() => query.cancel(), 100)
570
+ const result = await query
571
+ ```
572
+
573
+ ### Execute
574
+
575
+ #### ```await sql``.execute()```
576
+
577
+ The lazy Promise implementation in Postgres.js is what allows it to distinguish [Nested Fragments](#building-queries) from the main outer query. This also means that queries are always executed at the earliest in the following tick. If you have a specific need to execute the query in the same tick, you can call `.execute()`
578
+
579
+ ### Unsafe raw string queries
580
+
581
+ <details>
582
+ <summary>Advanced unsafe use cases</summary>
583
+
584
+ ### `await sql.unsafe(query, [args], [options]) -> Result[]`
585
+
586
+ If you know what you're doing, you can use `unsafe` to pass any string you'd like to postgres. Please note that this can lead to SQL injection if you're not careful.
587
+
588
+ ```js
589
+ sql.unsafe('select ' + danger + ' from users where id = ' + dragons)
590
+ ```
591
+
592
+ By default, `sql.unsafe` assumes the `query` string is sufficiently dynamic that prepared statements do not make sense, and so defaults them to off. If you'd like to re-enable prepared statements, you can pass `{ prepare: true }`.
593
+
594
+ You can also nest `sql.unsafe` within a safe `sql` expression. This is useful if only part of your fraction has unsafe elements.
595
+
596
+ ```js
597
+ const triggerName = 'friend_created'
598
+ const triggerFnName = 'on_friend_created'
599
+ const eventType = 'insert'
600
+ const schema_name = 'app'
601
+ const table_name = 'friends'
602
+
603
+ await sql`
604
+ create or replace trigger ${sql(triggerName)}
605
+ after ${sql.unsafe(eventType)} on ${sql.unsafe(`${schema_name}.${table_name}`)}
606
+ for each row
607
+ execute function ${sql(triggerFnName)}()
608
+ `
609
+
610
+ await sql`
611
+ create role friend_service with login password ${sql.unsafe(`'${password}'`)}
612
+ `
613
+ ```
614
+
615
+ </details>
616
+
617
+ ## Transactions
618
+
619
+ #### BEGIN / COMMIT `await sql.begin([options = ''], fn) -> fn()`
620
+
621
+ Use `sql.begin` to start a new transaction. Postgres.js will reserve a connection for the transaction and supply a scoped `sql` instance for all transaction uses in the callback function. `sql.begin` will resolve with the returned value from the callback function.
622
+
623
+ `BEGIN` is automatically sent with the optional options, and if anything fails `ROLLBACK` will be called so the connection can be released and execution can continue.
624
+
625
+ ```js
626
+ const [user, account] = await sql.begin(async sql => {
627
+ const [user] = await sql`
628
+ insert into users (
629
+ name
630
+ ) values (
631
+ 'Murray'
632
+ )
633
+ returning *
634
+ `
635
+
636
+ const [account] = await sql`
637
+ insert into accounts (
638
+ user_id
639
+ ) values (
640
+ ${ user.user_id }
641
+ )
642
+ returning *
643
+ `
644
+
645
+ return [user, account]
646
+ })
647
+ ```
648
+
649
+ Do note that you can often achieve the same result using [`WITH` queries (Common Table Expressions)](https://www.postgresql.org/docs/current/queries-with.html) instead of using transactions.
650
+
651
+ It's also possible to pipeline the requests in a transaction if needed by returning an array with queries from the callback function like this:
652
+
653
+ ```js
654
+ const result = await sql.begin(sql => [
655
+ sql`update ...`,
656
+ sql`update ...`,
657
+ sql`insert ...`
658
+ ])
659
+ ```
660
+
661
+ #### SAVEPOINT `await sql.savepoint([name], fn) -> fn()`
662
+
663
+ ```js
664
+ sql.begin('read write', async sql => {
665
+ const [user] = await sql`
666
+ insert into users (
667
+ name
668
+ ) values (
669
+ 'Murray'
670
+ )
671
+ `
672
+
673
+ const [account] = (await sql.savepoint(sql =>
674
+ sql`
675
+ insert into accounts (
676
+ user_id
677
+ ) values (
678
+ ${ user.user_id }
679
+ )
680
+ `
681
+ ).catch(err => {
682
+ // Account could not be created. ROLLBACK SAVEPOINT is called because we caught the rejection.
683
+ })) || []
684
+
685
+ return [user, account]
686
+ })
687
+ .then(([user, account]) => {
688
+ // great success - COMMIT succeeded
689
+ })
690
+ .catch(() => {
691
+ // not so good - ROLLBACK was called
692
+ })
693
+ ```
694
+
695
+
696
+ #### PREPARE TRANSACTION `await sql.prepare([name]) -> fn()`
697
+
698
+ Indicates that the transactions should be prepared using the [`PREPARE TRANSACTION [NAME]`](https://www.postgresql.org/docs/current/sql-prepare-transaction.html) statement
699
+ instead of being committed.
700
+
701
+ ```js
702
+ sql.begin('read write', async sql => {
703
+ const [user] = await sql`
704
+ insert into users (
705
+ name
706
+ ) values (
707
+ 'Murray'
708
+ )
709
+ `
710
+
711
+ await sql.prepare('tx1')
712
+ })
713
+ ```
714
+
715
+ ## Data Transformation
716
+
717
+ Postgres.js allows for transformation of the data passed to or returned from a query by using the `transform` option.
718
+
719
+ Built in transformation functions are:
720
+
721
+ * For camelCase - `postgres.camel`, `postgres.toCamel`, `postgres.fromCamel`
722
+ * For PascalCase - `postgres.pascal`, `postgres.toPascal`, `postgres.fromPascal`
723
+ * For Kebab-Case - `postgres.kebab`, `postgres.toKebab`, `postgres.fromKebab`
724
+
725
+ These built in transformations will only convert to/from snake_case. For example, using `{ transform: postgres.toCamel }` will convert the column names to camelCase only if the column names are in snake_case to begin with. `{ transform: postgres.fromCamel }` will convert camelCase only to snake_case.
726
+
727
+ By default, using `postgres.camel`, `postgres.pascal` and `postgres.kebab` will perform a two-way transformation - both the data passed to the query and the data returned by the query will be transformed:
728
+
729
+ ```js
730
+ // Transform the column names to and from camel case
731
+ const sql = postgres({ transform: postgres.camel })
732
+
733
+ await sql`CREATE TABLE IF NOT EXISTS camel_case (a_test INTEGER, b_test TEXT)`
734
+ await sql`INSERT INTO camel_case ${ sql([{ aTest: 1, bTest: 1 }]) }`
735
+ const data = await sql`SELECT ${ sql('aTest', 'bTest') } FROM camel_case`
736
+
737
+ console.log(data) // [ { aTest: 1, bTest: '1' } ]
738
+ ```
739
+
740
+ To only perform half of the transformation (eg. only the transformation **to** or **from** camel case), use the other transformation functions:
741
+
742
+ ```js
743
+ // Transform the column names only to camel case
744
+ // (for the results that are returned from the query)
745
+ postgres({ transform: postgres.toCamel })
746
+
747
+ await sql`CREATE TABLE IF NOT EXISTS camel_case (a_test INTEGER)`
748
+ await sql`INSERT INTO camel_case ${ sql([{ a_test: 1 }]) }`
749
+ const data = await sql`SELECT a_test FROM camel_case`
750
+
751
+ console.log(data) // [ { aTest: 1 } ]
752
+ ```
753
+
754
+ ```js
755
+ // Transform the column names only from camel case
756
+ // (for interpolated inserts, updates, and selects)
757
+ const sql = postgres({ transform: postgres.fromCamel })
758
+
759
+ await sql`CREATE TABLE IF NOT EXISTS camel_case (a_test INTEGER)`
760
+ await sql`INSERT INTO camel_case ${ sql([{ aTest: 1 }]) }`
761
+ const data = await sql`SELECT ${ sql('aTest') } FROM camel_case`
762
+
763
+ console.log(data) // [ { a_test: 1 } ]
764
+ ```
765
+
766
+ > Note that Postgres.js does not rewrite the static parts of the tagged template strings. So to transform column names in your queries, the `sql()` helper must be used - eg. `${ sql('columnName') }` as in the examples above.
767
+
768
+ ### Transform `undefined` Values
769
+
770
+ By default, Postgres.js will throw the error `UNDEFINED_VALUE: Undefined values are not allowed` when undefined values are passed
771
+
772
+ ```js
773
+ // Transform the column names to and from camel case
774
+ const sql = postgres({
775
+ transform: {
776
+ undefined: null
777
+ }
778
+ })
779
+
780
+ await sql`CREATE TABLE IF NOT EXISTS transform_undefined (a_test INTEGER)`
781
+ await sql`INSERT INTO transform_undefined ${ sql([{ a_test: undefined }]) }`
782
+ const data = await sql`SELECT a_test FROM transform_undefined`
783
+
784
+ console.log(data) // [ { a_test: null } ]
785
+ ```
786
+
787
+ To combine with the built in transform functions, spread the transform in the `transform` object:
788
+
789
+ ```js
790
+ // Transform the column names to and from camel case
791
+ const sql = postgres({
792
+ transform: {
793
+ ...postgres.camel,
794
+ undefined: null
795
+ }
796
+ })
797
+
798
+ await sql`CREATE TABLE IF NOT EXISTS transform_undefined (a_test INTEGER)`
799
+ await sql`INSERT INTO transform_undefined ${ sql([{ aTest: undefined }]) }`
800
+ const data = await sql`SELECT ${ sql('aTest') } FROM transform_undefined`
801
+
802
+ console.log(data) // [ { aTest: null } ]
803
+ ```
804
+
805
+ ### Custom Transform Functions
806
+
807
+ To specify your own transformation functions, you can use the `column`, `value` and `row` options inside of `transform`, each an object possibly including `to` and `from` keys:
808
+
809
+ * `to`: The function to transform the outgoing query column name to, i.e `SELECT ${ sql('aName') }` to `SELECT a_name` when using `postgres.toCamel`.
810
+ * `from`: The function to transform the incoming query result column name to, see example below.
811
+
812
+ > Both parameters are optional, if not provided, the default transformation function will be used.
813
+
814
+ ```js
815
+ // Implement your own functions, look at postgres.toCamel, etc
816
+ // as a reference:
817
+ // https://github.com/porsager/postgres/blob/4241824ffd7aa94ffb482e54ca9f585d9d0a4eea/src/types.js#L310-L328
818
+ function transformColumnToDatabase() { /* ... */ }
819
+ function transformColumnFromDatabase() { /* ... */ }
820
+
821
+ const sql = postgres({
822
+ transform: {
823
+ column: {
824
+ to: transformColumnToDatabase,
825
+ from: transformColumnFromDatabase,
826
+ },
827
+ value: { /* ... */ },
828
+ row: { /* ... */ }
829
+ }
830
+ })
831
+ ```
832
+
833
+ ## Listen & notify
834
+
835
+ When you call `.listen`, a dedicated connection will be created to ensure that you receive notifications instantly. This connection will be used for any further calls to `.listen`. The connection will automatically reconnect according to a backoff reconnection pattern to not overload the database server.
836
+
837
+ ### Listen `await sql.listen(channel, onnotify, [onlisten]) -> { state }`
838
+ `.listen` takes the channel name, a function to handle each notify, and an optional function to run every time listen is registered and ready (happens on initial connect and reconnects). It returns a promise which resolves once the `LISTEN` query to Postgres completes, or if there is already a listener active.
839
+
840
+ ```js
841
+ await sql.listen('news', payload => {
842
+ const json = JSON.parse(payload)
843
+ console.log(json.this) // logs 'is'
844
+ })
845
+ ```
846
+
847
+ The optional `onlisten` method is great to use for a very simply queue mechanism:
848
+
849
+ ```js
850
+ await sql.listen(
851
+ 'jobs',
852
+ (x) => run(JSON.parse(x)),
853
+ ( ) => sql`select unfinished_jobs()`.forEach(run)
854
+ )
855
+
856
+ function run(job) {
857
+ // And here you do the work you please
858
+ }
859
+ ```
860
+ ### Notify `await sql.notify(channel, payload) -> Result[]`
861
+ Notify can be done as usual in SQL, or by using the `sql.notify` method.
862
+ ```js
863
+ sql.notify('news', JSON.stringify({ no: 'this', is: 'news' }))
864
+ ```
865
+
866
+ ## Realtime subscribe
867
+
868
+ Postgres.js implements the logical replication protocol of PostgreSQL to support subscription to real-time updates of `insert`, `update` and `delete` operations.
869
+
870
+ > **NOTE** To make this work you must [create the proper publications in your database](https://www.postgresql.org/docs/current/sql-createpublication.html), enable logical replication by setting `wal_level = logical` in `postgresql.conf` and connect using either a replication or superuser.
871
+
872
+ ### Quick start
873
+
874
+ #### Create a publication (eg. in migration)
875
+ ```sql
876
+ CREATE PUBLICATION alltables FOR ALL TABLES
877
+ ```
878
+
879
+ #### Subscribe to updates
880
+ ```js
881
+ const sql = postgres({ publications: 'alltables' })
882
+
883
+ const { unsubscribe } = await sql.subscribe(
884
+ 'insert:events',
885
+ (row, { command, relation, key, old }) => {
886
+ // Callback function for each row change
887
+ // tell about new event row over eg. websockets or do something else
888
+ },
889
+ () => {
890
+ // Callback on initial connect and potential reconnects
891
+ }
892
+ )
893
+ ```
894
+
895
+ ### Subscribe pattern
896
+
897
+ You can subscribe to specific operations, tables, or even rows with primary keys.
898
+
899
+ #### `operation` `:` `schema` `.` `table` `=` `primary_key`
900
+
901
+ **`operation`** is one of ``` * | insert | update | delete ``` and defaults to `*`
902
+
903
+ **`schema`** defaults to `public`
904
+
905
+ **`table`** is a specific table name and defaults to `*`
906
+
907
+ **`primary_key`** can be used to only subscribe to specific rows
908
+
909
+ ### Examples
910
+
911
+ ```js
912
+ sql.subscribe('*', () => /* everything */ )
913
+ sql.subscribe('insert', () => /* all inserts */ )
914
+ sql.subscribe('*:users', () => /* all operations on the public.users table */ )
915
+ sql.subscribe('delete:users', () => /* all deletes on the public.users table */ )
916
+ sql.subscribe('update:users=1', () => /* all updates on the users row with a primary key = 1 */ )
917
+ ```
918
+
919
+ ## Numbers, bigint, numeric
920
+
921
+ `Number` in javascript is only able to represent 2<sup>53</sup>-1 safely which means that types in PostgreSQLs like `bigint` and `numeric` won't fit into `Number`.
922
+
923
+ Since Node.js v10.4 we can use [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) to match the PostgreSQL type `bigint` which is returned for eg. `count(*)`. Unfortunately, it doesn't work with `JSON.stringify` out of the box, so Postgres.js will return it as a string.
924
+
925
+ If you want to use `BigInt` you can add this custom type:
926
+
927
+ ```js
928
+ const sql = postgres({
929
+ types: {
930
+ bigint: postgres.BigInt
931
+ }
932
+ })
933
+ ```
934
+
935
+ There is currently no guaranteed way to handle `numeric` / `decimal` types in native Javascript. **These [and similar] types will be returned as a `string`**. The best way in this case is to use [custom types](#custom-types).
936
+
937
+ ## Result Array
938
+
939
+ The `Result` Array returned from queries is a custom array allowing for easy destructuring or passing on directly to JSON.stringify or general Array usage. It includes the following properties.
940
+
941
+ ### .count
942
+
943
+ The `count` property is the number of affected rows returned by the database. This is useful for insert, update and delete operations to know the number of rows since .length will be 0 in these cases if not using `RETURNING ...`.
944
+
945
+ ### .command
946
+
947
+ The `command` run by the query - eg. one of `SELECT`, `UPDATE`, `INSERT`, `DELETE`
948
+
949
+ ### .columns
950
+
951
+ The `columns` returned by the query useful to determine types, or map to the result values when using `.values()`
952
+
953
+ ```js
954
+ {
955
+ name : String, // Column name,
956
+ type : oid, // PostgreSQL oid column type
957
+ parser: Function // The function used by Postgres.js for parsing
958
+ }
959
+ ```
960
+
961
+ ### .statement
962
+
963
+ The `statement` contains information about the statement implicitly created by Postgres.js.
964
+
965
+ ```js
966
+ {
967
+ name : String, // The auto generated statement name
968
+ string : String, // The actual query string executed
969
+ types : [oid], // An array of oid expected as input parameters
970
+ columns : [Column] // Array of columns - same as Result.columns
971
+ }
972
+ ```
973
+
974
+ ### .state
975
+
976
+ This is the state `{ pid, secret }` of the connection that executed the query.
977
+
978
+ ## Connection details
979
+
980
+ ### All Postgres options
981
+
982
+ ```js
983
+ const sql = postgres('postgres://username:password@host:port/database', {
984
+ host : '', // Postgres ip address[es] or domain name[s]
985
+ port : 5432, // Postgres server port[s]
986
+ path : '', // unix socket path (usually '/tmp')
987
+ database : '', // Name of database to connect to
988
+ username : '', // Username of database user
989
+ password : '', // Password of database user
990
+ ssl : false, // true, prefer, require, tls.connect options
991
+ sslnegotiation : null, // direct
992
+ max : 10, // Max number of connections
993
+ max_lifetime : null, // Max lifetime in seconds (more info below)
994
+ idle_timeout : 0, // Idle connection timeout in seconds
995
+ connect_timeout : 30, // Connect timeout in seconds
996
+ prepare : true, // Automatic creation of prepared statements
997
+ types : [], // Array of custom types, see more below
998
+ onnotice : fn, // Default console.log, set false to silence NOTICE
999
+ onparameter : fn, // (key, value) when server param change
1000
+ debug : fn, // Is called with (connection, query, params, types)
1001
+ socket : fn, // fn returning custom socket to use
1002
+ transform : {
1003
+ undefined : undefined, // Transforms undefined values (eg. to null)
1004
+ column : fn, // Transforms incoming column names
1005
+ value : fn, // Transforms incoming row values
1006
+ row : fn // Transforms entire rows
1007
+ },
1008
+ connection : {
1009
+ application_name : 'postgres.js', // Default application_name
1010
+ ... // Other connection parameters, see https://www.postgresql.org/docs/current/runtime-config-client.html
1011
+ },
1012
+ target_session_attrs : null, // Use 'read-write' with multiple hosts to
1013
+ // ensure only connecting to primary
1014
+ fetch_types : true, // Automatically fetches types on connect
1015
+ // on initial connection.
1016
+ })
1017
+ ```
1018
+
1019
+ Note that `max_lifetime = 60 * (30 + Math.random() * 30)` by default. This resolves to an interval between 30 and 60 minutes to optimize for the benefits of prepared statements **and** working nicely with Linux's OOM killer.
1020
+
1021
+ ### Dynamic passwords
1022
+
1023
+ When clients need to use alternative authentication schemes such as access tokens or connections to databases with rotating passwords, provide either a synchronous or asynchronous function that will resolve the dynamic password value at connection time.
1024
+
1025
+ ```js
1026
+ const sql = postgres(url, {
1027
+ // Other connection config
1028
+ ...
1029
+ // Password function for the database user
1030
+ password : async () => await signer.getAuthToken(),
1031
+ })
1032
+ ```
1033
+
1034
+ ### SSL
1035
+
1036
+ Although [vulnerable to MITM attacks](https://security.stackexchange.com/a/229297/174913), a common configuration for the `ssl` option for some cloud providers is to set `rejectUnauthorized` to `false` (if `NODE_ENV` is `production`):
1037
+
1038
+ ```js
1039
+ const sql =
1040
+ process.env.NODE_ENV === 'production'
1041
+ ? // "Unless you're using a Private or Shield Heroku Postgres database, Heroku Postgres does not currently support verifiable certificates"
1042
+ // https://help.heroku.com/3DELT3RK/why-can-t-my-third-party-utility-connect-to-heroku-postgres-with-ssl
1043
+ postgres({ ssl: { rejectUnauthorized: false } })
1044
+ : postgres()
1045
+ ```
1046
+
1047
+ For more information regarding `ssl` with `postgres`, check out the [Node.js documentation for tls](https://nodejs.org/dist/latest-v16.x/docs/api/tls.html#new-tlstlssocketsocket-options).
1048
+
1049
+
1050
+ ### Multi-host connections - High Availability (HA)
1051
+
1052
+ Multiple connection strings can be passed to `postgres()` in the form of `postgres('postgres://localhost:5432,localhost:5433', ...)`. This works the same as native the `psql` command. Read more at [multiple host URIs](https://www.postgresql.org/docs/13/libpq-connect.html#LIBPQ-MULTIPLE-HOSTS).
1053
+
1054
+ Connections will be attempted in order of the specified hosts/ports. On a successful connection, all retries will be reset. This ensures that hosts can come up and down seamlessly.
1055
+
1056
+ If you specify `target_session_attrs: 'primary'` or `PGTARGETSESSIONATTRS=primary` Postgres.js will only connect to the primary host, allowing for zero downtime failovers.
1057
+
1058
+ ### The Connection Pool
1059
+
1060
+ Connections are created lazily once a query is created. This means that simply doing const `sql = postgres(...)` won't have any effect other than instantiating a new `sql` instance.
1061
+
1062
+ > No connection will be made until a query is made.
1063
+
1064
+ For example:
1065
+
1066
+ ```js
1067
+ const sql = postgres() // no connections are opened
1068
+
1069
+ await sql`...` // one connection is now opened
1070
+ await sql`...` // previous opened connection is reused
1071
+
1072
+ // two connections are opened now
1073
+ await Promise.all([
1074
+ sql`...`,
1075
+ sql`...`
1076
+ ])
1077
+ ```
1078
+
1079
+ > When there are high amount of concurrent queries, `postgres` will open as many connections as needed up until `max` number of connections is reached. By default `max` is 10. This can be changed by setting `max` in the `postgres()` call. Example - `postgres('connectionURL', { max: 20 })`.
1080
+
1081
+ This means that we get a much simpler story for error handling and reconnections. Queries will be sent over the wire immediately on the next available connection in the pool. Connections are automatically taken out of the pool if you start a transaction using `sql.begin()`, and automatically returned to the pool once your transaction is done.
1082
+
1083
+ Any query which was already sent over the wire will be rejected if the connection is lost. It'll automatically defer to the error handling you have for that query, and since connections are lazy it'll automatically try to reconnect the next time a query is made. The benefit of this is no weird generic "onerror" handler that tries to get things back to normal, and also simpler application code since you don't have to handle errors out of context.
1084
+
1085
+ There are no guarantees about queries executing in order unless using a transaction with `sql.begin()` or setting `max: 1`. Of course doing a series of queries, one awaiting the other will work as expected, but that's just due to the nature of js async/promise handling, so it's not necessary for this library to be concerned with ordering.
1086
+
1087
+ Since this library automatically creates prepared statements, it also has a default max lifetime for connections to prevent memory bloat on the database itself. This is a random interval for each connection between 45 and 90 minutes. This allows multiple connections to independently come up and down without affecting the service.
1088
+
1089
+ ### Connection timeout
1090
+
1091
+ By default, connections will not close until `.end()` is called. However, it may be useful to have them close automatically when:
1092
+
1093
+ - re-instantiating multiple ` sql`` ` instances
1094
+ - using Postgres.js in a Serverless environment (Lambda, etc.)
1095
+ - using Postgres.js with a database service that automatically closes connections after some time (see [`ECONNRESET` issue](https://github.com/porsager/postgres/issues/179))
1096
+
1097
+ This can be done using the `idle_timeout` or `max_lifetime` options. These configuration options specify the number of seconds to wait before automatically closing an idle connection and the maximum time a connection can exist, respectively.
1098
+
1099
+ For example, to close a connection that has either been idle for 20 seconds or existed for more than 30 minutes:
1100
+
1101
+ ```js
1102
+ const sql = postgres({
1103
+ idle_timeout: 20,
1104
+ max_lifetime: 60 * 30
1105
+ })
1106
+ ```
1107
+
1108
+ ### Cloudflare Workers support
1109
+
1110
+ Postgres.js has built-in support for the [TCP socket API](https://developers.cloudflare.com/workers/runtime-apis/tcp-sockets/) in Cloudflare Workers, which is [on-track](https://github.com/wintercg/proposal-sockets-api) to be standardized and adopted in Node.js and other JavaScript runtimes, such as Deno.
1111
+
1112
+ You can use Postgres.js directly in a Worker, or to benefit from connection pooling and query caching, via the [Hyperdrive](https://developers.cloudflare.com/hyperdrive/learning/connect-to-postgres/#driver-examples) service available to Workers by passing the Hyperdrive `connectionString` when creating a new `postgres` client as follows:
1113
+
1114
+ ```ts
1115
+ // Requires Postgres.js 3.4.0 or later
1116
+ import postgres from 'postgres'
1117
+
1118
+ interface Env {
1119
+ HYPERDRIVE: Hyperdrive;
1120
+ }
1121
+
1122
+ export default async fetch(req: Request, env: Env, ctx: ExecutionContext) {
1123
+ // The Postgres.js library accepts a connection string directly
1124
+ const sql = postgres(env.HYPERDRIVE.connectionString)
1125
+ const results = await sql`SELECT * FROM users LIMIT 10`
1126
+ return Response.json(results)
1127
+ }
1128
+ ```
1129
+
1130
+ In `wrangler.toml` you will need to enable the `nodejs_compat` compatibility flag to allow Postgres.js to operate in the Workers environment:
1131
+
1132
+ ```toml
1133
+ compatibility_flags = ["nodejs_compat"]
1134
+ ```
1135
+
1136
+ ### Auto fetching of array types
1137
+
1138
+ Postgres.js will automatically fetch table/array-type information when it first connects to a database.
1139
+
1140
+ If you have revoked access to `pg_catalog` this feature will no longer work and will need to be disabled.
1141
+
1142
+ You can disable this feature by setting `fetch_types` to `false`.
1143
+
1144
+ ### Environmental variables
1145
+
1146
+ It is also possible to connect to the database without a connection string or any options. Postgres.js will fall back to the common environment variables used by `psql` as in the table below:
1147
+
1148
+ ```js
1149
+ const sql = postgres()
1150
+ ```
1151
+
1152
+ | Option | Environment Variables |
1153
+ | ------------------ | ------------------------ |
1154
+ | `host` | `PGHOST` |
1155
+ | `port` | `PGPORT` |
1156
+ | `database` | `PGDATABASE` |
1157
+ | `username` | `PGUSERNAME` or `PGUSER` |
1158
+ | `password` | `PGPASSWORD` |
1159
+ | `application_name` | `PGAPPNAME` |
1160
+ | `idle_timeout` | `PGIDLE_TIMEOUT` |
1161
+ | `connect_timeout` | `PGCONNECT_TIMEOUT` |
1162
+
1163
+ ### Prepared statements
1164
+
1165
+ Prepared statements will automatically be created for any queries where it can be inferred that the query is static. This can be disabled by using the `prepare: false` option. For instance — this is useful when [using PGBouncer in `transaction mode`](https://github.com/porsager/postgres/issues/93#issuecomment-656290493).
1166
+
1167
+ **update**: [since 1.21.0](https://www.pgbouncer.org/2023/10/pgbouncer-1-21-0)
1168
+ PGBouncer supports protocol-level named prepared statements when [configured
1169
+ properly](https://www.pgbouncer.org/config.html#max_prepared_statements)
1170
+
1171
+ ## Custom Types
1172
+
1173
+ You can add ergonomic support for custom types, or simply use `sql.typed(value, type)` inline, where type is the PostgreSQL `oid` for the type and the correctly serialized string. _(`oid` values for types can be found in the `pg_catalog.pg_type` table.)_
1174
+
1175
+ Adding Query helpers is the cleanest approach which can be done like this:
1176
+
1177
+ ```js
1178
+ const sql = postgres({
1179
+ types: {
1180
+ rect: {
1181
+ // The pg_types oid to pass to the db along with the serialized value.
1182
+ to : 1337,
1183
+
1184
+ // An array of pg_types oids to handle when parsing values coming from the db.
1185
+ from : [1337],
1186
+
1187
+ //Function that transform values before sending them to the db.
1188
+ serialize : ({ x, y, width, height }) => [x, y, width, height],
1189
+
1190
+ // Function that transforms values coming from the db.
1191
+ parse : ([x, y, width, height]) => { x, y, width, height }
1192
+ }
1193
+ }
1194
+ })
1195
+
1196
+ // Now you can use sql.typed.rect() as specified above
1197
+ const [custom] = await sql`
1198
+ insert into rectangles (
1199
+ name,
1200
+ rect
1201
+ ) values (
1202
+ 'wat',
1203
+ ${ sql.typed.rect({ x: 13, y: 37, width: 42, height: 80 }) }
1204
+ )
1205
+ returning *
1206
+ `
1207
+
1208
+ // custom = { name: 'wat', rect: { x: 13, y: 37, width: 42, height: 80 } }
1209
+
1210
+ ```
1211
+
1212
+ ### Custom socket
1213
+
1214
+ Easily do in-process ssh tunneling to your database by providing a custom socket for Postgres.js to use. The function (optionally async) must return a socket-like duplex stream.
1215
+
1216
+ Here's a sample using [ssh2](https://github.com/mscdex/ssh2)
1217
+
1218
+ ```js
1219
+ import ssh2 from 'ssh2'
1220
+
1221
+ const sql = postgres({
1222
+ ...options,
1223
+ socket: ({ host: [host], port: [port] }) => new Promise((resolve, reject) => {
1224
+ const ssh = new ssh2.Client()
1225
+ ssh
1226
+ .on('error', reject)
1227
+ .on('ready', () =>
1228
+ ssh.forwardOut('127.0.0.1', 12345, host, port,
1229
+ (err, socket) => err ? reject(err) : resolve(socket)
1230
+ )
1231
+ )
1232
+ .connect(sshOptions)
1233
+ })
1234
+ })
1235
+ ```
1236
+
1237
+ ## Teardown / Cleanup
1238
+
1239
+ To ensure proper teardown and cleanup on server restarts use `await sql.end()` before `process.exit()`.
1240
+
1241
+ Calling `sql.end()` will reject new queries and return a Promise which resolves when all queries are finished and the underlying connections are closed. If a `{ timeout }` option is provided any pending queries will be rejected once the timeout (in seconds) is reached and the connections will be destroyed.
1242
+
1243
+ #### Sample shutdown using [Prexit](https://github.com/porsager/prexit)
1244
+
1245
+ ```js
1246
+ import prexit from 'prexit'
1247
+
1248
+ prexit(async () => {
1249
+ await sql.end({ timeout: 5 })
1250
+ await new Promise(r => server.close(r))
1251
+ })
1252
+ ```
1253
+
1254
+ ## Reserving connections
1255
+
1256
+ ### `await sql.reserve()`
1257
+
1258
+ The `reserve` method pulls out a connection from the pool, and returns a client that wraps the single connection. This can be used for running queries on an isolated connection.
1259
+
1260
+ ```ts
1261
+ const reserved = await sql.reserve()
1262
+ await reserved`select * from users`
1263
+ await reserved.release()
1264
+ ```
1265
+
1266
+ ### `reserved.release()`
1267
+
1268
+ Once you have finished with the reserved connection, call `release` to add it back to the pool.
1269
+
1270
+ ## Error handling
1271
+
1272
+ Errors are all thrown to related queries and never globally. Errors coming from database itself are always in the [native Postgres format](https://www.postgresql.org/docs/current/errcodes-appendix.html), and the same goes for any [Node.js errors](https://nodejs.org/api/errors.html#errors_common_system_errors) eg. coming from the underlying connection.
1273
+
1274
+ Query errors will contain a stored error with the origin of the query to aid in tracing errors.
1275
+
1276
+ Query errors will also contain the `query` string and the `parameters`. These are not enumerable to avoid accidentally leaking confidential information in logs. To log these it is required to specifically access `error.query` and `error.parameters`, or set `debug: true` in options.
1277
+
1278
+ There are also the following errors specifically for this library.
1279
+
1280
+ ##### UNSAFE_TRANSACTION
1281
+ > Only use sql.begin or max: 1
1282
+
1283
+ To ensure statements in a transaction runs on the same connection (which is required for them to run inside the transaction), you must use [`sql.begin(...)`](#transactions) or only allow a single connection in options (`max: 1`).
1284
+
1285
+ ##### UNDEFINED_VALUE
1286
+ > Undefined values are not allowed
1287
+
1288
+ Postgres.js won't accept `undefined` as values in tagged template queries since it becomes ambiguous what to do with the value. If you want to set something to null, use `null` explicitly.
1289
+
1290
+ ##### MESSAGE_NOT_SUPPORTED
1291
+ > X (X) is not supported
1292
+
1293
+ Whenever a message is received from Postgres which is not supported by this library. Feel free to file an issue if you think something is missing.
1294
+
1295
+ ##### MAX_PARAMETERS_EXCEEDED
1296
+ > Max number of parameters (65534) exceeded
1297
+
1298
+ The postgres protocol doesn't allow more than 65534 (16bit) parameters. If you run into this issue there are various workarounds such as using `sql([...])` to escape values instead of passing them as parameters.
1299
+
1300
+ ##### SASL_SIGNATURE_MISMATCH
1301
+ > Message type X not supported
1302
+
1303
+ When using SASL authentication the server responds with a signature at the end of the authentication flow which needs to match the one on the client. This is to avoid [man-in-the-middle attacks](https://en.wikipedia.org/wiki/Man-in-the-middle_attack). If you receive this error the connection was canceled because the server did not reply with the expected signature.
1304
+
1305
+ ##### NOT_TAGGED_CALL
1306
+ > Query not called as a tagged template literal
1307
+
1308
+ Making queries has to be done using the sql function as a [tagged template](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates). This is to ensure parameters are serialized and passed to Postgres as query parameters with correct types and to avoid SQL injection.
1309
+
1310
+ ##### AUTH_TYPE_NOT_IMPLEMENTED
1311
+ > Auth type X not implemented
1312
+
1313
+ Postgres supports many different authentication types. This one is not supported.
1314
+
1315
+ ##### CONNECTION_CLOSED
1316
+ > write CONNECTION_CLOSED host:port
1317
+
1318
+ This error is thrown if the connection was closed without an error. This should not happen during normal operations, so please create an issue if this was unexpected.
1319
+
1320
+ ##### CONNECTION_ENDED
1321
+ > write CONNECTION_ENDED host:port
1322
+
1323
+ This error is thrown if the user has called [`sql.end()`](#teardown--cleanup) and performed a query afterward.
1324
+
1325
+ ##### CONNECTION_DESTROYED
1326
+ > write CONNECTION_DESTROYED host:port
1327
+
1328
+ This error is thrown for any queries that were pending when the timeout to [`sql.end({ timeout: X })`](#teardown--cleanup) was reached.
1329
+
1330
+ ##### CONNECT_TIMEOUT
1331
+ > write CONNECT_TIMEOUT host:port
1332
+
1333
+ This error is thrown if the startup phase of the connection (tcp, protocol negotiation, and auth) took more than the default 30 seconds or what was specified using `connect_timeout` or `PGCONNECT_TIMEOUT`.
1334
+
1335
+ ##### COPY_IN_PROGRESS
1336
+ > You cannot execute queries during copy
1337
+
1338
+ This error is thrown if trying to run a query during a copy operation (writable / readable).
1339
+
1340
+ ## TypeScript support
1341
+
1342
+ `postgres` has TypeScript support. You can pass a row list type for your queries in this way:
1343
+ ```ts
1344
+ interface User {
1345
+ id: number
1346
+ name: string
1347
+ }
1348
+
1349
+ const users = await sql<User[]>`SELECT * FROM users`
1350
+ users[0].id // ok => number
1351
+ users[1].name // ok => string
1352
+ users[0].invalid // fails: `invalid` does not exists on `User`
1353
+ ```
1354
+
1355
+ However, be sure to check the array length to avoid accessing properties of `undefined` rows:
1356
+ ```ts
1357
+ const users = await sql<User[]>`SELECT * FROM users WHERE id = ${id}`
1358
+ if (!users.length)
1359
+ throw new Error('Not found')
1360
+ return users[0]
1361
+ ```
1362
+
1363
+ You can also prefer destructuring when you only care about a fixed number of rows.
1364
+ In this case, we recommend you to prefer using tuples to handle `undefined` properly:
1365
+ ```ts
1366
+ const [user]: [User?] = await sql`SELECT * FROM users WHERE id = ${id}`
1367
+ if (!user) // => User | undefined
1368
+ throw new Error('Not found')
1369
+ return user // => User
1370
+
1371
+ // NOTE:
1372
+ const [first, second]: [User?] = await sql`SELECT * FROM users WHERE id = ${id}` // fails: `second` does not exist on `[User?]`
1373
+ const [first, second] = await sql<[User?]>`SELECT * FROM users WHERE id = ${id}` // don't fail : `second: User | undefined`
1374
+ ```
1375
+
1376
+ We do our best to type all the public API, however types are not always updated when features are added or changed. Feel free to open an issue if you have trouble with types.
1377
+
1378
+ ## Migration tools
1379
+
1380
+ Postgres.js doesn't come with any migration solution since it's way out of scope, but here are some modules that support Postgres.js for migrations:
1381
+
1382
+ - https://github.com/porsager/postgres-shift
1383
+ - https://github.com/lukeed/ley
1384
+ - https://github.com/JAForbes/pgmg
1385
+
1386
+ ## Thank you
1387
+
1388
+ A really big thank you to [@JAForbes](https://twitter.com/jmsfbs) who introduced me to Postgres and still holds my hand navigating all the great opportunities we have.
1389
+
1390
+ Thanks to [@ACXgit](https://twitter.com/andreacoiutti) for initial tests and dogfooding.
1391
+
1392
+ Also thanks to [Ryan Dahl](https://github.com/ry) for letting me have the `postgres` npm package name.
node_modules/postgres/cf/polyfills.js ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { EventEmitter } from 'node:events'
2
+ import { Buffer } from 'node:buffer'
3
+
4
+ const Crypto = globalThis.crypto
5
+
6
+ let ids = 1
7
+ const tasks = new Set()
8
+
9
+ const v4Seg = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
10
+ const v4Str = `(${v4Seg}[.]){3}${v4Seg}`
11
+ const IPv4Reg = new RegExp(`^${v4Str}$`)
12
+
13
+ const v6Seg = '(?:[0-9a-fA-F]{1,4})'
14
+ const IPv6Reg = new RegExp(
15
+ '^(' +
16
+ `(?:${v6Seg}:){7}(?:${v6Seg}|:)|` +
17
+ `(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` +
18
+ `(?:${v6Seg}:){5}(?::${v4Str}|(:${v6Seg}){1,2}|:)|` +
19
+ `(?:${v6Seg}:){4}(?:(:${v6Seg}){0,1}:${v4Str}|(:${v6Seg}){1,3}|:)|` +
20
+ `(?:${v6Seg}:){3}(?:(:${v6Seg}){0,2}:${v4Str}|(:${v6Seg}){1,4}|:)|` +
21
+ `(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|` +
22
+ `(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|` +
23
+ `(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` +
24
+ ')(%[0-9a-zA-Z-.:]{1,})?$'
25
+ )
26
+
27
+ const textEncoder = new TextEncoder()
28
+ export const crypto = {
29
+ randomBytes: l => Crypto.getRandomValues(Buffer.alloc(l)),
30
+ pbkdf2Sync: async(password, salt, iterations, keylen) =>
31
+ Crypto.subtle.deriveBits(
32
+ {
33
+ name: 'PBKDF2',
34
+ hash: 'SHA-256',
35
+ salt,
36
+ iterations
37
+ },
38
+ await Crypto.subtle.importKey(
39
+ 'raw',
40
+ textEncoder.encode(password),
41
+ 'PBKDF2',
42
+ false,
43
+ ['deriveBits']
44
+ ),
45
+ keylen * 8,
46
+ ['deriveBits']
47
+ ),
48
+ createHash: type => ({
49
+ update: x => ({
50
+ digest: encoding => {
51
+ if (!(x instanceof Uint8Array)) {
52
+ x = textEncoder.encode(x)
53
+ }
54
+ let prom
55
+ if (type === 'sha256') {
56
+ prom = Crypto.subtle.digest('SHA-256', x)
57
+ } else if (type === 'md5') {
58
+ prom = Crypto.subtle.digest('md5', x)
59
+ } else {
60
+ throw Error('createHash only supports sha256 or md5 in this environment, not ${type}.')
61
+ }
62
+ if (encoding === 'hex') {
63
+ return prom.then((arrayBuf) => Buffer.from(arrayBuf).toString('hex'))
64
+ } else if (encoding) {
65
+ throw Error(`createHash only supports hex encoding or unencoded in this environment, not ${encoding}`)
66
+ } else {
67
+ return prom
68
+ }
69
+ }
70
+ })
71
+ }),
72
+ createHmac: (type, key) => ({
73
+ update: x => ({
74
+ digest: async() =>
75
+ Buffer.from(
76
+ await Crypto.subtle.sign(
77
+ 'HMAC',
78
+ await Crypto.subtle.importKey('raw', key, { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']),
79
+ textEncoder.encode(x)
80
+ )
81
+ )
82
+ })
83
+ })
84
+ }
85
+
86
+ export const performance = globalThis.performance
87
+
88
+ export const process = {
89
+ env: {}
90
+ }
91
+
92
+ export const os = {
93
+ userInfo() {
94
+ return { username: 'postgres' }
95
+ }
96
+ }
97
+
98
+ export const fs = {
99
+ readFile() {
100
+ throw new Error('Reading files not supported on CloudFlare')
101
+ }
102
+ }
103
+
104
+ export const net = {
105
+ isIP: (x) => IPv4Reg.test(x) ? 4 : IPv6Reg.test(x) ? 6 : 0,
106
+ Socket
107
+ }
108
+
109
+ export { setImmediate, clearImmediate }
110
+
111
+ export const tls = {
112
+ connect({ socket: tcp, servername }) {
113
+ tcp.writer.releaseLock()
114
+ tcp.reader.releaseLock()
115
+ tcp.readyState = 'upgrading'
116
+ tcp.raw = tcp.raw.startTls({ servername })
117
+ tcp.raw.closed.then(
118
+ () => tcp.emit('close'),
119
+ (e) => tcp.emit('error', e)
120
+ )
121
+ tcp.writer = tcp.raw.writable.getWriter()
122
+ tcp.reader = tcp.raw.readable.getReader()
123
+
124
+ tcp.writer.ready.then(() => {
125
+ tcp.read()
126
+ tcp.readyState = 'upgrade'
127
+ })
128
+ return tcp
129
+ }
130
+ }
131
+
132
+ function Socket() {
133
+ const tcp = Object.assign(new EventEmitter(), {
134
+ readyState: 'open',
135
+ raw: null,
136
+ writer: null,
137
+ reader: null,
138
+ connect,
139
+ write,
140
+ end,
141
+ destroy,
142
+ read
143
+ })
144
+
145
+ return tcp
146
+
147
+ async function connect(port, host) {
148
+ try {
149
+ tcp.readyState = 'opening'
150
+ const { connect } = await import('cloudflare:sockets')
151
+ tcp.raw = connect(host + ':' + port, tcp.ssl ? { secureTransport: 'starttls' } : {})
152
+ tcp.raw.closed.then(
153
+ () => {
154
+ tcp.readyState !== 'upgrade'
155
+ ? close()
156
+ : ((tcp.readyState = 'open'), tcp.emit('secureConnect'))
157
+ },
158
+ (e) => tcp.emit('error', e)
159
+ )
160
+ tcp.writer = tcp.raw.writable.getWriter()
161
+ tcp.reader = tcp.raw.readable.getReader()
162
+
163
+ tcp.ssl ? readFirst() : read()
164
+ tcp.writer.ready.then(() => {
165
+ tcp.readyState = 'open'
166
+ tcp.emit('connect')
167
+ })
168
+ } catch (err) {
169
+ error(err)
170
+ }
171
+ }
172
+
173
+ function close() {
174
+ if (tcp.readyState === 'closed')
175
+ return
176
+
177
+ tcp.readyState = 'closed'
178
+ tcp.emit('close')
179
+ }
180
+
181
+ function write(data, cb) {
182
+ tcp.writer.write(data).then(cb, error)
183
+ return true
184
+ }
185
+
186
+ function end(data) {
187
+ return data
188
+ ? tcp.write(data, () => tcp.raw.close())
189
+ : tcp.raw.close()
190
+ }
191
+
192
+ function destroy() {
193
+ tcp.destroyed = true
194
+ tcp.end()
195
+ }
196
+
197
+ async function read() {
198
+ try {
199
+ let done
200
+ , value
201
+ while (({ done, value } = await tcp.reader.read(), !done))
202
+ tcp.emit('data', Buffer.from(value))
203
+ } catch (err) {
204
+ error(err)
205
+ }
206
+ }
207
+
208
+ async function readFirst() {
209
+ const { value } = await tcp.reader.read()
210
+ tcp.emit('data', Buffer.from(value))
211
+ }
212
+
213
+ function error(err) {
214
+ tcp.emit('error', err)
215
+ tcp.emit('close')
216
+ }
217
+ }
218
+
219
+ function setImmediate(fn) {
220
+ const id = ids++
221
+ tasks.add(id)
222
+ queueMicrotask(() => {
223
+ if (tasks.has(id)) {
224
+ fn()
225
+ tasks.delete(id)
226
+ }
227
+ })
228
+ return id
229
+ }
230
+
231
+ function clearImmediate(id) {
232
+ tasks.delete(id)
233
+ }
node_modules/postgres/cf/src/bytes.js ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Buffer } from 'node:buffer'
2
+ const size = 256
3
+ let buffer = Buffer.allocUnsafe(size)
4
+
5
+ const messages = 'BCcDdEFfHPpQSX'.split('').reduce((acc, x) => {
6
+ const v = x.charCodeAt(0)
7
+ acc[x] = () => {
8
+ buffer[0] = v
9
+ b.i = 5
10
+ return b
11
+ }
12
+ return acc
13
+ }, {})
14
+
15
+ const b = Object.assign(reset, messages, {
16
+ N: String.fromCharCode(0),
17
+ i: 0,
18
+ inc(x) {
19
+ b.i += x
20
+ return b
21
+ },
22
+ str(x) {
23
+ const length = Buffer.byteLength(x)
24
+ fit(length)
25
+ b.i += buffer.write(x, b.i, length, 'utf8')
26
+ return b
27
+ },
28
+ i16(x) {
29
+ fit(2)
30
+ buffer.writeUInt16BE(x, b.i)
31
+ b.i += 2
32
+ return b
33
+ },
34
+ i32(x, i) {
35
+ if (i || i === 0) {
36
+ buffer.writeUInt32BE(x, i)
37
+ return b
38
+ }
39
+ fit(4)
40
+ buffer.writeUInt32BE(x, b.i)
41
+ b.i += 4
42
+ return b
43
+ },
44
+ z(x) {
45
+ fit(x)
46
+ buffer.fill(0, b.i, b.i + x)
47
+ b.i += x
48
+ return b
49
+ },
50
+ raw(x) {
51
+ buffer = Buffer.concat([buffer.subarray(0, b.i), x])
52
+ b.i = buffer.length
53
+ return b
54
+ },
55
+ end(at = 1) {
56
+ buffer.writeUInt32BE(b.i - at, at)
57
+ const out = buffer.subarray(0, b.i)
58
+ b.i = 0
59
+ buffer = Buffer.allocUnsafe(size)
60
+ return out
61
+ }
62
+ })
63
+
64
+ export default b
65
+
66
+ function fit(x) {
67
+ if (buffer.length - b.i < x) {
68
+ const prev = buffer
69
+ , length = prev.length
70
+
71
+ buffer = Buffer.allocUnsafe(length + (length >> 1) + x)
72
+ prev.copy(buffer)
73
+ }
74
+ }
75
+
76
+ function reset() {
77
+ b.i = 0
78
+ return b
79
+ }
node_modules/postgres/cf/src/connection.js ADDED
@@ -0,0 +1,1064 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Buffer } from 'node:buffer'
2
+ import { setImmediate, clearImmediate } from '../polyfills.js'
3
+ import { net } from '../polyfills.js'
4
+ import { tls } from '../polyfills.js'
5
+ import { crypto } from '../polyfills.js'
6
+ import Stream from 'node:stream'
7
+ import { performance } from '../polyfills.js'
8
+
9
+ import { stringify, handleValue, arrayParser, arraySerializer } from './types.js'
10
+ import { Errors } from './errors.js'
11
+ import Result from './result.js'
12
+ import Queue from './queue.js'
13
+ import { Query, CLOSE } from './query.js'
14
+ import b from './bytes.js'
15
+
16
+ export default Connection
17
+
18
+ let uid = 1
19
+
20
+ const Sync = b().S().end()
21
+ , Flush = b().H().end()
22
+ , SSLRequest = b().i32(8).i32(80877103).end(8)
23
+ , ExecuteUnnamed = Buffer.concat([b().E().str(b.N).i32(0).end(), Sync])
24
+ , DescribeUnnamed = b().D().str('S').str(b.N).end()
25
+ , noop = () => { /* noop */ }
26
+
27
+ const retryRoutines = new Set([
28
+ 'FetchPreparedStatement',
29
+ 'RevalidateCachedQuery',
30
+ 'transformAssignedExpr'
31
+ ])
32
+
33
+ const errorFields = {
34
+ 83 : 'severity_local', // S
35
+ 86 : 'severity', // V
36
+ 67 : 'code', // C
37
+ 77 : 'message', // M
38
+ 68 : 'detail', // D
39
+ 72 : 'hint', // H
40
+ 80 : 'position', // P
41
+ 112 : 'internal_position', // p
42
+ 113 : 'internal_query', // q
43
+ 87 : 'where', // W
44
+ 115 : 'schema_name', // s
45
+ 116 : 'table_name', // t
46
+ 99 : 'column_name', // c
47
+ 100 : 'data type_name', // d
48
+ 110 : 'constraint_name', // n
49
+ 70 : 'file', // F
50
+ 76 : 'line', // L
51
+ 82 : 'routine' // R
52
+ }
53
+
54
+ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose = noop } = {}) {
55
+ const {
56
+ sslnegotiation,
57
+ ssl,
58
+ max,
59
+ user,
60
+ host,
61
+ port,
62
+ database,
63
+ parsers,
64
+ transform,
65
+ onnotice,
66
+ onnotify,
67
+ onparameter,
68
+ max_pipeline,
69
+ keep_alive,
70
+ backoff,
71
+ target_session_attrs
72
+ } = options
73
+
74
+ const sent = Queue()
75
+ , id = uid++
76
+ , backend = { pid: null, secret: null }
77
+ , idleTimer = timer(end, options.idle_timeout)
78
+ , lifeTimer = timer(end, options.max_lifetime)
79
+ , connectTimer = timer(connectTimedOut, options.connect_timeout)
80
+
81
+ let socket = null
82
+ , cancelMessage
83
+ , errorResponse = null
84
+ , result = new Result()
85
+ , incoming = Buffer.alloc(0)
86
+ , needsTypes = options.fetch_types
87
+ , backendParameters = {}
88
+ , statements = {}
89
+ , statementId = Math.random().toString(36).slice(2)
90
+ , statementCount = 1
91
+ , closedTime = 0
92
+ , remaining = 0
93
+ , hostIndex = 0
94
+ , retries = 0
95
+ , length = 0
96
+ , delay = 0
97
+ , rows = 0
98
+ , serverSignature = null
99
+ , nextWriteTimer = null
100
+ , terminated = false
101
+ , incomings = null
102
+ , results = null
103
+ , initial = null
104
+ , ending = null
105
+ , stream = null
106
+ , chunk = null
107
+ , ended = null
108
+ , nonce = null
109
+ , query = null
110
+ , final = null
111
+
112
+ const connection = {
113
+ queue: queues.closed,
114
+ idleTimer,
115
+ connect(query) {
116
+ initial = query
117
+ reconnect()
118
+ },
119
+ terminate,
120
+ execute,
121
+ cancel,
122
+ end,
123
+ count: 0,
124
+ id
125
+ }
126
+
127
+ queues.closed && queues.closed.push(connection)
128
+
129
+ return connection
130
+
131
+ async function createSocket() {
132
+ let x
133
+ try {
134
+ x = options.socket
135
+ ? (await Promise.resolve(options.socket(options)))
136
+ : new net.Socket()
137
+ } catch (e) {
138
+ error(e)
139
+ return
140
+ }
141
+ x.on('error', error)
142
+ x.on('close', closed)
143
+ x.on('drain', drain)
144
+ return x
145
+ }
146
+
147
+ async function cancel({ pid, secret }, resolve, reject) {
148
+ try {
149
+ cancelMessage = b().i32(16).i32(80877102).i32(pid).i32(secret).end(16)
150
+ await connect()
151
+ socket.once('error', reject)
152
+ socket.once('close', resolve)
153
+ } catch (error) {
154
+ reject(error)
155
+ }
156
+ }
157
+
158
+ function execute(q) {
159
+ if (terminated)
160
+ return queryError(q, Errors.connection('CONNECTION_DESTROYED', options))
161
+
162
+ if (stream)
163
+ return queryError(q, Errors.generic('COPY_IN_PROGRESS', 'You cannot execute queries during copy'))
164
+
165
+ if (q.cancelled)
166
+ return
167
+
168
+ try {
169
+ q.state = backend
170
+ query
171
+ ? sent.push(q)
172
+ : (query = q, query.active = true)
173
+
174
+ build(q)
175
+ return write(toBuffer(q))
176
+ && !q.describeFirst
177
+ && !q.cursorFn
178
+ && sent.length < max_pipeline
179
+ && (!q.options.onexecute || q.options.onexecute(connection))
180
+ } catch (error) {
181
+ sent.length === 0 && write(Sync)
182
+ errored(error)
183
+ return true
184
+ }
185
+ }
186
+
187
+ function toBuffer(q) {
188
+ if (q.parameters.length >= 65534)
189
+ throw Errors.generic('MAX_PARAMETERS_EXCEEDED', 'Max number of parameters (65534) exceeded')
190
+
191
+ return q.options.simple
192
+ ? b().Q().str(q.statement.string + b.N).end()
193
+ : q.describeFirst
194
+ ? Buffer.concat([describe(q), Flush])
195
+ : q.prepare
196
+ ? q.prepared
197
+ ? prepared(q)
198
+ : Buffer.concat([describe(q), prepared(q)])
199
+ : unnamed(q)
200
+ }
201
+
202
+ function describe(q) {
203
+ return Buffer.concat([
204
+ Parse(q.statement.string, q.parameters, q.statement.types, q.statement.name),
205
+ Describe('S', q.statement.name)
206
+ ])
207
+ }
208
+
209
+ function prepared(q) {
210
+ return Buffer.concat([
211
+ Bind(q.parameters, q.statement.types, q.statement.name, q.cursorName),
212
+ q.cursorFn
213
+ ? Execute('', q.cursorRows)
214
+ : ExecuteUnnamed
215
+ ])
216
+ }
217
+
218
+ function unnamed(q) {
219
+ return Buffer.concat([
220
+ Parse(q.statement.string, q.parameters, q.statement.types),
221
+ DescribeUnnamed,
222
+ prepared(q)
223
+ ])
224
+ }
225
+
226
+ function build(q) {
227
+ const parameters = []
228
+ , types = []
229
+
230
+ const string = stringify(q, q.strings[0], q.args[0], parameters, types, options)
231
+
232
+ !q.tagged && q.args.forEach(x => handleValue(x, parameters, types, options))
233
+
234
+ q.prepare = options.prepare && ('prepare' in q.options ? q.options.prepare : true)
235
+ q.string = string
236
+ q.signature = q.prepare && types + string
237
+ q.onlyDescribe && (delete statements[q.signature])
238
+ q.parameters = q.parameters || parameters
239
+ q.prepared = q.prepare && q.signature in statements
240
+ q.describeFirst = q.onlyDescribe || (parameters.length && !q.prepared)
241
+ q.statement = q.prepared
242
+ ? statements[q.signature]
243
+ : { string, types, name: q.prepare ? statementId + statementCount++ : '' }
244
+
245
+ typeof options.debug === 'function' && options.debug(id, string, parameters, types)
246
+ }
247
+
248
+ function write(x, fn) {
249
+ chunk = chunk ? Buffer.concat([chunk, x]) : Buffer.from(x)
250
+ if (fn || chunk.length >= 1024)
251
+ return nextWrite(fn)
252
+ nextWriteTimer === null && (nextWriteTimer = setImmediate(nextWrite))
253
+ return true
254
+ }
255
+
256
+ function nextWrite(fn) {
257
+ const x = socket.write(chunk, fn)
258
+ nextWriteTimer !== null && clearImmediate(nextWriteTimer)
259
+ chunk = nextWriteTimer = null
260
+ return x
261
+ }
262
+
263
+ function connectTimedOut() {
264
+ errored(Errors.connection('CONNECT_TIMEOUT', options, socket))
265
+ socket.destroy()
266
+ }
267
+
268
+ async function secure() {
269
+ if (sslnegotiation !== 'direct') {
270
+ write(SSLRequest)
271
+ const canSSL = await new Promise(r => socket.once('data', x => r(x[0] === 83))) // S
272
+
273
+ if (!canSSL && ssl === 'prefer')
274
+ return connected()
275
+ }
276
+
277
+ const options = {
278
+ socket,
279
+ servername: net.isIP(socket.host) ? undefined : socket.host
280
+ }
281
+
282
+ if (sslnegotiation === 'direct')
283
+ options.ALPNProtocols = ['postgresql']
284
+
285
+ if (ssl === 'require' || ssl === 'allow' || ssl === 'prefer')
286
+ options.rejectUnauthorized = false
287
+ else if (typeof ssl === 'object')
288
+ Object.assign(options, ssl)
289
+
290
+ socket.removeAllListeners()
291
+ socket = tls.connect(options)
292
+ socket.on('secureConnect', connected)
293
+ socket.on('error', error)
294
+ socket.on('close', closed)
295
+ socket.on('drain', drain)
296
+ }
297
+
298
+ /* c8 ignore next 3 */
299
+ function drain() {
300
+ !query && onopen(connection)
301
+ }
302
+
303
+ function data(x) {
304
+ if (incomings) {
305
+ incomings.push(x)
306
+ remaining -= x.length
307
+ if (remaining > 0)
308
+ return
309
+ }
310
+
311
+ incoming = incomings
312
+ ? Buffer.concat(incomings, length - remaining)
313
+ : incoming.length === 0
314
+ ? x
315
+ : Buffer.concat([incoming, x], incoming.length + x.length)
316
+
317
+ while (incoming.length > 4) {
318
+ length = incoming.readUInt32BE(1)
319
+ if (length >= incoming.length) {
320
+ remaining = length - incoming.length
321
+ incomings = [incoming]
322
+ break
323
+ }
324
+
325
+ try {
326
+ handle(incoming.subarray(0, length + 1))
327
+ } catch (e) {
328
+ query && (query.cursorFn || query.describeFirst) && write(Sync)
329
+ errored(e)
330
+ }
331
+ incoming = incoming.subarray(length + 1)
332
+ remaining = 0
333
+ incomings = null
334
+ }
335
+ }
336
+
337
+ async function connect() {
338
+ terminated = false
339
+ backendParameters = {}
340
+ socket || (socket = await createSocket())
341
+
342
+ if (!socket)
343
+ return
344
+
345
+ connectTimer.start()
346
+
347
+ if (options.socket)
348
+ return ssl ? secure() : connected()
349
+
350
+ socket.on('connect', ssl ? secure : connected)
351
+
352
+ if (options.path)
353
+ return socket.connect(options.path)
354
+
355
+ socket.ssl = ssl
356
+ socket.connect(port[hostIndex], host[hostIndex])
357
+ socket.host = host[hostIndex]
358
+ socket.port = port[hostIndex]
359
+
360
+ hostIndex = (hostIndex + 1) % port.length
361
+ }
362
+
363
+ function reconnect() {
364
+ setTimeout(connect, closedTime ? Math.max(0, closedTime + delay - performance.now()) : 0)
365
+ }
366
+
367
+ function connected() {
368
+ try {
369
+ statements = {}
370
+ needsTypes = options.fetch_types
371
+ statementId = Math.random().toString(36).slice(2)
372
+ statementCount = 1
373
+ lifeTimer.start()
374
+ socket.on('data', data)
375
+ keep_alive && socket.setKeepAlive && socket.setKeepAlive(true, 1000 * keep_alive)
376
+ const s = StartupMessage()
377
+ write(s)
378
+ } catch (err) {
379
+ error(err)
380
+ }
381
+ }
382
+
383
+ function error(err) {
384
+ if (connection.queue === queues.connecting && options.host[retries + 1])
385
+ return
386
+
387
+ errored(err)
388
+ while (sent.length)
389
+ queryError(sent.shift(), err)
390
+ }
391
+
392
+ function errored(err) {
393
+ stream && (stream.destroy(err), stream = null)
394
+ query && queryError(query, err)
395
+ initial && (queryError(initial, err), initial = null)
396
+ }
397
+
398
+ function queryError(query, err) {
399
+ if (query.reserve)
400
+ return query.reject(err)
401
+
402
+ if (!err || typeof err !== 'object')
403
+ err = new Error(err)
404
+
405
+ 'query' in err || 'parameters' in err || Object.defineProperties(err, {
406
+ stack: { value: err.stack + query.origin.replace(/.*\n/, '\n'), enumerable: options.debug },
407
+ query: { value: query.string, enumerable: options.debug },
408
+ parameters: { value: query.parameters, enumerable: options.debug },
409
+ args: { value: query.args, enumerable: options.debug },
410
+ types: { value: query.statement && query.statement.types, enumerable: options.debug }
411
+ })
412
+ query.reject(err)
413
+ }
414
+
415
+ function end() {
416
+ return ending || (
417
+ !connection.reserved && onend(connection),
418
+ !connection.reserved && !initial && !query && sent.length === 0
419
+ ? (terminate(), new Promise(r => socket && socket.readyState !== 'closed' ? socket.once('close', r) : r()))
420
+ : ending = new Promise(r => ended = r)
421
+ )
422
+ }
423
+
424
+ function terminate() {
425
+ terminated = true
426
+ if (stream || query || initial || sent.length)
427
+ error(Errors.connection('CONNECTION_DESTROYED', options))
428
+
429
+ clearImmediate(nextWriteTimer)
430
+ if (socket) {
431
+ socket.removeListener('data', data)
432
+ socket.removeListener('connect', connected)
433
+ socket.readyState === 'open' && socket.end(b().X().end())
434
+ }
435
+ ended && (ended(), ending = ended = null)
436
+ }
437
+
438
+ async function closed(hadError) {
439
+ incoming = Buffer.alloc(0)
440
+ remaining = 0
441
+ incomings = null
442
+ clearImmediate(nextWriteTimer)
443
+ socket.removeListener('data', data)
444
+ socket.removeListener('connect', connected)
445
+ idleTimer.cancel()
446
+ lifeTimer.cancel()
447
+ connectTimer.cancel()
448
+
449
+ socket.removeAllListeners()
450
+ socket = null
451
+
452
+ if (initial)
453
+ return reconnect()
454
+
455
+ !hadError && (query || sent.length) && error(Errors.connection('CONNECTION_CLOSED', options, socket))
456
+ closedTime = performance.now()
457
+ hadError && options.shared.retries++
458
+ delay = (typeof backoff === 'function' ? backoff(options.shared.retries) : backoff) * 1000
459
+ onclose(connection, Errors.connection('CONNECTION_CLOSED', options, socket))
460
+ }
461
+
462
+ /* Handlers */
463
+ function handle(xs, x = xs[0]) {
464
+ (
465
+ x === 68 ? DataRow : // D
466
+ x === 100 ? CopyData : // d
467
+ x === 65 ? NotificationResponse : // A
468
+ x === 83 ? ParameterStatus : // S
469
+ x === 90 ? ReadyForQuery : // Z
470
+ x === 67 ? CommandComplete : // C
471
+ x === 50 ? BindComplete : // 2
472
+ x === 49 ? ParseComplete : // 1
473
+ x === 116 ? ParameterDescription : // t
474
+ x === 84 ? RowDescription : // T
475
+ x === 82 ? Authentication : // R
476
+ x === 110 ? NoData : // n
477
+ x === 75 ? BackendKeyData : // K
478
+ x === 69 ? ErrorResponse : // E
479
+ x === 115 ? PortalSuspended : // s
480
+ x === 51 ? CloseComplete : // 3
481
+ x === 71 ? CopyInResponse : // G
482
+ x === 78 ? NoticeResponse : // N
483
+ x === 72 ? CopyOutResponse : // H
484
+ x === 99 ? CopyDone : // c
485
+ x === 73 ? EmptyQueryResponse : // I
486
+ x === 86 ? FunctionCallResponse : // V
487
+ x === 118 ? NegotiateProtocolVersion : // v
488
+ x === 87 ? CopyBothResponse : // W
489
+ /* c8 ignore next */
490
+ UnknownMessage
491
+ )(xs)
492
+ }
493
+
494
+ function DataRow(x) {
495
+ let index = 7
496
+ let length
497
+ let column
498
+ let value
499
+
500
+ const row = query.isRaw ? new Array(query.statement.columns.length) : {}
501
+ for (let i = 0; i < query.statement.columns.length; i++) {
502
+ column = query.statement.columns[i]
503
+ length = x.readInt32BE(index)
504
+ index += 4
505
+
506
+ value = length === -1
507
+ ? null
508
+ : query.isRaw === true
509
+ ? x.subarray(index, index += length)
510
+ : column.parser === undefined
511
+ ? x.toString('utf8', index, index += length)
512
+ : column.parser.array === true
513
+ ? column.parser(x.toString('utf8', index + 1, index += length))
514
+ : column.parser(x.toString('utf8', index, index += length))
515
+
516
+ query.isRaw
517
+ ? (row[i] = query.isRaw === true
518
+ ? value
519
+ : transform.value.from ? transform.value.from(value, column) : value)
520
+ : (row[column.name] = transform.value.from ? transform.value.from(value, column) : value)
521
+ }
522
+
523
+ query.forEachFn
524
+ ? query.forEachFn(transform.row.from ? transform.row.from(row) : row, result)
525
+ : (result[rows++] = transform.row.from ? transform.row.from(row) : row)
526
+ }
527
+
528
+ function ParameterStatus(x) {
529
+ const [k, v] = x.toString('utf8', 5, x.length - 1).split(b.N)
530
+ backendParameters[k] = v
531
+ if (options.parameters[k] !== v) {
532
+ options.parameters[k] = v
533
+ onparameter && onparameter(k, v)
534
+ }
535
+ }
536
+
537
+ function ReadyForQuery(x) {
538
+ if (query) {
539
+ if (errorResponse) {
540
+ query.retried
541
+ ? errored(query.retried)
542
+ : query.prepared && retryRoutines.has(errorResponse.routine)
543
+ ? retry(query, errorResponse)
544
+ : errored(errorResponse)
545
+ } else {
546
+ query.resolve(results || result)
547
+ }
548
+ } else if (errorResponse) {
549
+ errored(errorResponse)
550
+ }
551
+
552
+ query = results = errorResponse = null
553
+ result = new Result()
554
+ connectTimer.cancel()
555
+
556
+ if (initial) {
557
+ if (target_session_attrs) {
558
+ if (!backendParameters.in_hot_standby || !backendParameters.default_transaction_read_only)
559
+ return fetchState()
560
+ else if (tryNext(target_session_attrs, backendParameters))
561
+ return terminate()
562
+ }
563
+
564
+ if (needsTypes) {
565
+ initial.reserve && (initial = null)
566
+ return fetchArrayTypes()
567
+ }
568
+
569
+ initial && !initial.reserve && execute(initial)
570
+ options.shared.retries = retries = 0
571
+ initial = null
572
+ return
573
+ }
574
+
575
+ while (sent.length && (query = sent.shift()) && (query.active = true, query.cancelled))
576
+ Connection(options).cancel(query.state, query.cancelled.resolve, query.cancelled.reject)
577
+
578
+ if (query)
579
+ return // Consider opening if able and sent.length < 50
580
+
581
+ connection.reserved
582
+ ? !connection.reserved.release && x[5] === 73 // I
583
+ ? ending
584
+ ? terminate()
585
+ : (connection.reserved = null, onopen(connection))
586
+ : connection.reserved()
587
+ : ending
588
+ ? terminate()
589
+ : onopen(connection)
590
+ }
591
+
592
+ function CommandComplete(x) {
593
+ rows = 0
594
+
595
+ for (let i = x.length - 1; i > 0; i--) {
596
+ if (x[i] === 32 && x[i + 1] < 58 && result.count === null)
597
+ result.count = +x.toString('utf8', i + 1, x.length - 1)
598
+ if (x[i - 1] >= 65) {
599
+ result.command = x.toString('utf8', 5, i)
600
+ result.state = backend
601
+ break
602
+ }
603
+ }
604
+
605
+ final && (final(), final = null)
606
+
607
+ if (result.command === 'BEGIN' && max !== 1 && !connection.reserved)
608
+ return errored(Errors.generic('UNSAFE_TRANSACTION', 'Only use sql.begin, sql.reserved or max: 1'))
609
+
610
+ if (query.options.simple)
611
+ return BindComplete()
612
+
613
+ if (query.cursorFn) {
614
+ result.count && query.cursorFn(result)
615
+ write(Sync)
616
+ }
617
+ }
618
+
619
+ function ParseComplete() {
620
+ query.parsing = false
621
+ }
622
+
623
+ function BindComplete() {
624
+ !result.statement && (result.statement = query.statement)
625
+ result.columns = query.statement.columns
626
+ }
627
+
628
+ function ParameterDescription(x) {
629
+ const length = x.readUInt16BE(5)
630
+
631
+ for (let i = 0; i < length; ++i)
632
+ !query.statement.types[i] && (query.statement.types[i] = x.readUInt32BE(7 + i * 4))
633
+
634
+ query.prepare && (statements[query.signature] = query.statement)
635
+ query.describeFirst && !query.onlyDescribe && (write(prepared(query)), query.describeFirst = false)
636
+ }
637
+
638
+ function RowDescription(x) {
639
+ if (result.command) {
640
+ results = results || [result]
641
+ results.push(result = new Result())
642
+ result.count = null
643
+ query.statement.columns = null
644
+ }
645
+
646
+ const length = x.readUInt16BE(5)
647
+ let index = 7
648
+ let start
649
+
650
+ query.statement.columns = Array(length)
651
+
652
+ for (let i = 0; i < length; ++i) {
653
+ start = index
654
+ while (x[index++] !== 0);
655
+ const table = x.readUInt32BE(index)
656
+ const number = x.readUInt16BE(index + 4)
657
+ const type = x.readUInt32BE(index + 6)
658
+ query.statement.columns[i] = {
659
+ name: transform.column.from
660
+ ? transform.column.from(x.toString('utf8', start, index - 1))
661
+ : x.toString('utf8', start, index - 1),
662
+ parser: parsers[type],
663
+ table,
664
+ number,
665
+ type
666
+ }
667
+ index += 18
668
+ }
669
+
670
+ result.statement = query.statement
671
+ if (query.onlyDescribe)
672
+ return (query.resolve(query.statement), write(Sync))
673
+ }
674
+
675
+ async function Authentication(x, type = x.readUInt32BE(5)) {
676
+ (
677
+ type === 3 ? AuthenticationCleartextPassword :
678
+ type === 5 ? AuthenticationMD5Password :
679
+ type === 10 ? SASL :
680
+ type === 11 ? SASLContinue :
681
+ type === 12 ? SASLFinal :
682
+ type !== 0 ? UnknownAuth :
683
+ noop
684
+ )(x, type)
685
+ }
686
+
687
+ /* c8 ignore next 5 */
688
+ async function AuthenticationCleartextPassword() {
689
+ const payload = await Pass()
690
+ write(
691
+ b().p().str(payload).z(1).end()
692
+ )
693
+ }
694
+
695
+ async function AuthenticationMD5Password(x) {
696
+ const payload = 'md5' + (
697
+ await md5(
698
+ Buffer.concat([
699
+ Buffer.from(await md5((await Pass()) + user)),
700
+ x.subarray(9)
701
+ ])
702
+ )
703
+ )
704
+ write(
705
+ b().p().str(payload).z(1).end()
706
+ )
707
+ }
708
+
709
+ async function SASL() {
710
+ nonce = (await crypto.randomBytes(18)).toString('base64')
711
+ b().p().str('SCRAM-SHA-256' + b.N)
712
+ const i = b.i
713
+ write(b.inc(4).str('n,,n=*,r=' + nonce).i32(b.i - i - 4, i).end())
714
+ }
715
+
716
+ async function SASLContinue(x) {
717
+ const res = x.toString('utf8', 9).split(',').reduce((acc, x) => (acc[x[0]] = x.slice(2), acc), {})
718
+
719
+ const saltedPassword = await crypto.pbkdf2Sync(
720
+ await Pass(),
721
+ Buffer.from(res.s, 'base64'),
722
+ parseInt(res.i), 32,
723
+ 'sha256'
724
+ )
725
+
726
+ const clientKey = await hmac(saltedPassword, 'Client Key')
727
+
728
+ const auth = 'n=*,r=' + nonce + ','
729
+ + 'r=' + res.r + ',s=' + res.s + ',i=' + res.i
730
+ + ',c=biws,r=' + res.r
731
+
732
+ serverSignature = (await hmac(await hmac(saltedPassword, 'Server Key'), auth)).toString('base64')
733
+
734
+ const payload = 'c=biws,r=' + res.r + ',p=' + xor(
735
+ clientKey, Buffer.from(await hmac(await sha256(clientKey), auth))
736
+ ).toString('base64')
737
+
738
+ write(
739
+ b().p().str(payload).end()
740
+ )
741
+ }
742
+
743
+ function SASLFinal(x) {
744
+ if (x.toString('utf8', 9).split(b.N, 1)[0].slice(2) === serverSignature)
745
+ return
746
+ /* c8 ignore next 5 */
747
+ errored(Errors.generic('SASL_SIGNATURE_MISMATCH', 'The server did not return the correct signature'))
748
+ socket.destroy()
749
+ }
750
+
751
+ function Pass() {
752
+ return Promise.resolve(typeof options.pass === 'function'
753
+ ? options.pass()
754
+ : options.pass
755
+ )
756
+ }
757
+
758
+ function NoData() {
759
+ result.statement = query.statement
760
+ result.statement.columns = []
761
+ if (query.onlyDescribe)
762
+ return (query.resolve(query.statement), write(Sync))
763
+ }
764
+
765
+ function BackendKeyData(x) {
766
+ backend.pid = x.readUInt32BE(5)
767
+ backend.secret = x.readUInt32BE(9)
768
+ }
769
+
770
+ async function fetchArrayTypes() {
771
+ needsTypes = false
772
+ const types = await new Query([`
773
+ select b.oid, b.typarray
774
+ from pg_catalog.pg_type a
775
+ left join pg_catalog.pg_type b on b.oid = a.typelem
776
+ where a.typcategory = 'A'
777
+ group by b.oid, b.typarray
778
+ order by b.oid
779
+ `], [], execute)
780
+ types.forEach(({ oid, typarray }) => addArrayType(oid, typarray))
781
+ }
782
+
783
+ function addArrayType(oid, typarray) {
784
+ if (!!options.parsers[typarray] && !!options.serializers[typarray]) return
785
+ const parser = options.parsers[oid]
786
+ options.shared.typeArrayMap[oid] = typarray
787
+ options.parsers[typarray] = (xs) => arrayParser(xs, parser, typarray)
788
+ options.parsers[typarray].array = true
789
+ options.serializers[typarray] = (xs) => arraySerializer(xs, options.serializers[oid], options, typarray)
790
+ }
791
+
792
+ function tryNext(x, xs) {
793
+ return (
794
+ (x === 'read-write' && xs.default_transaction_read_only === 'on') ||
795
+ (x === 'read-only' && xs.default_transaction_read_only === 'off') ||
796
+ (x === 'primary' && xs.in_hot_standby === 'on') ||
797
+ (x === 'standby' && xs.in_hot_standby === 'off') ||
798
+ (x === 'prefer-standby' && xs.in_hot_standby === 'off' && options.host[retries])
799
+ )
800
+ }
801
+
802
+ function fetchState() {
803
+ const query = new Query([`
804
+ show transaction_read_only;
805
+ select pg_catalog.pg_is_in_recovery()
806
+ `], [], execute, null, { simple: true })
807
+ query.resolve = ([[a], [b]]) => {
808
+ backendParameters.default_transaction_read_only = a.transaction_read_only
809
+ backendParameters.in_hot_standby = b.pg_is_in_recovery ? 'on' : 'off'
810
+ }
811
+ query.execute()
812
+ }
813
+
814
+ function ErrorResponse(x) {
815
+ if (query) {
816
+ (query.cursorFn || query.describeFirst) && write(Sync)
817
+ errorResponse = Errors.postgres(parseError(x))
818
+ } else {
819
+ errored(Errors.postgres(parseError(x)))
820
+ }
821
+ }
822
+
823
+ function retry(q, error) {
824
+ delete statements[q.signature]
825
+ q.retried = error
826
+ execute(q)
827
+ }
828
+
829
+ function NotificationResponse(x) {
830
+ if (!onnotify)
831
+ return
832
+
833
+ let index = 9
834
+ while (x[index++] !== 0);
835
+ onnotify(
836
+ x.toString('utf8', 9, index - 1),
837
+ x.toString('utf8', index, x.length - 1)
838
+ )
839
+ }
840
+
841
+ async function PortalSuspended() {
842
+ try {
843
+ const x = await Promise.resolve(query.cursorFn(result))
844
+ rows = 0
845
+ x === CLOSE
846
+ ? write(Close(query.portal))
847
+ : (result = new Result(), write(Execute('', query.cursorRows)))
848
+ } catch (err) {
849
+ write(Sync)
850
+ query.reject(err)
851
+ }
852
+ }
853
+
854
+ function CloseComplete() {
855
+ result.count && query.cursorFn(result)
856
+ query.resolve(result)
857
+ }
858
+
859
+ function CopyInResponse() {
860
+ stream = new Stream.Writable({
861
+ autoDestroy: true,
862
+ write(chunk, encoding, callback) {
863
+ socket.write(b().d().raw(chunk).end(), callback)
864
+ },
865
+ destroy(error, callback) {
866
+ callback(error)
867
+ socket.write(b().f().str(error + b.N).end())
868
+ stream = null
869
+ },
870
+ final(callback) {
871
+ socket.write(b().c().end())
872
+ final = callback
873
+ stream = null
874
+ }
875
+ })
876
+ query.resolve(stream)
877
+ }
878
+
879
+ function CopyOutResponse() {
880
+ stream = new Stream.Readable({
881
+ read() { socket.resume() }
882
+ })
883
+ query.resolve(stream)
884
+ }
885
+
886
+ /* c8 ignore next 3 */
887
+ function CopyBothResponse() {
888
+ stream = new Stream.Duplex({
889
+ autoDestroy: true,
890
+ read() { socket.resume() },
891
+ /* c8 ignore next 11 */
892
+ write(chunk, encoding, callback) {
893
+ socket.write(b().d().raw(chunk).end(), callback)
894
+ },
895
+ destroy(error, callback) {
896
+ callback(error)
897
+ socket.write(b().f().str(error + b.N).end())
898
+ stream = null
899
+ },
900
+ final(callback) {
901
+ socket.write(b().c().end())
902
+ final = callback
903
+ }
904
+ })
905
+ query.resolve(stream)
906
+ }
907
+
908
+ function CopyData(x) {
909
+ stream && (stream.push(x.subarray(5)) || socket.pause())
910
+ }
911
+
912
+ function CopyDone() {
913
+ stream && stream.push(null)
914
+ stream = null
915
+ }
916
+
917
+ function NoticeResponse(x) {
918
+ onnotice
919
+ ? onnotice(parseError(x))
920
+ : console.log(parseError(x)) // eslint-disable-line
921
+
922
+ }
923
+
924
+ /* c8 ignore next 3 */
925
+ function EmptyQueryResponse() {
926
+ /* noop */
927
+ }
928
+
929
+ /* c8 ignore next 3 */
930
+ function FunctionCallResponse() {
931
+ errored(Errors.notSupported('FunctionCallResponse'))
932
+ }
933
+
934
+ /* c8 ignore next 3 */
935
+ function NegotiateProtocolVersion() {
936
+ errored(Errors.notSupported('NegotiateProtocolVersion'))
937
+ }
938
+
939
+ /* c8 ignore next 3 */
940
+ function UnknownMessage(x) {
941
+ console.error('Postgres.js : Unknown Message:', x[0]) // eslint-disable-line
942
+ }
943
+
944
+ /* c8 ignore next 3 */
945
+ function UnknownAuth(x, type) {
946
+ console.error('Postgres.js : Unknown Auth:', type) // eslint-disable-line
947
+ }
948
+
949
+ /* Messages */
950
+ function Bind(parameters, types, statement = '', portal = '') {
951
+ let prev
952
+ , type
953
+
954
+ b().B().str(portal + b.N).str(statement + b.N).i16(0).i16(parameters.length)
955
+
956
+ parameters.forEach((x, i) => {
957
+ if (x === null)
958
+ return b.i32(0xFFFFFFFF)
959
+
960
+ type = types[i]
961
+ parameters[i] = x = type in options.serializers
962
+ ? options.serializers[type](x)
963
+ : '' + x
964
+
965
+ prev = b.i
966
+ b.inc(4).str(x).i32(b.i - prev - 4, prev)
967
+ })
968
+
969
+ b.i16(0)
970
+
971
+ return b.end()
972
+ }
973
+
974
+ function Parse(str, parameters, types, name = '') {
975
+ b().P().str(name + b.N).str(str + b.N).i16(parameters.length)
976
+ parameters.forEach((x, i) => b.i32(types[i] || 0))
977
+ return b.end()
978
+ }
979
+
980
+ function Describe(x, name = '') {
981
+ return b().D().str(x).str(name + b.N).end()
982
+ }
983
+
984
+ function Execute(portal = '', rows = 0) {
985
+ return Buffer.concat([
986
+ b().E().str(portal + b.N).i32(rows).end(),
987
+ Flush
988
+ ])
989
+ }
990
+
991
+ function Close(portal = '') {
992
+ return Buffer.concat([
993
+ b().C().str('P').str(portal + b.N).end(),
994
+ b().S().end()
995
+ ])
996
+ }
997
+
998
+ function StartupMessage() {
999
+ return cancelMessage || b().inc(4).i16(3).z(2).str(
1000
+ Object.entries(Object.assign({
1001
+ user,
1002
+ database,
1003
+ client_encoding: 'UTF8'
1004
+ },
1005
+ options.connection
1006
+ )).filter(([, v]) => v).map(([k, v]) => k + b.N + v).join(b.N)
1007
+ ).z(2).end(0)
1008
+ }
1009
+
1010
+ }
1011
+
1012
+ function parseError(x) {
1013
+ const error = {}
1014
+ let start = 5
1015
+ for (let i = 5; i < x.length - 1; i++) {
1016
+ if (x[i] === 0) {
1017
+ error[errorFields[x[start]]] = x.toString('utf8', start + 1, i)
1018
+ start = i + 1
1019
+ }
1020
+ }
1021
+ return error
1022
+ }
1023
+
1024
+ function md5(x) {
1025
+ return crypto.createHash('md5').update(x).digest('hex')
1026
+ }
1027
+
1028
+ function hmac(key, x) {
1029
+ return crypto.createHmac('sha256', key).update(x).digest()
1030
+ }
1031
+
1032
+ function sha256(x) {
1033
+ return crypto.createHash('sha256').update(x).digest()
1034
+ }
1035
+
1036
+ function xor(a, b) {
1037
+ const length = Math.max(a.length, b.length)
1038
+ const buffer = Buffer.allocUnsafe(length)
1039
+ for (let i = 0; i < length; i++)
1040
+ buffer[i] = a[i] ^ b[i]
1041
+ return buffer
1042
+ }
1043
+
1044
+ function timer(fn, seconds) {
1045
+ seconds = typeof seconds === 'function' ? seconds() : seconds
1046
+ if (!seconds)
1047
+ return { cancel: noop, start: noop }
1048
+
1049
+ let timer
1050
+ return {
1051
+ cancel() {
1052
+ timer && (clearTimeout(timer), timer = null)
1053
+ },
1054
+ start() {
1055
+ timer && clearTimeout(timer)
1056
+ timer = setTimeout(done, seconds * 1000, arguments)
1057
+ }
1058
+ }
1059
+
1060
+ function done(args) {
1061
+ fn.apply(null, args)
1062
+ timer = null
1063
+ }
1064
+ }
node_modules/postgres/cf/src/errors.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export class PostgresError extends Error {
2
+ constructor(x) {
3
+ super(x.message)
4
+ this.name = this.constructor.name
5
+ Object.assign(this, x)
6
+ }
7
+ }
8
+
9
+ export const Errors = {
10
+ connection,
11
+ postgres,
12
+ generic,
13
+ notSupported
14
+ }
15
+
16
+ function connection(x, options, socket) {
17
+ const { host, port } = socket || options
18
+ const error = Object.assign(
19
+ new Error(('write ' + x + ' ' + (options.path || (host + ':' + port)))),
20
+ {
21
+ code: x,
22
+ errno: x,
23
+ address: options.path || host
24
+ }, options.path ? {} : { port: port }
25
+ )
26
+ Error.captureStackTrace(error, connection)
27
+ return error
28
+ }
29
+
30
+ function postgres(x) {
31
+ const error = new PostgresError(x)
32
+ Error.captureStackTrace(error, postgres)
33
+ return error
34
+ }
35
+
36
+ function generic(code, message) {
37
+ const error = Object.assign(new Error(code + ': ' + message), { code })
38
+ Error.captureStackTrace(error, generic)
39
+ return error
40
+ }
41
+
42
+ /* c8 ignore next 10 */
43
+ function notSupported(x) {
44
+ const error = Object.assign(
45
+ new Error(x + ' (B) is not supported'),
46
+ {
47
+ code: 'MESSAGE_NOT_SUPPORTED',
48
+ name: x
49
+ }
50
+ )
51
+ Error.captureStackTrace(error, notSupported)
52
+ return error
53
+ }
node_modules/postgres/cf/src/index.js ADDED
@@ -0,0 +1,568 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { process } from '../polyfills.js'
2
+ import { os } from '../polyfills.js'
3
+ import { fs } from '../polyfills.js'
4
+
5
+ import {
6
+ mergeUserTypes,
7
+ inferType,
8
+ Parameter,
9
+ Identifier,
10
+ Builder,
11
+ toPascal,
12
+ pascal,
13
+ toCamel,
14
+ camel,
15
+ toKebab,
16
+ kebab,
17
+ fromPascal,
18
+ fromCamel,
19
+ fromKebab
20
+ } from './types.js'
21
+
22
+ import Connection from './connection.js'
23
+ import { Query, CLOSE } from './query.js'
24
+ import Queue from './queue.js'
25
+ import { Errors, PostgresError } from './errors.js'
26
+ import Subscribe from './subscribe.js'
27
+ import largeObject from './large.js'
28
+
29
+ Object.assign(Postgres, {
30
+ PostgresError,
31
+ toPascal,
32
+ pascal,
33
+ toCamel,
34
+ camel,
35
+ toKebab,
36
+ kebab,
37
+ fromPascal,
38
+ fromCamel,
39
+ fromKebab,
40
+ BigInt: {
41
+ to: 20,
42
+ from: [20],
43
+ parse: x => BigInt(x), // eslint-disable-line
44
+ serialize: x => x.toString()
45
+ }
46
+ })
47
+
48
+ export default Postgres
49
+
50
+ function Postgres(a, b) {
51
+ const options = parseOptions(a, b)
52
+ , subscribe = options.no_subscribe || Subscribe(Postgres, { ...options })
53
+
54
+ let ending = false
55
+
56
+ const queries = Queue()
57
+ , connecting = Queue()
58
+ , reserved = Queue()
59
+ , closed = Queue()
60
+ , ended = Queue()
61
+ , open = Queue()
62
+ , busy = Queue()
63
+ , full = Queue()
64
+ , queues = { connecting, reserved, closed, ended, open, busy, full }
65
+
66
+ const connections = [...Array(options.max)].map(() => Connection(options, queues, { onopen, onend, onclose }))
67
+
68
+ const sql = Sql(handler)
69
+
70
+ Object.assign(sql, {
71
+ get parameters() { return options.parameters },
72
+ largeObject: largeObject.bind(null, sql),
73
+ subscribe,
74
+ CLOSE,
75
+ END: CLOSE,
76
+ PostgresError,
77
+ options,
78
+ reserve,
79
+ listen,
80
+ begin,
81
+ close,
82
+ end
83
+ })
84
+
85
+ return sql
86
+
87
+ function Sql(handler) {
88
+ handler.debug = options.debug
89
+
90
+ Object.entries(options.types).reduce((acc, [name, type]) => {
91
+ acc[name] = (x) => new Parameter(x, type.to)
92
+ return acc
93
+ }, typed)
94
+
95
+ Object.assign(sql, {
96
+ types: typed,
97
+ typed,
98
+ unsafe,
99
+ notify,
100
+ array,
101
+ json,
102
+ file
103
+ })
104
+
105
+ return sql
106
+
107
+ function typed(value, type) {
108
+ return new Parameter(value, type)
109
+ }
110
+
111
+ function sql(strings, ...args) {
112
+ const query = strings && Array.isArray(strings.raw)
113
+ ? new Query(strings, args, handler, cancel)
114
+ : typeof strings === 'string' && !args.length
115
+ ? new Identifier(options.transform.column.to ? options.transform.column.to(strings) : strings)
116
+ : new Builder(strings, args)
117
+ return query
118
+ }
119
+
120
+ function unsafe(string, args = [], options = {}) {
121
+ arguments.length === 2 && !Array.isArray(args) && (options = args, args = [])
122
+ const query = new Query([string], args, handler, cancel, {
123
+ prepare: false,
124
+ ...options,
125
+ simple: 'simple' in options ? options.simple : args.length === 0
126
+ })
127
+ return query
128
+ }
129
+
130
+ function file(path, args = [], options = {}) {
131
+ arguments.length === 2 && !Array.isArray(args) && (options = args, args = [])
132
+ const query = new Query([], args, (query) => {
133
+ fs.readFile(path, 'utf8', (err, string) => {
134
+ if (err)
135
+ return query.reject(err)
136
+
137
+ query.strings = [string]
138
+ handler(query)
139
+ })
140
+ }, cancel, {
141
+ ...options,
142
+ simple: 'simple' in options ? options.simple : args.length === 0
143
+ })
144
+ return query
145
+ }
146
+ }
147
+
148
+ async function listen(name, fn, onlisten) {
149
+ const listener = { fn, onlisten }
150
+
151
+ const sql = listen.sql || (listen.sql = Postgres({
152
+ ...options,
153
+ max: 1,
154
+ idle_timeout: null,
155
+ max_lifetime: null,
156
+ fetch_types: false,
157
+ onclose() {
158
+ Object.entries(listen.channels).forEach(([name, { listeners }]) => {
159
+ delete listen.channels[name]
160
+ Promise.all(listeners.map(l => listen(name, l.fn, l.onlisten).catch(() => { /* noop */ })))
161
+ })
162
+ },
163
+ onnotify(c, x) {
164
+ c in listen.channels && listen.channels[c].listeners.forEach(l => l.fn(x))
165
+ }
166
+ }))
167
+
168
+ const channels = listen.channels || (listen.channels = {})
169
+ , exists = name in channels
170
+
171
+ if (exists) {
172
+ channels[name].listeners.push(listener)
173
+ const result = await channels[name].result
174
+ listener.onlisten && listener.onlisten()
175
+ return { state: result.state, unlisten }
176
+ }
177
+
178
+ channels[name] = { result: sql`listen ${
179
+ sql.unsafe('"' + name.replace(/"/g, '""') + '"')
180
+ }`, listeners: [listener] }
181
+ const result = await channels[name].result
182
+ listener.onlisten && listener.onlisten()
183
+ return { state: result.state, unlisten }
184
+
185
+ async function unlisten() {
186
+ if (name in channels === false)
187
+ return
188
+
189
+ channels[name].listeners = channels[name].listeners.filter(x => x !== listener)
190
+ if (channels[name].listeners.length)
191
+ return
192
+
193
+ delete channels[name]
194
+ return sql`unlisten ${
195
+ sql.unsafe('"' + name.replace(/"/g, '""') + '"')
196
+ }`
197
+ }
198
+ }
199
+
200
+ async function notify(channel, payload) {
201
+ return await sql`select pg_notify(${ channel }, ${ '' + payload })`
202
+ }
203
+
204
+ async function reserve() {
205
+ const queue = Queue()
206
+ const c = open.length
207
+ ? open.shift()
208
+ : await new Promise((resolve, reject) => {
209
+ const query = { reserve: resolve, reject }
210
+ queries.push(query)
211
+ closed.length && connect(closed.shift(), query)
212
+ })
213
+
214
+ move(c, reserved)
215
+ c.reserved = () => queue.length
216
+ ? c.execute(queue.shift())
217
+ : move(c, reserved)
218
+ c.reserved.release = true
219
+
220
+ const sql = Sql(handler)
221
+ sql.release = () => {
222
+ c.reserved = null
223
+ onopen(c)
224
+ }
225
+
226
+ return sql
227
+
228
+ function handler(q) {
229
+ c.queue === full
230
+ ? queue.push(q)
231
+ : c.execute(q) || move(c, full)
232
+ }
233
+ }
234
+
235
+ async function begin(options, fn) {
236
+ !fn && (fn = options, options = '')
237
+ const queries = Queue()
238
+ let savepoints = 0
239
+ , connection
240
+ , prepare = null
241
+
242
+ try {
243
+ await sql.unsafe('begin ' + options.replace(/[^a-z ]/ig, ''), [], { onexecute }).execute()
244
+ return await Promise.race([
245
+ scope(connection, fn),
246
+ new Promise((_, reject) => connection.onclose = reject)
247
+ ])
248
+ } catch (error) {
249
+ throw error
250
+ }
251
+
252
+ async function scope(c, fn, name) {
253
+ const sql = Sql(handler)
254
+ sql.savepoint = savepoint
255
+ sql.prepare = x => prepare = x.replace(/[^a-z0-9$-_. ]/gi)
256
+ let uncaughtError
257
+ , result
258
+
259
+ name && await sql`savepoint ${ sql(name) }`
260
+ try {
261
+ result = await new Promise((resolve, reject) => {
262
+ const x = fn(sql)
263
+ Promise.resolve(Array.isArray(x) ? Promise.all(x) : x).then(resolve, reject)
264
+ })
265
+
266
+ if (uncaughtError)
267
+ throw uncaughtError
268
+ } catch (e) {
269
+ await (name
270
+ ? sql`rollback to ${ sql(name) }`
271
+ : sql`rollback`
272
+ )
273
+ throw e instanceof PostgresError && e.code === '25P02' && uncaughtError || e
274
+ }
275
+
276
+ if (!name) {
277
+ prepare
278
+ ? await sql`prepare transaction '${ sql.unsafe(prepare) }'`
279
+ : await sql`commit`
280
+ }
281
+
282
+ return result
283
+
284
+ function savepoint(name, fn) {
285
+ if (name && Array.isArray(name.raw))
286
+ return savepoint(sql => sql.apply(sql, arguments))
287
+
288
+ arguments.length === 1 && (fn = name, name = null)
289
+ return scope(c, fn, 's' + savepoints++ + (name ? '_' + name : ''))
290
+ }
291
+
292
+ function handler(q) {
293
+ q.catch(e => uncaughtError || (uncaughtError = e))
294
+ c.queue === full
295
+ ? queries.push(q)
296
+ : c.execute(q) || move(c, full)
297
+ }
298
+ }
299
+
300
+ function onexecute(c) {
301
+ connection = c
302
+ move(c, reserved)
303
+ c.reserved = () => queries.length
304
+ ? c.execute(queries.shift())
305
+ : move(c, reserved)
306
+ }
307
+ }
308
+
309
+ function move(c, queue) {
310
+ c.queue.remove(c)
311
+ queue.push(c)
312
+ c.queue = queue
313
+ queue === open
314
+ ? c.idleTimer.start()
315
+ : c.idleTimer.cancel()
316
+ return c
317
+ }
318
+
319
+ function json(x) {
320
+ return new Parameter(x, 3802)
321
+ }
322
+
323
+ function array(x, type) {
324
+ if (!Array.isArray(x))
325
+ return array(Array.from(arguments))
326
+
327
+ return new Parameter(x, type || (x.length ? inferType(x) || 25 : 0), options.shared.typeArrayMap)
328
+ }
329
+
330
+ function handler(query) {
331
+ if (ending)
332
+ return query.reject(Errors.connection('CONNECTION_ENDED', options, options))
333
+
334
+ if (open.length)
335
+ return go(open.shift(), query)
336
+
337
+ if (closed.length)
338
+ return connect(closed.shift(), query)
339
+
340
+ busy.length
341
+ ? go(busy.shift(), query)
342
+ : queries.push(query)
343
+ }
344
+
345
+ function go(c, query) {
346
+ return c.execute(query)
347
+ ? move(c, busy)
348
+ : move(c, full)
349
+ }
350
+
351
+ function cancel(query) {
352
+ return new Promise((resolve, reject) => {
353
+ query.state
354
+ ? query.active
355
+ ? Connection(options).cancel(query.state, resolve, reject)
356
+ : query.cancelled = { resolve, reject }
357
+ : (
358
+ queries.remove(query),
359
+ query.cancelled = true,
360
+ query.reject(Errors.generic('57014', 'canceling statement due to user request')),
361
+ resolve()
362
+ )
363
+ })
364
+ }
365
+
366
+ async function end({ timeout = null } = {}) {
367
+ if (ending)
368
+ return ending
369
+
370
+ await 1
371
+ let timer
372
+ return ending = Promise.race([
373
+ new Promise(r => timeout !== null && (timer = setTimeout(destroy, timeout * 1000, r))),
374
+ Promise.all(connections.map(c => c.end()).concat(
375
+ listen.sql ? listen.sql.end({ timeout: 0 }) : [],
376
+ subscribe.sql ? subscribe.sql.end({ timeout: 0 }) : []
377
+ ))
378
+ ]).then(() => clearTimeout(timer))
379
+ }
380
+
381
+ async function close() {
382
+ await Promise.all(connections.map(c => c.end()))
383
+ }
384
+
385
+ async function destroy(resolve) {
386
+ await Promise.all(connections.map(c => c.terminate()))
387
+ while (queries.length)
388
+ queries.shift().reject(Errors.connection('CONNECTION_DESTROYED', options))
389
+ resolve()
390
+ }
391
+
392
+ function connect(c, query) {
393
+ move(c, connecting)
394
+ c.connect(query)
395
+ return c
396
+ }
397
+
398
+ function onend(c) {
399
+ move(c, ended)
400
+ }
401
+
402
+ function onopen(c) {
403
+ if (queries.length === 0)
404
+ return move(c, open)
405
+
406
+ let max = Math.ceil(queries.length / (connecting.length + 1))
407
+ , ready = true
408
+
409
+ while (ready && queries.length && max-- > 0) {
410
+ const query = queries.shift()
411
+ if (query.reserve)
412
+ return query.reserve(c)
413
+
414
+ ready = c.execute(query)
415
+ }
416
+
417
+ ready
418
+ ? move(c, busy)
419
+ : move(c, full)
420
+ }
421
+
422
+ function onclose(c, e) {
423
+ move(c, closed)
424
+ c.reserved = null
425
+ c.onclose && (c.onclose(e), c.onclose = null)
426
+ options.onclose && options.onclose(c.id)
427
+ queries.length && connect(c, queries.shift())
428
+ }
429
+ }
430
+
431
+ function parseOptions(a, b) {
432
+ if (a && a.shared)
433
+ return a
434
+
435
+ const env = process.env // eslint-disable-line
436
+ , o = (!a || typeof a === 'string' ? b : a) || {}
437
+ , { url, multihost } = parseUrl(a)
438
+ , query = [...url.searchParams].reduce((a, [b, c]) => (a[b] = c, a), {})
439
+ , host = o.hostname || o.host || multihost || url.hostname || env.PGHOST || 'localhost'
440
+ , port = o.port || url.port || env.PGPORT || 5432
441
+ , user = o.user || o.username || url.username || env.PGUSERNAME || env.PGUSER || osUsername()
442
+
443
+ o.no_prepare && (o.prepare = false)
444
+ query.sslmode && (query.ssl = query.sslmode, delete query.sslmode)
445
+ 'timeout' in o && (console.log('The timeout option is deprecated, use idle_timeout instead'), o.idle_timeout = o.timeout) // eslint-disable-line
446
+ query.sslrootcert === 'system' && (query.ssl = 'verify-full')
447
+
448
+ const ints = ['idle_timeout', 'connect_timeout', 'max_lifetime', 'max_pipeline', 'backoff', 'keep_alive']
449
+ const defaults = {
450
+ max : globalThis.Cloudflare ? 3 : 10,
451
+ ssl : false,
452
+ sslnegotiation : null,
453
+ idle_timeout : null,
454
+ connect_timeout : 30,
455
+ max_lifetime : max_lifetime,
456
+ max_pipeline : 100,
457
+ backoff : backoff,
458
+ keep_alive : 60,
459
+ prepare : true,
460
+ debug : false,
461
+ fetch_types : true,
462
+ publications : 'alltables',
463
+ target_session_attrs: null
464
+ }
465
+
466
+ return {
467
+ host : Array.isArray(host) ? host : host.split(',').map(x => x.split(':')[0]),
468
+ port : Array.isArray(port) ? port : host.split(',').map(x => parseInt(x.split(':')[1] || port)),
469
+ path : o.path || host.indexOf('/') > -1 && host + '/.s.PGSQL.' + port,
470
+ database : o.database || o.db || (url.pathname || '').slice(1) || env.PGDATABASE || user,
471
+ user : user,
472
+ pass : o.pass || o.password || url.password || env.PGPASSWORD || '',
473
+ ...Object.entries(defaults).reduce(
474
+ (acc, [k, d]) => {
475
+ const value = k in o ? o[k] : k in query
476
+ ? (query[k] === 'disable' || query[k] === 'false' ? false : query[k])
477
+ : env['PG' + k.toUpperCase()] || d
478
+ acc[k] = typeof value === 'string' && ints.includes(k)
479
+ ? +value
480
+ : value
481
+ return acc
482
+ },
483
+ {}
484
+ ),
485
+ connection : {
486
+ application_name: env.PGAPPNAME || 'postgres.js',
487
+ ...o.connection,
488
+ ...Object.entries(query).reduce((acc, [k, v]) => (k in defaults || (acc[k] = v), acc), {})
489
+ },
490
+ types : o.types || {},
491
+ target_session_attrs: tsa(o, url, env),
492
+ onnotice : o.onnotice,
493
+ onnotify : o.onnotify,
494
+ onclose : o.onclose,
495
+ onparameter : o.onparameter,
496
+ socket : o.socket,
497
+ transform : parseTransform(o.transform || { undefined: undefined }),
498
+ parameters : {},
499
+ shared : { retries: 0, typeArrayMap: {} },
500
+ ...mergeUserTypes(o.types)
501
+ }
502
+ }
503
+
504
+ function tsa(o, url, env) {
505
+ const x = o.target_session_attrs || url.searchParams.get('target_session_attrs') || env.PGTARGETSESSIONATTRS
506
+ if (!x || ['read-write', 'read-only', 'primary', 'standby', 'prefer-standby'].includes(x))
507
+ return x
508
+
509
+ throw new Error('target_session_attrs ' + x + ' is not supported')
510
+ }
511
+
512
+ function backoff(retries) {
513
+ return (0.5 + Math.random() / 2) * Math.min(3 ** retries / 100, 20)
514
+ }
515
+
516
+ function max_lifetime() {
517
+ return 60 * (30 + Math.random() * 30)
518
+ }
519
+
520
+ function parseTransform(x) {
521
+ return {
522
+ undefined: x.undefined,
523
+ column: {
524
+ from: typeof x.column === 'function' ? x.column : x.column && x.column.from,
525
+ to: x.column && x.column.to
526
+ },
527
+ value: {
528
+ from: typeof x.value === 'function' ? x.value : x.value && x.value.from,
529
+ to: x.value && x.value.to
530
+ },
531
+ row: {
532
+ from: typeof x.row === 'function' ? x.row : x.row && x.row.from,
533
+ to: x.row && x.row.to
534
+ }
535
+ }
536
+ }
537
+
538
+ function parseUrl(url) {
539
+ if (!url || typeof url !== 'string')
540
+ return { url: { searchParams: new Map() } }
541
+
542
+ let host = url
543
+ host = host.slice(host.indexOf('://') + 3).split(/[?/]/)[0]
544
+ host = decodeURIComponent(host.slice(host.indexOf('@') + 1))
545
+
546
+ const urlObj = new URL(url.replace(host, host.split(',')[0]))
547
+
548
+ return {
549
+ url: {
550
+ username: decodeURIComponent(urlObj.username),
551
+ password: decodeURIComponent(urlObj.password),
552
+ host: urlObj.host,
553
+ hostname: urlObj.hostname,
554
+ port: urlObj.port,
555
+ pathname: urlObj.pathname,
556
+ searchParams: urlObj.searchParams
557
+ },
558
+ multihost: host.indexOf(',') > -1 && host
559
+ }
560
+ }
561
+
562
+ function osUsername() {
563
+ try {
564
+ return os.userInfo().username // eslint-disable-line
565
+ } catch (_) {
566
+ return process.env.USERNAME || process.env.USER || process.env.LOGNAME // eslint-disable-line
567
+ }
568
+ }
node_modules/postgres/cf/src/large.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Stream from 'node:stream'
2
+
3
+ export default function largeObject(sql, oid, mode = 0x00020000 | 0x00040000) {
4
+ return new Promise(async(resolve, reject) => {
5
+ await sql.begin(async sql => {
6
+ let finish
7
+ !oid && ([{ oid }] = await sql`select lo_creat(-1) as oid`)
8
+ const [{ fd }] = await sql`select lo_open(${ oid }, ${ mode }) as fd`
9
+
10
+ const lo = {
11
+ writable,
12
+ readable,
13
+ close : () => sql`select lo_close(${ fd })`.then(finish),
14
+ tell : () => sql`select lo_tell64(${ fd })`,
15
+ read : (x) => sql`select loread(${ fd }, ${ x }) as data`,
16
+ write : (x) => sql`select lowrite(${ fd }, ${ x })`,
17
+ truncate : (x) => sql`select lo_truncate64(${ fd }, ${ x })`,
18
+ seek : (x, whence = 0) => sql`select lo_lseek64(${ fd }, ${ x }, ${ whence })`,
19
+ size : () => sql`
20
+ select
21
+ lo_lseek64(${ fd }, location, 0) as position,
22
+ seek.size
23
+ from (
24
+ select
25
+ lo_lseek64($1, 0, 2) as size,
26
+ tell.location
27
+ from (select lo_tell64($1) as location) tell
28
+ ) seek
29
+ `
30
+ }
31
+
32
+ resolve(lo)
33
+
34
+ return new Promise(async r => finish = r)
35
+
36
+ async function readable({
37
+ highWaterMark = 2048 * 8,
38
+ start = 0,
39
+ end = Infinity
40
+ } = {}) {
41
+ let max = end - start
42
+ start && await lo.seek(start)
43
+ return new Stream.Readable({
44
+ highWaterMark,
45
+ async read(size) {
46
+ const l = size > max ? size - max : size
47
+ max -= size
48
+ const [{ data }] = await lo.read(l)
49
+ this.push(data)
50
+ if (data.length < size)
51
+ this.push(null)
52
+ }
53
+ })
54
+ }
55
+
56
+ async function writable({
57
+ highWaterMark = 2048 * 8,
58
+ start = 0
59
+ } = {}) {
60
+ start && await lo.seek(start)
61
+ return new Stream.Writable({
62
+ highWaterMark,
63
+ write(chunk, encoding, callback) {
64
+ lo.write(chunk).then(() => callback(), callback)
65
+ }
66
+ })
67
+ }
68
+ }).catch(reject)
69
+ })
70
+ }
node_modules/postgres/cf/src/query.js ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const originCache = new Map()
2
+ , originStackCache = new Map()
3
+ , originError = Symbol('OriginError')
4
+
5
+ export const CLOSE = {}
6
+ export class Query extends Promise {
7
+ constructor(strings, args, handler, canceller, options = {}) {
8
+ let resolve
9
+ , reject
10
+
11
+ super((a, b) => {
12
+ resolve = a
13
+ reject = b
14
+ })
15
+
16
+ this.tagged = Array.isArray(strings.raw)
17
+ this.strings = strings
18
+ this.args = args
19
+ this.handler = handler
20
+ this.canceller = canceller
21
+ this.options = options
22
+
23
+ this.state = null
24
+ this.statement = null
25
+
26
+ this.resolve = x => (this.active = false, resolve(x))
27
+ this.reject = x => (this.active = false, reject(x))
28
+
29
+ this.active = false
30
+ this.cancelled = null
31
+ this.executed = false
32
+ this.signature = ''
33
+
34
+ this[originError] = this.handler.debug
35
+ ? new Error()
36
+ : this.tagged && cachedError(this.strings)
37
+ }
38
+
39
+ get origin() {
40
+ return (this.handler.debug
41
+ ? this[originError].stack
42
+ : this.tagged && originStackCache.has(this.strings)
43
+ ? originStackCache.get(this.strings)
44
+ : originStackCache.set(this.strings, this[originError].stack).get(this.strings)
45
+ ) || ''
46
+ }
47
+
48
+ static get [Symbol.species]() {
49
+ return Promise
50
+ }
51
+
52
+ cancel() {
53
+ return this.canceller && (this.canceller(this), this.canceller = null)
54
+ }
55
+
56
+ simple() {
57
+ this.options.simple = true
58
+ this.options.prepare = false
59
+ return this
60
+ }
61
+
62
+ async readable() {
63
+ this.simple()
64
+ this.streaming = true
65
+ return this
66
+ }
67
+
68
+ async writable() {
69
+ this.simple()
70
+ this.streaming = true
71
+ return this
72
+ }
73
+
74
+ cursor(rows = 1, fn) {
75
+ this.options.simple = false
76
+ if (typeof rows === 'function') {
77
+ fn = rows
78
+ rows = 1
79
+ }
80
+
81
+ this.cursorRows = rows
82
+
83
+ if (typeof fn === 'function')
84
+ return (this.cursorFn = fn, this)
85
+
86
+ let prev
87
+ return {
88
+ [Symbol.asyncIterator]: () => ({
89
+ next: () => {
90
+ if (this.executed && !this.active)
91
+ return { done: true }
92
+
93
+ prev && prev()
94
+ const promise = new Promise((resolve, reject) => {
95
+ this.cursorFn = value => {
96
+ resolve({ value, done: false })
97
+ return new Promise(r => prev = r)
98
+ }
99
+ this.resolve = () => (this.active = false, resolve({ done: true }))
100
+ this.reject = x => (this.active = false, reject(x))
101
+ })
102
+ this.execute()
103
+ return promise
104
+ },
105
+ return() {
106
+ prev && prev(CLOSE)
107
+ return { done: true }
108
+ }
109
+ })
110
+ }
111
+ }
112
+
113
+ describe() {
114
+ this.options.simple = false
115
+ this.onlyDescribe = this.options.prepare = true
116
+ return this
117
+ }
118
+
119
+ stream() {
120
+ throw new Error('.stream has been renamed to .forEach')
121
+ }
122
+
123
+ forEach(fn) {
124
+ this.forEachFn = fn
125
+ this.handle()
126
+ return this
127
+ }
128
+
129
+ raw() {
130
+ this.isRaw = true
131
+ return this
132
+ }
133
+
134
+ values() {
135
+ this.isRaw = 'values'
136
+ return this
137
+ }
138
+
139
+ async handle() {
140
+ !this.executed && (this.executed = true) && await 1 && this.handler(this)
141
+ }
142
+
143
+ execute() {
144
+ this.handle()
145
+ return this
146
+ }
147
+
148
+ then() {
149
+ this.handle()
150
+ return super.then.apply(this, arguments)
151
+ }
152
+
153
+ catch() {
154
+ this.handle()
155
+ return super.catch.apply(this, arguments)
156
+ }
157
+
158
+ finally() {
159
+ this.handle()
160
+ return super.finally.apply(this, arguments)
161
+ }
162
+ }
163
+
164
+ function cachedError(xs) {
165
+ if (originCache.has(xs))
166
+ return originCache.get(xs)
167
+
168
+ const x = Error.stackTraceLimit
169
+ Error.stackTraceLimit = 4
170
+ originCache.set(xs, new Error())
171
+ Error.stackTraceLimit = x
172
+ return originCache.get(xs)
173
+ }
node_modules/postgres/cf/src/queue.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default Queue
2
+
3
+ function Queue(initial = []) {
4
+ let xs = initial.slice()
5
+ let index = 0
6
+
7
+ return {
8
+ get length() {
9
+ return xs.length - index
10
+ },
11
+ remove: (x) => {
12
+ const index = xs.indexOf(x)
13
+ return index === -1
14
+ ? null
15
+ : (xs.splice(index, 1), x)
16
+ },
17
+ push: (x) => (xs.push(x), x),
18
+ shift: () => {
19
+ const out = xs[index++]
20
+
21
+ if (index === xs.length) {
22
+ index = 0
23
+ xs = []
24
+ } else {
25
+ xs[index - 1] = undefined
26
+ }
27
+
28
+ return out
29
+ }
30
+ }
31
+ }
node_modules/postgres/cf/src/result.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default class Result extends Array {
2
+ constructor() {
3
+ super()
4
+ Object.defineProperties(this, {
5
+ count: { value: null, writable: true },
6
+ state: { value: null, writable: true },
7
+ command: { value: null, writable: true },
8
+ columns: { value: null, writable: true },
9
+ statement: { value: null, writable: true }
10
+ })
11
+ }
12
+
13
+ static get [Symbol.species]() {
14
+ return Array
15
+ }
16
+ }
node_modules/postgres/cf/src/subscribe.js ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Buffer } from 'node:buffer'
2
+ const noop = () => { /* noop */ }
3
+
4
+ export default function Subscribe(postgres, options) {
5
+ const subscribers = new Map()
6
+ , slot = 'postgresjs_' + Math.random().toString(36).slice(2)
7
+ , state = {}
8
+
9
+ let connection
10
+ , stream
11
+ , ended = false
12
+
13
+ const sql = subscribe.sql = postgres({
14
+ ...options,
15
+ transform: { column: {}, value: {}, row: {} },
16
+ max: 1,
17
+ fetch_types: false,
18
+ idle_timeout: null,
19
+ max_lifetime: null,
20
+ connection: {
21
+ ...options.connection,
22
+ replication: 'database'
23
+ },
24
+ onclose: async function() {
25
+ if (ended)
26
+ return
27
+ stream = null
28
+ state.pid = state.secret = undefined
29
+ connected(await init(sql, slot, options.publications))
30
+ subscribers.forEach(event => event.forEach(({ onsubscribe }) => onsubscribe()))
31
+ },
32
+ no_subscribe: true
33
+ })
34
+
35
+ const end = sql.end
36
+ , close = sql.close
37
+
38
+ sql.end = async() => {
39
+ ended = true
40
+ stream && (await new Promise(r => (stream.once('close', r), stream.end())))
41
+ return end()
42
+ }
43
+
44
+ sql.close = async() => {
45
+ stream && (await new Promise(r => (stream.once('close', r), stream.end())))
46
+ return close()
47
+ }
48
+
49
+ return subscribe
50
+
51
+ async function subscribe(event, fn, onsubscribe = noop, onerror = noop) {
52
+ event = parseEvent(event)
53
+
54
+ if (!connection)
55
+ connection = init(sql, slot, options.publications)
56
+
57
+ const subscriber = { fn, onsubscribe }
58
+ const fns = subscribers.has(event)
59
+ ? subscribers.get(event).add(subscriber)
60
+ : subscribers.set(event, new Set([subscriber])).get(event)
61
+
62
+ const unsubscribe = () => {
63
+ fns.delete(subscriber)
64
+ fns.size === 0 && subscribers.delete(event)
65
+ }
66
+
67
+ return connection.then(x => {
68
+ connected(x)
69
+ onsubscribe()
70
+ stream && stream.on('error', onerror)
71
+ return { unsubscribe, state, sql }
72
+ })
73
+ }
74
+
75
+ function connected(x) {
76
+ stream = x.stream
77
+ state.pid = x.state.pid
78
+ state.secret = x.state.secret
79
+ }
80
+
81
+ async function init(sql, slot, publications) {
82
+ if (!publications)
83
+ throw new Error('Missing publication names')
84
+
85
+ const xs = await sql.unsafe(
86
+ `CREATE_REPLICATION_SLOT ${ slot } TEMPORARY LOGICAL pgoutput NOEXPORT_SNAPSHOT`
87
+ )
88
+
89
+ const [x] = xs
90
+
91
+ const stream = await sql.unsafe(
92
+ `START_REPLICATION SLOT ${ slot } LOGICAL ${
93
+ x.consistent_point
94
+ } (proto_version '1', publication_names '${ publications }')`
95
+ ).writable()
96
+
97
+ const state = {
98
+ lsn: Buffer.concat(x.consistent_point.split('/').map(x => Buffer.from(('00000000' + x).slice(-8), 'hex')))
99
+ }
100
+
101
+ stream.on('data', data)
102
+ stream.on('error', error)
103
+ stream.on('close', sql.close)
104
+
105
+ return { stream, state: xs.state }
106
+
107
+ function error(e) {
108
+ console.error('Unexpected error during logical streaming - reconnecting', e) // eslint-disable-line
109
+ }
110
+
111
+ function data(x) {
112
+ if (x[0] === 0x77) {
113
+ parse(x.subarray(25), state, sql.options.parsers, handle, options.transform)
114
+ } else if (x[0] === 0x6b && x[17]) {
115
+ state.lsn = x.subarray(1, 9)
116
+ pong()
117
+ }
118
+ }
119
+
120
+ function handle(a, b) {
121
+ const path = b.relation.schema + '.' + b.relation.table
122
+ call('*', a, b)
123
+ call('*:' + path, a, b)
124
+ b.relation.keys.length && call('*:' + path + '=' + b.relation.keys.map(x => a[x.name]), a, b)
125
+ call(b.command, a, b)
126
+ call(b.command + ':' + path, a, b)
127
+ b.relation.keys.length && call(b.command + ':' + path + '=' + b.relation.keys.map(x => a[x.name]), a, b)
128
+ }
129
+
130
+ function pong() {
131
+ const x = Buffer.alloc(34)
132
+ x[0] = 'r'.charCodeAt(0)
133
+ x.fill(state.lsn, 1)
134
+ x.writeBigInt64BE(BigInt(Date.now() - Date.UTC(2000, 0, 1)) * BigInt(1000), 25)
135
+ stream.write(x)
136
+ }
137
+ }
138
+
139
+ function call(x, a, b) {
140
+ subscribers.has(x) && subscribers.get(x).forEach(({ fn }) => fn(a, b, x))
141
+ }
142
+ }
143
+
144
+ function Time(x) {
145
+ return new Date(Date.UTC(2000, 0, 1) + Number(x / BigInt(1000)))
146
+ }
147
+
148
+ function parse(x, state, parsers, handle, transform) {
149
+ const char = (acc, [k, v]) => (acc[k.charCodeAt(0)] = v, acc)
150
+
151
+ Object.entries({
152
+ R: x => { // Relation
153
+ let i = 1
154
+ const r = state[x.readUInt32BE(i)] = {
155
+ schema: x.toString('utf8', i += 4, i = x.indexOf(0, i)) || 'pg_catalog',
156
+ table: x.toString('utf8', i + 1, i = x.indexOf(0, i + 1)),
157
+ columns: Array(x.readUInt16BE(i += 2)),
158
+ keys: []
159
+ }
160
+ i += 2
161
+
162
+ let columnIndex = 0
163
+ , column
164
+
165
+ while (i < x.length) {
166
+ column = r.columns[columnIndex++] = {
167
+ key: x[i++],
168
+ name: transform.column.from
169
+ ? transform.column.from(x.toString('utf8', i, i = x.indexOf(0, i)))
170
+ : x.toString('utf8', i, i = x.indexOf(0, i)),
171
+ type: x.readUInt32BE(i += 1),
172
+ parser: parsers[x.readUInt32BE(i)],
173
+ atttypmod: x.readUInt32BE(i += 4)
174
+ }
175
+
176
+ column.key && r.keys.push(column)
177
+ i += 4
178
+ }
179
+ },
180
+ Y: () => { /* noop */ }, // Type
181
+ O: () => { /* noop */ }, // Origin
182
+ B: x => { // Begin
183
+ state.date = Time(x.readBigInt64BE(9))
184
+ state.lsn = x.subarray(1, 9)
185
+ },
186
+ I: x => { // Insert
187
+ let i = 1
188
+ const relation = state[x.readUInt32BE(i)]
189
+ const { row } = tuples(x, relation.columns, i += 7, transform)
190
+
191
+ handle(row, {
192
+ command: 'insert',
193
+ relation
194
+ })
195
+ },
196
+ D: x => { // Delete
197
+ let i = 1
198
+ const relation = state[x.readUInt32BE(i)]
199
+ i += 4
200
+ const key = x[i] === 75
201
+ handle(key || x[i] === 79
202
+ ? tuples(x, relation.columns, i += 3, transform).row
203
+ : null
204
+ , {
205
+ command: 'delete',
206
+ relation,
207
+ key
208
+ })
209
+ },
210
+ U: x => { // Update
211
+ let i = 1
212
+ const relation = state[x.readUInt32BE(i)]
213
+ i += 4
214
+ const key = x[i] === 75
215
+ const xs = key || x[i] === 79
216
+ ? tuples(x, relation.columns, i += 3, transform)
217
+ : null
218
+
219
+ xs && (i = xs.i)
220
+
221
+ const { row } = tuples(x, relation.columns, i + 3, transform)
222
+
223
+ handle(row, {
224
+ command: 'update',
225
+ relation,
226
+ key,
227
+ old: xs && xs.row
228
+ })
229
+ },
230
+ T: () => { /* noop */ }, // Truncate,
231
+ C: () => { /* noop */ } // Commit
232
+ }).reduce(char, {})[x[0]](x)
233
+ }
234
+
235
+ function tuples(x, columns, xi, transform) {
236
+ let type
237
+ , column
238
+ , value
239
+
240
+ const row = transform.raw ? new Array(columns.length) : {}
241
+ for (let i = 0; i < columns.length; i++) {
242
+ type = x[xi++]
243
+ column = columns[i]
244
+ value = type === 110 // n
245
+ ? null
246
+ : type === 117 // u
247
+ ? undefined
248
+ : column.parser === undefined
249
+ ? x.toString('utf8', xi + 4, xi += 4 + x.readUInt32BE(xi))
250
+ : column.parser.array === true
251
+ ? column.parser(x.toString('utf8', xi + 5, xi += 4 + x.readUInt32BE(xi)))
252
+ : column.parser(x.toString('utf8', xi + 4, xi += 4 + x.readUInt32BE(xi)))
253
+
254
+ transform.raw
255
+ ? (row[i] = transform.raw === true
256
+ ? value
257
+ : transform.value.from ? transform.value.from(value, column) : value)
258
+ : (row[column.name] = transform.value.from
259
+ ? transform.value.from(value, column)
260
+ : value
261
+ )
262
+ }
263
+
264
+ return { i: xi, row: transform.row.from ? transform.row.from(row) : row }
265
+ }
266
+
267
+ function parseEvent(x) {
268
+ const xs = x.match(/^(\*|insert|update|delete)?:?([^.]+?\.?[^=]+)?=?(.+)?/i) || []
269
+
270
+ if (!xs)
271
+ throw new Error('Malformed subscribe pattern: ' + x)
272
+
273
+ const [, command, path, key] = xs
274
+
275
+ return (command || '*')
276
+ + (path ? ':' + (path.indexOf('.') === -1 ? 'public.' + path : path) : '')
277
+ + (key ? '=' + key : '')
278
+ }
node_modules/postgres/cf/src/types.js ADDED
@@ -0,0 +1,368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Buffer } from 'node:buffer'
2
+ import { Query } from './query.js'
3
+ import { Errors } from './errors.js'
4
+
5
+ export const types = {
6
+ string: {
7
+ to: 25,
8
+ from: null, // defaults to string
9
+ serialize: x => '' + x
10
+ },
11
+ number: {
12
+ to: 0,
13
+ from: [21, 23, 26, 700, 701],
14
+ serialize: x => '' + x,
15
+ parse: x => +x
16
+ },
17
+ json: {
18
+ to: 114,
19
+ from: [114, 3802],
20
+ serialize: x => JSON.stringify(x),
21
+ parse: x => JSON.parse(x)
22
+ },
23
+ boolean: {
24
+ to: 16,
25
+ from: 16,
26
+ serialize: x => x === true ? 't' : 'f',
27
+ parse: x => x === 't'
28
+ },
29
+ date: {
30
+ to: 1184,
31
+ from: [1082, 1114, 1184],
32
+ serialize: x => (x instanceof Date ? x : new Date(x)).toISOString(),
33
+ parse: x => new Date(x)
34
+ },
35
+ bytea: {
36
+ to: 17,
37
+ from: 17,
38
+ serialize: x => '\\x' + Buffer.from(x).toString('hex'),
39
+ parse: x => Buffer.from(x.slice(2), 'hex')
40
+ }
41
+ }
42
+
43
+ class NotTagged { then() { notTagged() } catch() { notTagged() } finally() { notTagged() }}
44
+
45
+ export class Identifier extends NotTagged {
46
+ constructor(value) {
47
+ super()
48
+ this.value = escapeIdentifier(value)
49
+ }
50
+ }
51
+
52
+ export class Parameter extends NotTagged {
53
+ constructor(value, type, array) {
54
+ super()
55
+ this.value = value
56
+ this.type = type
57
+ this.array = array
58
+ }
59
+ }
60
+
61
+ export class Builder extends NotTagged {
62
+ constructor(first, rest) {
63
+ super()
64
+ this.first = first
65
+ this.rest = rest
66
+ }
67
+
68
+ build(before, parameters, types, options) {
69
+ const keyword = builders.map(([x, fn]) => ({ fn, i: before.search(x) })).sort((a, b) => a.i - b.i).pop()
70
+ return keyword.i === -1
71
+ ? escapeIdentifiers(this.first, options)
72
+ : keyword.fn(this.first, this.rest, parameters, types, options)
73
+ }
74
+ }
75
+
76
+ export function handleValue(x, parameters, types, options) {
77
+ let value = x instanceof Parameter ? x.value : x
78
+ if (value === undefined) {
79
+ x instanceof Parameter
80
+ ? x.value = options.transform.undefined
81
+ : value = x = options.transform.undefined
82
+
83
+ if (value === undefined)
84
+ throw Errors.generic('UNDEFINED_VALUE', 'Undefined values are not allowed')
85
+ }
86
+
87
+ return '$' + (types.push(
88
+ x instanceof Parameter
89
+ ? (parameters.push(x.value), x.array
90
+ ? x.array[x.type || inferType(x.value)] || x.type || firstIsString(x.value)
91
+ : x.type
92
+ )
93
+ : (parameters.push(x), inferType(x))
94
+ ))
95
+ }
96
+
97
+ const defaultHandlers = typeHandlers(types)
98
+
99
+ export function stringify(q, string, value, parameters, types, options) { // eslint-disable-line
100
+ for (let i = 1; i < q.strings.length; i++) {
101
+ string += (stringifyValue(string, value, parameters, types, options)) + q.strings[i]
102
+ value = q.args[i]
103
+ }
104
+
105
+ return string
106
+ }
107
+
108
+ function stringifyValue(string, value, parameters, types, o) {
109
+ return (
110
+ value instanceof Builder ? value.build(string, parameters, types, o) :
111
+ value instanceof Query ? fragment(value, parameters, types, o) :
112
+ value instanceof Identifier ? value.value :
113
+ value && value[0] instanceof Query ? value.reduce((acc, x) => acc + ' ' + fragment(x, parameters, types, o), '') :
114
+ handleValue(value, parameters, types, o)
115
+ )
116
+ }
117
+
118
+ function fragment(q, parameters, types, options) {
119
+ q.fragment = true
120
+ return stringify(q, q.strings[0], q.args[0], parameters, types, options)
121
+ }
122
+
123
+ function valuesBuilder(first, parameters, types, columns, options) {
124
+ return first.map(row =>
125
+ '(' + columns.map(column =>
126
+ stringifyValue('values', row[column], parameters, types, options)
127
+ ).join(',') + ')'
128
+ ).join(',')
129
+ }
130
+
131
+ function values(first, rest, parameters, types, options) {
132
+ const multi = Array.isArray(first[0])
133
+ const columns = rest.length ? rest.flat() : Object.keys(multi ? first[0] : first)
134
+ return valuesBuilder(multi ? first : [first], parameters, types, columns, options)
135
+ }
136
+
137
+ function select(first, rest, parameters, types, options) {
138
+ typeof first === 'string' && (first = [first].concat(rest))
139
+ if (Array.isArray(first))
140
+ return escapeIdentifiers(first, options)
141
+
142
+ let value
143
+ const columns = rest.length ? rest.flat() : Object.keys(first)
144
+ return columns.map(x => {
145
+ value = first[x]
146
+ return (
147
+ value instanceof Query ? fragment(value, parameters, types, options) :
148
+ value instanceof Identifier ? value.value :
149
+ handleValue(value, parameters, types, options)
150
+ ) + ' as ' + escapeIdentifier(options.transform.column.to ? options.transform.column.to(x) : x)
151
+ }).join(',')
152
+ }
153
+
154
+ const builders = Object.entries({
155
+ values,
156
+ in: (...xs) => {
157
+ const x = values(...xs)
158
+ return x === '()' ? '(null)' : x
159
+ },
160
+ select,
161
+ as: select,
162
+ returning: select,
163
+ '\\(': select,
164
+
165
+ update(first, rest, parameters, types, options) {
166
+ return (rest.length ? rest.flat() : Object.keys(first)).map(x =>
167
+ escapeIdentifier(options.transform.column.to ? options.transform.column.to(x) : x) +
168
+ '=' + stringifyValue('values', first[x], parameters, types, options)
169
+ )
170
+ },
171
+
172
+ insert(first, rest, parameters, types, options) {
173
+ const columns = rest.length ? rest.flat() : Object.keys(Array.isArray(first) ? first[0] : first)
174
+ return '(' + escapeIdentifiers(columns, options) + ')values' +
175
+ valuesBuilder(Array.isArray(first) ? first : [first], parameters, types, columns, options)
176
+ }
177
+ }).map(([x, fn]) => ([new RegExp('((?:^|[\\s(])' + x + '(?:$|[\\s(]))(?![\\s\\S]*\\1)', 'i'), fn]))
178
+
179
+ function notTagged() {
180
+ throw Errors.generic('NOT_TAGGED_CALL', 'Query not called as a tagged template literal')
181
+ }
182
+
183
+ export const serializers = defaultHandlers.serializers
184
+ export const parsers = defaultHandlers.parsers
185
+
186
+ export const END = {}
187
+
188
+ function firstIsString(x) {
189
+ if (Array.isArray(x))
190
+ return firstIsString(x[0])
191
+ return typeof x === 'string' ? 1009 : 0
192
+ }
193
+
194
+ export const mergeUserTypes = function(types) {
195
+ const user = typeHandlers(types || {})
196
+ return {
197
+ serializers: Object.assign({}, serializers, user.serializers),
198
+ parsers: Object.assign({}, parsers, user.parsers)
199
+ }
200
+ }
201
+
202
+ function typeHandlers(types) {
203
+ return Object.keys(types).reduce((acc, k) => {
204
+ types[k].from && [].concat(types[k].from).forEach(x => acc.parsers[x] = types[k].parse)
205
+ if (types[k].serialize) {
206
+ acc.serializers[types[k].to] = types[k].serialize
207
+ types[k].from && [].concat(types[k].from).forEach(x => acc.serializers[x] = types[k].serialize)
208
+ }
209
+ return acc
210
+ }, { parsers: {}, serializers: {} })
211
+ }
212
+
213
+ function escapeIdentifiers(xs, { transform: { column } }) {
214
+ return xs.map(x => escapeIdentifier(column.to ? column.to(x) : x)).join(',')
215
+ }
216
+
217
+ export const escapeIdentifier = function escape(str) {
218
+ return '"' + str.replace(/"/g, '""').replace(/\./g, '"."') + '"'
219
+ }
220
+
221
+ export const inferType = function inferType(x) {
222
+ return (
223
+ x instanceof Parameter ? x.type :
224
+ x instanceof Date ? 1184 :
225
+ x instanceof Uint8Array ? 17 :
226
+ (x === true || x === false) ? 16 :
227
+ typeof x === 'bigint' ? 20 :
228
+ Array.isArray(x) ? inferType(x[0]) :
229
+ 0
230
+ )
231
+ }
232
+
233
+ const escapeBackslash = /\\/g
234
+ const escapeQuote = /"/g
235
+
236
+ function arrayEscape(x) {
237
+ return x
238
+ .replace(escapeBackslash, '\\\\')
239
+ .replace(escapeQuote, '\\"')
240
+ }
241
+
242
+ export const arraySerializer = function arraySerializer(xs, serializer, options, typarray) {
243
+ if (Array.isArray(xs) === false)
244
+ return xs
245
+
246
+ if (!xs.length)
247
+ return '{}'
248
+
249
+ const first = xs[0]
250
+ // Only _box (1020) has the ';' delimiter for arrays, all other types use the ',' delimiter
251
+ const delimiter = typarray === 1020 ? ';' : ','
252
+
253
+ if (Array.isArray(first) && !first.type)
254
+ return '{' + xs.map(x => arraySerializer(x, serializer, options, typarray)).join(delimiter) + '}'
255
+
256
+ return '{' + xs.map(x => {
257
+ if (x === undefined) {
258
+ x = options.transform.undefined
259
+ if (x === undefined)
260
+ throw Errors.generic('UNDEFINED_VALUE', 'Undefined values are not allowed')
261
+ }
262
+
263
+ return x === null
264
+ ? 'null'
265
+ : '"' + arrayEscape(serializer ? serializer(x.type ? x.value : x) : '' + x) + '"'
266
+ }).join(delimiter) + '}'
267
+ }
268
+
269
+ const arrayParserState = {
270
+ i: 0,
271
+ char: null,
272
+ str: '',
273
+ quoted: false,
274
+ last: 0
275
+ }
276
+
277
+ export const arrayParser = function arrayParser(x, parser, typarray) {
278
+ arrayParserState.i = arrayParserState.last = 0
279
+ return arrayParserLoop(arrayParserState, x, parser, typarray)
280
+ }
281
+
282
+ function arrayParserLoop(s, x, parser, typarray) {
283
+ const xs = []
284
+ // Only _box (1020) has the ';' delimiter for arrays, all other types use the ',' delimiter
285
+ const delimiter = typarray === 1020 ? ';' : ','
286
+ for (; s.i < x.length; s.i++) {
287
+ s.char = x[s.i]
288
+ if (s.quoted) {
289
+ if (s.char === '\\') {
290
+ s.str += x[++s.i]
291
+ } else if (s.char === '"') {
292
+ xs.push(parser ? parser(s.str) : s.str)
293
+ s.str = ''
294
+ s.quoted = x[s.i + 1] === '"'
295
+ s.last = s.i + 2
296
+ } else {
297
+ s.str += s.char
298
+ }
299
+ } else if (s.char === '"') {
300
+ s.quoted = true
301
+ } else if (s.char === '{') {
302
+ s.last = ++s.i
303
+ xs.push(arrayParserLoop(s, x, parser, typarray))
304
+ } else if (s.char === '}') {
305
+ s.quoted = false
306
+ s.last < s.i && xs.push(parser ? parser(x.slice(s.last, s.i)) : x.slice(s.last, s.i))
307
+ s.last = s.i + 1
308
+ break
309
+ } else if (s.char === delimiter && s.p !== '}' && s.p !== '"') {
310
+ xs.push(parser ? parser(x.slice(s.last, s.i)) : x.slice(s.last, s.i))
311
+ s.last = s.i + 1
312
+ }
313
+ s.p = s.char
314
+ }
315
+ s.last < s.i && xs.push(parser ? parser(x.slice(s.last, s.i + 1)) : x.slice(s.last, s.i + 1))
316
+ return xs
317
+ }
318
+
319
+ export const toCamel = x => {
320
+ let str = x[0]
321
+ for (let i = 1; i < x.length; i++)
322
+ str += x[i] === '_' ? x[++i].toUpperCase() : x[i]
323
+ return str
324
+ }
325
+
326
+ export const toPascal = x => {
327
+ let str = x[0].toUpperCase()
328
+ for (let i = 1; i < x.length; i++)
329
+ str += x[i] === '_' ? x[++i].toUpperCase() : x[i]
330
+ return str
331
+ }
332
+
333
+ export const toKebab = x => x.replace(/_/g, '-')
334
+
335
+ export const fromCamel = x => x.replace(/([A-Z])/g, '_$1').toLowerCase()
336
+ export const fromPascal = x => (x.slice(0, 1) + x.slice(1).replace(/([A-Z])/g, '_$1')).toLowerCase()
337
+ export const fromKebab = x => x.replace(/-/g, '_')
338
+
339
+ function createJsonTransform(fn) {
340
+ return function jsonTransform(x, column) {
341
+ return typeof x === 'object' && x !== null && (column.type === 114 || column.type === 3802)
342
+ ? Array.isArray(x)
343
+ ? x.map(x => jsonTransform(x, column))
344
+ : Object.entries(x).reduce((acc, [k, v]) => Object.assign(acc, { [fn(k)]: jsonTransform(v, column) }), {})
345
+ : x
346
+ }
347
+ }
348
+
349
+ toCamel.column = { from: toCamel }
350
+ toCamel.value = { from: createJsonTransform(toCamel) }
351
+ fromCamel.column = { to: fromCamel }
352
+
353
+ export const camel = { ...toCamel }
354
+ camel.column.to = fromCamel
355
+
356
+ toPascal.column = { from: toPascal }
357
+ toPascal.value = { from: createJsonTransform(toPascal) }
358
+ fromPascal.column = { to: fromPascal }
359
+
360
+ export const pascal = { ...toPascal }
361
+ pascal.column.to = fromPascal
362
+
363
+ toKebab.column = { from: toKebab }
364
+ toKebab.value = { from: createJsonTransform(toKebab) }
365
+ fromKebab.column = { to: fromKebab }
366
+
367
+ export const kebab = { ...toKebab }
368
+ kebab.column.to = fromKebab
node_modules/postgres/cjs/package.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"type":"commonjs"}
node_modules/postgres/cjs/src/bytes.js ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const size = 256
2
+ let buffer = Buffer.allocUnsafe(size)
3
+
4
+ const messages = 'BCcDdEFfHPpQSX'.split('').reduce((acc, x) => {
5
+ const v = x.charCodeAt(0)
6
+ acc[x] = () => {
7
+ buffer[0] = v
8
+ b.i = 5
9
+ return b
10
+ }
11
+ return acc
12
+ }, {})
13
+
14
+ const b = Object.assign(reset, messages, {
15
+ N: String.fromCharCode(0),
16
+ i: 0,
17
+ inc(x) {
18
+ b.i += x
19
+ return b
20
+ },
21
+ str(x) {
22
+ const length = Buffer.byteLength(x)
23
+ fit(length)
24
+ b.i += buffer.write(x, b.i, length, 'utf8')
25
+ return b
26
+ },
27
+ i16(x) {
28
+ fit(2)
29
+ buffer.writeUInt16BE(x, b.i)
30
+ b.i += 2
31
+ return b
32
+ },
33
+ i32(x, i) {
34
+ if (i || i === 0) {
35
+ buffer.writeUInt32BE(x, i)
36
+ return b
37
+ }
38
+ fit(4)
39
+ buffer.writeUInt32BE(x, b.i)
40
+ b.i += 4
41
+ return b
42
+ },
43
+ z(x) {
44
+ fit(x)
45
+ buffer.fill(0, b.i, b.i + x)
46
+ b.i += x
47
+ return b
48
+ },
49
+ raw(x) {
50
+ buffer = Buffer.concat([buffer.subarray(0, b.i), x])
51
+ b.i = buffer.length
52
+ return b
53
+ },
54
+ end(at = 1) {
55
+ buffer.writeUInt32BE(b.i - at, at)
56
+ const out = buffer.subarray(0, b.i)
57
+ b.i = 0
58
+ buffer = Buffer.allocUnsafe(size)
59
+ return out
60
+ }
61
+ })
62
+
63
+ module.exports = b
64
+
65
+ function fit(x) {
66
+ if (buffer.length - b.i < x) {
67
+ const prev = buffer
68
+ , length = prev.length
69
+
70
+ buffer = Buffer.allocUnsafe(length + (length >> 1) + x)
71
+ prev.copy(buffer)
72
+ }
73
+ }
74
+
75
+ function reset() {
76
+ b.i = 0
77
+ return b
78
+ }
node_modules/postgres/cjs/src/connection.js ADDED
@@ -0,0 +1,1062 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const net = require('net')
2
+ const tls = require('tls')
3
+ const crypto = require('crypto')
4
+ const Stream = require('stream')
5
+ const { performance } = require('perf_hooks')
6
+
7
+ const { stringify, handleValue, arrayParser, arraySerializer } = require('./types.js')
8
+ const { Errors } = require('./errors.js')
9
+ const Result = require('./result.js')
10
+ const Queue = require('./queue.js')
11
+ const { Query, CLOSE } = require('./query.js')
12
+ const b = require('./bytes.js')
13
+
14
+ module.exports = Connection
15
+
16
+ let uid = 1
17
+
18
+ const Sync = b().S().end()
19
+ , Flush = b().H().end()
20
+ , SSLRequest = b().i32(8).i32(80877103).end(8)
21
+ , ExecuteUnnamed = Buffer.concat([b().E().str(b.N).i32(0).end(), Sync])
22
+ , DescribeUnnamed = b().D().str('S').str(b.N).end()
23
+ , noop = () => { /* noop */ }
24
+
25
+ const retryRoutines = new Set([
26
+ 'FetchPreparedStatement',
27
+ 'RevalidateCachedQuery',
28
+ 'transformAssignedExpr'
29
+ ])
30
+
31
+ const errorFields = {
32
+ 83 : 'severity_local', // S
33
+ 86 : 'severity', // V
34
+ 67 : 'code', // C
35
+ 77 : 'message', // M
36
+ 68 : 'detail', // D
37
+ 72 : 'hint', // H
38
+ 80 : 'position', // P
39
+ 112 : 'internal_position', // p
40
+ 113 : 'internal_query', // q
41
+ 87 : 'where', // W
42
+ 115 : 'schema_name', // s
43
+ 116 : 'table_name', // t
44
+ 99 : 'column_name', // c
45
+ 100 : 'data type_name', // d
46
+ 110 : 'constraint_name', // n
47
+ 70 : 'file', // F
48
+ 76 : 'line', // L
49
+ 82 : 'routine' // R
50
+ }
51
+
52
+ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose = noop } = {}) {
53
+ const {
54
+ sslnegotiation,
55
+ ssl,
56
+ max,
57
+ user,
58
+ host,
59
+ port,
60
+ database,
61
+ parsers,
62
+ transform,
63
+ onnotice,
64
+ onnotify,
65
+ onparameter,
66
+ max_pipeline,
67
+ keep_alive,
68
+ backoff,
69
+ target_session_attrs
70
+ } = options
71
+
72
+ const sent = Queue()
73
+ , id = uid++
74
+ , backend = { pid: null, secret: null }
75
+ , idleTimer = timer(end, options.idle_timeout)
76
+ , lifeTimer = timer(end, options.max_lifetime)
77
+ , connectTimer = timer(connectTimedOut, options.connect_timeout)
78
+
79
+ let socket = null
80
+ , cancelMessage
81
+ , errorResponse = null
82
+ , result = new Result()
83
+ , incoming = Buffer.alloc(0)
84
+ , needsTypes = options.fetch_types
85
+ , backendParameters = {}
86
+ , statements = {}
87
+ , statementId = Math.random().toString(36).slice(2)
88
+ , statementCount = 1
89
+ , closedTime = 0
90
+ , remaining = 0
91
+ , hostIndex = 0
92
+ , retries = 0
93
+ , length = 0
94
+ , delay = 0
95
+ , rows = 0
96
+ , serverSignature = null
97
+ , nextWriteTimer = null
98
+ , terminated = false
99
+ , incomings = null
100
+ , results = null
101
+ , initial = null
102
+ , ending = null
103
+ , stream = null
104
+ , chunk = null
105
+ , ended = null
106
+ , nonce = null
107
+ , query = null
108
+ , final = null
109
+
110
+ const connection = {
111
+ queue: queues.closed,
112
+ idleTimer,
113
+ connect(query) {
114
+ initial = query
115
+ reconnect()
116
+ },
117
+ terminate,
118
+ execute,
119
+ cancel,
120
+ end,
121
+ count: 0,
122
+ id
123
+ }
124
+
125
+ queues.closed && queues.closed.push(connection)
126
+
127
+ return connection
128
+
129
+ async function createSocket() {
130
+ let x
131
+ try {
132
+ x = options.socket
133
+ ? (await Promise.resolve(options.socket(options)))
134
+ : new net.Socket()
135
+ } catch (e) {
136
+ error(e)
137
+ return
138
+ }
139
+ x.on('error', error)
140
+ x.on('close', closed)
141
+ x.on('drain', drain)
142
+ return x
143
+ }
144
+
145
+ async function cancel({ pid, secret }, resolve, reject) {
146
+ try {
147
+ cancelMessage = b().i32(16).i32(80877102).i32(pid).i32(secret).end(16)
148
+ await connect()
149
+ socket.once('error', reject)
150
+ socket.once('close', resolve)
151
+ } catch (error) {
152
+ reject(error)
153
+ }
154
+ }
155
+
156
+ function execute(q) {
157
+ if (terminated)
158
+ return queryError(q, Errors.connection('CONNECTION_DESTROYED', options))
159
+
160
+ if (stream)
161
+ return queryError(q, Errors.generic('COPY_IN_PROGRESS', 'You cannot execute queries during copy'))
162
+
163
+ if (q.cancelled)
164
+ return
165
+
166
+ try {
167
+ q.state = backend
168
+ query
169
+ ? sent.push(q)
170
+ : (query = q, query.active = true)
171
+
172
+ build(q)
173
+ return write(toBuffer(q))
174
+ && !q.describeFirst
175
+ && !q.cursorFn
176
+ && sent.length < max_pipeline
177
+ && (!q.options.onexecute || q.options.onexecute(connection))
178
+ } catch (error) {
179
+ sent.length === 0 && write(Sync)
180
+ errored(error)
181
+ return true
182
+ }
183
+ }
184
+
185
+ function toBuffer(q) {
186
+ if (q.parameters.length >= 65534)
187
+ throw Errors.generic('MAX_PARAMETERS_EXCEEDED', 'Max number of parameters (65534) exceeded')
188
+
189
+ return q.options.simple
190
+ ? b().Q().str(q.statement.string + b.N).end()
191
+ : q.describeFirst
192
+ ? Buffer.concat([describe(q), Flush])
193
+ : q.prepare
194
+ ? q.prepared
195
+ ? prepared(q)
196
+ : Buffer.concat([describe(q), prepared(q)])
197
+ : unnamed(q)
198
+ }
199
+
200
+ function describe(q) {
201
+ return Buffer.concat([
202
+ Parse(q.statement.string, q.parameters, q.statement.types, q.statement.name),
203
+ Describe('S', q.statement.name)
204
+ ])
205
+ }
206
+
207
+ function prepared(q) {
208
+ return Buffer.concat([
209
+ Bind(q.parameters, q.statement.types, q.statement.name, q.cursorName),
210
+ q.cursorFn
211
+ ? Execute('', q.cursorRows)
212
+ : ExecuteUnnamed
213
+ ])
214
+ }
215
+
216
+ function unnamed(q) {
217
+ return Buffer.concat([
218
+ Parse(q.statement.string, q.parameters, q.statement.types),
219
+ DescribeUnnamed,
220
+ prepared(q)
221
+ ])
222
+ }
223
+
224
+ function build(q) {
225
+ const parameters = []
226
+ , types = []
227
+
228
+ const string = stringify(q, q.strings[0], q.args[0], parameters, types, options)
229
+
230
+ !q.tagged && q.args.forEach(x => handleValue(x, parameters, types, options))
231
+
232
+ q.prepare = options.prepare && ('prepare' in q.options ? q.options.prepare : true)
233
+ q.string = string
234
+ q.signature = q.prepare && types + string
235
+ q.onlyDescribe && (delete statements[q.signature])
236
+ q.parameters = q.parameters || parameters
237
+ q.prepared = q.prepare && q.signature in statements
238
+ q.describeFirst = q.onlyDescribe || (parameters.length && !q.prepared)
239
+ q.statement = q.prepared
240
+ ? statements[q.signature]
241
+ : { string, types, name: q.prepare ? statementId + statementCount++ : '' }
242
+
243
+ typeof options.debug === 'function' && options.debug(id, string, parameters, types)
244
+ }
245
+
246
+ function write(x, fn) {
247
+ chunk = chunk ? Buffer.concat([chunk, x]) : Buffer.from(x)
248
+ if (fn || chunk.length >= 1024)
249
+ return nextWrite(fn)
250
+ nextWriteTimer === null && (nextWriteTimer = setImmediate(nextWrite))
251
+ return true
252
+ }
253
+
254
+ function nextWrite(fn) {
255
+ const x = socket.write(chunk, fn)
256
+ nextWriteTimer !== null && clearImmediate(nextWriteTimer)
257
+ chunk = nextWriteTimer = null
258
+ return x
259
+ }
260
+
261
+ function connectTimedOut() {
262
+ errored(Errors.connection('CONNECT_TIMEOUT', options, socket))
263
+ socket.destroy()
264
+ }
265
+
266
+ async function secure() {
267
+ if (sslnegotiation !== 'direct') {
268
+ write(SSLRequest)
269
+ const canSSL = await new Promise(r => socket.once('data', x => r(x[0] === 83))) // S
270
+
271
+ if (!canSSL && ssl === 'prefer')
272
+ return connected()
273
+ }
274
+
275
+ const options = {
276
+ socket,
277
+ servername: net.isIP(socket.host) ? undefined : socket.host
278
+ }
279
+
280
+ if (sslnegotiation === 'direct')
281
+ options.ALPNProtocols = ['postgresql']
282
+
283
+ if (ssl === 'require' || ssl === 'allow' || ssl === 'prefer')
284
+ options.rejectUnauthorized = false
285
+ else if (typeof ssl === 'object')
286
+ Object.assign(options, ssl)
287
+
288
+ socket.removeAllListeners()
289
+ socket = tls.connect(options)
290
+ socket.on('secureConnect', connected)
291
+ socket.on('error', error)
292
+ socket.on('close', closed)
293
+ socket.on('drain', drain)
294
+ }
295
+
296
+ /* c8 ignore next 3 */
297
+ function drain() {
298
+ !query && onopen(connection)
299
+ }
300
+
301
+ function data(x) {
302
+ if (incomings) {
303
+ incomings.push(x)
304
+ remaining -= x.length
305
+ if (remaining > 0)
306
+ return
307
+ }
308
+
309
+ incoming = incomings
310
+ ? Buffer.concat(incomings, length - remaining)
311
+ : incoming.length === 0
312
+ ? x
313
+ : Buffer.concat([incoming, x], incoming.length + x.length)
314
+
315
+ while (incoming.length > 4) {
316
+ length = incoming.readUInt32BE(1)
317
+ if (length >= incoming.length) {
318
+ remaining = length - incoming.length
319
+ incomings = [incoming]
320
+ break
321
+ }
322
+
323
+ try {
324
+ handle(incoming.subarray(0, length + 1))
325
+ } catch (e) {
326
+ query && (query.cursorFn || query.describeFirst) && write(Sync)
327
+ errored(e)
328
+ }
329
+ incoming = incoming.subarray(length + 1)
330
+ remaining = 0
331
+ incomings = null
332
+ }
333
+ }
334
+
335
+ async function connect() {
336
+ terminated = false
337
+ backendParameters = {}
338
+ socket || (socket = await createSocket())
339
+
340
+ if (!socket)
341
+ return
342
+
343
+ connectTimer.start()
344
+
345
+ if (options.socket)
346
+ return ssl ? secure() : connected()
347
+
348
+ socket.on('connect', ssl ? secure : connected)
349
+
350
+ if (options.path)
351
+ return socket.connect(options.path)
352
+
353
+ socket.ssl = ssl
354
+ socket.connect(port[hostIndex], host[hostIndex])
355
+ socket.host = host[hostIndex]
356
+ socket.port = port[hostIndex]
357
+
358
+ hostIndex = (hostIndex + 1) % port.length
359
+ }
360
+
361
+ function reconnect() {
362
+ setTimeout(connect, closedTime ? Math.max(0, closedTime + delay - performance.now()) : 0)
363
+ }
364
+
365
+ function connected() {
366
+ try {
367
+ statements = {}
368
+ needsTypes = options.fetch_types
369
+ statementId = Math.random().toString(36).slice(2)
370
+ statementCount = 1
371
+ lifeTimer.start()
372
+ socket.on('data', data)
373
+ keep_alive && socket.setKeepAlive && socket.setKeepAlive(true, 1000 * keep_alive)
374
+ const s = StartupMessage()
375
+ write(s)
376
+ } catch (err) {
377
+ error(err)
378
+ }
379
+ }
380
+
381
+ function error(err) {
382
+ if (connection.queue === queues.connecting && options.host[retries + 1])
383
+ return
384
+
385
+ errored(err)
386
+ while (sent.length)
387
+ queryError(sent.shift(), err)
388
+ }
389
+
390
+ function errored(err) {
391
+ stream && (stream.destroy(err), stream = null)
392
+ query && queryError(query, err)
393
+ initial && (queryError(initial, err), initial = null)
394
+ }
395
+
396
+ function queryError(query, err) {
397
+ if (query.reserve)
398
+ return query.reject(err)
399
+
400
+ if (!err || typeof err !== 'object')
401
+ err = new Error(err)
402
+
403
+ 'query' in err || 'parameters' in err || Object.defineProperties(err, {
404
+ stack: { value: err.stack + query.origin.replace(/.*\n/, '\n'), enumerable: options.debug },
405
+ query: { value: query.string, enumerable: options.debug },
406
+ parameters: { value: query.parameters, enumerable: options.debug },
407
+ args: { value: query.args, enumerable: options.debug },
408
+ types: { value: query.statement && query.statement.types, enumerable: options.debug }
409
+ })
410
+ query.reject(err)
411
+ }
412
+
413
+ function end() {
414
+ return ending || (
415
+ !connection.reserved && onend(connection),
416
+ !connection.reserved && !initial && !query && sent.length === 0
417
+ ? (terminate(), new Promise(r => socket && socket.readyState !== 'closed' ? socket.once('close', r) : r()))
418
+ : ending = new Promise(r => ended = r)
419
+ )
420
+ }
421
+
422
+ function terminate() {
423
+ terminated = true
424
+ if (stream || query || initial || sent.length)
425
+ error(Errors.connection('CONNECTION_DESTROYED', options))
426
+
427
+ clearImmediate(nextWriteTimer)
428
+ if (socket) {
429
+ socket.removeListener('data', data)
430
+ socket.removeListener('connect', connected)
431
+ socket.readyState === 'open' && socket.end(b().X().end())
432
+ }
433
+ ended && (ended(), ending = ended = null)
434
+ }
435
+
436
+ async function closed(hadError) {
437
+ incoming = Buffer.alloc(0)
438
+ remaining = 0
439
+ incomings = null
440
+ clearImmediate(nextWriteTimer)
441
+ socket.removeListener('data', data)
442
+ socket.removeListener('connect', connected)
443
+ idleTimer.cancel()
444
+ lifeTimer.cancel()
445
+ connectTimer.cancel()
446
+
447
+ socket.removeAllListeners()
448
+ socket = null
449
+
450
+ if (initial)
451
+ return reconnect()
452
+
453
+ !hadError && (query || sent.length) && error(Errors.connection('CONNECTION_CLOSED', options, socket))
454
+ closedTime = performance.now()
455
+ hadError && options.shared.retries++
456
+ delay = (typeof backoff === 'function' ? backoff(options.shared.retries) : backoff) * 1000
457
+ onclose(connection, Errors.connection('CONNECTION_CLOSED', options, socket))
458
+ }
459
+
460
+ /* Handlers */
461
+ function handle(xs, x = xs[0]) {
462
+ (
463
+ x === 68 ? DataRow : // D
464
+ x === 100 ? CopyData : // d
465
+ x === 65 ? NotificationResponse : // A
466
+ x === 83 ? ParameterStatus : // S
467
+ x === 90 ? ReadyForQuery : // Z
468
+ x === 67 ? CommandComplete : // C
469
+ x === 50 ? BindComplete : // 2
470
+ x === 49 ? ParseComplete : // 1
471
+ x === 116 ? ParameterDescription : // t
472
+ x === 84 ? RowDescription : // T
473
+ x === 82 ? Authentication : // R
474
+ x === 110 ? NoData : // n
475
+ x === 75 ? BackendKeyData : // K
476
+ x === 69 ? ErrorResponse : // E
477
+ x === 115 ? PortalSuspended : // s
478
+ x === 51 ? CloseComplete : // 3
479
+ x === 71 ? CopyInResponse : // G
480
+ x === 78 ? NoticeResponse : // N
481
+ x === 72 ? CopyOutResponse : // H
482
+ x === 99 ? CopyDone : // c
483
+ x === 73 ? EmptyQueryResponse : // I
484
+ x === 86 ? FunctionCallResponse : // V
485
+ x === 118 ? NegotiateProtocolVersion : // v
486
+ x === 87 ? CopyBothResponse : // W
487
+ /* c8 ignore next */
488
+ UnknownMessage
489
+ )(xs)
490
+ }
491
+
492
+ function DataRow(x) {
493
+ let index = 7
494
+ let length
495
+ let column
496
+ let value
497
+
498
+ const row = query.isRaw ? new Array(query.statement.columns.length) : {}
499
+ for (let i = 0; i < query.statement.columns.length; i++) {
500
+ column = query.statement.columns[i]
501
+ length = x.readInt32BE(index)
502
+ index += 4
503
+
504
+ value = length === -1
505
+ ? null
506
+ : query.isRaw === true
507
+ ? x.subarray(index, index += length)
508
+ : column.parser === undefined
509
+ ? x.toString('utf8', index, index += length)
510
+ : column.parser.array === true
511
+ ? column.parser(x.toString('utf8', index + 1, index += length))
512
+ : column.parser(x.toString('utf8', index, index += length))
513
+
514
+ query.isRaw
515
+ ? (row[i] = query.isRaw === true
516
+ ? value
517
+ : transform.value.from ? transform.value.from(value, column) : value)
518
+ : (row[column.name] = transform.value.from ? transform.value.from(value, column) : value)
519
+ }
520
+
521
+ query.forEachFn
522
+ ? query.forEachFn(transform.row.from ? transform.row.from(row) : row, result)
523
+ : (result[rows++] = transform.row.from ? transform.row.from(row) : row)
524
+ }
525
+
526
+ function ParameterStatus(x) {
527
+ const [k, v] = x.toString('utf8', 5, x.length - 1).split(b.N)
528
+ backendParameters[k] = v
529
+ if (options.parameters[k] !== v) {
530
+ options.parameters[k] = v
531
+ onparameter && onparameter(k, v)
532
+ }
533
+ }
534
+
535
+ function ReadyForQuery(x) {
536
+ if (query) {
537
+ if (errorResponse) {
538
+ query.retried
539
+ ? errored(query.retried)
540
+ : query.prepared && retryRoutines.has(errorResponse.routine)
541
+ ? retry(query, errorResponse)
542
+ : errored(errorResponse)
543
+ } else {
544
+ query.resolve(results || result)
545
+ }
546
+ } else if (errorResponse) {
547
+ errored(errorResponse)
548
+ }
549
+
550
+ query = results = errorResponse = null
551
+ result = new Result()
552
+ connectTimer.cancel()
553
+
554
+ if (initial) {
555
+ if (target_session_attrs) {
556
+ if (!backendParameters.in_hot_standby || !backendParameters.default_transaction_read_only)
557
+ return fetchState()
558
+ else if (tryNext(target_session_attrs, backendParameters))
559
+ return terminate()
560
+ }
561
+
562
+ if (needsTypes) {
563
+ initial.reserve && (initial = null)
564
+ return fetchArrayTypes()
565
+ }
566
+
567
+ initial && !initial.reserve && execute(initial)
568
+ options.shared.retries = retries = 0
569
+ initial = null
570
+ return
571
+ }
572
+
573
+ while (sent.length && (query = sent.shift()) && (query.active = true, query.cancelled))
574
+ Connection(options).cancel(query.state, query.cancelled.resolve, query.cancelled.reject)
575
+
576
+ if (query)
577
+ return // Consider opening if able and sent.length < 50
578
+
579
+ connection.reserved
580
+ ? !connection.reserved.release && x[5] === 73 // I
581
+ ? ending
582
+ ? terminate()
583
+ : (connection.reserved = null, onopen(connection))
584
+ : connection.reserved()
585
+ : ending
586
+ ? terminate()
587
+ : onopen(connection)
588
+ }
589
+
590
+ function CommandComplete(x) {
591
+ rows = 0
592
+
593
+ for (let i = x.length - 1; i > 0; i--) {
594
+ if (x[i] === 32 && x[i + 1] < 58 && result.count === null)
595
+ result.count = +x.toString('utf8', i + 1, x.length - 1)
596
+ if (x[i - 1] >= 65) {
597
+ result.command = x.toString('utf8', 5, i)
598
+ result.state = backend
599
+ break
600
+ }
601
+ }
602
+
603
+ final && (final(), final = null)
604
+
605
+ if (result.command === 'BEGIN' && max !== 1 && !connection.reserved)
606
+ return errored(Errors.generic('UNSAFE_TRANSACTION', 'Only use sql.begin, sql.reserved or max: 1'))
607
+
608
+ if (query.options.simple)
609
+ return BindComplete()
610
+
611
+ if (query.cursorFn) {
612
+ result.count && query.cursorFn(result)
613
+ write(Sync)
614
+ }
615
+ }
616
+
617
+ function ParseComplete() {
618
+ query.parsing = false
619
+ }
620
+
621
+ function BindComplete() {
622
+ !result.statement && (result.statement = query.statement)
623
+ result.columns = query.statement.columns
624
+ }
625
+
626
+ function ParameterDescription(x) {
627
+ const length = x.readUInt16BE(5)
628
+
629
+ for (let i = 0; i < length; ++i)
630
+ !query.statement.types[i] && (query.statement.types[i] = x.readUInt32BE(7 + i * 4))
631
+
632
+ query.prepare && (statements[query.signature] = query.statement)
633
+ query.describeFirst && !query.onlyDescribe && (write(prepared(query)), query.describeFirst = false)
634
+ }
635
+
636
+ function RowDescription(x) {
637
+ if (result.command) {
638
+ results = results || [result]
639
+ results.push(result = new Result())
640
+ result.count = null
641
+ query.statement.columns = null
642
+ }
643
+
644
+ const length = x.readUInt16BE(5)
645
+ let index = 7
646
+ let start
647
+
648
+ query.statement.columns = Array(length)
649
+
650
+ for (let i = 0; i < length; ++i) {
651
+ start = index
652
+ while (x[index++] !== 0);
653
+ const table = x.readUInt32BE(index)
654
+ const number = x.readUInt16BE(index + 4)
655
+ const type = x.readUInt32BE(index + 6)
656
+ query.statement.columns[i] = {
657
+ name: transform.column.from
658
+ ? transform.column.from(x.toString('utf8', start, index - 1))
659
+ : x.toString('utf8', start, index - 1),
660
+ parser: parsers[type],
661
+ table,
662
+ number,
663
+ type
664
+ }
665
+ index += 18
666
+ }
667
+
668
+ result.statement = query.statement
669
+ if (query.onlyDescribe)
670
+ return (query.resolve(query.statement), write(Sync))
671
+ }
672
+
673
+ async function Authentication(x, type = x.readUInt32BE(5)) {
674
+ (
675
+ type === 3 ? AuthenticationCleartextPassword :
676
+ type === 5 ? AuthenticationMD5Password :
677
+ type === 10 ? SASL :
678
+ type === 11 ? SASLContinue :
679
+ type === 12 ? SASLFinal :
680
+ type !== 0 ? UnknownAuth :
681
+ noop
682
+ )(x, type)
683
+ }
684
+
685
+ /* c8 ignore next 5 */
686
+ async function AuthenticationCleartextPassword() {
687
+ const payload = await Pass()
688
+ write(
689
+ b().p().str(payload).z(1).end()
690
+ )
691
+ }
692
+
693
+ async function AuthenticationMD5Password(x) {
694
+ const payload = 'md5' + (
695
+ await md5(
696
+ Buffer.concat([
697
+ Buffer.from(await md5((await Pass()) + user)),
698
+ x.subarray(9)
699
+ ])
700
+ )
701
+ )
702
+ write(
703
+ b().p().str(payload).z(1).end()
704
+ )
705
+ }
706
+
707
+ async function SASL() {
708
+ nonce = (await crypto.randomBytes(18)).toString('base64')
709
+ b().p().str('SCRAM-SHA-256' + b.N)
710
+ const i = b.i
711
+ write(b.inc(4).str('n,,n=*,r=' + nonce).i32(b.i - i - 4, i).end())
712
+ }
713
+
714
+ async function SASLContinue(x) {
715
+ const res = x.toString('utf8', 9).split(',').reduce((acc, x) => (acc[x[0]] = x.slice(2), acc), {})
716
+
717
+ const saltedPassword = await crypto.pbkdf2Sync(
718
+ await Pass(),
719
+ Buffer.from(res.s, 'base64'),
720
+ parseInt(res.i), 32,
721
+ 'sha256'
722
+ )
723
+
724
+ const clientKey = await hmac(saltedPassword, 'Client Key')
725
+
726
+ const auth = 'n=*,r=' + nonce + ','
727
+ + 'r=' + res.r + ',s=' + res.s + ',i=' + res.i
728
+ + ',c=biws,r=' + res.r
729
+
730
+ serverSignature = (await hmac(await hmac(saltedPassword, 'Server Key'), auth)).toString('base64')
731
+
732
+ const payload = 'c=biws,r=' + res.r + ',p=' + xor(
733
+ clientKey, Buffer.from(await hmac(await sha256(clientKey), auth))
734
+ ).toString('base64')
735
+
736
+ write(
737
+ b().p().str(payload).end()
738
+ )
739
+ }
740
+
741
+ function SASLFinal(x) {
742
+ if (x.toString('utf8', 9).split(b.N, 1)[0].slice(2) === serverSignature)
743
+ return
744
+ /* c8 ignore next 5 */
745
+ errored(Errors.generic('SASL_SIGNATURE_MISMATCH', 'The server did not return the correct signature'))
746
+ socket.destroy()
747
+ }
748
+
749
+ function Pass() {
750
+ return Promise.resolve(typeof options.pass === 'function'
751
+ ? options.pass()
752
+ : options.pass
753
+ )
754
+ }
755
+
756
+ function NoData() {
757
+ result.statement = query.statement
758
+ result.statement.columns = []
759
+ if (query.onlyDescribe)
760
+ return (query.resolve(query.statement), write(Sync))
761
+ }
762
+
763
+ function BackendKeyData(x) {
764
+ backend.pid = x.readUInt32BE(5)
765
+ backend.secret = x.readUInt32BE(9)
766
+ }
767
+
768
+ async function fetchArrayTypes() {
769
+ needsTypes = false
770
+ const types = await new Query([`
771
+ select b.oid, b.typarray
772
+ from pg_catalog.pg_type a
773
+ left join pg_catalog.pg_type b on b.oid = a.typelem
774
+ where a.typcategory = 'A'
775
+ group by b.oid, b.typarray
776
+ order by b.oid
777
+ `], [], execute)
778
+ types.forEach(({ oid, typarray }) => addArrayType(oid, typarray))
779
+ }
780
+
781
+ function addArrayType(oid, typarray) {
782
+ if (!!options.parsers[typarray] && !!options.serializers[typarray]) return
783
+ const parser = options.parsers[oid]
784
+ options.shared.typeArrayMap[oid] = typarray
785
+ options.parsers[typarray] = (xs) => arrayParser(xs, parser, typarray)
786
+ options.parsers[typarray].array = true
787
+ options.serializers[typarray] = (xs) => arraySerializer(xs, options.serializers[oid], options, typarray)
788
+ }
789
+
790
+ function tryNext(x, xs) {
791
+ return (
792
+ (x === 'read-write' && xs.default_transaction_read_only === 'on') ||
793
+ (x === 'read-only' && xs.default_transaction_read_only === 'off') ||
794
+ (x === 'primary' && xs.in_hot_standby === 'on') ||
795
+ (x === 'standby' && xs.in_hot_standby === 'off') ||
796
+ (x === 'prefer-standby' && xs.in_hot_standby === 'off' && options.host[retries])
797
+ )
798
+ }
799
+
800
+ function fetchState() {
801
+ const query = new Query([`
802
+ show transaction_read_only;
803
+ select pg_catalog.pg_is_in_recovery()
804
+ `], [], execute, null, { simple: true })
805
+ query.resolve = ([[a], [b]]) => {
806
+ backendParameters.default_transaction_read_only = a.transaction_read_only
807
+ backendParameters.in_hot_standby = b.pg_is_in_recovery ? 'on' : 'off'
808
+ }
809
+ query.execute()
810
+ }
811
+
812
+ function ErrorResponse(x) {
813
+ if (query) {
814
+ (query.cursorFn || query.describeFirst) && write(Sync)
815
+ errorResponse = Errors.postgres(parseError(x))
816
+ } else {
817
+ errored(Errors.postgres(parseError(x)))
818
+ }
819
+ }
820
+
821
+ function retry(q, error) {
822
+ delete statements[q.signature]
823
+ q.retried = error
824
+ execute(q)
825
+ }
826
+
827
+ function NotificationResponse(x) {
828
+ if (!onnotify)
829
+ return
830
+
831
+ let index = 9
832
+ while (x[index++] !== 0);
833
+ onnotify(
834
+ x.toString('utf8', 9, index - 1),
835
+ x.toString('utf8', index, x.length - 1)
836
+ )
837
+ }
838
+
839
+ async function PortalSuspended() {
840
+ try {
841
+ const x = await Promise.resolve(query.cursorFn(result))
842
+ rows = 0
843
+ x === CLOSE
844
+ ? write(Close(query.portal))
845
+ : (result = new Result(), write(Execute('', query.cursorRows)))
846
+ } catch (err) {
847
+ write(Sync)
848
+ query.reject(err)
849
+ }
850
+ }
851
+
852
+ function CloseComplete() {
853
+ result.count && query.cursorFn(result)
854
+ query.resolve(result)
855
+ }
856
+
857
+ function CopyInResponse() {
858
+ stream = new Stream.Writable({
859
+ autoDestroy: true,
860
+ write(chunk, encoding, callback) {
861
+ socket.write(b().d().raw(chunk).end(), callback)
862
+ },
863
+ destroy(error, callback) {
864
+ callback(error)
865
+ socket.write(b().f().str(error + b.N).end())
866
+ stream = null
867
+ },
868
+ final(callback) {
869
+ socket.write(b().c().end())
870
+ final = callback
871
+ stream = null
872
+ }
873
+ })
874
+ query.resolve(stream)
875
+ }
876
+
877
+ function CopyOutResponse() {
878
+ stream = new Stream.Readable({
879
+ read() { socket.resume() }
880
+ })
881
+ query.resolve(stream)
882
+ }
883
+
884
+ /* c8 ignore next 3 */
885
+ function CopyBothResponse() {
886
+ stream = new Stream.Duplex({
887
+ autoDestroy: true,
888
+ read() { socket.resume() },
889
+ /* c8 ignore next 11 */
890
+ write(chunk, encoding, callback) {
891
+ socket.write(b().d().raw(chunk).end(), callback)
892
+ },
893
+ destroy(error, callback) {
894
+ callback(error)
895
+ socket.write(b().f().str(error + b.N).end())
896
+ stream = null
897
+ },
898
+ final(callback) {
899
+ socket.write(b().c().end())
900
+ final = callback
901
+ }
902
+ })
903
+ query.resolve(stream)
904
+ }
905
+
906
+ function CopyData(x) {
907
+ stream && (stream.push(x.subarray(5)) || socket.pause())
908
+ }
909
+
910
+ function CopyDone() {
911
+ stream && stream.push(null)
912
+ stream = null
913
+ }
914
+
915
+ function NoticeResponse(x) {
916
+ onnotice
917
+ ? onnotice(parseError(x))
918
+ : console.log(parseError(x)) // eslint-disable-line
919
+
920
+ }
921
+
922
+ /* c8 ignore next 3 */
923
+ function EmptyQueryResponse() {
924
+ /* noop */
925
+ }
926
+
927
+ /* c8 ignore next 3 */
928
+ function FunctionCallResponse() {
929
+ errored(Errors.notSupported('FunctionCallResponse'))
930
+ }
931
+
932
+ /* c8 ignore next 3 */
933
+ function NegotiateProtocolVersion() {
934
+ errored(Errors.notSupported('NegotiateProtocolVersion'))
935
+ }
936
+
937
+ /* c8 ignore next 3 */
938
+ function UnknownMessage(x) {
939
+ console.error('Postgres.js : Unknown Message:', x[0]) // eslint-disable-line
940
+ }
941
+
942
+ /* c8 ignore next 3 */
943
+ function UnknownAuth(x, type) {
944
+ console.error('Postgres.js : Unknown Auth:', type) // eslint-disable-line
945
+ }
946
+
947
+ /* Messages */
948
+ function Bind(parameters, types, statement = '', portal = '') {
949
+ let prev
950
+ , type
951
+
952
+ b().B().str(portal + b.N).str(statement + b.N).i16(0).i16(parameters.length)
953
+
954
+ parameters.forEach((x, i) => {
955
+ if (x === null)
956
+ return b.i32(0xFFFFFFFF)
957
+
958
+ type = types[i]
959
+ parameters[i] = x = type in options.serializers
960
+ ? options.serializers[type](x)
961
+ : '' + x
962
+
963
+ prev = b.i
964
+ b.inc(4).str(x).i32(b.i - prev - 4, prev)
965
+ })
966
+
967
+ b.i16(0)
968
+
969
+ return b.end()
970
+ }
971
+
972
+ function Parse(str, parameters, types, name = '') {
973
+ b().P().str(name + b.N).str(str + b.N).i16(parameters.length)
974
+ parameters.forEach((x, i) => b.i32(types[i] || 0))
975
+ return b.end()
976
+ }
977
+
978
+ function Describe(x, name = '') {
979
+ return b().D().str(x).str(name + b.N).end()
980
+ }
981
+
982
+ function Execute(portal = '', rows = 0) {
983
+ return Buffer.concat([
984
+ b().E().str(portal + b.N).i32(rows).end(),
985
+ Flush
986
+ ])
987
+ }
988
+
989
+ function Close(portal = '') {
990
+ return Buffer.concat([
991
+ b().C().str('P').str(portal + b.N).end(),
992
+ b().S().end()
993
+ ])
994
+ }
995
+
996
+ function StartupMessage() {
997
+ return cancelMessage || b().inc(4).i16(3).z(2).str(
998
+ Object.entries(Object.assign({
999
+ user,
1000
+ database,
1001
+ client_encoding: 'UTF8'
1002
+ },
1003
+ options.connection
1004
+ )).filter(([, v]) => v).map(([k, v]) => k + b.N + v).join(b.N)
1005
+ ).z(2).end(0)
1006
+ }
1007
+
1008
+ }
1009
+
1010
+ function parseError(x) {
1011
+ const error = {}
1012
+ let start = 5
1013
+ for (let i = 5; i < x.length - 1; i++) {
1014
+ if (x[i] === 0) {
1015
+ error[errorFields[x[start]]] = x.toString('utf8', start + 1, i)
1016
+ start = i + 1
1017
+ }
1018
+ }
1019
+ return error
1020
+ }
1021
+
1022
+ function md5(x) {
1023
+ return crypto.createHash('md5').update(x).digest('hex')
1024
+ }
1025
+
1026
+ function hmac(key, x) {
1027
+ return crypto.createHmac('sha256', key).update(x).digest()
1028
+ }
1029
+
1030
+ function sha256(x) {
1031
+ return crypto.createHash('sha256').update(x).digest()
1032
+ }
1033
+
1034
+ function xor(a, b) {
1035
+ const length = Math.max(a.length, b.length)
1036
+ const buffer = Buffer.allocUnsafe(length)
1037
+ for (let i = 0; i < length; i++)
1038
+ buffer[i] = a[i] ^ b[i]
1039
+ return buffer
1040
+ }
1041
+
1042
+ function timer(fn, seconds) {
1043
+ seconds = typeof seconds === 'function' ? seconds() : seconds
1044
+ if (!seconds)
1045
+ return { cancel: noop, start: noop }
1046
+
1047
+ let timer
1048
+ return {
1049
+ cancel() {
1050
+ timer && (clearTimeout(timer), timer = null)
1051
+ },
1052
+ start() {
1053
+ timer && clearTimeout(timer)
1054
+ timer = setTimeout(done, seconds * 1000, arguments)
1055
+ }
1056
+ }
1057
+
1058
+ function done(args) {
1059
+ fn.apply(null, args)
1060
+ timer = null
1061
+ }
1062
+ }
node_modules/postgres/cjs/src/errors.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const PostgresError = module.exports.PostgresError = class PostgresError extends Error {
2
+ constructor(x) {
3
+ super(x.message)
4
+ this.name = this.constructor.name
5
+ Object.assign(this, x)
6
+ }
7
+ }
8
+
9
+ const Errors = module.exports.Errors = {
10
+ connection,
11
+ postgres,
12
+ generic,
13
+ notSupported
14
+ }
15
+
16
+ function connection(x, options, socket) {
17
+ const { host, port } = socket || options
18
+ const error = Object.assign(
19
+ new Error(('write ' + x + ' ' + (options.path || (host + ':' + port)))),
20
+ {
21
+ code: x,
22
+ errno: x,
23
+ address: options.path || host
24
+ }, options.path ? {} : { port: port }
25
+ )
26
+ Error.captureStackTrace(error, connection)
27
+ return error
28
+ }
29
+
30
+ function postgres(x) {
31
+ const error = new PostgresError(x)
32
+ Error.captureStackTrace(error, postgres)
33
+ return error
34
+ }
35
+
36
+ function generic(code, message) {
37
+ const error = Object.assign(new Error(code + ': ' + message), { code })
38
+ Error.captureStackTrace(error, generic)
39
+ return error
40
+ }
41
+
42
+ /* c8 ignore next 10 */
43
+ function notSupported(x) {
44
+ const error = Object.assign(
45
+ new Error(x + ' (B) is not supported'),
46
+ {
47
+ code: 'MESSAGE_NOT_SUPPORTED',
48
+ name: x
49
+ }
50
+ )
51
+ Error.captureStackTrace(error, notSupported)
52
+ return error
53
+ }
node_modules/postgres/cjs/src/index.js ADDED
@@ -0,0 +1,567 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const os = require('os')
2
+ const fs = require('fs')
3
+
4
+ const {
5
+ mergeUserTypes,
6
+ inferType,
7
+ Parameter,
8
+ Identifier,
9
+ Builder,
10
+ toPascal,
11
+ pascal,
12
+ toCamel,
13
+ camel,
14
+ toKebab,
15
+ kebab,
16
+ fromPascal,
17
+ fromCamel,
18
+ fromKebab
19
+ } = require('./types.js')
20
+
21
+ const Connection = require('./connection.js')
22
+ const { Query, CLOSE } = require('./query.js')
23
+ const Queue = require('./queue.js')
24
+ const { Errors, PostgresError } = require('./errors.js')
25
+ const Subscribe = require('./subscribe.js')
26
+ const largeObject = require('./large.js')
27
+
28
+ Object.assign(Postgres, {
29
+ PostgresError,
30
+ toPascal,
31
+ pascal,
32
+ toCamel,
33
+ camel,
34
+ toKebab,
35
+ kebab,
36
+ fromPascal,
37
+ fromCamel,
38
+ fromKebab,
39
+ BigInt: {
40
+ to: 20,
41
+ from: [20],
42
+ parse: x => BigInt(x), // eslint-disable-line
43
+ serialize: x => x.toString()
44
+ }
45
+ })
46
+
47
+ module.exports = Postgres
48
+
49
+ function Postgres(a, b) {
50
+ const options = parseOptions(a, b)
51
+ , subscribe = options.no_subscribe || Subscribe(Postgres, { ...options })
52
+
53
+ let ending = false
54
+
55
+ const queries = Queue()
56
+ , connecting = Queue()
57
+ , reserved = Queue()
58
+ , closed = Queue()
59
+ , ended = Queue()
60
+ , open = Queue()
61
+ , busy = Queue()
62
+ , full = Queue()
63
+ , queues = { connecting, reserved, closed, ended, open, busy, full }
64
+
65
+ const connections = [...Array(options.max)].map(() => Connection(options, queues, { onopen, onend, onclose }))
66
+
67
+ const sql = Sql(handler)
68
+
69
+ Object.assign(sql, {
70
+ get parameters() { return options.parameters },
71
+ largeObject: largeObject.bind(null, sql),
72
+ subscribe,
73
+ CLOSE,
74
+ END: CLOSE,
75
+ PostgresError,
76
+ options,
77
+ reserve,
78
+ listen,
79
+ begin,
80
+ close,
81
+ end
82
+ })
83
+
84
+ return sql
85
+
86
+ function Sql(handler) {
87
+ handler.debug = options.debug
88
+
89
+ Object.entries(options.types).reduce((acc, [name, type]) => {
90
+ acc[name] = (x) => new Parameter(x, type.to)
91
+ return acc
92
+ }, typed)
93
+
94
+ Object.assign(sql, {
95
+ types: typed,
96
+ typed,
97
+ unsafe,
98
+ notify,
99
+ array,
100
+ json,
101
+ file
102
+ })
103
+
104
+ return sql
105
+
106
+ function typed(value, type) {
107
+ return new Parameter(value, type)
108
+ }
109
+
110
+ function sql(strings, ...args) {
111
+ const query = strings && Array.isArray(strings.raw)
112
+ ? new Query(strings, args, handler, cancel)
113
+ : typeof strings === 'string' && !args.length
114
+ ? new Identifier(options.transform.column.to ? options.transform.column.to(strings) : strings)
115
+ : new Builder(strings, args)
116
+ return query
117
+ }
118
+
119
+ function unsafe(string, args = [], options = {}) {
120
+ arguments.length === 2 && !Array.isArray(args) && (options = args, args = [])
121
+ const query = new Query([string], args, handler, cancel, {
122
+ prepare: false,
123
+ ...options,
124
+ simple: 'simple' in options ? options.simple : args.length === 0
125
+ })
126
+ return query
127
+ }
128
+
129
+ function file(path, args = [], options = {}) {
130
+ arguments.length === 2 && !Array.isArray(args) && (options = args, args = [])
131
+ const query = new Query([], args, (query) => {
132
+ fs.readFile(path, 'utf8', (err, string) => {
133
+ if (err)
134
+ return query.reject(err)
135
+
136
+ query.strings = [string]
137
+ handler(query)
138
+ })
139
+ }, cancel, {
140
+ ...options,
141
+ simple: 'simple' in options ? options.simple : args.length === 0
142
+ })
143
+ return query
144
+ }
145
+ }
146
+
147
+ async function listen(name, fn, onlisten) {
148
+ const listener = { fn, onlisten }
149
+
150
+ const sql = listen.sql || (listen.sql = Postgres({
151
+ ...options,
152
+ max: 1,
153
+ idle_timeout: null,
154
+ max_lifetime: null,
155
+ fetch_types: false,
156
+ onclose() {
157
+ Object.entries(listen.channels).forEach(([name, { listeners }]) => {
158
+ delete listen.channels[name]
159
+ Promise.all(listeners.map(l => listen(name, l.fn, l.onlisten).catch(() => { /* noop */ })))
160
+ })
161
+ },
162
+ onnotify(c, x) {
163
+ c in listen.channels && listen.channels[c].listeners.forEach(l => l.fn(x))
164
+ }
165
+ }))
166
+
167
+ const channels = listen.channels || (listen.channels = {})
168
+ , exists = name in channels
169
+
170
+ if (exists) {
171
+ channels[name].listeners.push(listener)
172
+ const result = await channels[name].result
173
+ listener.onlisten && listener.onlisten()
174
+ return { state: result.state, unlisten }
175
+ }
176
+
177
+ channels[name] = { result: sql`listen ${
178
+ sql.unsafe('"' + name.replace(/"/g, '""') + '"')
179
+ }`, listeners: [listener] }
180
+ const result = await channels[name].result
181
+ listener.onlisten && listener.onlisten()
182
+ return { state: result.state, unlisten }
183
+
184
+ async function unlisten() {
185
+ if (name in channels === false)
186
+ return
187
+
188
+ channels[name].listeners = channels[name].listeners.filter(x => x !== listener)
189
+ if (channels[name].listeners.length)
190
+ return
191
+
192
+ delete channels[name]
193
+ return sql`unlisten ${
194
+ sql.unsafe('"' + name.replace(/"/g, '""') + '"')
195
+ }`
196
+ }
197
+ }
198
+
199
+ async function notify(channel, payload) {
200
+ return await sql`select pg_notify(${ channel }, ${ '' + payload })`
201
+ }
202
+
203
+ async function reserve() {
204
+ const queue = Queue()
205
+ const c = open.length
206
+ ? open.shift()
207
+ : await new Promise((resolve, reject) => {
208
+ const query = { reserve: resolve, reject }
209
+ queries.push(query)
210
+ closed.length && connect(closed.shift(), query)
211
+ })
212
+
213
+ move(c, reserved)
214
+ c.reserved = () => queue.length
215
+ ? c.execute(queue.shift())
216
+ : move(c, reserved)
217
+ c.reserved.release = true
218
+
219
+ const sql = Sql(handler)
220
+ sql.release = () => {
221
+ c.reserved = null
222
+ onopen(c)
223
+ }
224
+
225
+ return sql
226
+
227
+ function handler(q) {
228
+ c.queue === full
229
+ ? queue.push(q)
230
+ : c.execute(q) || move(c, full)
231
+ }
232
+ }
233
+
234
+ async function begin(options, fn) {
235
+ !fn && (fn = options, options = '')
236
+ const queries = Queue()
237
+ let savepoints = 0
238
+ , connection
239
+ , prepare = null
240
+
241
+ try {
242
+ await sql.unsafe('begin ' + options.replace(/[^a-z ]/ig, ''), [], { onexecute }).execute()
243
+ return await Promise.race([
244
+ scope(connection, fn),
245
+ new Promise((_, reject) => connection.onclose = reject)
246
+ ])
247
+ } catch (error) {
248
+ throw error
249
+ }
250
+
251
+ async function scope(c, fn, name) {
252
+ const sql = Sql(handler)
253
+ sql.savepoint = savepoint
254
+ sql.prepare = x => prepare = x.replace(/[^a-z0-9$-_. ]/gi)
255
+ let uncaughtError
256
+ , result
257
+
258
+ name && await sql`savepoint ${ sql(name) }`
259
+ try {
260
+ result = await new Promise((resolve, reject) => {
261
+ const x = fn(sql)
262
+ Promise.resolve(Array.isArray(x) ? Promise.all(x) : x).then(resolve, reject)
263
+ })
264
+
265
+ if (uncaughtError)
266
+ throw uncaughtError
267
+ } catch (e) {
268
+ await (name
269
+ ? sql`rollback to ${ sql(name) }`
270
+ : sql`rollback`
271
+ )
272
+ throw e instanceof PostgresError && e.code === '25P02' && uncaughtError || e
273
+ }
274
+
275
+ if (!name) {
276
+ prepare
277
+ ? await sql`prepare transaction '${ sql.unsafe(prepare) }'`
278
+ : await sql`commit`
279
+ }
280
+
281
+ return result
282
+
283
+ function savepoint(name, fn) {
284
+ if (name && Array.isArray(name.raw))
285
+ return savepoint(sql => sql.apply(sql, arguments))
286
+
287
+ arguments.length === 1 && (fn = name, name = null)
288
+ return scope(c, fn, 's' + savepoints++ + (name ? '_' + name : ''))
289
+ }
290
+
291
+ function handler(q) {
292
+ q.catch(e => uncaughtError || (uncaughtError = e))
293
+ c.queue === full
294
+ ? queries.push(q)
295
+ : c.execute(q) || move(c, full)
296
+ }
297
+ }
298
+
299
+ function onexecute(c) {
300
+ connection = c
301
+ move(c, reserved)
302
+ c.reserved = () => queries.length
303
+ ? c.execute(queries.shift())
304
+ : move(c, reserved)
305
+ }
306
+ }
307
+
308
+ function move(c, queue) {
309
+ c.queue.remove(c)
310
+ queue.push(c)
311
+ c.queue = queue
312
+ queue === open
313
+ ? c.idleTimer.start()
314
+ : c.idleTimer.cancel()
315
+ return c
316
+ }
317
+
318
+ function json(x) {
319
+ return new Parameter(x, 3802)
320
+ }
321
+
322
+ function array(x, type) {
323
+ if (!Array.isArray(x))
324
+ return array(Array.from(arguments))
325
+
326
+ return new Parameter(x, type || (x.length ? inferType(x) || 25 : 0), options.shared.typeArrayMap)
327
+ }
328
+
329
+ function handler(query) {
330
+ if (ending)
331
+ return query.reject(Errors.connection('CONNECTION_ENDED', options, options))
332
+
333
+ if (open.length)
334
+ return go(open.shift(), query)
335
+
336
+ if (closed.length)
337
+ return connect(closed.shift(), query)
338
+
339
+ busy.length
340
+ ? go(busy.shift(), query)
341
+ : queries.push(query)
342
+ }
343
+
344
+ function go(c, query) {
345
+ return c.execute(query)
346
+ ? move(c, busy)
347
+ : move(c, full)
348
+ }
349
+
350
+ function cancel(query) {
351
+ return new Promise((resolve, reject) => {
352
+ query.state
353
+ ? query.active
354
+ ? Connection(options).cancel(query.state, resolve, reject)
355
+ : query.cancelled = { resolve, reject }
356
+ : (
357
+ queries.remove(query),
358
+ query.cancelled = true,
359
+ query.reject(Errors.generic('57014', 'canceling statement due to user request')),
360
+ resolve()
361
+ )
362
+ })
363
+ }
364
+
365
+ async function end({ timeout = null } = {}) {
366
+ if (ending)
367
+ return ending
368
+
369
+ await 1
370
+ let timer
371
+ return ending = Promise.race([
372
+ new Promise(r => timeout !== null && (timer = setTimeout(destroy, timeout * 1000, r))),
373
+ Promise.all(connections.map(c => c.end()).concat(
374
+ listen.sql ? listen.sql.end({ timeout: 0 }) : [],
375
+ subscribe.sql ? subscribe.sql.end({ timeout: 0 }) : []
376
+ ))
377
+ ]).then(() => clearTimeout(timer))
378
+ }
379
+
380
+ async function close() {
381
+ await Promise.all(connections.map(c => c.end()))
382
+ }
383
+
384
+ async function destroy(resolve) {
385
+ await Promise.all(connections.map(c => c.terminate()))
386
+ while (queries.length)
387
+ queries.shift().reject(Errors.connection('CONNECTION_DESTROYED', options))
388
+ resolve()
389
+ }
390
+
391
+ function connect(c, query) {
392
+ move(c, connecting)
393
+ c.connect(query)
394
+ return c
395
+ }
396
+
397
+ function onend(c) {
398
+ move(c, ended)
399
+ }
400
+
401
+ function onopen(c) {
402
+ if (queries.length === 0)
403
+ return move(c, open)
404
+
405
+ let max = Math.ceil(queries.length / (connecting.length + 1))
406
+ , ready = true
407
+
408
+ while (ready && queries.length && max-- > 0) {
409
+ const query = queries.shift()
410
+ if (query.reserve)
411
+ return query.reserve(c)
412
+
413
+ ready = c.execute(query)
414
+ }
415
+
416
+ ready
417
+ ? move(c, busy)
418
+ : move(c, full)
419
+ }
420
+
421
+ function onclose(c, e) {
422
+ move(c, closed)
423
+ c.reserved = null
424
+ c.onclose && (c.onclose(e), c.onclose = null)
425
+ options.onclose && options.onclose(c.id)
426
+ queries.length && connect(c, queries.shift())
427
+ }
428
+ }
429
+
430
+ function parseOptions(a, b) {
431
+ if (a && a.shared)
432
+ return a
433
+
434
+ const env = process.env // eslint-disable-line
435
+ , o = (!a || typeof a === 'string' ? b : a) || {}
436
+ , { url, multihost } = parseUrl(a)
437
+ , query = [...url.searchParams].reduce((a, [b, c]) => (a[b] = c, a), {})
438
+ , host = o.hostname || o.host || multihost || url.hostname || env.PGHOST || 'localhost'
439
+ , port = o.port || url.port || env.PGPORT || 5432
440
+ , user = o.user || o.username || url.username || env.PGUSERNAME || env.PGUSER || osUsername()
441
+
442
+ o.no_prepare && (o.prepare = false)
443
+ query.sslmode && (query.ssl = query.sslmode, delete query.sslmode)
444
+ 'timeout' in o && (console.log('The timeout option is deprecated, use idle_timeout instead'), o.idle_timeout = o.timeout) // eslint-disable-line
445
+ query.sslrootcert === 'system' && (query.ssl = 'verify-full')
446
+
447
+ const ints = ['idle_timeout', 'connect_timeout', 'max_lifetime', 'max_pipeline', 'backoff', 'keep_alive']
448
+ const defaults = {
449
+ max : globalThis.Cloudflare ? 3 : 10,
450
+ ssl : false,
451
+ sslnegotiation : null,
452
+ idle_timeout : null,
453
+ connect_timeout : 30,
454
+ max_lifetime : max_lifetime,
455
+ max_pipeline : 100,
456
+ backoff : backoff,
457
+ keep_alive : 60,
458
+ prepare : true,
459
+ debug : false,
460
+ fetch_types : true,
461
+ publications : 'alltables',
462
+ target_session_attrs: null
463
+ }
464
+
465
+ return {
466
+ host : Array.isArray(host) ? host : host.split(',').map(x => x.split(':')[0]),
467
+ port : Array.isArray(port) ? port : host.split(',').map(x => parseInt(x.split(':')[1] || port)),
468
+ path : o.path || host.indexOf('/') > -1 && host + '/.s.PGSQL.' + port,
469
+ database : o.database || o.db || (url.pathname || '').slice(1) || env.PGDATABASE || user,
470
+ user : user,
471
+ pass : o.pass || o.password || url.password || env.PGPASSWORD || '',
472
+ ...Object.entries(defaults).reduce(
473
+ (acc, [k, d]) => {
474
+ const value = k in o ? o[k] : k in query
475
+ ? (query[k] === 'disable' || query[k] === 'false' ? false : query[k])
476
+ : env['PG' + k.toUpperCase()] || d
477
+ acc[k] = typeof value === 'string' && ints.includes(k)
478
+ ? +value
479
+ : value
480
+ return acc
481
+ },
482
+ {}
483
+ ),
484
+ connection : {
485
+ application_name: env.PGAPPNAME || 'postgres.js',
486
+ ...o.connection,
487
+ ...Object.entries(query).reduce((acc, [k, v]) => (k in defaults || (acc[k] = v), acc), {})
488
+ },
489
+ types : o.types || {},
490
+ target_session_attrs: tsa(o, url, env),
491
+ onnotice : o.onnotice,
492
+ onnotify : o.onnotify,
493
+ onclose : o.onclose,
494
+ onparameter : o.onparameter,
495
+ socket : o.socket,
496
+ transform : parseTransform(o.transform || { undefined: undefined }),
497
+ parameters : {},
498
+ shared : { retries: 0, typeArrayMap: {} },
499
+ ...mergeUserTypes(o.types)
500
+ }
501
+ }
502
+
503
+ function tsa(o, url, env) {
504
+ const x = o.target_session_attrs || url.searchParams.get('target_session_attrs') || env.PGTARGETSESSIONATTRS
505
+ if (!x || ['read-write', 'read-only', 'primary', 'standby', 'prefer-standby'].includes(x))
506
+ return x
507
+
508
+ throw new Error('target_session_attrs ' + x + ' is not supported')
509
+ }
510
+
511
+ function backoff(retries) {
512
+ return (0.5 + Math.random() / 2) * Math.min(3 ** retries / 100, 20)
513
+ }
514
+
515
+ function max_lifetime() {
516
+ return 60 * (30 + Math.random() * 30)
517
+ }
518
+
519
+ function parseTransform(x) {
520
+ return {
521
+ undefined: x.undefined,
522
+ column: {
523
+ from: typeof x.column === 'function' ? x.column : x.column && x.column.from,
524
+ to: x.column && x.column.to
525
+ },
526
+ value: {
527
+ from: typeof x.value === 'function' ? x.value : x.value && x.value.from,
528
+ to: x.value && x.value.to
529
+ },
530
+ row: {
531
+ from: typeof x.row === 'function' ? x.row : x.row && x.row.from,
532
+ to: x.row && x.row.to
533
+ }
534
+ }
535
+ }
536
+
537
+ function parseUrl(url) {
538
+ if (!url || typeof url !== 'string')
539
+ return { url: { searchParams: new Map() } }
540
+
541
+ let host = url
542
+ host = host.slice(host.indexOf('://') + 3).split(/[?/]/)[0]
543
+ host = decodeURIComponent(host.slice(host.indexOf('@') + 1))
544
+
545
+ const urlObj = new URL(url.replace(host, host.split(',')[0]))
546
+
547
+ return {
548
+ url: {
549
+ username: decodeURIComponent(urlObj.username),
550
+ password: decodeURIComponent(urlObj.password),
551
+ host: urlObj.host,
552
+ hostname: urlObj.hostname,
553
+ port: urlObj.port,
554
+ pathname: urlObj.pathname,
555
+ searchParams: urlObj.searchParams
556
+ },
557
+ multihost: host.indexOf(',') > -1 && host
558
+ }
559
+ }
560
+
561
+ function osUsername() {
562
+ try {
563
+ return os.userInfo().username // eslint-disable-line
564
+ } catch (_) {
565
+ return process.env.USERNAME || process.env.USER || process.env.LOGNAME // eslint-disable-line
566
+ }
567
+ }
node_modules/postgres/cjs/src/large.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const Stream = require('stream')
2
+
3
+ module.exports = largeObject;function largeObject(sql, oid, mode = 0x00020000 | 0x00040000) {
4
+ return new Promise(async(resolve, reject) => {
5
+ await sql.begin(async sql => {
6
+ let finish
7
+ !oid && ([{ oid }] = await sql`select lo_creat(-1) as oid`)
8
+ const [{ fd }] = await sql`select lo_open(${ oid }, ${ mode }) as fd`
9
+
10
+ const lo = {
11
+ writable,
12
+ readable,
13
+ close : () => sql`select lo_close(${ fd })`.then(finish),
14
+ tell : () => sql`select lo_tell64(${ fd })`,
15
+ read : (x) => sql`select loread(${ fd }, ${ x }) as data`,
16
+ write : (x) => sql`select lowrite(${ fd }, ${ x })`,
17
+ truncate : (x) => sql`select lo_truncate64(${ fd }, ${ x })`,
18
+ seek : (x, whence = 0) => sql`select lo_lseek64(${ fd }, ${ x }, ${ whence })`,
19
+ size : () => sql`
20
+ select
21
+ lo_lseek64(${ fd }, location, 0) as position,
22
+ seek.size
23
+ from (
24
+ select
25
+ lo_lseek64($1, 0, 2) as size,
26
+ tell.location
27
+ from (select lo_tell64($1) as location) tell
28
+ ) seek
29
+ `
30
+ }
31
+
32
+ resolve(lo)
33
+
34
+ return new Promise(async r => finish = r)
35
+
36
+ async function readable({
37
+ highWaterMark = 2048 * 8,
38
+ start = 0,
39
+ end = Infinity
40
+ } = {}) {
41
+ let max = end - start
42
+ start && await lo.seek(start)
43
+ return new Stream.Readable({
44
+ highWaterMark,
45
+ async read(size) {
46
+ const l = size > max ? size - max : size
47
+ max -= size
48
+ const [{ data }] = await lo.read(l)
49
+ this.push(data)
50
+ if (data.length < size)
51
+ this.push(null)
52
+ }
53
+ })
54
+ }
55
+
56
+ async function writable({
57
+ highWaterMark = 2048 * 8,
58
+ start = 0
59
+ } = {}) {
60
+ start && await lo.seek(start)
61
+ return new Stream.Writable({
62
+ highWaterMark,
63
+ write(chunk, encoding, callback) {
64
+ lo.write(chunk).then(() => callback(), callback)
65
+ }
66
+ })
67
+ }
68
+ }).catch(reject)
69
+ })
70
+ }
node_modules/postgres/cjs/src/query.js ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const originCache = new Map()
2
+ , originStackCache = new Map()
3
+ , originError = Symbol('OriginError')
4
+
5
+ const CLOSE = module.exports.CLOSE = {}
6
+ const Query = module.exports.Query = class Query extends Promise {
7
+ constructor(strings, args, handler, canceller, options = {}) {
8
+ let resolve
9
+ , reject
10
+
11
+ super((a, b) => {
12
+ resolve = a
13
+ reject = b
14
+ })
15
+
16
+ this.tagged = Array.isArray(strings.raw)
17
+ this.strings = strings
18
+ this.args = args
19
+ this.handler = handler
20
+ this.canceller = canceller
21
+ this.options = options
22
+
23
+ this.state = null
24
+ this.statement = null
25
+
26
+ this.resolve = x => (this.active = false, resolve(x))
27
+ this.reject = x => (this.active = false, reject(x))
28
+
29
+ this.active = false
30
+ this.cancelled = null
31
+ this.executed = false
32
+ this.signature = ''
33
+
34
+ this[originError] = this.handler.debug
35
+ ? new Error()
36
+ : this.tagged && cachedError(this.strings)
37
+ }
38
+
39
+ get origin() {
40
+ return (this.handler.debug
41
+ ? this[originError].stack
42
+ : this.tagged && originStackCache.has(this.strings)
43
+ ? originStackCache.get(this.strings)
44
+ : originStackCache.set(this.strings, this[originError].stack).get(this.strings)
45
+ ) || ''
46
+ }
47
+
48
+ static get [Symbol.species]() {
49
+ return Promise
50
+ }
51
+
52
+ cancel() {
53
+ return this.canceller && (this.canceller(this), this.canceller = null)
54
+ }
55
+
56
+ simple() {
57
+ this.options.simple = true
58
+ this.options.prepare = false
59
+ return this
60
+ }
61
+
62
+ async readable() {
63
+ this.simple()
64
+ this.streaming = true
65
+ return this
66
+ }
67
+
68
+ async writable() {
69
+ this.simple()
70
+ this.streaming = true
71
+ return this
72
+ }
73
+
74
+ cursor(rows = 1, fn) {
75
+ this.options.simple = false
76
+ if (typeof rows === 'function') {
77
+ fn = rows
78
+ rows = 1
79
+ }
80
+
81
+ this.cursorRows = rows
82
+
83
+ if (typeof fn === 'function')
84
+ return (this.cursorFn = fn, this)
85
+
86
+ let prev
87
+ return {
88
+ [Symbol.asyncIterator]: () => ({
89
+ next: () => {
90
+ if (this.executed && !this.active)
91
+ return { done: true }
92
+
93
+ prev && prev()
94
+ const promise = new Promise((resolve, reject) => {
95
+ this.cursorFn = value => {
96
+ resolve({ value, done: false })
97
+ return new Promise(r => prev = r)
98
+ }
99
+ this.resolve = () => (this.active = false, resolve({ done: true }))
100
+ this.reject = x => (this.active = false, reject(x))
101
+ })
102
+ this.execute()
103
+ return promise
104
+ },
105
+ return() {
106
+ prev && prev(CLOSE)
107
+ return { done: true }
108
+ }
109
+ })
110
+ }
111
+ }
112
+
113
+ describe() {
114
+ this.options.simple = false
115
+ this.onlyDescribe = this.options.prepare = true
116
+ return this
117
+ }
118
+
119
+ stream() {
120
+ throw new Error('.stream has been renamed to .forEach')
121
+ }
122
+
123
+ forEach(fn) {
124
+ this.forEachFn = fn
125
+ this.handle()
126
+ return this
127
+ }
128
+
129
+ raw() {
130
+ this.isRaw = true
131
+ return this
132
+ }
133
+
134
+ values() {
135
+ this.isRaw = 'values'
136
+ return this
137
+ }
138
+
139
+ async handle() {
140
+ !this.executed && (this.executed = true) && await 1 && this.handler(this)
141
+ }
142
+
143
+ execute() {
144
+ this.handle()
145
+ return this
146
+ }
147
+
148
+ then() {
149
+ this.handle()
150
+ return super.then.apply(this, arguments)
151
+ }
152
+
153
+ catch() {
154
+ this.handle()
155
+ return super.catch.apply(this, arguments)
156
+ }
157
+
158
+ finally() {
159
+ this.handle()
160
+ return super.finally.apply(this, arguments)
161
+ }
162
+ }
163
+
164
+ function cachedError(xs) {
165
+ if (originCache.has(xs))
166
+ return originCache.get(xs)
167
+
168
+ const x = Error.stackTraceLimit
169
+ Error.stackTraceLimit = 4
170
+ originCache.set(xs, new Error())
171
+ Error.stackTraceLimit = x
172
+ return originCache.get(xs)
173
+ }
node_modules/postgres/cjs/src/queue.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = Queue
2
+
3
+ function Queue(initial = []) {
4
+ let xs = initial.slice()
5
+ let index = 0
6
+
7
+ return {
8
+ get length() {
9
+ return xs.length - index
10
+ },
11
+ remove: (x) => {
12
+ const index = xs.indexOf(x)
13
+ return index === -1
14
+ ? null
15
+ : (xs.splice(index, 1), x)
16
+ },
17
+ push: (x) => (xs.push(x), x),
18
+ shift: () => {
19
+ const out = xs[index++]
20
+
21
+ if (index === xs.length) {
22
+ index = 0
23
+ xs = []
24
+ } else {
25
+ xs[index - 1] = undefined
26
+ }
27
+
28
+ return out
29
+ }
30
+ }
31
+ }
node_modules/postgres/cjs/src/result.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = class Result extends Array {
2
+ constructor() {
3
+ super()
4
+ Object.defineProperties(this, {
5
+ count: { value: null, writable: true },
6
+ state: { value: null, writable: true },
7
+ command: { value: null, writable: true },
8
+ columns: { value: null, writable: true },
9
+ statement: { value: null, writable: true }
10
+ })
11
+ }
12
+
13
+ static get [Symbol.species]() {
14
+ return Array
15
+ }
16
+ }
node_modules/postgres/cjs/src/subscribe.js ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const noop = () => { /* noop */ }
2
+
3
+ module.exports = Subscribe;function Subscribe(postgres, options) {
4
+ const subscribers = new Map()
5
+ , slot = 'postgresjs_' + Math.random().toString(36).slice(2)
6
+ , state = {}
7
+
8
+ let connection
9
+ , stream
10
+ , ended = false
11
+
12
+ const sql = subscribe.sql = postgres({
13
+ ...options,
14
+ transform: { column: {}, value: {}, row: {} },
15
+ max: 1,
16
+ fetch_types: false,
17
+ idle_timeout: null,
18
+ max_lifetime: null,
19
+ connection: {
20
+ ...options.connection,
21
+ replication: 'database'
22
+ },
23
+ onclose: async function() {
24
+ if (ended)
25
+ return
26
+ stream = null
27
+ state.pid = state.secret = undefined
28
+ connected(await init(sql, slot, options.publications))
29
+ subscribers.forEach(event => event.forEach(({ onsubscribe }) => onsubscribe()))
30
+ },
31
+ no_subscribe: true
32
+ })
33
+
34
+ const end = sql.end
35
+ , close = sql.close
36
+
37
+ sql.end = async() => {
38
+ ended = true
39
+ stream && (await new Promise(r => (stream.once('close', r), stream.end())))
40
+ return end()
41
+ }
42
+
43
+ sql.close = async() => {
44
+ stream && (await new Promise(r => (stream.once('close', r), stream.end())))
45
+ return close()
46
+ }
47
+
48
+ return subscribe
49
+
50
+ async function subscribe(event, fn, onsubscribe = noop, onerror = noop) {
51
+ event = parseEvent(event)
52
+
53
+ if (!connection)
54
+ connection = init(sql, slot, options.publications)
55
+
56
+ const subscriber = { fn, onsubscribe }
57
+ const fns = subscribers.has(event)
58
+ ? subscribers.get(event).add(subscriber)
59
+ : subscribers.set(event, new Set([subscriber])).get(event)
60
+
61
+ const unsubscribe = () => {
62
+ fns.delete(subscriber)
63
+ fns.size === 0 && subscribers.delete(event)
64
+ }
65
+
66
+ return connection.then(x => {
67
+ connected(x)
68
+ onsubscribe()
69
+ stream && stream.on('error', onerror)
70
+ return { unsubscribe, state, sql }
71
+ })
72
+ }
73
+
74
+ function connected(x) {
75
+ stream = x.stream
76
+ state.pid = x.state.pid
77
+ state.secret = x.state.secret
78
+ }
79
+
80
+ async function init(sql, slot, publications) {
81
+ if (!publications)
82
+ throw new Error('Missing publication names')
83
+
84
+ const xs = await sql.unsafe(
85
+ `CREATE_REPLICATION_SLOT ${ slot } TEMPORARY LOGICAL pgoutput NOEXPORT_SNAPSHOT`
86
+ )
87
+
88
+ const [x] = xs
89
+
90
+ const stream = await sql.unsafe(
91
+ `START_REPLICATION SLOT ${ slot } LOGICAL ${
92
+ x.consistent_point
93
+ } (proto_version '1', publication_names '${ publications }')`
94
+ ).writable()
95
+
96
+ const state = {
97
+ lsn: Buffer.concat(x.consistent_point.split('/').map(x => Buffer.from(('00000000' + x).slice(-8), 'hex')))
98
+ }
99
+
100
+ stream.on('data', data)
101
+ stream.on('error', error)
102
+ stream.on('close', sql.close)
103
+
104
+ return { stream, state: xs.state }
105
+
106
+ function error(e) {
107
+ console.error('Unexpected error during logical streaming - reconnecting', e) // eslint-disable-line
108
+ }
109
+
110
+ function data(x) {
111
+ if (x[0] === 0x77) {
112
+ parse(x.subarray(25), state, sql.options.parsers, handle, options.transform)
113
+ } else if (x[0] === 0x6b && x[17]) {
114
+ state.lsn = x.subarray(1, 9)
115
+ pong()
116
+ }
117
+ }
118
+
119
+ function handle(a, b) {
120
+ const path = b.relation.schema + '.' + b.relation.table
121
+ call('*', a, b)
122
+ call('*:' + path, a, b)
123
+ b.relation.keys.length && call('*:' + path + '=' + b.relation.keys.map(x => a[x.name]), a, b)
124
+ call(b.command, a, b)
125
+ call(b.command + ':' + path, a, b)
126
+ b.relation.keys.length && call(b.command + ':' + path + '=' + b.relation.keys.map(x => a[x.name]), a, b)
127
+ }
128
+
129
+ function pong() {
130
+ const x = Buffer.alloc(34)
131
+ x[0] = 'r'.charCodeAt(0)
132
+ x.fill(state.lsn, 1)
133
+ x.writeBigInt64BE(BigInt(Date.now() - Date.UTC(2000, 0, 1)) * BigInt(1000), 25)
134
+ stream.write(x)
135
+ }
136
+ }
137
+
138
+ function call(x, a, b) {
139
+ subscribers.has(x) && subscribers.get(x).forEach(({ fn }) => fn(a, b, x))
140
+ }
141
+ }
142
+
143
+ function Time(x) {
144
+ return new Date(Date.UTC(2000, 0, 1) + Number(x / BigInt(1000)))
145
+ }
146
+
147
+ function parse(x, state, parsers, handle, transform) {
148
+ const char = (acc, [k, v]) => (acc[k.charCodeAt(0)] = v, acc)
149
+
150
+ Object.entries({
151
+ R: x => { // Relation
152
+ let i = 1
153
+ const r = state[x.readUInt32BE(i)] = {
154
+ schema: x.toString('utf8', i += 4, i = x.indexOf(0, i)) || 'pg_catalog',
155
+ table: x.toString('utf8', i + 1, i = x.indexOf(0, i + 1)),
156
+ columns: Array(x.readUInt16BE(i += 2)),
157
+ keys: []
158
+ }
159
+ i += 2
160
+
161
+ let columnIndex = 0
162
+ , column
163
+
164
+ while (i < x.length) {
165
+ column = r.columns[columnIndex++] = {
166
+ key: x[i++],
167
+ name: transform.column.from
168
+ ? transform.column.from(x.toString('utf8', i, i = x.indexOf(0, i)))
169
+ : x.toString('utf8', i, i = x.indexOf(0, i)),
170
+ type: x.readUInt32BE(i += 1),
171
+ parser: parsers[x.readUInt32BE(i)],
172
+ atttypmod: x.readUInt32BE(i += 4)
173
+ }
174
+
175
+ column.key && r.keys.push(column)
176
+ i += 4
177
+ }
178
+ },
179
+ Y: () => { /* noop */ }, // Type
180
+ O: () => { /* noop */ }, // Origin
181
+ B: x => { // Begin
182
+ state.date = Time(x.readBigInt64BE(9))
183
+ state.lsn = x.subarray(1, 9)
184
+ },
185
+ I: x => { // Insert
186
+ let i = 1
187
+ const relation = state[x.readUInt32BE(i)]
188
+ const { row } = tuples(x, relation.columns, i += 7, transform)
189
+
190
+ handle(row, {
191
+ command: 'insert',
192
+ relation
193
+ })
194
+ },
195
+ D: x => { // Delete
196
+ let i = 1
197
+ const relation = state[x.readUInt32BE(i)]
198
+ i += 4
199
+ const key = x[i] === 75
200
+ handle(key || x[i] === 79
201
+ ? tuples(x, relation.columns, i += 3, transform).row
202
+ : null
203
+ , {
204
+ command: 'delete',
205
+ relation,
206
+ key
207
+ })
208
+ },
209
+ U: x => { // Update
210
+ let i = 1
211
+ const relation = state[x.readUInt32BE(i)]
212
+ i += 4
213
+ const key = x[i] === 75
214
+ const xs = key || x[i] === 79
215
+ ? tuples(x, relation.columns, i += 3, transform)
216
+ : null
217
+
218
+ xs && (i = xs.i)
219
+
220
+ const { row } = tuples(x, relation.columns, i + 3, transform)
221
+
222
+ handle(row, {
223
+ command: 'update',
224
+ relation,
225
+ key,
226
+ old: xs && xs.row
227
+ })
228
+ },
229
+ T: () => { /* noop */ }, // Truncate,
230
+ C: () => { /* noop */ } // Commit
231
+ }).reduce(char, {})[x[0]](x)
232
+ }
233
+
234
+ function tuples(x, columns, xi, transform) {
235
+ let type
236
+ , column
237
+ , value
238
+
239
+ const row = transform.raw ? new Array(columns.length) : {}
240
+ for (let i = 0; i < columns.length; i++) {
241
+ type = x[xi++]
242
+ column = columns[i]
243
+ value = type === 110 // n
244
+ ? null
245
+ : type === 117 // u
246
+ ? undefined
247
+ : column.parser === undefined
248
+ ? x.toString('utf8', xi + 4, xi += 4 + x.readUInt32BE(xi))
249
+ : column.parser.array === true
250
+ ? column.parser(x.toString('utf8', xi + 5, xi += 4 + x.readUInt32BE(xi)))
251
+ : column.parser(x.toString('utf8', xi + 4, xi += 4 + x.readUInt32BE(xi)))
252
+
253
+ transform.raw
254
+ ? (row[i] = transform.raw === true
255
+ ? value
256
+ : transform.value.from ? transform.value.from(value, column) : value)
257
+ : (row[column.name] = transform.value.from
258
+ ? transform.value.from(value, column)
259
+ : value
260
+ )
261
+ }
262
+
263
+ return { i: xi, row: transform.row.from ? transform.row.from(row) : row }
264
+ }
265
+
266
+ function parseEvent(x) {
267
+ const xs = x.match(/^(\*|insert|update|delete)?:?([^.]+?\.?[^=]+)?=?(.+)?/i) || []
268
+
269
+ if (!xs)
270
+ throw new Error('Malformed subscribe pattern: ' + x)
271
+
272
+ const [, command, path, key] = xs
273
+
274
+ return (command || '*')
275
+ + (path ? ':' + (path.indexOf('.') === -1 ? 'public.' + path : path) : '')
276
+ + (key ? '=' + key : '')
277
+ }
node_modules/postgres/cjs/src/types.js ADDED
@@ -0,0 +1,367 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { Query } = require('./query.js')
2
+ const { Errors } = require('./errors.js')
3
+
4
+ const types = module.exports.types = {
5
+ string: {
6
+ to: 25,
7
+ from: null, // defaults to string
8
+ serialize: x => '' + x
9
+ },
10
+ number: {
11
+ to: 0,
12
+ from: [21, 23, 26, 700, 701],
13
+ serialize: x => '' + x,
14
+ parse: x => +x
15
+ },
16
+ json: {
17
+ to: 114,
18
+ from: [114, 3802],
19
+ serialize: x => JSON.stringify(x),
20
+ parse: x => JSON.parse(x)
21
+ },
22
+ boolean: {
23
+ to: 16,
24
+ from: 16,
25
+ serialize: x => x === true ? 't' : 'f',
26
+ parse: x => x === 't'
27
+ },
28
+ date: {
29
+ to: 1184,
30
+ from: [1082, 1114, 1184],
31
+ serialize: x => (x instanceof Date ? x : new Date(x)).toISOString(),
32
+ parse: x => new Date(x)
33
+ },
34
+ bytea: {
35
+ to: 17,
36
+ from: 17,
37
+ serialize: x => '\\x' + Buffer.from(x).toString('hex'),
38
+ parse: x => Buffer.from(x.slice(2), 'hex')
39
+ }
40
+ }
41
+
42
+ class NotTagged { then() { notTagged() } catch() { notTagged() } finally() { notTagged() }}
43
+
44
+ const Identifier = module.exports.Identifier = class Identifier extends NotTagged {
45
+ constructor(value) {
46
+ super()
47
+ this.value = escapeIdentifier(value)
48
+ }
49
+ }
50
+
51
+ const Parameter = module.exports.Parameter = class Parameter extends NotTagged {
52
+ constructor(value, type, array) {
53
+ super()
54
+ this.value = value
55
+ this.type = type
56
+ this.array = array
57
+ }
58
+ }
59
+
60
+ const Builder = module.exports.Builder = class Builder extends NotTagged {
61
+ constructor(first, rest) {
62
+ super()
63
+ this.first = first
64
+ this.rest = rest
65
+ }
66
+
67
+ build(before, parameters, types, options) {
68
+ const keyword = builders.map(([x, fn]) => ({ fn, i: before.search(x) })).sort((a, b) => a.i - b.i).pop()
69
+ return keyword.i === -1
70
+ ? escapeIdentifiers(this.first, options)
71
+ : keyword.fn(this.first, this.rest, parameters, types, options)
72
+ }
73
+ }
74
+
75
+ module.exports.handleValue = handleValue;function handleValue(x, parameters, types, options) {
76
+ let value = x instanceof Parameter ? x.value : x
77
+ if (value === undefined) {
78
+ x instanceof Parameter
79
+ ? x.value = options.transform.undefined
80
+ : value = x = options.transform.undefined
81
+
82
+ if (value === undefined)
83
+ throw Errors.generic('UNDEFINED_VALUE', 'Undefined values are not allowed')
84
+ }
85
+
86
+ return '$' + (types.push(
87
+ x instanceof Parameter
88
+ ? (parameters.push(x.value), x.array
89
+ ? x.array[x.type || inferType(x.value)] || x.type || firstIsString(x.value)
90
+ : x.type
91
+ )
92
+ : (parameters.push(x), inferType(x))
93
+ ))
94
+ }
95
+
96
+ const defaultHandlers = typeHandlers(types)
97
+
98
+ module.exports.stringify = stringify;function stringify(q, string, value, parameters, types, options) { // eslint-disable-line
99
+ for (let i = 1; i < q.strings.length; i++) {
100
+ string += (stringifyValue(string, value, parameters, types, options)) + q.strings[i]
101
+ value = q.args[i]
102
+ }
103
+
104
+ return string
105
+ }
106
+
107
+ function stringifyValue(string, value, parameters, types, o) {
108
+ return (
109
+ value instanceof Builder ? value.build(string, parameters, types, o) :
110
+ value instanceof Query ? fragment(value, parameters, types, o) :
111
+ value instanceof Identifier ? value.value :
112
+ value && value[0] instanceof Query ? value.reduce((acc, x) => acc + ' ' + fragment(x, parameters, types, o), '') :
113
+ handleValue(value, parameters, types, o)
114
+ )
115
+ }
116
+
117
+ function fragment(q, parameters, types, options) {
118
+ q.fragment = true
119
+ return stringify(q, q.strings[0], q.args[0], parameters, types, options)
120
+ }
121
+
122
+ function valuesBuilder(first, parameters, types, columns, options) {
123
+ return first.map(row =>
124
+ '(' + columns.map(column =>
125
+ stringifyValue('values', row[column], parameters, types, options)
126
+ ).join(',') + ')'
127
+ ).join(',')
128
+ }
129
+
130
+ function values(first, rest, parameters, types, options) {
131
+ const multi = Array.isArray(first[0])
132
+ const columns = rest.length ? rest.flat() : Object.keys(multi ? first[0] : first)
133
+ return valuesBuilder(multi ? first : [first], parameters, types, columns, options)
134
+ }
135
+
136
+ function select(first, rest, parameters, types, options) {
137
+ typeof first === 'string' && (first = [first].concat(rest))
138
+ if (Array.isArray(first))
139
+ return escapeIdentifiers(first, options)
140
+
141
+ let value
142
+ const columns = rest.length ? rest.flat() : Object.keys(first)
143
+ return columns.map(x => {
144
+ value = first[x]
145
+ return (
146
+ value instanceof Query ? fragment(value, parameters, types, options) :
147
+ value instanceof Identifier ? value.value :
148
+ handleValue(value, parameters, types, options)
149
+ ) + ' as ' + escapeIdentifier(options.transform.column.to ? options.transform.column.to(x) : x)
150
+ }).join(',')
151
+ }
152
+
153
+ const builders = Object.entries({
154
+ values,
155
+ in: (...xs) => {
156
+ const x = values(...xs)
157
+ return x === '()' ? '(null)' : x
158
+ },
159
+ select,
160
+ as: select,
161
+ returning: select,
162
+ '\\(': select,
163
+
164
+ update(first, rest, parameters, types, options) {
165
+ return (rest.length ? rest.flat() : Object.keys(first)).map(x =>
166
+ escapeIdentifier(options.transform.column.to ? options.transform.column.to(x) : x) +
167
+ '=' + stringifyValue('values', first[x], parameters, types, options)
168
+ )
169
+ },
170
+
171
+ insert(first, rest, parameters, types, options) {
172
+ const columns = rest.length ? rest.flat() : Object.keys(Array.isArray(first) ? first[0] : first)
173
+ return '(' + escapeIdentifiers(columns, options) + ')values' +
174
+ valuesBuilder(Array.isArray(first) ? first : [first], parameters, types, columns, options)
175
+ }
176
+ }).map(([x, fn]) => ([new RegExp('((?:^|[\\s(])' + x + '(?:$|[\\s(]))(?![\\s\\S]*\\1)', 'i'), fn]))
177
+
178
+ function notTagged() {
179
+ throw Errors.generic('NOT_TAGGED_CALL', 'Query not called as a tagged template literal')
180
+ }
181
+
182
+ const serializers = module.exports.serializers = defaultHandlers.serializers
183
+ const parsers = module.exports.parsers = defaultHandlers.parsers
184
+
185
+ const END = module.exports.END = {}
186
+
187
+ function firstIsString(x) {
188
+ if (Array.isArray(x))
189
+ return firstIsString(x[0])
190
+ return typeof x === 'string' ? 1009 : 0
191
+ }
192
+
193
+ const mergeUserTypes = module.exports.mergeUserTypes = function(types) {
194
+ const user = typeHandlers(types || {})
195
+ return {
196
+ serializers: Object.assign({}, serializers, user.serializers),
197
+ parsers: Object.assign({}, parsers, user.parsers)
198
+ }
199
+ }
200
+
201
+ function typeHandlers(types) {
202
+ return Object.keys(types).reduce((acc, k) => {
203
+ types[k].from && [].concat(types[k].from).forEach(x => acc.parsers[x] = types[k].parse)
204
+ if (types[k].serialize) {
205
+ acc.serializers[types[k].to] = types[k].serialize
206
+ types[k].from && [].concat(types[k].from).forEach(x => acc.serializers[x] = types[k].serialize)
207
+ }
208
+ return acc
209
+ }, { parsers: {}, serializers: {} })
210
+ }
211
+
212
+ function escapeIdentifiers(xs, { transform: { column } }) {
213
+ return xs.map(x => escapeIdentifier(column.to ? column.to(x) : x)).join(',')
214
+ }
215
+
216
+ const escapeIdentifier = module.exports.escapeIdentifier = function escape(str) {
217
+ return '"' + str.replace(/"/g, '""').replace(/\./g, '"."') + '"'
218
+ }
219
+
220
+ const inferType = module.exports.inferType = function inferType(x) {
221
+ return (
222
+ x instanceof Parameter ? x.type :
223
+ x instanceof Date ? 1184 :
224
+ x instanceof Uint8Array ? 17 :
225
+ (x === true || x === false) ? 16 :
226
+ typeof x === 'bigint' ? 20 :
227
+ Array.isArray(x) ? inferType(x[0]) :
228
+ 0
229
+ )
230
+ }
231
+
232
+ const escapeBackslash = /\\/g
233
+ const escapeQuote = /"/g
234
+
235
+ function arrayEscape(x) {
236
+ return x
237
+ .replace(escapeBackslash, '\\\\')
238
+ .replace(escapeQuote, '\\"')
239
+ }
240
+
241
+ const arraySerializer = module.exports.arraySerializer = function arraySerializer(xs, serializer, options, typarray) {
242
+ if (Array.isArray(xs) === false)
243
+ return xs
244
+
245
+ if (!xs.length)
246
+ return '{}'
247
+
248
+ const first = xs[0]
249
+ // Only _box (1020) has the ';' delimiter for arrays, all other types use the ',' delimiter
250
+ const delimiter = typarray === 1020 ? ';' : ','
251
+
252
+ if (Array.isArray(first) && !first.type)
253
+ return '{' + xs.map(x => arraySerializer(x, serializer, options, typarray)).join(delimiter) + '}'
254
+
255
+ return '{' + xs.map(x => {
256
+ if (x === undefined) {
257
+ x = options.transform.undefined
258
+ if (x === undefined)
259
+ throw Errors.generic('UNDEFINED_VALUE', 'Undefined values are not allowed')
260
+ }
261
+
262
+ return x === null
263
+ ? 'null'
264
+ : '"' + arrayEscape(serializer ? serializer(x.type ? x.value : x) : '' + x) + '"'
265
+ }).join(delimiter) + '}'
266
+ }
267
+
268
+ const arrayParserState = {
269
+ i: 0,
270
+ char: null,
271
+ str: '',
272
+ quoted: false,
273
+ last: 0
274
+ }
275
+
276
+ const arrayParser = module.exports.arrayParser = function arrayParser(x, parser, typarray) {
277
+ arrayParserState.i = arrayParserState.last = 0
278
+ return arrayParserLoop(arrayParserState, x, parser, typarray)
279
+ }
280
+
281
+ function arrayParserLoop(s, x, parser, typarray) {
282
+ const xs = []
283
+ // Only _box (1020) has the ';' delimiter for arrays, all other types use the ',' delimiter
284
+ const delimiter = typarray === 1020 ? ';' : ','
285
+ for (; s.i < x.length; s.i++) {
286
+ s.char = x[s.i]
287
+ if (s.quoted) {
288
+ if (s.char === '\\') {
289
+ s.str += x[++s.i]
290
+ } else if (s.char === '"') {
291
+ xs.push(parser ? parser(s.str) : s.str)
292
+ s.str = ''
293
+ s.quoted = x[s.i + 1] === '"'
294
+ s.last = s.i + 2
295
+ } else {
296
+ s.str += s.char
297
+ }
298
+ } else if (s.char === '"') {
299
+ s.quoted = true
300
+ } else if (s.char === '{') {
301
+ s.last = ++s.i
302
+ xs.push(arrayParserLoop(s, x, parser, typarray))
303
+ } else if (s.char === '}') {
304
+ s.quoted = false
305
+ s.last < s.i && xs.push(parser ? parser(x.slice(s.last, s.i)) : x.slice(s.last, s.i))
306
+ s.last = s.i + 1
307
+ break
308
+ } else if (s.char === delimiter && s.p !== '}' && s.p !== '"') {
309
+ xs.push(parser ? parser(x.slice(s.last, s.i)) : x.slice(s.last, s.i))
310
+ s.last = s.i + 1
311
+ }
312
+ s.p = s.char
313
+ }
314
+ s.last < s.i && xs.push(parser ? parser(x.slice(s.last, s.i + 1)) : x.slice(s.last, s.i + 1))
315
+ return xs
316
+ }
317
+
318
+ const toCamel = module.exports.toCamel = x => {
319
+ let str = x[0]
320
+ for (let i = 1; i < x.length; i++)
321
+ str += x[i] === '_' ? x[++i].toUpperCase() : x[i]
322
+ return str
323
+ }
324
+
325
+ const toPascal = module.exports.toPascal = x => {
326
+ let str = x[0].toUpperCase()
327
+ for (let i = 1; i < x.length; i++)
328
+ str += x[i] === '_' ? x[++i].toUpperCase() : x[i]
329
+ return str
330
+ }
331
+
332
+ const toKebab = module.exports.toKebab = x => x.replace(/_/g, '-')
333
+
334
+ const fromCamel = module.exports.fromCamel = x => x.replace(/([A-Z])/g, '_$1').toLowerCase()
335
+ const fromPascal = module.exports.fromPascal = x => (x.slice(0, 1) + x.slice(1).replace(/([A-Z])/g, '_$1')).toLowerCase()
336
+ const fromKebab = module.exports.fromKebab = x => x.replace(/-/g, '_')
337
+
338
+ function createJsonTransform(fn) {
339
+ return function jsonTransform(x, column) {
340
+ return typeof x === 'object' && x !== null && (column.type === 114 || column.type === 3802)
341
+ ? Array.isArray(x)
342
+ ? x.map(x => jsonTransform(x, column))
343
+ : Object.entries(x).reduce((acc, [k, v]) => Object.assign(acc, { [fn(k)]: jsonTransform(v, column) }), {})
344
+ : x
345
+ }
346
+ }
347
+
348
+ toCamel.column = { from: toCamel }
349
+ toCamel.value = { from: createJsonTransform(toCamel) }
350
+ fromCamel.column = { to: fromCamel }
351
+
352
+ const camel = module.exports.camel = { ...toCamel }
353
+ camel.column.to = fromCamel
354
+
355
+ toPascal.column = { from: toPascal }
356
+ toPascal.value = { from: createJsonTransform(toPascal) }
357
+ fromPascal.column = { to: fromPascal }
358
+
359
+ const pascal = module.exports.pascal = { ...toPascal }
360
+ pascal.column.to = fromPascal
361
+
362
+ toKebab.column = { from: toKebab }
363
+ toKebab.value = { from: createJsonTransform(toKebab) }
364
+ fromKebab.column = { to: fromKebab }
365
+
366
+ const kebab = module.exports.kebab = { ...toKebab }
367
+ kebab.column.to = fromKebab