@hiai-gg/docsmint 2.1.0 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist/backend/index.js +50507 -67754
- package/dist/backend-account-runtime-cleanup.js +308 -292
- package/dist/backend-api-key-facade.js +4 -4
- package/dist/backend-pipeline-cancellation.js +285 -285
- package/dist/frontend/CategoryDialog-CVJi5PJu.js +602 -0
- package/dist/frontend/{ConfirmDialog-B1MjKlVQ.js → ConfirmDialog-0JwB8mKN.js} +5 -8
- package/dist/frontend/{CreateSnapshotDialog-BTMoPFdj.js → CreateSnapshotDialog-BLrtuYs5.js} +63 -68
- package/dist/frontend/{DatePicker-Bmjko3X7.js → DatePicker-BwSb8TRv.js} +17 -29
- package/dist/frontend/{DeleteDialog-BkfIeKXO.js → DeleteDialog-s7Dr6bXg.js} +51 -56
- package/dist/frontend/{FolderNode-Do8pIfyA.js → FolderNode-Y7cV9xeX.js} +105 -106
- package/dist/frontend/{FolderTreeSelector-FyxhcHjr.js → FolderTreeSelector-BR3lYmPU.js} +18 -20
- package/dist/frontend/HiAiEditor-BHz46Iqd.js +3078 -0
- package/dist/frontend/{HiaiDocsExtensionProvider-Cc3yzW5I.js → HiaiDocsExtensionProvider-A2nGddUR.js} +2 -3
- package/dist/frontend/{Icon-3EYzvNyk.js → Icon-CiHcxcpv.js} +1 -2
- package/dist/frontend/SettingsDialog-BvS74JZu.js +978 -0
- package/dist/frontend/{ShareDialog-Ddvl7xvb.js → ShareDialog-Bo50h_Oe.js} +23 -25
- package/dist/frontend/Sidebar-i0kbanpg.js +2123 -0
- package/dist/frontend/{TagCreateDialog-DQmMJe_E.js → TagCreateDialog-DhKfsfv3.js} +78 -86
- package/dist/frontend/action_cancel-BdsWzQKU.js +4 -0
- package/dist/frontend/action_close-CVhfLPRQ.js +4 -0
- package/dist/frontend/action_create-ByaroO1_.js +4 -0
- package/dist/frontend/action_delete-SRloglWY.js +4 -0
- package/dist/frontend/action_go_to-DO1bicF-.js +4 -0
- package/dist/frontend/action_loading-iQ0KsN6i.js +4 -0
- package/dist/frontend/action_save-DeqrZQwV.js +4 -0
- package/dist/frontend/api/attachments.js +1 -2
- package/dist/frontend/api/categories.js +1 -2
- package/dist/frontend/api/documents.js +1 -2
- package/dist/frontend/api/folders.js +1 -2
- package/dist/frontend/api/settings.js +1 -2
- package/dist/frontend/api/share.js +1 -2
- package/dist/frontend/api/tags.js +1 -2
- package/dist/frontend/{api-keys-DIwAdYkg.js → api-keys-B63imiLr.js} +2 -3
- package/dist/frontend/app-shell.js +55 -79
- package/dist/frontend/{attachments-C225gTA7.js → attachments-Bfly-sam.js} +2 -3
- package/dist/frontend/{auth-client-C5EyWdAF.js → auth-client-Dx7d9Tzo.js} +252 -253
- package/dist/frontend/{bundle-mjs-CZ3g1Uzr.js → bundle-mjs-clTO1WW-.js} +5 -23
- package/dist/frontend/{camera-DtgHzfVI.js → camera-DsdOPOcD.js} +2 -3
- package/dist/frontend/{categories-C8AAkhCR.js → categories-CusvHb5Y.js} +3 -4
- package/dist/frontend/{categories_update_error-4aSI8PTr.js → categories_update_error-Cn8DBBHv.js} +2 -3
- package/dist/frontend/{check-DVx65aSv.js → check-DiMZRkKS.js} +2 -3
- package/dist/frontend/{chevron-down-C2tbZ8Ol.js → chevron-down-CxFrMFDJ.js} +2 -3
- package/dist/frontend/{circle-check-BAN-D7yg.js → circle-check-B4F_qgPx.js} +2 -3
- package/dist/frontend/{client-GbtOH90i.js → client-BDdDd84W.js} +1 -2
- package/dist/frontend/{clipboard-Cgzxc0_R.js → clipboard-Dt1oW6nm.js} +1 -2
- package/dist/frontend/{clock-ByiB0SwQ.js → clock-dcpueRk-.js} +2 -3
- package/dist/frontend/collaboration.js +9 -13
- package/dist/frontend/components/category-dialog.js +1 -2
- package/dist/frontend/components/create-snapshot-dialog.js +1 -2
- package/dist/frontend/components/delete-dialog.js +1 -2
- package/dist/frontend/components/editor/compact-editor.js +2 -3
- package/dist/frontend/components/editor/document-editor.js +1 -2
- package/dist/frontend/components/editor/document-title.js +3 -4
- package/dist/frontend/components/editor/docx-serializer.js +123 -167
- package/dist/frontend/components/editor/extensions.js +1 -2
- package/dist/frontend/components/editor/markdown-toggle.js +5 -6
- package/dist/frontend/components/editor/markdown.js +1 -2
- package/dist/frontend/components/folder-node.js +1 -2
- package/dist/frontend/components/folder-tree-selector.js +1 -2
- package/dist/frontend/components/save-as-dialog.js +86 -90
- package/dist/frontend/components/settings.js +1 -2
- package/dist/frontend/components/share-dialog.js +1 -2
- package/dist/frontend/components/sidebar.js +1 -2
- package/dist/frontend/components/tag-create-dialog.js +1 -2
- package/dist/frontend/components/version-history.js +256 -190
- package/dist/frontend/{context-D0zPFXZ4.js → context-BguSRnCt.js} +1 -2
- package/dist/frontend/{copy-CRzvfZGb.js → copy-Bag46YaR.js} +2 -3
- package/dist/frontend/dashboard.js +666 -690
- package/dist/frontend/{db-CgTtukT4.js → db-B1ZV452J.js} +22 -39
- package/dist/frontend/{dialog-a_ZcpEC5.js → dialog-C0Bpok1d.js} +10 -18
- package/dist/frontend/{dist-CcHOStsA.js → dist-BlcV_BOY.js} +2 -3
- package/dist/frontend/{dist-qd_OnyUC.js → dist-DjId3RKL.js} +8 -21
- package/dist/frontend/dist-Dl9qg10h.js +301 -0
- package/dist/frontend/{dndzone-CDhrbpTg.js → dndzone-C62yjeG3.js} +38 -53
- package/dist/frontend/doc-tabs.js +1 -2
- package/dist/frontend/doc_title_label-BOuZzvqv.js +4 -0
- package/dist/frontend/doc_title_placeholder-ZxpdWWEn.js +4 -0
- package/dist/frontend/{document-drop-coordinator-Da7HcXgv.js → document-drop-coordinator-C_o93kKW.js} +3 -4
- package/dist/frontend/document-drop-coordinator.js +1 -2
- package/dist/frontend/{documents-CwCs1rA7.js → documents-CDJb8dv-.js} +4 -8
- package/dist/frontend/{dropdown-menu-DrHYReIC.js → dropdown-menu-B3nk2aM-.js} +13 -24
- package/dist/frontend/{editor-content-sanitizer-CWjqiz0T.js → editor-content-sanitizer-5MjSVPVn.js} +1 -2
- package/dist/frontend/editor-preferences.js +1 -2
- package/dist/frontend/{editor-preferences.svelte-Bt_A9k7n.js → editor-preferences.svelte-BpTE4mbz.js} +3 -5
- package/dist/frontend/{editorExtensions-DPR-CjMu.js → editorExtensions-DbiFj4tn.js} +3 -4
- package/dist/frontend/{editor_markdown_placeholder-BIWDUF1E.js → editor_markdown_placeholder-BztIY9Ci.js} +2 -3
- package/dist/frontend/{ellipsis-vertical-qxNgoXu-.js → ellipsis-vertical-Oymsv1R4.js} +2 -3
- package/dist/frontend/{error_dismiss-Dx_JbRjs.js → error_dismiss-C651ZdWI.js} +2 -3
- package/dist/frontend/error_generic-BlWqOE-a.js +4 -0
- package/dist/frontend/extension.js +1 -2
- package/dist/frontend/{folder-D74E-Kdp.js → folder-BpmB_sAy.js} +3 -5
- package/dist/frontend/folder-refresh.js +1 -2
- package/dist/frontend/{folders-CC0UWkZH.js → folders-DgKSovXa.js} +2 -3
- package/dist/frontend/{folders_rename-BJo4Gipq.js → folders_rename-Cxbg5GIw.js} +2 -3
- package/dist/frontend/frontend.css +1 -1
- package/dist/frontend/i18n.js +144 -145
- package/dist/frontend/{identity-CNhtuCJV.js → identity-B7HeOzDJ.js} +4 -5
- package/dist/frontend/{input-Q_7qCfnU.js → input-CbeB9220.js} +2 -3
- package/dist/frontend/keyboard.js +1 -2
- package/dist/frontend/{keyboard.svelte-CApmX0vl.js → keyboard.svelte-BBUdhTsM.js} +2 -3
- package/dist/frontend/{label-Dj8FDEhf.js → label-CfBWf3gI.js} +2 -3
- package/dist/frontend/{lib-aUbBbIW2.js → lib-CITdCbKa.js} +176 -365
- package/dist/frontend/{loader-circle-D3t5NkvC.js → loader-circle-skKwfRCB.js} +2 -3
- package/dist/frontend/markdown-6E9TWC6V.js +11 -0
- package/dist/frontend/offline/identity.js +1 -2
- package/dist/frontend/{popper-layer-force-mount-CNtiLgbV.js → popper-layer-force-mount-BG0eyrCk.js} +112 -284
- package/dist/frontend/{resolve-BG4HgzpN.js → resolve-DbT-KhGZ.js} +2 -3
- package/dist/frontend/{rolldown-runtime-DArdT4gl.js → rolldown-runtime-CwxnZyOB.js} +2 -3
- package/dist/frontend/{rotate-ccw-B1ybQ8oQ.js → rotate-ccw-DAUX7np7.js} +2 -3
- package/dist/frontend/{route-context-DYQlUfzL.js → route-context-6OHiGtfb.js} +2 -4
- package/dist/frontend/{runtime-CwWSo6c9.js → runtime-CGUiMzK6.js} +1 -2
- package/dist/frontend/{schemas-1Na35n71.js → schemas-YXxhj5o8.js} +850 -880
- package/dist/frontend/scroll_to_top_aria-lJc2RSx_.js +4 -0
- package/dist/frontend/{search-preferences-B1GdbdUc.js → search-preferences-DuLDczRu.js} +1 -2
- package/dist/frontend/search.js +277 -292
- package/dist/frontend/{search_title-DOC0cPlQ.js → search_title-BETwQYJq.js} +2 -3
- package/dist/frontend/{select-value-BkI1W1bn.js → select-value-BY5Hw6Rl.js} +28 -65
- package/dist/frontend/{settings-CHx4wBwb.js → settings-DyePuqjp.js} +3 -4
- package/dist/frontend/{share-D5yo0JOh.js → share-3gWTTYvH.js} +2 -3
- package/dist/frontend/{share-context-BJ4GF4yT.js → share-context-C2xyVP9M.js} +29 -37
- package/dist/frontend/{share_copied-DPxVzfWh.js → share_copied-BuAnmpbz.js} +2 -3
- package/dist/frontend/{share_toggle_password-DdxfIjj1.js → share_toggle_password-LEYUeHWr.js} +2 -3
- package/dist/frontend/shared-document.js +27 -36
- package/dist/frontend/{sidebar_uncategorized-qJ2_Aonf.js → sidebar_uncategorized-C5PGOflV.js} +2 -3
- package/dist/frontend/{sort_relevance-DwYX5MO9.js → sort_relevance-DpCVLby_.js} +2 -3
- package/dist/frontend/{subfolders-refresh-store.svelte-DxP21a1c.js → subfolders-refresh-store.svelte-CeyqvNpu.js} +1 -2
- package/dist/frontend/{tag-qbTBLj-g.js → tag-Wdfe0rKU.js} +3 -5
- package/dist/frontend/{tag-store.svelte-ogVCMCbv.js → tag-store.svelte-C9VYWqLQ.js} +2 -3
- package/dist/frontend/{tags-CF_cqzSV.js → tags-DlDVothf.js} +3 -4
- package/dist/frontend/{tags_load_error-BKjA1pI0.js → tags_load_error-BINNpPPV.js} +2 -3
- package/dist/frontend/{tags_new-BiNAJ9Bx.js → tags_new-Dw0Uy43-.js} +2 -3
- package/dist/frontend/{textarea-BNK0LFUK.js → textarea-D6emvAwM.js} +2 -3
- package/dist/frontend/theme.js +2 -3
- package/dist/frontend/{theme.svelte-BRdxXd-B.js → theme.svelte-BiXvrqwh.js} +7 -23
- package/dist/frontend/{theme_system-BBNUhYKh.js → theme_system-YIfa_2Xt.js} +2 -3
- package/dist/frontend/utils/clipboard.js +1 -2
- package/dist/frontend/utils/dndzone.js +1 -2
- package/dist/frontend/{utils-BovMJHdA.js → utils-CnAmIMwr.js} +2 -3
- package/dist/frontend/utils-DH0uqK40.js +6 -0
- package/dist/frontend/utils.js +1 -2
- package/dist/frontend/version_create_snapshot-D8xjbuCq.js +4 -0
- package/dist/frontend/{version_restored_from-dVRN3Zdk.js → version_restored_from-DYFFSuQj.js} +2 -3
- package/dist/frontend/{version_snapshot_label_placeholder-DrMikux0.js → version_snapshot_label_placeholder-BhKq1NQ7.js} +2 -3
- package/dist/frontend/{weekday_we-C5H_M-df.js → weekday_we-BxbzNVWR.js} +2 -3
- package/dist/frontend/{x-CvSSnrjl.js → x-CBUgPygC.js} +2 -3
- package/dist/frontend/{yjs-VUcKqaKW.js → yjs-BbwnvxgY.js} +9 -23
- package/dist/frontend-ssr/api/attachments.js +2 -3
- package/dist/frontend-ssr/api/categories.js +1 -2
- package/dist/frontend-ssr/api/documents.js +1 -2
- package/dist/frontend-ssr/api/folders.js +1 -2
- package/dist/frontend-ssr/api/settings.js +1 -2
- package/dist/frontend-ssr/api/share.js +2 -3
- package/dist/frontend-ssr/api/tags.js +1 -2
- package/dist/frontend-ssr/app-shell.js +19 -28
- package/dist/frontend-ssr/assets/{CategoryDialog-DuZLLlt7.js → CategoryDialog-2CCX508O.js} +17 -20
- package/dist/frontend-ssr/assets/{ConfirmDialog-0WVu9BCE.js → ConfirmDialog-Cc6lcY1N.js} +8 -14
- package/dist/frontend-ssr/assets/{CreateSnapshotDialog-3vhDTFNu.js → CreateSnapshotDialog-BB8fXF9W.js} +9 -10
- package/dist/frontend-ssr/assets/{DatePicker-t12leL2Y.js → DatePicker-CfzKzipR.js} +9 -15
- package/dist/frontend-ssr/assets/{DeleteDialog-B0AU1fJR.js → DeleteDialog-DRU4UgOW.js} +4 -5
- package/dist/frontend-ssr/assets/{FolderNode-C-B-s8x1.js → FolderNode-Dg_5-orQ.js} +11 -12
- package/dist/frontend-ssr/assets/{FolderTreeSelector-DdQuEcj0.js → FolderTreeSelector-D0reTdFS.js} +5 -7
- package/dist/frontend-ssr/assets/{HiAiEditor-Cj3B2Dt6.js → HiAiEditor-BQGlGd3z.js} +57 -83
- package/dist/frontend-ssr/assets/{HiaiDocsExtensionProvider-BRKWmcDd.js → HiaiDocsExtensionProvider-D6cGL-9s.js} +2 -3
- package/dist/frontend-ssr/assets/{Icon-DE_3EnuF.js → Icon-CrIRbT5O.js} +4 -8
- package/dist/frontend-ssr/assets/{SettingsDialog-DAT-Zxu0.js → SettingsDialog-BpHY3IMb.js} +29 -40
- package/dist/frontend-ssr/assets/{ShareDialog-CpE9zd_f.js → ShareDialog-CY40nWZJ.js} +7 -9
- package/dist/frontend-ssr/assets/{Sidebar-B_Ey6QNL.js → Sidebar-fpYk5MGO.js} +55 -63
- package/dist/frontend-ssr/assets/{TagCreateDialog-DBHO1DPU.js → TagCreateDialog-C2tpdEuj.js} +13 -14
- package/dist/frontend-ssr/assets/{action_cancel-OVgQDP5Q.js → action_cancel-CsBbxW0m.js} +2 -3
- package/dist/frontend-ssr/assets/{action_close-DagDyMXk.js → action_close-lFKBqBwg.js} +2 -3
- package/dist/frontend-ssr/assets/{action_create-hqJWjyqh.js → action_create-BV4ZOcQW.js} +2 -3
- package/dist/frontend-ssr/assets/{action_delete-B1-16jSo.js → action_delete-CNmRhKQP.js} +2 -3
- package/dist/frontend-ssr/assets/{action_go_to-DQScgw7P.js → action_go_to-tN5I26xM.js} +2 -3
- package/dist/frontend-ssr/assets/{action_save-Bx7vlLZI.js → action_save-YCfMiKb4.js} +2 -3
- package/dist/frontend-ssr/assets/{api-keys-CHOrbU-Q.js → api-keys-G6oimJIv.js} +2 -3
- package/dist/frontend-ssr/assets/{auth-client-CITU3xkE.js → auth-client-BnnnJDAb.js} +102 -71
- package/dist/frontend-ssr/assets/{camera-B6ldo_Js.js → camera-OYNSMvMd.js} +2 -3
- package/dist/frontend-ssr/assets/{categories-C_dxFoHi.js → categories-bBPviKjl.js} +2 -3
- package/dist/frontend-ssr/assets/{categories_update_error-DkKgsqdD.js → categories_update_error-Bfx5vtvt.js} +11 -21
- package/dist/frontend-ssr/assets/{chevron-down-DQcr6JUc.js → chevron-down-DB6YsSbQ.js} +2 -3
- package/dist/frontend-ssr/assets/{chevron-right-9szrliZx.js → chevron-right-DOt2uY6b.js} +2 -3
- package/dist/frontend-ssr/assets/{circle-check-BgP9MRRv.js → circle-check-DQhTm9YR.js} +2 -3
- package/dist/frontend-ssr/assets/{client-rfwQYYHY.js → client-B2AniXwV.js} +1 -2
- package/dist/frontend-ssr/assets/{clipboard-CXOaoz2W.js → clipboard-CXKnyYba.js} +1 -2
- package/dist/frontend-ssr/assets/{clock-roNtGlT6.js → clock-B08dVWtf.js} +2 -3
- package/dist/frontend-ssr/assets/{context-Bi_mO-NS.js → context-C_xxvxnR.js} +1 -2
- package/dist/frontend-ssr/assets/{copy-BYqYnBIQ.js → copy-2jsznHar.js} +2 -3
- package/dist/frontend-ssr/assets/{db-DxRzq-kx.js → db-BEKLU5Fc.js} +2 -3
- package/dist/frontend-ssr/assets/{dialog-SqCnTT43.js → dialog-C6U-DqLr.js} +9 -17
- package/dist/frontend-ssr/assets/{dist-CaZQ1FhA.js → dist-DqXTz_zE.js} +9 -12
- package/dist/frontend-ssr/assets/{dist-CqxHwOlp.js → dist-ip9bPdma.js} +3 -6
- package/dist/frontend-ssr/assets/{dndzone-CnTCMhPd.js → dndzone-Dx3jt_e4.js} +4 -6
- package/dist/frontend-ssr/assets/{doc_title_label-Ev_ltlh3.js → doc_title_label-CE_l-Gum.js} +2 -3
- package/dist/frontend-ssr/assets/{doc_title_placeholder-DSHpUb7w.js → doc_title_placeholder-7_i7PtG6.js} +2 -3
- package/dist/frontend-ssr/assets/{document-drop-coordinator-CEaYACsC.js → document-drop-coordinator-BVytYy2K.js} +1 -2
- package/dist/frontend-ssr/assets/{documents-CEuA1V6N.js → documents-B_wpQFTh.js} +2 -3
- package/dist/frontend-ssr/assets/{dropdown-menu-CE6U0f1b.js → dropdown-menu-BS5fcN9l.js} +12 -23
- package/dist/frontend-ssr/assets/{editor-content-sanitizer-Gjm93iR-.js → editor-content-sanitizer-CIdFjBSC.js} +1 -2
- package/dist/frontend-ssr/assets/{editor-preferences.svelte-iI5jJM1x.js → editor-preferences.svelte-CdAXTd-I.js} +2 -4
- package/dist/frontend-ssr/assets/{editorExtensions-rhletNji.js → editorExtensions-2O7O2Nhv.js} +2 -3
- package/dist/frontend-ssr/assets/{editor_markdown_placeholder-BpezdkOr.js → editor_markdown_placeholder-CAeLJjFT.js} +3 -5
- package/dist/frontend-ssr/assets/{editor_toolbar_undo-CKJAOqv2.js → editor_toolbar_undo-CVCfQIS1.js} +29 -57
- package/dist/frontend-ssr/assets/{ellipsis-vertical-Cg1MrZsl.js → ellipsis-vertical-IFHt2NM1.js} +2 -3
- package/dist/frontend-ssr/assets/{error_generic-DTK0kwxT.js → error_generic-BB80i0Vk.js} +3 -5
- package/dist/frontend-ssr/assets/{folder-DHB-CEcQ.js → folder-CXa1_bm5.js} +2 -3
- package/dist/frontend-ssr/assets/{folders-BOXeb9hz.js → folders-CTLqWbMm.js} +2 -3
- package/dist/frontend-ssr/assets/{folders_rename-DvciOb6K.js → folders_rename-ydbfwQlj.js} +7 -13
- package/dist/frontend-ssr/assets/{identity-B7ngLQzZ.js → identity-DTz1SQwC.js} +2 -3
- package/dist/frontend-ssr/assets/{input-DVrBVPgs.js → input-Bxw9sFF0.js} +2 -3
- package/dist/frontend-ssr/assets/{keyboard.svelte-BgF47N3L.js → keyboard.svelte-njehUCm3.js} +1 -2
- package/dist/frontend-ssr/assets/{label-vtCK3pTp.js → label-CMWedjs6.js} +2 -3
- package/dist/frontend-ssr/assets/{loader-circle-D3NWhCif.js → loader-circle-zbKj9Qb-.js} +2 -3
- package/dist/frontend-ssr/assets/{markdown-Co31-Tl2.js → markdown-BmIhDQp7.js} +2 -3
- package/dist/frontend-ssr/assets/{popper-layer-force-mount-C4dMMt-f.js → popper-layer-force-mount-CSHZsG2E.js} +78 -156
- package/dist/frontend-ssr/assets/{resolve-BqHozBXl.js → resolve-Wqdff4CL.js} +1 -2
- package/dist/frontend-ssr/assets/{rotate-ccw-DNf3nwMD.js → rotate-ccw-B7SaTFWf.js} +2 -3
- package/dist/frontend-ssr/assets/{route-context-BPRerEtZ.js → route-context-BsqLFt5Y.js} +2 -4
- package/dist/frontend-ssr/assets/{runtime-O78RzRqx.js → runtime-BX6-jTn_.js} +1 -2
- package/dist/frontend-ssr/assets/{scroll_to_top_aria-BN4ZfOnM.js → scroll_to_top_aria-CAYSiGHO.js} +2 -3
- package/dist/frontend-ssr/assets/{search_title-CKUsQDT0.js → search_title-C7NVXXq3.js} +2 -3
- package/dist/frontend-ssr/assets/{search_toggle_filters-hS9rvQhC.js → search_toggle_filters-Bq_YVD8s.js} +15 -29
- package/dist/frontend-ssr/assets/{select-value-Ce5c_fuA.js → select-value-TgslfiUB.js} +18 -34
- package/dist/frontend-ssr/assets/{settings-BRxvn30Y.js → settings-B1MA_FjO.js} +3 -4
- package/dist/frontend-ssr/assets/{share-context-B4UpvTSw.js → share-context-RVh8AExX.js} +17 -22
- package/dist/frontend-ssr/assets/{share_copied-BxU9rjXG.js → share_copied-CrwEwkb3.js} +31 -61
- package/dist/frontend-ssr/assets/{share_toggle_password-C6OmroqR.js → share_toggle_password-Co56z0Ha.js} +11 -21
- package/dist/frontend-ssr/assets/{sidebar_uncategorized-Dx-LTd5w.js → sidebar_uncategorized-COWdmZ3d.js} +6 -11
- package/dist/frontend-ssr/assets/{subfolders-refresh-store.svelte-CXHxQWKh.js → subfolders-refresh-store.svelte-LxG18U0n.js} +1 -2
- package/dist/frontend-ssr/assets/{tag-Cqv0fWVG.js → tag-BGhtDKpP.js} +3 -5
- package/dist/frontend-ssr/assets/{tag-store.svelte-QRysvGKe.js → tag-store.svelte-CUUgAaDD.js} +2 -3
- package/dist/frontend-ssr/assets/{tags-BBCoFYro.js → tags-C7u-LBsl.js} +2 -3
- package/dist/frontend-ssr/assets/{tags_load_error-CPrc6Gzs.js → tags_load_error-DW4FbHvr.js} +19 -37
- package/dist/frontend-ssr/assets/{tags_new-VmMr9v2V.js → tags_new-Dr3ByMPZ.js} +4 -7
- package/dist/frontend-ssr/assets/{textarea-BdjOJJVb.js → textarea-Bz5Tz4rw.js} +2 -3
- package/dist/frontend-ssr/assets/{theme.svelte-D6bbaJ9m.js → theme.svelte-CdHah46l.js} +3 -5
- package/dist/frontend-ssr/assets/{theme_system-BucaNntV.js → theme_system-E97FASeq.js} +19 -37
- package/dist/frontend-ssr/assets/{utils-DvZnctjz.js → utils-085zSPe5.js} +1 -2
- package/dist/frontend-ssr/assets/{utils-D3X7I8nz.js → utils-DF6CmRDX.js} +1 -2
- package/dist/frontend-ssr/assets/{version_create_snapshot-COHzwjle.js → version_create_snapshot-DeeYB7bb.js} +2 -3
- package/dist/frontend-ssr/assets/{version_restored_from-CertjFDl.js → version_restored_from-CTt2LM4A.js} +13 -25
- package/dist/frontend-ssr/assets/{version_snapshot_label_placeholder-Cy_rMCij.js → version_snapshot_label_placeholder-BbGD9YuN.js} +12 -23
- package/dist/frontend-ssr/assets/{weekday_we-DrI3U230.js → weekday_we-BzGQ-iFc.js} +22 -43
- package/dist/frontend-ssr/collaboration.js +5 -5
- package/dist/frontend-ssr/components/category-dialog.js +1 -2
- package/dist/frontend-ssr/components/create-snapshot-dialog.js +1 -2
- package/dist/frontend-ssr/components/delete-dialog.js +1 -2
- package/dist/frontend-ssr/components/editor/compact-editor.js +2 -3
- package/dist/frontend-ssr/components/editor/document-editor.js +1 -2
- package/dist/frontend-ssr/components/editor/document-title.js +3 -4
- package/dist/frontend-ssr/components/editor/docx-serializer.js +1 -2
- package/dist/frontend-ssr/components/editor/extensions.js +1 -2
- package/dist/frontend-ssr/components/editor/markdown-toggle.js +4 -5
- package/dist/frontend-ssr/components/editor/markdown.js +1 -2
- package/dist/frontend-ssr/components/folder-node.js +1 -2
- package/dist/frontend-ssr/components/folder-tree-selector.js +1 -2
- package/dist/frontend-ssr/components/save-as-dialog.js +12 -13
- package/dist/frontend-ssr/components/settings.js +1 -2
- package/dist/frontend-ssr/components/share-dialog.js +1 -2
- package/dist/frontend-ssr/components/sidebar.js +1 -2
- package/dist/frontend-ssr/components/tag-create-dialog.js +1 -2
- package/dist/frontend-ssr/components/version-history.js +70 -29
- package/dist/frontend-ssr/dashboard.js +64 -88
- package/dist/frontend-ssr/doc-tabs.js +1 -2
- package/dist/frontend-ssr/document-drop-coordinator.js +1 -2
- package/dist/frontend-ssr/editor-preferences.js +1 -2
- package/dist/frontend-ssr/extension.js +1 -2
- package/dist/frontend-ssr/folder-refresh.js +1 -2
- package/dist/frontend-ssr/i18n.js +315 -603
- package/dist/frontend-ssr/keyboard.js +1 -2
- package/dist/frontend-ssr/offline/identity.js +1 -2
- package/dist/frontend-ssr/search.js +17 -20
- package/dist/frontend-ssr/shared-document.js +5 -8
- package/dist/frontend-ssr/theme.js +2 -3
- package/dist/frontend-ssr/utils/clipboard.js +1 -2
- package/dist/frontend-ssr/utils/dndzone.js +1 -2
- package/dist/frontend-ssr/utils.js +1 -2
- package/dist/lifecycle-runtime.js +3996 -17873
- package/dist/mcp-cli.js +64 -64
- package/dist/mcp-server.js +68 -68
- package/package.json +4 -4
- package/packages/cli/src/index.ts +1 -1
- package/server.json +2 -2
- package/dist/frontend/CategoryDialog-CJeAYxcd.js +0 -630
- package/dist/frontend/HiAiEditor-D6ad_auS.js +0 -3129
- package/dist/frontend/SettingsDialog-B8Oswuqb.js +0 -991
- package/dist/frontend/Sidebar-BV0IDqTS.js +0 -2149
- package/dist/frontend/action_cancel-Cuxsznzz.js +0 -5
- package/dist/frontend/action_close-BJm_52wm.js +0 -5
- package/dist/frontend/action_create-CtBQrRuj.js +0 -5
- package/dist/frontend/action_delete-BXBIzvn0.js +0 -5
- package/dist/frontend/action_go_to-VmK5jmEk.js +0 -5
- package/dist/frontend/action_loading-BLCGJVA9.js +0 -5
- package/dist/frontend/action_save-BRN2Z_GP.js +0 -5
- package/dist/frontend/dist-DcHl92QO.js +0 -316
- package/dist/frontend/doc_title_label-DS9jSIh2.js +0 -5
- package/dist/frontend/doc_title_placeholder-DBQpM1aH.js +0 -5
- package/dist/frontend/error_generic-CzNtmBT4.js +0 -5
- package/dist/frontend/markdown-O9YJA70S.js +0 -12
- package/dist/frontend/scroll_to_top_aria-CvkNF_Hu.js +0 -5
- package/dist/frontend/utils-BlHvR6OL.js +0 -7
- package/dist/frontend/version_create_snapshot-3bu-0qzH.js +0 -5
|
@@ -987,44 +987,44 @@ class Builder extends NotTagged {
|
|
|
987
987
|
this.first = first;
|
|
988
988
|
this.rest = rest;
|
|
989
989
|
}
|
|
990
|
-
build(before, parameters,
|
|
990
|
+
build(before, parameters, types, options) {
|
|
991
991
|
const keyword = builders.map(([x, fn]) => ({ fn, i: before.search(x) })).sort((a, b) => a.i - b.i).pop();
|
|
992
|
-
return keyword.i === -1 ? escapeIdentifiers(this.first, options) : keyword.fn(this.first, this.rest, parameters,
|
|
992
|
+
return keyword.i === -1 ? escapeIdentifiers(this.first, options) : keyword.fn(this.first, this.rest, parameters, types, options);
|
|
993
993
|
}
|
|
994
994
|
}
|
|
995
|
-
function handleValue(x, parameters,
|
|
995
|
+
function handleValue(x, parameters, types, options) {
|
|
996
996
|
let value = x instanceof Parameter ? x.value : x;
|
|
997
997
|
if (value === undefined) {
|
|
998
998
|
x instanceof Parameter ? x.value = options.transform.undefined : value = x = options.transform.undefined;
|
|
999
999
|
if (value === undefined)
|
|
1000
1000
|
throw Errors.generic("UNDEFINED_VALUE", "Undefined values are not allowed");
|
|
1001
1001
|
}
|
|
1002
|
-
return "$" +
|
|
1002
|
+
return "$" + types.push(x instanceof Parameter ? (parameters.push(x.value), x.array ? x.array[x.type || inferType(x.value)] || x.type || firstIsString(x.value) : x.type) : (parameters.push(x), inferType(x)));
|
|
1003
1003
|
}
|
|
1004
1004
|
var defaultHandlers = typeHandlers(types);
|
|
1005
|
-
function stringify(q, string, value, parameters,
|
|
1005
|
+
function stringify(q, string, value, parameters, types, options) {
|
|
1006
1006
|
for (let i = 1;i < q.strings.length; i++) {
|
|
1007
|
-
string += stringifyValue(string, value, parameters,
|
|
1007
|
+
string += stringifyValue(string, value, parameters, types, options) + q.strings[i];
|
|
1008
1008
|
value = q.args[i];
|
|
1009
1009
|
}
|
|
1010
1010
|
return string;
|
|
1011
1011
|
}
|
|
1012
|
-
function stringifyValue(string, value, parameters,
|
|
1013
|
-
return value instanceof Builder ? value.build(string, parameters,
|
|
1012
|
+
function stringifyValue(string, value, parameters, types, o) {
|
|
1013
|
+
return value instanceof Builder ? value.build(string, parameters, types, o) : value instanceof Query ? fragment(value, parameters, types, o) : value instanceof Identifier ? value.value : value && value[0] instanceof Query ? value.reduce((acc, x) => acc + " " + fragment(x, parameters, types, o), "") : handleValue(value, parameters, types, o);
|
|
1014
1014
|
}
|
|
1015
|
-
function fragment(q, parameters,
|
|
1015
|
+
function fragment(q, parameters, types, options) {
|
|
1016
1016
|
q.fragment = true;
|
|
1017
|
-
return stringify(q, q.strings[0], q.args[0], parameters,
|
|
1017
|
+
return stringify(q, q.strings[0], q.args[0], parameters, types, options);
|
|
1018
1018
|
}
|
|
1019
|
-
function valuesBuilder(first, parameters,
|
|
1020
|
-
return first.map((row) => "(" + columns.map((column) => stringifyValue("values", row[column], parameters,
|
|
1019
|
+
function valuesBuilder(first, parameters, types, columns, options) {
|
|
1020
|
+
return first.map((row) => "(" + columns.map((column) => stringifyValue("values", row[column], parameters, types, options)).join(",") + ")").join(",");
|
|
1021
1021
|
}
|
|
1022
|
-
function values(first, rest, parameters,
|
|
1022
|
+
function values(first, rest, parameters, types, options) {
|
|
1023
1023
|
const multi = Array.isArray(first[0]);
|
|
1024
1024
|
const columns = rest.length ? rest.flat() : Object.keys(multi ? first[0] : first);
|
|
1025
|
-
return valuesBuilder(multi ? first : [first], parameters,
|
|
1025
|
+
return valuesBuilder(multi ? first : [first], parameters, types, columns, options);
|
|
1026
1026
|
}
|
|
1027
|
-
function select(first, rest, parameters,
|
|
1027
|
+
function select(first, rest, parameters, types, options) {
|
|
1028
1028
|
typeof first === "string" && (first = [first].concat(rest));
|
|
1029
1029
|
if (Array.isArray(first))
|
|
1030
1030
|
return escapeIdentifiers(first, options);
|
|
@@ -1032,7 +1032,7 @@ function select(first, rest, parameters, types2, options) {
|
|
|
1032
1032
|
const columns = rest.length ? rest.flat() : Object.keys(first);
|
|
1033
1033
|
return columns.map((x) => {
|
|
1034
1034
|
value = first[x];
|
|
1035
|
-
return (value instanceof Query ? fragment(value, parameters,
|
|
1035
|
+
return (value instanceof Query ? fragment(value, parameters, types, options) : value instanceof Identifier ? value.value : handleValue(value, parameters, types, options)) + " as " + escapeIdentifier(options.transform.column.to ? options.transform.column.to(x) : x);
|
|
1036
1036
|
}).join(",");
|
|
1037
1037
|
}
|
|
1038
1038
|
var builders = Object.entries({
|
|
@@ -1045,12 +1045,12 @@ var builders = Object.entries({
|
|
|
1045
1045
|
as: select,
|
|
1046
1046
|
returning: select,
|
|
1047
1047
|
"\\(": select,
|
|
1048
|
-
update(first, rest, parameters,
|
|
1049
|
-
return (rest.length ? rest.flat() : Object.keys(first)).map((x) => escapeIdentifier(options.transform.column.to ? options.transform.column.to(x) : x) + "=" + stringifyValue("values", first[x], parameters,
|
|
1048
|
+
update(first, rest, parameters, types, options) {
|
|
1049
|
+
return (rest.length ? rest.flat() : Object.keys(first)).map((x) => escapeIdentifier(options.transform.column.to ? options.transform.column.to(x) : x) + "=" + stringifyValue("values", first[x], parameters, types, options));
|
|
1050
1050
|
},
|
|
1051
|
-
insert(first, rest, parameters,
|
|
1051
|
+
insert(first, rest, parameters, types, options) {
|
|
1052
1052
|
const columns = rest.length ? rest.flat() : Object.keys(Array.isArray(first) ? first[0] : first);
|
|
1053
|
-
return "(" + escapeIdentifiers(columns, options) + ")values" + valuesBuilder(Array.isArray(first) ? first : [first], parameters,
|
|
1053
|
+
return "(" + escapeIdentifiers(columns, options) + ")values" + valuesBuilder(Array.isArray(first) ? first : [first], parameters, types, columns, options);
|
|
1054
1054
|
}
|
|
1055
1055
|
}).map(([x, fn]) => [new RegExp("((?:^|[\\s(])" + x + "(?:$|[\\s(]))(?![\\s\\S]*\\1)", "i"), fn]);
|
|
1056
1056
|
function notTagged() {
|
|
@@ -1063,19 +1063,19 @@ function firstIsString(x) {
|
|
|
1063
1063
|
return firstIsString(x[0]);
|
|
1064
1064
|
return typeof x === "string" ? 1009 : 0;
|
|
1065
1065
|
}
|
|
1066
|
-
var mergeUserTypes = function(
|
|
1067
|
-
const user = typeHandlers(
|
|
1066
|
+
var mergeUserTypes = function(types) {
|
|
1067
|
+
const user = typeHandlers(types || {});
|
|
1068
1068
|
return {
|
|
1069
1069
|
serializers: Object.assign({}, serializers, user.serializers),
|
|
1070
1070
|
parsers: Object.assign({}, parsers, user.parsers)
|
|
1071
1071
|
};
|
|
1072
1072
|
};
|
|
1073
|
-
function typeHandlers(
|
|
1074
|
-
return Object.keys(
|
|
1075
|
-
|
|
1076
|
-
if (
|
|
1077
|
-
acc.serializers[
|
|
1078
|
-
|
|
1073
|
+
function typeHandlers(types) {
|
|
1074
|
+
return Object.keys(types).reduce((acc, k) => {
|
|
1075
|
+
types[k].from && [].concat(types[k].from).forEach((x) => acc.parsers[x] = types[k].parse);
|
|
1076
|
+
if (types[k].serialize) {
|
|
1077
|
+
acc.serializers[types[k].to] = types[k].serialize;
|
|
1078
|
+
types[k].from && [].concat(types[k].from).forEach((x) => acc.serializers[x] = types[k].serialize);
|
|
1079
1079
|
}
|
|
1080
1080
|
return acc;
|
|
1081
1081
|
}, { parsers: {}, serializers: {} });
|
|
@@ -1086,15 +1086,15 @@ function escapeIdentifiers(xs, { transform: { column } }) {
|
|
|
1086
1086
|
var escapeIdentifier = function escape(str) {
|
|
1087
1087
|
return '"' + str.replace(/"/g, '""').replace(/\./g, '"."') + '"';
|
|
1088
1088
|
};
|
|
1089
|
-
var inferType = function
|
|
1090
|
-
return x instanceof Parameter ? x.type : x instanceof Date ? 1184 : x instanceof Uint8Array ? 17 : x === true || x === false ? 16 : typeof x === "bigint" ? 20 : Array.isArray(x) ?
|
|
1089
|
+
var inferType = function inferType(x) {
|
|
1090
|
+
return x instanceof Parameter ? x.type : x instanceof Date ? 1184 : x instanceof Uint8Array ? 17 : x === true || x === false ? 16 : typeof x === "bigint" ? 20 : Array.isArray(x) ? inferType(x[0]) : 0;
|
|
1091
1091
|
};
|
|
1092
1092
|
var escapeBackslash = /\\/g;
|
|
1093
1093
|
var escapeQuote = /"/g;
|
|
1094
1094
|
function arrayEscape(x) {
|
|
1095
1095
|
return x.replace(escapeBackslash, "\\\\").replace(escapeQuote, "\\\"");
|
|
1096
1096
|
}
|
|
1097
|
-
var arraySerializer = function
|
|
1097
|
+
var arraySerializer = function arraySerializer(xs, serializer, options, typarray) {
|
|
1098
1098
|
if (Array.isArray(xs) === false)
|
|
1099
1099
|
return xs;
|
|
1100
1100
|
if (!xs.length)
|
|
@@ -1102,7 +1102,7 @@ var arraySerializer = function arraySerializer2(xs, serializer, options, typarra
|
|
|
1102
1102
|
const first = xs[0];
|
|
1103
1103
|
const delimiter = typarray === 1020 ? ";" : ",";
|
|
1104
1104
|
if (Array.isArray(first) && !first.type)
|
|
1105
|
-
return "{" + xs.map((x) =>
|
|
1105
|
+
return "{" + xs.map((x) => arraySerializer(x, serializer, options, typarray)).join(delimiter) + "}";
|
|
1106
1106
|
return "{" + xs.map((x) => {
|
|
1107
1107
|
if (x === undefined) {
|
|
1108
1108
|
x = options.transform.undefined;
|
|
@@ -1119,7 +1119,7 @@ var arrayParserState = {
|
|
|
1119
1119
|
quoted: false,
|
|
1120
1120
|
last: 0
|
|
1121
1121
|
};
|
|
1122
|
-
var arrayParser = function
|
|
1122
|
+
var arrayParser = function arrayParser(x, parser, typarray) {
|
|
1123
1123
|
arrayParserState.i = arrayParserState.last = 0;
|
|
1124
1124
|
return arrayParserLoop(arrayParserState, x, parser, typarray);
|
|
1125
1125
|
};
|
|
@@ -1176,7 +1176,7 @@ var fromPascal = (x) => (x.slice(0, 1) + x.slice(1).replace(/([A-Z])/g, "_$1")).
|
|
|
1176
1176
|
var fromKebab = (x) => x.replace(/-/g, "_");
|
|
1177
1177
|
function createJsonTransform(fn) {
|
|
1178
1178
|
return function jsonTransform(x, column) {
|
|
1179
|
-
return typeof x === "object" && x !== null && (column.type === 114 || column.type === 3802) ? Array.isArray(x) ? x.map((
|
|
1179
|
+
return typeof x === "object" && x !== null && (column.type === 114 || column.type === 3802) ? Array.isArray(x) ? x.map((x) => jsonTransform(x, column)) : Object.entries(x).reduce((acc, [k, v]) => Object.assign(acc, { [fn(k)]: jsonTransform(v, column) }), {}) : x;
|
|
1180
1180
|
};
|
|
1181
1181
|
}
|
|
1182
1182
|
toCamel.column = { from: toCamel };
|
|
@@ -1223,23 +1223,23 @@ class Result extends Array {
|
|
|
1223
1223
|
var queue_default = Queue;
|
|
1224
1224
|
function Queue(initial = []) {
|
|
1225
1225
|
let xs = initial.slice();
|
|
1226
|
-
let
|
|
1226
|
+
let index = 0;
|
|
1227
1227
|
return {
|
|
1228
1228
|
get length() {
|
|
1229
|
-
return xs.length -
|
|
1229
|
+
return xs.length - index;
|
|
1230
1230
|
},
|
|
1231
1231
|
remove: (x) => {
|
|
1232
|
-
const
|
|
1233
|
-
return
|
|
1232
|
+
const index = xs.indexOf(x);
|
|
1233
|
+
return index === -1 ? null : (xs.splice(index, 1), x);
|
|
1234
1234
|
},
|
|
1235
1235
|
push: (x) => (xs.push(x), x),
|
|
1236
1236
|
shift: () => {
|
|
1237
|
-
const out = xs[
|
|
1238
|
-
if (
|
|
1239
|
-
|
|
1237
|
+
const out = xs[index++];
|
|
1238
|
+
if (index === xs.length) {
|
|
1239
|
+
index = 0;
|
|
1240
1240
|
xs = [];
|
|
1241
1241
|
} else {
|
|
1242
|
-
xs[
|
|
1242
|
+
xs[index - 1] = undefined;
|
|
1243
1243
|
}
|
|
1244
1244
|
return out;
|
|
1245
1245
|
}
|
|
@@ -1362,7 +1362,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1362
1362
|
host,
|
|
1363
1363
|
port,
|
|
1364
1364
|
database,
|
|
1365
|
-
parsers
|
|
1365
|
+
parsers,
|
|
1366
1366
|
transform,
|
|
1367
1367
|
onnotice,
|
|
1368
1368
|
onnotify,
|
|
@@ -1374,11 +1374,11 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1374
1374
|
} = options;
|
|
1375
1375
|
const sent = queue_default(), id = uid++, backend = { pid: null, secret: null }, idleTimer = timer(end, options.idle_timeout), lifeTimer = timer(end, options.max_lifetime), connectTimer = timer(connectTimedOut, options.connect_timeout);
|
|
1376
1376
|
let socket = null, cancelMessage, errorResponse = null, result = new Result, incoming = Buffer.alloc(0), needsTypes = options.fetch_types, backendParameters = {}, statements = {}, statementId = Math.random().toString(36).slice(2), statementCount = 1, closedTime = 0, remaining = 0, hostIndex = 0, retries = 0, length = 0, delay = 0, rows = 0, serverSignature = null, nextWriteTimer = null, terminated = false, incomings = null, results = null, initial = null, ending = null, stream = null, chunk = null, ended = null, nonce = null, query = null, final = null;
|
|
1377
|
-
const
|
|
1377
|
+
const connection = {
|
|
1378
1378
|
queue: queues.closed,
|
|
1379
1379
|
idleTimer,
|
|
1380
|
-
connect(
|
|
1381
|
-
initial =
|
|
1380
|
+
connect(query) {
|
|
1381
|
+
initial = query;
|
|
1382
1382
|
reconnect();
|
|
1383
1383
|
},
|
|
1384
1384
|
terminate,
|
|
@@ -1388,8 +1388,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1388
1388
|
count: 0,
|
|
1389
1389
|
id
|
|
1390
1390
|
};
|
|
1391
|
-
queues.closed && queues.closed.push(
|
|
1392
|
-
return
|
|
1391
|
+
queues.closed && queues.closed.push(connection);
|
|
1392
|
+
return connection;
|
|
1393
1393
|
async function createSocket() {
|
|
1394
1394
|
let x;
|
|
1395
1395
|
try {
|
|
@@ -1409,8 +1409,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1409
1409
|
await connect();
|
|
1410
1410
|
socket.once("error", reject);
|
|
1411
1411
|
socket.once("close", resolve);
|
|
1412
|
-
} catch (
|
|
1413
|
-
reject(
|
|
1412
|
+
} catch (error) {
|
|
1413
|
+
reject(error);
|
|
1414
1414
|
}
|
|
1415
1415
|
}
|
|
1416
1416
|
function execute(q) {
|
|
@@ -1424,10 +1424,10 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1424
1424
|
q.state = backend;
|
|
1425
1425
|
query ? sent.push(q) : (query = q, query.active = true);
|
|
1426
1426
|
build(q);
|
|
1427
|
-
return write(toBuffer(q)) && !q.describeFirst && !q.cursorFn && sent.length < max_pipeline && (!q.options.onexecute || q.options.onexecute(
|
|
1428
|
-
} catch (
|
|
1427
|
+
return write(toBuffer(q)) && !q.describeFirst && !q.cursorFn && sent.length < max_pipeline && (!q.options.onexecute || q.options.onexecute(connection));
|
|
1428
|
+
} catch (error) {
|
|
1429
1429
|
sent.length === 0 && write(Sync);
|
|
1430
|
-
errored(
|
|
1430
|
+
errored(error);
|
|
1431
1431
|
return true;
|
|
1432
1432
|
}
|
|
1433
1433
|
}
|
|
@@ -1456,18 +1456,18 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1456
1456
|
]);
|
|
1457
1457
|
}
|
|
1458
1458
|
function build(q) {
|
|
1459
|
-
const parameters = [],
|
|
1460
|
-
const string = stringify(q, q.strings[0], q.args[0], parameters,
|
|
1461
|
-
!q.tagged && q.args.forEach((x) => handleValue(x, parameters,
|
|
1459
|
+
const parameters = [], types = [];
|
|
1460
|
+
const string = stringify(q, q.strings[0], q.args[0], parameters, types, options);
|
|
1461
|
+
!q.tagged && q.args.forEach((x) => handleValue(x, parameters, types, options));
|
|
1462
1462
|
q.prepare = options.prepare && ("prepare" in q.options ? q.options.prepare : true);
|
|
1463
1463
|
q.string = string;
|
|
1464
|
-
q.signature = q.prepare &&
|
|
1464
|
+
q.signature = q.prepare && types + string;
|
|
1465
1465
|
q.onlyDescribe && delete statements[q.signature];
|
|
1466
1466
|
q.parameters = q.parameters || parameters;
|
|
1467
1467
|
q.prepared = q.prepare && q.signature in statements;
|
|
1468
1468
|
q.describeFirst = q.onlyDescribe || parameters.length && !q.prepared;
|
|
1469
|
-
q.statement = q.prepared ? statements[q.signature] : { string, types
|
|
1470
|
-
typeof options.debug === "function" && options.debug(id, string, parameters,
|
|
1469
|
+
q.statement = q.prepared ? statements[q.signature] : { string, types, name: q.prepare ? statementId + statementCount++ : "" };
|
|
1470
|
+
typeof options.debug === "function" && options.debug(id, string, parameters, types);
|
|
1471
1471
|
}
|
|
1472
1472
|
function write(x, fn) {
|
|
1473
1473
|
chunk = chunk ? Buffer.concat([chunk, x]) : Buffer.from(x);
|
|
@@ -1493,25 +1493,25 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1493
1493
|
if (!canSSL && ssl === "prefer")
|
|
1494
1494
|
return connected();
|
|
1495
1495
|
}
|
|
1496
|
-
const
|
|
1496
|
+
const options = {
|
|
1497
1497
|
socket,
|
|
1498
1498
|
servername: net.isIP(socket.host) ? undefined : socket.host
|
|
1499
1499
|
};
|
|
1500
1500
|
if (sslnegotiation === "direct")
|
|
1501
|
-
|
|
1501
|
+
options.ALPNProtocols = ["postgresql"];
|
|
1502
1502
|
if (ssl === "require" || ssl === "allow" || ssl === "prefer")
|
|
1503
|
-
|
|
1503
|
+
options.rejectUnauthorized = false;
|
|
1504
1504
|
else if (typeof ssl === "object")
|
|
1505
|
-
Object.assign(
|
|
1505
|
+
Object.assign(options, ssl);
|
|
1506
1506
|
socket.removeAllListeners();
|
|
1507
|
-
socket = tls.connect(
|
|
1507
|
+
socket = tls.connect(options);
|
|
1508
1508
|
socket.on("secureConnect", connected);
|
|
1509
1509
|
socket.on("error", error);
|
|
1510
1510
|
socket.on("close", closed);
|
|
1511
1511
|
socket.on("drain", drain);
|
|
1512
1512
|
}
|
|
1513
1513
|
function drain() {
|
|
1514
|
-
!query && onopen(
|
|
1514
|
+
!query && onopen(connection);
|
|
1515
1515
|
}
|
|
1516
1516
|
function data(x) {
|
|
1517
1517
|
if (incomings) {
|
|
@@ -1576,7 +1576,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1576
1576
|
}
|
|
1577
1577
|
}
|
|
1578
1578
|
function error(err) {
|
|
1579
|
-
if (
|
|
1579
|
+
if (connection.queue === queues.connecting && options.host[retries + 1])
|
|
1580
1580
|
return;
|
|
1581
1581
|
errored(err);
|
|
1582
1582
|
while (sent.length)
|
|
@@ -1587,23 +1587,23 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1587
1587
|
query && queryError(query, err);
|
|
1588
1588
|
initial && (queryError(initial, err), initial = null);
|
|
1589
1589
|
}
|
|
1590
|
-
function queryError(
|
|
1591
|
-
if (
|
|
1592
|
-
return
|
|
1590
|
+
function queryError(query, err) {
|
|
1591
|
+
if (query.reserve)
|
|
1592
|
+
return query.reject(err);
|
|
1593
1593
|
if (!err || typeof err !== "object")
|
|
1594
1594
|
err = new Error(err);
|
|
1595
1595
|
"query" in err || "parameters" in err || Object.defineProperties(err, {
|
|
1596
|
-
stack: { value: err.stack +
|
|
1596
|
+
stack: { value: err.stack + query.origin.replace(/.*\n/, `
|
|
1597
1597
|
`), enumerable: options.debug },
|
|
1598
|
-
query: { value:
|
|
1599
|
-
parameters: { value:
|
|
1600
|
-
args: { value:
|
|
1601
|
-
types: { value:
|
|
1598
|
+
query: { value: query.string, enumerable: options.debug },
|
|
1599
|
+
parameters: { value: query.parameters, enumerable: options.debug },
|
|
1600
|
+
args: { value: query.args, enumerable: options.debug },
|
|
1601
|
+
types: { value: query.statement && query.statement.types, enumerable: options.debug }
|
|
1602
1602
|
});
|
|
1603
|
-
|
|
1603
|
+
query.reject(err);
|
|
1604
1604
|
}
|
|
1605
1605
|
function end() {
|
|
1606
|
-
return ending || (!
|
|
1606
|
+
return ending || (!connection.reserved && onend(connection), !connection.reserved && !initial && !query && sent.length === 0 ? (terminate(), new Promise((r) => socket && socket.readyState !== "closed" ? socket.once("close", r) : r())) : ending = new Promise((r) => ended = r));
|
|
1607
1607
|
}
|
|
1608
1608
|
function terminate() {
|
|
1609
1609
|
terminated = true;
|
|
@@ -1635,22 +1635,22 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1635
1635
|
closedTime = performance.now();
|
|
1636
1636
|
hadError && options.shared.retries++;
|
|
1637
1637
|
delay = (typeof backoff === "function" ? backoff(options.shared.retries) : backoff) * 1000;
|
|
1638
|
-
onclose(
|
|
1638
|
+
onclose(connection, Errors.connection("CONNECTION_CLOSED", options, socket));
|
|
1639
1639
|
}
|
|
1640
1640
|
function handle(xs, x = xs[0]) {
|
|
1641
1641
|
(x === 68 ? DataRow : x === 100 ? CopyData : x === 65 ? NotificationResponse : x === 83 ? ParameterStatus : x === 90 ? ReadyForQuery : x === 67 ? CommandComplete : x === 50 ? BindComplete : x === 49 ? ParseComplete : x === 116 ? ParameterDescription : x === 84 ? RowDescription : x === 82 ? Authentication : x === 110 ? NoData : x === 75 ? BackendKeyData : x === 69 ? ErrorResponse : x === 115 ? PortalSuspended : x === 51 ? CloseComplete : x === 71 ? CopyInResponse : x === 78 ? NoticeResponse : x === 72 ? CopyOutResponse : x === 99 ? CopyDone : x === 73 ? EmptyQueryResponse : x === 86 ? FunctionCallResponse : x === 118 ? NegotiateProtocolVersion : x === 87 ? CopyBothResponse : UnknownMessage)(xs);
|
|
1642
1642
|
}
|
|
1643
1643
|
function DataRow(x) {
|
|
1644
|
-
let
|
|
1645
|
-
let
|
|
1644
|
+
let index = 7;
|
|
1645
|
+
let length;
|
|
1646
1646
|
let column;
|
|
1647
1647
|
let value;
|
|
1648
1648
|
const row = query.isRaw ? new Array(query.statement.columns.length) : {};
|
|
1649
1649
|
for (let i = 0;i < query.statement.columns.length; i++) {
|
|
1650
1650
|
column = query.statement.columns[i];
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
value =
|
|
1651
|
+
length = x.readInt32BE(index);
|
|
1652
|
+
index += 4;
|
|
1653
|
+
value = length === -1 ? null : query.isRaw === true ? x.subarray(index, index += length) : column.parser === undefined ? x.toString("utf8", index, index += length) : column.parser.array === true ? column.parser(x.toString("utf8", index + 1, index += length)) : column.parser(x.toString("utf8", index, index += length));
|
|
1654
1654
|
query.isRaw ? row[i] = query.isRaw === true ? value : transform.value.from ? transform.value.from(value, column) : value : row[column.name] = transform.value.from ? transform.value.from(value, column) : value;
|
|
1655
1655
|
}
|
|
1656
1656
|
query.forEachFn ? query.forEachFn(transform.row.from ? transform.row.from(row) : row, result) : result[rows++] = transform.row.from ? transform.row.from(row) : row;
|
|
@@ -1696,7 +1696,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1696
1696
|
Connection(options).cancel(query.state, query.cancelled.resolve, query.cancelled.reject);
|
|
1697
1697
|
if (query)
|
|
1698
1698
|
return;
|
|
1699
|
-
|
|
1699
|
+
connection.reserved ? !connection.reserved.release && x[5] === 73 ? ending ? terminate() : (connection.reserved = null, onopen(connection)) : connection.reserved() : ending ? terminate() : onopen(connection);
|
|
1700
1700
|
}
|
|
1701
1701
|
function CommandComplete(x) {
|
|
1702
1702
|
rows = 0;
|
|
@@ -1710,7 +1710,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1710
1710
|
}
|
|
1711
1711
|
}
|
|
1712
1712
|
final && (final(), final = null);
|
|
1713
|
-
if (result.command === "BEGIN" && max !== 1 && !
|
|
1713
|
+
if (result.command === "BEGIN" && max !== 1 && !connection.reserved)
|
|
1714
1714
|
return errored(Errors.generic("UNSAFE_TRANSACTION", "Only use sql.begin, sql.reserved or max: 1"));
|
|
1715
1715
|
if (query.options.simple)
|
|
1716
1716
|
return BindComplete();
|
|
@@ -1727,8 +1727,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1727
1727
|
result.columns = query.statement.columns;
|
|
1728
1728
|
}
|
|
1729
1729
|
function ParameterDescription(x) {
|
|
1730
|
-
const
|
|
1731
|
-
for (let i = 0;i <
|
|
1730
|
+
const length = x.readUInt16BE(5);
|
|
1731
|
+
for (let i = 0;i < length; ++i)
|
|
1732
1732
|
!query.statement.types[i] && (query.statement.types[i] = x.readUInt32BE(7 + i * 4));
|
|
1733
1733
|
query.prepare && (statements[query.signature] = query.statement);
|
|
1734
1734
|
query.describeFirst && !query.onlyDescribe && (write(prepared(query)), query.describeFirst = false);
|
|
@@ -1740,25 +1740,25 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1740
1740
|
result.count = null;
|
|
1741
1741
|
query.statement.columns = null;
|
|
1742
1742
|
}
|
|
1743
|
-
const
|
|
1744
|
-
let
|
|
1743
|
+
const length = x.readUInt16BE(5);
|
|
1744
|
+
let index = 7;
|
|
1745
1745
|
let start;
|
|
1746
|
-
query.statement.columns = Array(
|
|
1747
|
-
for (let i = 0;i <
|
|
1748
|
-
start =
|
|
1749
|
-
while (x[
|
|
1746
|
+
query.statement.columns = Array(length);
|
|
1747
|
+
for (let i = 0;i < length; ++i) {
|
|
1748
|
+
start = index;
|
|
1749
|
+
while (x[index++] !== 0)
|
|
1750
1750
|
;
|
|
1751
|
-
const table = x.readUInt32BE(
|
|
1752
|
-
const number = x.readUInt16BE(
|
|
1753
|
-
const type = x.readUInt32BE(
|
|
1751
|
+
const table = x.readUInt32BE(index);
|
|
1752
|
+
const number = x.readUInt16BE(index + 4);
|
|
1753
|
+
const type = x.readUInt32BE(index + 6);
|
|
1754
1754
|
query.statement.columns[i] = {
|
|
1755
|
-
name: transform.column.from ? transform.column.from(x.toString("utf8", start,
|
|
1756
|
-
parser:
|
|
1755
|
+
name: transform.column.from ? transform.column.from(x.toString("utf8", start, index - 1)) : x.toString("utf8", start, index - 1),
|
|
1756
|
+
parser: parsers[type],
|
|
1757
1757
|
table,
|
|
1758
1758
|
number,
|
|
1759
1759
|
type
|
|
1760
1760
|
};
|
|
1761
|
-
|
|
1761
|
+
index += 18;
|
|
1762
1762
|
}
|
|
1763
1763
|
result.statement = query.statement;
|
|
1764
1764
|
if (query.onlyDescribe)
|
|
@@ -1785,7 +1785,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1785
1785
|
write(bytes_default.inc(4).str("n,,n=*,r=" + nonce).i32(bytes_default.i - i - 4, i).end());
|
|
1786
1786
|
}
|
|
1787
1787
|
async function SASLContinue(x) {
|
|
1788
|
-
const res = x.toString("utf8", 9).split(",").reduce((acc,
|
|
1788
|
+
const res = x.toString("utf8", 9).split(",").reduce((acc, x) => (acc[x[0]] = x.slice(2), acc), {});
|
|
1789
1789
|
const saltedPassword = await crypto.pbkdf2Sync(await Pass(), Buffer.from(res.s, "base64"), parseInt(res.i), 32, "sha256");
|
|
1790
1790
|
const clientKey = await hmac(saltedPassword, "Client Key");
|
|
1791
1791
|
const auth = "n=*,r=" + nonce + "," + "r=" + res.r + ",s=" + res.s + ",i=" + res.i + ",c=biws,r=" + res.r;
|
|
@@ -1814,7 +1814,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1814
1814
|
}
|
|
1815
1815
|
async function fetchArrayTypes() {
|
|
1816
1816
|
needsTypes = false;
|
|
1817
|
-
const
|
|
1817
|
+
const types = await new Query([`
|
|
1818
1818
|
select b.oid, b.typarray
|
|
1819
1819
|
from pg_catalog.pg_type a
|
|
1820
1820
|
left join pg_catalog.pg_type b on b.oid = a.typelem
|
|
@@ -1822,7 +1822,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1822
1822
|
group by b.oid, b.typarray
|
|
1823
1823
|
order by b.oid
|
|
1824
1824
|
`], [], execute);
|
|
1825
|
-
|
|
1825
|
+
types.forEach(({ oid, typarray }) => addArrayType(oid, typarray));
|
|
1826
1826
|
}
|
|
1827
1827
|
function addArrayType(oid, typarray) {
|
|
1828
1828
|
if (!!options.parsers[typarray] && !!options.serializers[typarray])
|
|
@@ -1837,15 +1837,15 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1837
1837
|
return x === "read-write" && xs.default_transaction_read_only === "on" || x === "read-only" && xs.default_transaction_read_only === "off" || x === "primary" && xs.in_hot_standby === "on" || x === "standby" && xs.in_hot_standby === "off" || x === "prefer-standby" && xs.in_hot_standby === "off" && options.host[retries];
|
|
1838
1838
|
}
|
|
1839
1839
|
function fetchState() {
|
|
1840
|
-
const
|
|
1840
|
+
const query = new Query([`
|
|
1841
1841
|
show transaction_read_only;
|
|
1842
1842
|
select pg_catalog.pg_is_in_recovery()
|
|
1843
1843
|
`], [], execute, null, { simple: true });
|
|
1844
|
-
|
|
1844
|
+
query.resolve = ([[a], [b]]) => {
|
|
1845
1845
|
backendParameters.default_transaction_read_only = a.transaction_read_only;
|
|
1846
|
-
backendParameters.in_hot_standby =
|
|
1846
|
+
backendParameters.in_hot_standby = b.pg_is_in_recovery ? "on" : "off";
|
|
1847
1847
|
};
|
|
1848
|
-
|
|
1848
|
+
query.execute();
|
|
1849
1849
|
}
|
|
1850
1850
|
function ErrorResponse(x) {
|
|
1851
1851
|
if (query) {
|
|
@@ -1855,18 +1855,18 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1855
1855
|
errored(Errors.postgres(parseError(x)));
|
|
1856
1856
|
}
|
|
1857
1857
|
}
|
|
1858
|
-
function retry(q,
|
|
1858
|
+
function retry(q, error) {
|
|
1859
1859
|
delete statements[q.signature];
|
|
1860
|
-
q.retried =
|
|
1860
|
+
q.retried = error;
|
|
1861
1861
|
execute(q);
|
|
1862
1862
|
}
|
|
1863
1863
|
function NotificationResponse(x) {
|
|
1864
1864
|
if (!onnotify)
|
|
1865
1865
|
return;
|
|
1866
|
-
let
|
|
1867
|
-
while (x[
|
|
1866
|
+
let index = 9;
|
|
1867
|
+
while (x[index++] !== 0)
|
|
1868
1868
|
;
|
|
1869
|
-
onnotify(x.toString("utf8", 9,
|
|
1869
|
+
onnotify(x.toString("utf8", 9, index - 1), x.toString("utf8", index, x.length - 1));
|
|
1870
1870
|
}
|
|
1871
1871
|
async function PortalSuspended() {
|
|
1872
1872
|
try {
|
|
@@ -1885,12 +1885,12 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1885
1885
|
function CopyInResponse() {
|
|
1886
1886
|
stream = new Stream.Writable({
|
|
1887
1887
|
autoDestroy: true,
|
|
1888
|
-
write(
|
|
1889
|
-
socket.write(bytes_default().d().raw(
|
|
1888
|
+
write(chunk, encoding, callback) {
|
|
1889
|
+
socket.write(bytes_default().d().raw(chunk).end(), callback);
|
|
1890
1890
|
},
|
|
1891
|
-
destroy(
|
|
1892
|
-
callback(
|
|
1893
|
-
socket.write(bytes_default().f().str(
|
|
1891
|
+
destroy(error, callback) {
|
|
1892
|
+
callback(error);
|
|
1893
|
+
socket.write(bytes_default().f().str(error + bytes_default.N).end());
|
|
1894
1894
|
stream = null;
|
|
1895
1895
|
},
|
|
1896
1896
|
final(callback) {
|
|
@@ -1915,12 +1915,12 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1915
1915
|
read() {
|
|
1916
1916
|
socket.resume();
|
|
1917
1917
|
},
|
|
1918
|
-
write(
|
|
1919
|
-
socket.write(bytes_default().d().raw(
|
|
1918
|
+
write(chunk, encoding, callback) {
|
|
1919
|
+
socket.write(bytes_default().d().raw(chunk).end(), callback);
|
|
1920
1920
|
},
|
|
1921
|
-
destroy(
|
|
1922
|
-
callback(
|
|
1923
|
-
socket.write(bytes_default().f().str(
|
|
1921
|
+
destroy(error, callback) {
|
|
1922
|
+
callback(error);
|
|
1923
|
+
socket.write(bytes_default().f().str(error + bytes_default.N).end());
|
|
1924
1924
|
stream = null;
|
|
1925
1925
|
},
|
|
1926
1926
|
final(callback) {
|
|
@@ -1953,13 +1953,13 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1953
1953
|
function UnknownAuth(x, type) {
|
|
1954
1954
|
console.error("Postgres.js : Unknown Auth:", type);
|
|
1955
1955
|
}
|
|
1956
|
-
function Bind(parameters,
|
|
1956
|
+
function Bind(parameters, types, statement = "", portal = "") {
|
|
1957
1957
|
let prev, type;
|
|
1958
1958
|
bytes_default().B().str(portal + bytes_default.N).str(statement + bytes_default.N).i16(0).i16(parameters.length);
|
|
1959
1959
|
parameters.forEach((x, i) => {
|
|
1960
1960
|
if (x === null)
|
|
1961
1961
|
return bytes_default.i32(4294967295);
|
|
1962
|
-
type =
|
|
1962
|
+
type = types[i];
|
|
1963
1963
|
parameters[i] = x = type in options.serializers ? options.serializers[type](x) : "" + x;
|
|
1964
1964
|
prev = bytes_default.i;
|
|
1965
1965
|
bytes_default.inc(4).str(x).i32(bytes_default.i - prev - 4, prev);
|
|
@@ -1967,17 +1967,17 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1967
1967
|
bytes_default.i16(0);
|
|
1968
1968
|
return bytes_default.end();
|
|
1969
1969
|
}
|
|
1970
|
-
function Parse(str, parameters,
|
|
1970
|
+
function Parse(str, parameters, types, name = "") {
|
|
1971
1971
|
bytes_default().P().str(name + bytes_default.N).str(str + bytes_default.N).i16(parameters.length);
|
|
1972
|
-
parameters.forEach((x, i) => bytes_default.i32(
|
|
1972
|
+
parameters.forEach((x, i) => bytes_default.i32(types[i] || 0));
|
|
1973
1973
|
return bytes_default.end();
|
|
1974
1974
|
}
|
|
1975
1975
|
function Describe(x, name = "") {
|
|
1976
1976
|
return bytes_default().D().str(x).str(name + bytes_default.N).end();
|
|
1977
1977
|
}
|
|
1978
|
-
function Execute(portal = "",
|
|
1978
|
+
function Execute(portal = "", rows = 0) {
|
|
1979
1979
|
return Buffer.concat([
|
|
1980
|
-
bytes_default().E().str(portal + bytes_default.N).i32(
|
|
1980
|
+
bytes_default().E().str(portal + bytes_default.N).i32(rows).end(),
|
|
1981
1981
|
Flush
|
|
1982
1982
|
]);
|
|
1983
1983
|
}
|
|
@@ -2015,39 +2015,39 @@ function hmac(key, x) {
|
|
|
2015
2015
|
function sha256(x) {
|
|
2016
2016
|
return crypto.createHash("sha256").update(x).digest();
|
|
2017
2017
|
}
|
|
2018
|
-
function xor(a,
|
|
2019
|
-
const length = Math.max(a.length,
|
|
2020
|
-
const
|
|
2018
|
+
function xor(a, b) {
|
|
2019
|
+
const length = Math.max(a.length, b.length);
|
|
2020
|
+
const buffer = Buffer.allocUnsafe(length);
|
|
2021
2021
|
for (let i = 0;i < length; i++)
|
|
2022
|
-
|
|
2023
|
-
return
|
|
2022
|
+
buffer[i] = a[i] ^ b[i];
|
|
2023
|
+
return buffer;
|
|
2024
2024
|
}
|
|
2025
2025
|
function timer(fn, seconds) {
|
|
2026
2026
|
seconds = typeof seconds === "function" ? seconds() : seconds;
|
|
2027
2027
|
if (!seconds)
|
|
2028
2028
|
return { cancel: noop, start: noop };
|
|
2029
|
-
let
|
|
2029
|
+
let timer;
|
|
2030
2030
|
return {
|
|
2031
2031
|
cancel() {
|
|
2032
|
-
|
|
2032
|
+
timer && (clearTimeout(timer), timer = null);
|
|
2033
2033
|
},
|
|
2034
2034
|
start() {
|
|
2035
|
-
|
|
2036
|
-
|
|
2035
|
+
timer && clearTimeout(timer);
|
|
2036
|
+
timer = setTimeout(done, seconds * 1000, arguments);
|
|
2037
2037
|
}
|
|
2038
2038
|
};
|
|
2039
2039
|
function done(args) {
|
|
2040
2040
|
fn.apply(null, args);
|
|
2041
|
-
|
|
2041
|
+
timer = null;
|
|
2042
2042
|
}
|
|
2043
2043
|
}
|
|
2044
2044
|
|
|
2045
2045
|
// ../../node_modules/.bun/postgres@3.4.9/node_modules/postgres/src/subscribe.js
|
|
2046
2046
|
var noop2 = () => {};
|
|
2047
|
-
function Subscribe(
|
|
2047
|
+
function Subscribe(postgres, options) {
|
|
2048
2048
|
const subscribers = new Map, slot = "postgresjs_" + Math.random().toString(36).slice(2), state = {};
|
|
2049
|
-
let
|
|
2050
|
-
const
|
|
2049
|
+
let connection, stream, ended = false;
|
|
2050
|
+
const sql = subscribe.sql = postgres({
|
|
2051
2051
|
...options,
|
|
2052
2052
|
transform: { column: {}, value: {}, row: {} },
|
|
2053
2053
|
max: 1,
|
|
@@ -2063,37 +2063,37 @@ function Subscribe(postgres2, options) {
|
|
|
2063
2063
|
return;
|
|
2064
2064
|
stream = null;
|
|
2065
2065
|
state.pid = state.secret = undefined;
|
|
2066
|
-
connected(await init(
|
|
2066
|
+
connected(await init(sql, slot, options.publications));
|
|
2067
2067
|
subscribers.forEach((event) => event.forEach(({ onsubscribe }) => onsubscribe()));
|
|
2068
2068
|
},
|
|
2069
2069
|
no_subscribe: true
|
|
2070
2070
|
});
|
|
2071
|
-
const { end, close } =
|
|
2072
|
-
|
|
2071
|
+
const { end, close } = sql;
|
|
2072
|
+
sql.end = async () => {
|
|
2073
2073
|
ended = true;
|
|
2074
2074
|
stream && await new Promise((r) => (stream.once("close", r), stream.end()));
|
|
2075
2075
|
return end();
|
|
2076
2076
|
};
|
|
2077
|
-
|
|
2077
|
+
sql.close = async () => {
|
|
2078
2078
|
stream && await new Promise((r) => (stream.once("close", r), stream.end()));
|
|
2079
2079
|
return close();
|
|
2080
2080
|
};
|
|
2081
2081
|
return subscribe;
|
|
2082
2082
|
async function subscribe(event, fn, onsubscribe = noop2, onerror = noop2) {
|
|
2083
2083
|
event = parseEvent(event);
|
|
2084
|
-
if (!
|
|
2085
|
-
|
|
2084
|
+
if (!connection)
|
|
2085
|
+
connection = init(sql, slot, options.publications);
|
|
2086
2086
|
const subscriber = { fn, onsubscribe };
|
|
2087
2087
|
const fns = subscribers.has(event) ? subscribers.get(event).add(subscriber) : subscribers.set(event, new Set([subscriber])).get(event);
|
|
2088
2088
|
const unsubscribe = () => {
|
|
2089
2089
|
fns.delete(subscriber);
|
|
2090
2090
|
fns.size === 0 && subscribers.delete(event);
|
|
2091
2091
|
};
|
|
2092
|
-
return
|
|
2092
|
+
return connection.then((x) => {
|
|
2093
2093
|
connected(x);
|
|
2094
2094
|
onsubscribe();
|
|
2095
2095
|
stream && stream.on("error", onerror);
|
|
2096
|
-
return { unsubscribe, state, sql
|
|
2096
|
+
return { unsubscribe, state, sql };
|
|
2097
2097
|
});
|
|
2098
2098
|
}
|
|
2099
2099
|
function connected(x) {
|
|
@@ -2101,74 +2101,74 @@ function Subscribe(postgres2, options) {
|
|
|
2101
2101
|
state.pid = x.state.pid;
|
|
2102
2102
|
state.secret = x.state.secret;
|
|
2103
2103
|
}
|
|
2104
|
-
async function init(
|
|
2104
|
+
async function init(sql, slot, publications) {
|
|
2105
2105
|
if (!publications)
|
|
2106
2106
|
throw new Error("Missing publication names");
|
|
2107
|
-
const xs = await
|
|
2107
|
+
const xs = await sql.unsafe(`CREATE_REPLICATION_SLOT ${slot} TEMPORARY LOGICAL pgoutput NOEXPORT_SNAPSHOT`);
|
|
2108
2108
|
const [x] = xs;
|
|
2109
|
-
const
|
|
2110
|
-
const
|
|
2111
|
-
lsn: Buffer.concat(x.consistent_point.split("/").map((
|
|
2109
|
+
const stream = await sql.unsafe(`START_REPLICATION SLOT ${slot} LOGICAL ${x.consistent_point} (proto_version '1', publication_names '${publications}')`).writable();
|
|
2110
|
+
const state = {
|
|
2111
|
+
lsn: Buffer.concat(x.consistent_point.split("/").map((x) => Buffer.from(("00000000" + x).slice(-8), "hex")))
|
|
2112
2112
|
};
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
return { stream
|
|
2113
|
+
stream.on("data", data);
|
|
2114
|
+
stream.on("error", error);
|
|
2115
|
+
stream.on("close", sql.close);
|
|
2116
|
+
return { stream, state: xs.state };
|
|
2117
2117
|
function error(e) {
|
|
2118
2118
|
console.error("Unexpected error during logical streaming - reconnecting", e);
|
|
2119
2119
|
}
|
|
2120
|
-
function data(
|
|
2121
|
-
if (
|
|
2122
|
-
parse(
|
|
2123
|
-
} else if (
|
|
2124
|
-
|
|
2120
|
+
function data(x) {
|
|
2121
|
+
if (x[0] === 119) {
|
|
2122
|
+
parse(x.subarray(25), state, sql.options.parsers, handle, options.transform);
|
|
2123
|
+
} else if (x[0] === 107 && x[17]) {
|
|
2124
|
+
state.lsn = x.subarray(1, 9);
|
|
2125
2125
|
pong();
|
|
2126
2126
|
}
|
|
2127
2127
|
}
|
|
2128
|
-
function handle(a,
|
|
2129
|
-
const path =
|
|
2130
|
-
call("*", a,
|
|
2131
|
-
call("*:" + path, a,
|
|
2132
|
-
|
|
2133
|
-
call(
|
|
2134
|
-
call(
|
|
2135
|
-
|
|
2128
|
+
function handle(a, b) {
|
|
2129
|
+
const path = b.relation.schema + "." + b.relation.table;
|
|
2130
|
+
call("*", a, b);
|
|
2131
|
+
call("*:" + path, a, b);
|
|
2132
|
+
b.relation.keys.length && call("*:" + path + "=" + b.relation.keys.map((x) => a[x.name]), a, b);
|
|
2133
|
+
call(b.command, a, b);
|
|
2134
|
+
call(b.command + ":" + path, a, b);
|
|
2135
|
+
b.relation.keys.length && call(b.command + ":" + path + "=" + b.relation.keys.map((x) => a[x.name]), a, b);
|
|
2136
2136
|
}
|
|
2137
2137
|
function pong() {
|
|
2138
|
-
const
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2138
|
+
const x = Buffer.alloc(34);
|
|
2139
|
+
x[0] = 114;
|
|
2140
|
+
x.fill(state.lsn, 1);
|
|
2141
|
+
x.writeBigInt64BE(BigInt(Date.now() - Date.UTC(2000, 0, 1)) * BigInt(1000), 25);
|
|
2142
|
+
stream.write(x);
|
|
2143
2143
|
}
|
|
2144
2144
|
}
|
|
2145
|
-
function call(x, a,
|
|
2146
|
-
subscribers.has(x) && subscribers.get(x).forEach(({ fn }) => fn(a,
|
|
2145
|
+
function call(x, a, b) {
|
|
2146
|
+
subscribers.has(x) && subscribers.get(x).forEach(({ fn }) => fn(a, b, x));
|
|
2147
2147
|
}
|
|
2148
2148
|
}
|
|
2149
2149
|
function Time(x) {
|
|
2150
2150
|
return new Date(Date.UTC(2000, 0, 1) + Number(x / BigInt(1000)));
|
|
2151
2151
|
}
|
|
2152
|
-
function parse(x, state,
|
|
2152
|
+
function parse(x, state, parsers, handle, transform) {
|
|
2153
2153
|
const char = (acc, [k, v]) => (acc[k.charCodeAt(0)] = v, acc);
|
|
2154
2154
|
Object.entries({
|
|
2155
|
-
R: (
|
|
2155
|
+
R: (x) => {
|
|
2156
2156
|
let i = 1;
|
|
2157
|
-
const r = state[
|
|
2158
|
-
schema:
|
|
2159
|
-
table:
|
|
2160
|
-
columns: Array(
|
|
2157
|
+
const r = state[x.readUInt32BE(i)] = {
|
|
2158
|
+
schema: x.toString("utf8", i += 4, i = x.indexOf(0, i)) || "pg_catalog",
|
|
2159
|
+
table: x.toString("utf8", i + 1, i = x.indexOf(0, i + 1)),
|
|
2160
|
+
columns: Array(x.readUInt16BE(i += 2)),
|
|
2161
2161
|
keys: []
|
|
2162
2162
|
};
|
|
2163
2163
|
i += 2;
|
|
2164
2164
|
let columnIndex = 0, column;
|
|
2165
|
-
while (i <
|
|
2165
|
+
while (i < x.length) {
|
|
2166
2166
|
column = r.columns[columnIndex++] = {
|
|
2167
|
-
key:
|
|
2168
|
-
name: transform.column.from ? transform.column.from(
|
|
2169
|
-
type:
|
|
2170
|
-
parser:
|
|
2171
|
-
atttypmod:
|
|
2167
|
+
key: x[i++],
|
|
2168
|
+
name: transform.column.from ? transform.column.from(x.toString("utf8", i, i = x.indexOf(0, i))) : x.toString("utf8", i, i = x.indexOf(0, i)),
|
|
2169
|
+
type: x.readUInt32BE(i += 1),
|
|
2170
|
+
parser: parsers[x.readUInt32BE(i)],
|
|
2171
|
+
atttypmod: x.readUInt32BE(i += 4)
|
|
2172
2172
|
};
|
|
2173
2173
|
column.key && r.keys.push(column);
|
|
2174
2174
|
i += 4;
|
|
@@ -2176,38 +2176,38 @@ function parse(x, state, parsers2, handle, transform) {
|
|
|
2176
2176
|
},
|
|
2177
2177
|
Y: () => {},
|
|
2178
2178
|
O: () => {},
|
|
2179
|
-
B: (
|
|
2180
|
-
state.date = Time(
|
|
2181
|
-
state.lsn =
|
|
2179
|
+
B: (x) => {
|
|
2180
|
+
state.date = Time(x.readBigInt64BE(9));
|
|
2181
|
+
state.lsn = x.subarray(1, 9);
|
|
2182
2182
|
},
|
|
2183
|
-
I: (
|
|
2183
|
+
I: (x) => {
|
|
2184
2184
|
let i = 1;
|
|
2185
|
-
const relation = state[
|
|
2186
|
-
const { row } = tuples(
|
|
2185
|
+
const relation = state[x.readUInt32BE(i)];
|
|
2186
|
+
const { row } = tuples(x, relation.columns, i += 7, transform);
|
|
2187
2187
|
handle(row, {
|
|
2188
2188
|
command: "insert",
|
|
2189
2189
|
relation
|
|
2190
2190
|
});
|
|
2191
2191
|
},
|
|
2192
|
-
D: (
|
|
2192
|
+
D: (x) => {
|
|
2193
2193
|
let i = 1;
|
|
2194
|
-
const relation = state[
|
|
2194
|
+
const relation = state[x.readUInt32BE(i)];
|
|
2195
2195
|
i += 4;
|
|
2196
|
-
const key =
|
|
2197
|
-
handle(key ||
|
|
2196
|
+
const key = x[i] === 75;
|
|
2197
|
+
handle(key || x[i] === 79 ? tuples(x, relation.columns, i += 3, transform).row : null, {
|
|
2198
2198
|
command: "delete",
|
|
2199
2199
|
relation,
|
|
2200
2200
|
key
|
|
2201
2201
|
});
|
|
2202
2202
|
},
|
|
2203
|
-
U: (
|
|
2203
|
+
U: (x) => {
|
|
2204
2204
|
let i = 1;
|
|
2205
|
-
const relation = state[
|
|
2205
|
+
const relation = state[x.readUInt32BE(i)];
|
|
2206
2206
|
i += 4;
|
|
2207
|
-
const key =
|
|
2208
|
-
const xs = key ||
|
|
2207
|
+
const key = x[i] === 75;
|
|
2208
|
+
const xs = key || x[i] === 79 ? tuples(x, relation.columns, i += 3, transform) : null;
|
|
2209
2209
|
xs && (i = xs.i);
|
|
2210
|
-
const { row } = tuples(
|
|
2210
|
+
const { row } = tuples(x, relation.columns, i + 3, transform);
|
|
2211
2211
|
handle(row, {
|
|
2212
2212
|
command: "update",
|
|
2213
2213
|
relation,
|
|
@@ -2240,22 +2240,22 @@ function parseEvent(x) {
|
|
|
2240
2240
|
|
|
2241
2241
|
// ../../node_modules/.bun/postgres@3.4.9/node_modules/postgres/src/large.js
|
|
2242
2242
|
import Stream2 from "stream";
|
|
2243
|
-
function largeObject(
|
|
2243
|
+
function largeObject(sql, oid, mode = 131072 | 262144) {
|
|
2244
2244
|
return new Promise(async (resolve, reject) => {
|
|
2245
|
-
await
|
|
2245
|
+
await sql.begin(async (sql) => {
|
|
2246
2246
|
let finish;
|
|
2247
|
-
!oid && ([{ oid }] = await
|
|
2248
|
-
const [{ fd }] = await
|
|
2247
|
+
!oid && ([{ oid }] = await sql`select lo_creat(-1) as oid`);
|
|
2248
|
+
const [{ fd }] = await sql`select lo_open(${oid}, ${mode}) as fd`;
|
|
2249
2249
|
const lo = {
|
|
2250
2250
|
writable,
|
|
2251
2251
|
readable,
|
|
2252
|
-
close: () =>
|
|
2253
|
-
tell: () =>
|
|
2254
|
-
read: (x) =>
|
|
2255
|
-
write: (x) =>
|
|
2256
|
-
truncate: (x) =>
|
|
2257
|
-
seek: (x, whence = 0) =>
|
|
2258
|
-
size: () =>
|
|
2252
|
+
close: () => sql`select lo_close(${fd})`.then(finish),
|
|
2253
|
+
tell: () => sql`select lo_tell64(${fd})`,
|
|
2254
|
+
read: (x) => sql`select loread(${fd}, ${x}) as data`,
|
|
2255
|
+
write: (x) => sql`select lowrite(${fd}, ${x})`,
|
|
2256
|
+
truncate: (x) => sql`select lo_truncate64(${fd}, ${x})`,
|
|
2257
|
+
seek: (x, whence = 0) => sql`select lo_lseek64(${fd}, ${x}, ${whence})`,
|
|
2258
|
+
size: () => sql`
|
|
2259
2259
|
select
|
|
2260
2260
|
lo_lseek64(${fd}, location, 0) as position,
|
|
2261
2261
|
seek.size
|
|
@@ -2278,12 +2278,12 @@ function largeObject(sql2, oid, mode = 131072 | 262144) {
|
|
|
2278
2278
|
start && await lo.seek(start);
|
|
2279
2279
|
return new Stream2.Readable({
|
|
2280
2280
|
highWaterMark,
|
|
2281
|
-
async read(
|
|
2282
|
-
const l =
|
|
2283
|
-
max -=
|
|
2281
|
+
async read(size) {
|
|
2282
|
+
const l = size > max ? size - max : size;
|
|
2283
|
+
max -= size;
|
|
2284
2284
|
const [{ data }] = await lo.read(l);
|
|
2285
2285
|
this.push(data);
|
|
2286
|
-
if (data.length <
|
|
2286
|
+
if (data.length < size)
|
|
2287
2287
|
this.push(null);
|
|
2288
2288
|
}
|
|
2289
2289
|
});
|
|
@@ -2324,17 +2324,17 @@ Object.assign(Postgres, {
|
|
|
2324
2324
|
}
|
|
2325
2325
|
});
|
|
2326
2326
|
var src_default = Postgres;
|
|
2327
|
-
function Postgres(a,
|
|
2328
|
-
const options = parseOptions(a,
|
|
2327
|
+
function Postgres(a, b) {
|
|
2328
|
+
const options = parseOptions(a, b), subscribe = options.no_subscribe || Subscribe(Postgres, { ...options });
|
|
2329
2329
|
let ending = false;
|
|
2330
2330
|
const queries = queue_default(), connecting = queue_default(), reserved = queue_default(), closed = queue_default(), ended = queue_default(), open = queue_default(), busy = queue_default(), full = queue_default(), queues = { connecting, reserved, closed, ended, open, busy, full };
|
|
2331
2331
|
const connections = [...Array(options.max)].map(() => connection_default(options, queues, { onopen, onend, onclose }));
|
|
2332
|
-
const
|
|
2333
|
-
Object.assign(
|
|
2332
|
+
const sql = Sql(handler);
|
|
2333
|
+
Object.assign(sql, {
|
|
2334
2334
|
get parameters() {
|
|
2335
2335
|
return options.parameters;
|
|
2336
2336
|
},
|
|
2337
|
-
largeObject: largeObject.bind(null,
|
|
2337
|
+
largeObject: largeObject.bind(null, sql),
|
|
2338
2338
|
subscribe,
|
|
2339
2339
|
CLOSE,
|
|
2340
2340
|
END: CLOSE,
|
|
@@ -2346,14 +2346,14 @@ function Postgres(a, b2) {
|
|
|
2346
2346
|
close,
|
|
2347
2347
|
end
|
|
2348
2348
|
});
|
|
2349
|
-
return
|
|
2350
|
-
function Sql(
|
|
2351
|
-
|
|
2349
|
+
return sql;
|
|
2350
|
+
function Sql(handler) {
|
|
2351
|
+
handler.debug = options.debug;
|
|
2352
2352
|
Object.entries(options.types).reduce((acc, [name, type]) => {
|
|
2353
2353
|
acc[name] = (x) => new Parameter(x, type.to);
|
|
2354
2354
|
return acc;
|
|
2355
2355
|
}, typed);
|
|
2356
|
-
Object.assign(
|
|
2356
|
+
Object.assign(sql, {
|
|
2357
2357
|
types: typed,
|
|
2358
2358
|
typed,
|
|
2359
2359
|
unsafe,
|
|
@@ -2362,51 +2362,51 @@ function Postgres(a, b2) {
|
|
|
2362
2362
|
json,
|
|
2363
2363
|
file
|
|
2364
2364
|
});
|
|
2365
|
-
return
|
|
2365
|
+
return sql;
|
|
2366
2366
|
function typed(value, type) {
|
|
2367
2367
|
return new Parameter(value, type);
|
|
2368
2368
|
}
|
|
2369
|
-
function
|
|
2370
|
-
const query = strings && Array.isArray(strings.raw) ? new Query(strings, args,
|
|
2369
|
+
function sql(strings, ...args) {
|
|
2370
|
+
const query = strings && Array.isArray(strings.raw) ? new Query(strings, args, handler, cancel) : typeof strings === "string" && !args.length ? new Identifier(options.transform.column.to ? options.transform.column.to(strings) : strings) : new Builder(strings, args);
|
|
2371
2371
|
return query;
|
|
2372
2372
|
}
|
|
2373
|
-
function unsafe(string, args = [],
|
|
2374
|
-
arguments.length === 2 && !Array.isArray(args) && (
|
|
2375
|
-
const query = new Query([string], args,
|
|
2373
|
+
function unsafe(string, args = [], options = {}) {
|
|
2374
|
+
arguments.length === 2 && !Array.isArray(args) && (options = args, args = []);
|
|
2375
|
+
const query = new Query([string], args, handler, cancel, {
|
|
2376
2376
|
prepare: false,
|
|
2377
|
-
...
|
|
2378
|
-
simple: "simple" in
|
|
2377
|
+
...options,
|
|
2378
|
+
simple: "simple" in options ? options.simple : args.length === 0
|
|
2379
2379
|
});
|
|
2380
2380
|
return query;
|
|
2381
2381
|
}
|
|
2382
|
-
function file(path, args = [],
|
|
2383
|
-
arguments.length === 2 && !Array.isArray(args) && (
|
|
2384
|
-
const query = new Query([], args, (
|
|
2382
|
+
function file(path, args = [], options = {}) {
|
|
2383
|
+
arguments.length === 2 && !Array.isArray(args) && (options = args, args = []);
|
|
2384
|
+
const query = new Query([], args, (query) => {
|
|
2385
2385
|
fs.readFile(path, "utf8", (err, string) => {
|
|
2386
2386
|
if (err)
|
|
2387
|
-
return
|
|
2388
|
-
|
|
2389
|
-
|
|
2387
|
+
return query.reject(err);
|
|
2388
|
+
query.strings = [string];
|
|
2389
|
+
handler(query);
|
|
2390
2390
|
});
|
|
2391
2391
|
}, cancel, {
|
|
2392
|
-
...
|
|
2393
|
-
simple: "simple" in
|
|
2392
|
+
...options,
|
|
2393
|
+
simple: "simple" in options ? options.simple : args.length === 0
|
|
2394
2394
|
});
|
|
2395
2395
|
return query;
|
|
2396
2396
|
}
|
|
2397
2397
|
}
|
|
2398
2398
|
async function listen(name, fn, onlisten) {
|
|
2399
2399
|
const listener = { fn, onlisten };
|
|
2400
|
-
const
|
|
2400
|
+
const sql = listen.sql || (listen.sql = Postgres({
|
|
2401
2401
|
...options,
|
|
2402
2402
|
max: 1,
|
|
2403
2403
|
idle_timeout: null,
|
|
2404
2404
|
max_lifetime: null,
|
|
2405
2405
|
fetch_types: false,
|
|
2406
2406
|
onclose() {
|
|
2407
|
-
Object.entries(listen.channels).forEach(([
|
|
2408
|
-
delete listen.channels[
|
|
2409
|
-
Promise.all(listeners.map((l) => listen(
|
|
2407
|
+
Object.entries(listen.channels).forEach(([name, { listeners }]) => {
|
|
2408
|
+
delete listen.channels[name];
|
|
2409
|
+
Promise.all(listeners.map((l) => listen(name, l.fn, l.onlisten).catch(() => {})));
|
|
2410
2410
|
});
|
|
2411
2411
|
},
|
|
2412
2412
|
onnotify(c, x) {
|
|
@@ -2416,11 +2416,11 @@ function Postgres(a, b2) {
|
|
|
2416
2416
|
const channels = listen.channels || (listen.channels = {}), exists = name in channels;
|
|
2417
2417
|
if (exists) {
|
|
2418
2418
|
channels[name].listeners.push(listener);
|
|
2419
|
-
const
|
|
2419
|
+
const result = await channels[name].result;
|
|
2420
2420
|
listener.onlisten && listener.onlisten();
|
|
2421
|
-
return { state:
|
|
2421
|
+
return { state: result.state, unlisten };
|
|
2422
2422
|
}
|
|
2423
|
-
channels[name] = { result:
|
|
2423
|
+
channels[name] = { result: sql`listen ${sql.unsafe('"' + name.replace(/"/g, '""') + '"')}`, listeners: [listener] };
|
|
2424
2424
|
const result = await channels[name].result;
|
|
2425
2425
|
listener.onlisten && listener.onlisten();
|
|
2426
2426
|
return { state: result.state, unlisten };
|
|
@@ -2431,11 +2431,11 @@ function Postgres(a, b2) {
|
|
|
2431
2431
|
if (channels[name].listeners.length)
|
|
2432
2432
|
return;
|
|
2433
2433
|
delete channels[name];
|
|
2434
|
-
return
|
|
2434
|
+
return sql`unlisten ${sql.unsafe('"' + name.replace(/"/g, '""') + '"')}`;
|
|
2435
2435
|
}
|
|
2436
2436
|
}
|
|
2437
2437
|
async function notify(channel, payload) {
|
|
2438
|
-
return await
|
|
2438
|
+
return await sql`select pg_notify(${channel}, ${"" + payload})`;
|
|
2439
2439
|
}
|
|
2440
2440
|
async function reserve() {
|
|
2441
2441
|
const queue = queue_default();
|
|
@@ -2447,65 +2447,65 @@ function Postgres(a, b2) {
|
|
|
2447
2447
|
move(c, reserved);
|
|
2448
2448
|
c.reserved = () => queue.length ? c.execute(queue.shift()) : move(c, reserved);
|
|
2449
2449
|
c.reserved.release = true;
|
|
2450
|
-
const
|
|
2451
|
-
|
|
2450
|
+
const sql = Sql(handler);
|
|
2451
|
+
sql.release = () => {
|
|
2452
2452
|
c.reserved = null;
|
|
2453
2453
|
onopen(c);
|
|
2454
2454
|
};
|
|
2455
|
-
return
|
|
2456
|
-
function
|
|
2455
|
+
return sql;
|
|
2456
|
+
function handler(q) {
|
|
2457
2457
|
c.queue === full ? queue.push(q) : c.execute(q) || move(c, full);
|
|
2458
2458
|
}
|
|
2459
2459
|
}
|
|
2460
|
-
async function begin(
|
|
2461
|
-
!fn && (fn =
|
|
2462
|
-
const
|
|
2463
|
-
let savepoints = 0,
|
|
2460
|
+
async function begin(options, fn) {
|
|
2461
|
+
!fn && (fn = options, options = "");
|
|
2462
|
+
const queries = queue_default();
|
|
2463
|
+
let savepoints = 0, connection, prepare = null;
|
|
2464
2464
|
try {
|
|
2465
|
-
await
|
|
2465
|
+
await sql.unsafe("begin " + options.replace(/[^a-z ]/ig, ""), [], { onexecute }).execute();
|
|
2466
2466
|
return await Promise.race([
|
|
2467
|
-
scope(
|
|
2468
|
-
new Promise((_, reject) =>
|
|
2467
|
+
scope(connection, fn),
|
|
2468
|
+
new Promise((_, reject) => connection.onclose = reject)
|
|
2469
2469
|
]);
|
|
2470
2470
|
} catch (error) {
|
|
2471
2471
|
throw error;
|
|
2472
2472
|
}
|
|
2473
|
-
async function scope(c,
|
|
2474
|
-
const
|
|
2475
|
-
|
|
2476
|
-
|
|
2473
|
+
async function scope(c, fn, name) {
|
|
2474
|
+
const sql = Sql(handler);
|
|
2475
|
+
sql.savepoint = savepoint;
|
|
2476
|
+
sql.prepare = (x) => prepare = x.replace(/[^a-z0-9$-_. ]/gi);
|
|
2477
2477
|
let uncaughtError, result;
|
|
2478
|
-
name && await
|
|
2478
|
+
name && await sql`savepoint ${sql(name)}`;
|
|
2479
2479
|
try {
|
|
2480
2480
|
result = await new Promise((resolve, reject) => {
|
|
2481
|
-
const x =
|
|
2481
|
+
const x = fn(sql);
|
|
2482
2482
|
Promise.resolve(Array.isArray(x) ? Promise.all(x) : x).then(resolve, reject);
|
|
2483
2483
|
});
|
|
2484
2484
|
if (uncaughtError)
|
|
2485
2485
|
throw uncaughtError;
|
|
2486
2486
|
} catch (e) {
|
|
2487
|
-
await (name ?
|
|
2487
|
+
await (name ? sql`rollback to ${sql(name)}` : sql`rollback`);
|
|
2488
2488
|
throw e instanceof PostgresError && e.code === "25P02" && uncaughtError || e;
|
|
2489
2489
|
}
|
|
2490
2490
|
if (!name) {
|
|
2491
|
-
prepare ? await
|
|
2491
|
+
prepare ? await sql`prepare transaction '${sql.unsafe(prepare)}'` : await sql`commit`;
|
|
2492
2492
|
}
|
|
2493
2493
|
return result;
|
|
2494
|
-
function savepoint(
|
|
2495
|
-
if (
|
|
2496
|
-
return savepoint((
|
|
2497
|
-
arguments.length === 1 && (
|
|
2498
|
-
return scope(c,
|
|
2494
|
+
function savepoint(name, fn) {
|
|
2495
|
+
if (name && Array.isArray(name.raw))
|
|
2496
|
+
return savepoint((sql) => sql.apply(sql, arguments));
|
|
2497
|
+
arguments.length === 1 && (fn = name, name = null);
|
|
2498
|
+
return scope(c, fn, "s" + savepoints++ + (name ? "_" + name : ""));
|
|
2499
2499
|
}
|
|
2500
|
-
function
|
|
2500
|
+
function handler(q) {
|
|
2501
2501
|
q.catch((e) => uncaughtError || (uncaughtError = e));
|
|
2502
|
-
c.queue === full ?
|
|
2502
|
+
c.queue === full ? queries.push(q) : c.execute(q) || move(c, full);
|
|
2503
2503
|
}
|
|
2504
2504
|
}
|
|
2505
2505
|
function onexecute(c) {
|
|
2506
|
-
|
|
2506
|
+
connection = c;
|
|
2507
2507
|
move(c, reserved);
|
|
2508
|
-
c.reserved = () =>
|
|
2508
|
+
c.reserved = () => queries.length ? c.execute(queries.shift()) : move(c, reserved);
|
|
2509
2509
|
}
|
|
2510
2510
|
}
|
|
2511
2511
|
function move(c, queue) {
|
|
@@ -2544,11 +2544,11 @@ function Postgres(a, b2) {
|
|
|
2544
2544
|
if (ending)
|
|
2545
2545
|
return ending;
|
|
2546
2546
|
await 1;
|
|
2547
|
-
let
|
|
2547
|
+
let timer;
|
|
2548
2548
|
return ending = Promise.race([
|
|
2549
|
-
new Promise((r) => timeout !== null && (
|
|
2549
|
+
new Promise((r) => timeout !== null && (timer = setTimeout(destroy, timeout * 1000, r))),
|
|
2550
2550
|
Promise.all(connections.map((c) => c.end()).concat(listen.sql ? listen.sql.end({ timeout: 0 }) : [], subscribe.sql ? subscribe.sql.end({ timeout: 0 }) : []))
|
|
2551
|
-
]).then(() => clearTimeout(
|
|
2551
|
+
]).then(() => clearTimeout(timer));
|
|
2552
2552
|
}
|
|
2553
2553
|
async function close() {
|
|
2554
2554
|
await Promise.all(connections.map((c) => c.end()));
|
|
@@ -2587,10 +2587,10 @@ function Postgres(a, b2) {
|
|
|
2587
2587
|
queries.length && connect(c, queries.shift());
|
|
2588
2588
|
}
|
|
2589
2589
|
}
|
|
2590
|
-
function parseOptions(a,
|
|
2590
|
+
function parseOptions(a, b) {
|
|
2591
2591
|
if (a && a.shared)
|
|
2592
2592
|
return a;
|
|
2593
|
-
const env = process.env, o = (!a || typeof a === "string" ?
|
|
2593
|
+
const env = process.env, o = (!a || typeof a === "string" ? b : a) || {}, { url, multihost } = parseUrl(a), query = [...url.searchParams].reduce((a, [b, c]) => (a[b] = c, a), {}), host = o.hostname || o.host || multihost || url.hostname || env.PGHOST || "localhost", port = o.port || url.port || env.PGPORT || 5432, user = o.user || o.username || url.username || env.PGUSERNAME || env.PGUSER || osUsername();
|
|
2594
2594
|
o.no_prepare && (o.prepare = false);
|
|
2595
2595
|
query.sslmode && (query.ssl = query.sslmode, delete query.sslmode);
|
|
2596
2596
|
"timeout" in o && (console.log("The timeout option is deprecated, use idle_timeout instead"), o.idle_timeout = o.timeout);
|