@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
|
@@ -960,44 +960,44 @@ class Builder extends NotTagged {
|
|
|
960
960
|
this.first = first;
|
|
961
961
|
this.rest = rest;
|
|
962
962
|
}
|
|
963
|
-
build(before, parameters,
|
|
963
|
+
build(before, parameters, types, options) {
|
|
964
964
|
const keyword = builders.map(([x, fn]) => ({ fn, i: before.search(x) })).sort((a, b) => a.i - b.i).pop();
|
|
965
|
-
return keyword.i === -1 ? escapeIdentifiers(this.first, options) : keyword.fn(this.first, this.rest, parameters,
|
|
965
|
+
return keyword.i === -1 ? escapeIdentifiers(this.first, options) : keyword.fn(this.first, this.rest, parameters, types, options);
|
|
966
966
|
}
|
|
967
967
|
}
|
|
968
|
-
function handleValue(x, parameters,
|
|
968
|
+
function handleValue(x, parameters, types, options) {
|
|
969
969
|
let value = x instanceof Parameter ? x.value : x;
|
|
970
970
|
if (value === undefined) {
|
|
971
971
|
x instanceof Parameter ? x.value = options.transform.undefined : value = x = options.transform.undefined;
|
|
972
972
|
if (value === undefined)
|
|
973
973
|
throw Errors.generic("UNDEFINED_VALUE", "Undefined values are not allowed");
|
|
974
974
|
}
|
|
975
|
-
return "$" +
|
|
975
|
+
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)));
|
|
976
976
|
}
|
|
977
977
|
var defaultHandlers = typeHandlers(types);
|
|
978
|
-
function stringify(q, string, value, parameters,
|
|
978
|
+
function stringify(q, string, value, parameters, types, options) {
|
|
979
979
|
for (let i = 1;i < q.strings.length; i++) {
|
|
980
|
-
string += stringifyValue(string, value, parameters,
|
|
980
|
+
string += stringifyValue(string, value, parameters, types, options) + q.strings[i];
|
|
981
981
|
value = q.args[i];
|
|
982
982
|
}
|
|
983
983
|
return string;
|
|
984
984
|
}
|
|
985
|
-
function stringifyValue(string, value, parameters,
|
|
986
|
-
return value instanceof Builder ? value.build(string, parameters,
|
|
985
|
+
function stringifyValue(string, value, parameters, types, o) {
|
|
986
|
+
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);
|
|
987
987
|
}
|
|
988
|
-
function fragment(q, parameters,
|
|
988
|
+
function fragment(q, parameters, types, options) {
|
|
989
989
|
q.fragment = true;
|
|
990
|
-
return stringify(q, q.strings[0], q.args[0], parameters,
|
|
990
|
+
return stringify(q, q.strings[0], q.args[0], parameters, types, options);
|
|
991
991
|
}
|
|
992
|
-
function valuesBuilder(first, parameters,
|
|
993
|
-
return first.map((row) => "(" + columns.map((column) => stringifyValue("values", row[column], parameters,
|
|
992
|
+
function valuesBuilder(first, parameters, types, columns, options) {
|
|
993
|
+
return first.map((row) => "(" + columns.map((column) => stringifyValue("values", row[column], parameters, types, options)).join(",") + ")").join(",");
|
|
994
994
|
}
|
|
995
|
-
function values(first, rest, parameters,
|
|
995
|
+
function values(first, rest, parameters, types, options) {
|
|
996
996
|
const multi = Array.isArray(first[0]);
|
|
997
997
|
const columns = rest.length ? rest.flat() : Object.keys(multi ? first[0] : first);
|
|
998
|
-
return valuesBuilder(multi ? first : [first], parameters,
|
|
998
|
+
return valuesBuilder(multi ? first : [first], parameters, types, columns, options);
|
|
999
999
|
}
|
|
1000
|
-
function select(first, rest, parameters,
|
|
1000
|
+
function select(first, rest, parameters, types, options) {
|
|
1001
1001
|
typeof first === "string" && (first = [first].concat(rest));
|
|
1002
1002
|
if (Array.isArray(first))
|
|
1003
1003
|
return escapeIdentifiers(first, options);
|
|
@@ -1005,7 +1005,7 @@ function select(first, rest, parameters, types2, options) {
|
|
|
1005
1005
|
const columns = rest.length ? rest.flat() : Object.keys(first);
|
|
1006
1006
|
return columns.map((x) => {
|
|
1007
1007
|
value = first[x];
|
|
1008
|
-
return (value instanceof Query ? fragment(value, parameters,
|
|
1008
|
+
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);
|
|
1009
1009
|
}).join(",");
|
|
1010
1010
|
}
|
|
1011
1011
|
var builders = Object.entries({
|
|
@@ -1018,12 +1018,12 @@ var builders = Object.entries({
|
|
|
1018
1018
|
as: select,
|
|
1019
1019
|
returning: select,
|
|
1020
1020
|
"\\(": select,
|
|
1021
|
-
update(first, rest, parameters,
|
|
1022
|
-
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,
|
|
1021
|
+
update(first, rest, parameters, types, options) {
|
|
1022
|
+
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));
|
|
1023
1023
|
},
|
|
1024
|
-
insert(first, rest, parameters,
|
|
1024
|
+
insert(first, rest, parameters, types, options) {
|
|
1025
1025
|
const columns = rest.length ? rest.flat() : Object.keys(Array.isArray(first) ? first[0] : first);
|
|
1026
|
-
return "(" + escapeIdentifiers(columns, options) + ")values" + valuesBuilder(Array.isArray(first) ? first : [first], parameters,
|
|
1026
|
+
return "(" + escapeIdentifiers(columns, options) + ")values" + valuesBuilder(Array.isArray(first) ? first : [first], parameters, types, columns, options);
|
|
1027
1027
|
}
|
|
1028
1028
|
}).map(([x, fn]) => [new RegExp("((?:^|[\\s(])" + x + "(?:$|[\\s(]))(?![\\s\\S]*\\1)", "i"), fn]);
|
|
1029
1029
|
function notTagged() {
|
|
@@ -1036,19 +1036,19 @@ function firstIsString(x) {
|
|
|
1036
1036
|
return firstIsString(x[0]);
|
|
1037
1037
|
return typeof x === "string" ? 1009 : 0;
|
|
1038
1038
|
}
|
|
1039
|
-
var mergeUserTypes = function(
|
|
1040
|
-
const user = typeHandlers(
|
|
1039
|
+
var mergeUserTypes = function(types) {
|
|
1040
|
+
const user = typeHandlers(types || {});
|
|
1041
1041
|
return {
|
|
1042
1042
|
serializers: Object.assign({}, serializers, user.serializers),
|
|
1043
1043
|
parsers: Object.assign({}, parsers, user.parsers)
|
|
1044
1044
|
};
|
|
1045
1045
|
};
|
|
1046
|
-
function typeHandlers(
|
|
1047
|
-
return Object.keys(
|
|
1048
|
-
|
|
1049
|
-
if (
|
|
1050
|
-
acc.serializers[
|
|
1051
|
-
|
|
1046
|
+
function typeHandlers(types) {
|
|
1047
|
+
return Object.keys(types).reduce((acc, k) => {
|
|
1048
|
+
types[k].from && [].concat(types[k].from).forEach((x) => acc.parsers[x] = types[k].parse);
|
|
1049
|
+
if (types[k].serialize) {
|
|
1050
|
+
acc.serializers[types[k].to] = types[k].serialize;
|
|
1051
|
+
types[k].from && [].concat(types[k].from).forEach((x) => acc.serializers[x] = types[k].serialize);
|
|
1052
1052
|
}
|
|
1053
1053
|
return acc;
|
|
1054
1054
|
}, { parsers: {}, serializers: {} });
|
|
@@ -1059,15 +1059,15 @@ function escapeIdentifiers(xs, { transform: { column } }) {
|
|
|
1059
1059
|
var escapeIdentifier = function escape(str) {
|
|
1060
1060
|
return '"' + str.replace(/"/g, '""').replace(/\./g, '"."') + '"';
|
|
1061
1061
|
};
|
|
1062
|
-
var inferType = function
|
|
1063
|
-
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) ?
|
|
1062
|
+
var inferType = function inferType(x) {
|
|
1063
|
+
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;
|
|
1064
1064
|
};
|
|
1065
1065
|
var escapeBackslash = /\\/g;
|
|
1066
1066
|
var escapeQuote = /"/g;
|
|
1067
1067
|
function arrayEscape(x) {
|
|
1068
1068
|
return x.replace(escapeBackslash, "\\\\").replace(escapeQuote, "\\\"");
|
|
1069
1069
|
}
|
|
1070
|
-
var arraySerializer = function
|
|
1070
|
+
var arraySerializer = function arraySerializer(xs, serializer, options, typarray) {
|
|
1071
1071
|
if (Array.isArray(xs) === false)
|
|
1072
1072
|
return xs;
|
|
1073
1073
|
if (!xs.length)
|
|
@@ -1075,7 +1075,7 @@ var arraySerializer = function arraySerializer2(xs, serializer, options, typarra
|
|
|
1075
1075
|
const first = xs[0];
|
|
1076
1076
|
const delimiter = typarray === 1020 ? ";" : ",";
|
|
1077
1077
|
if (Array.isArray(first) && !first.type)
|
|
1078
|
-
return "{" + xs.map((x) =>
|
|
1078
|
+
return "{" + xs.map((x) => arraySerializer(x, serializer, options, typarray)).join(delimiter) + "}";
|
|
1079
1079
|
return "{" + xs.map((x) => {
|
|
1080
1080
|
if (x === undefined) {
|
|
1081
1081
|
x = options.transform.undefined;
|
|
@@ -1092,7 +1092,7 @@ var arrayParserState = {
|
|
|
1092
1092
|
quoted: false,
|
|
1093
1093
|
last: 0
|
|
1094
1094
|
};
|
|
1095
|
-
var arrayParser = function
|
|
1095
|
+
var arrayParser = function arrayParser(x, parser, typarray) {
|
|
1096
1096
|
arrayParserState.i = arrayParserState.last = 0;
|
|
1097
1097
|
return arrayParserLoop(arrayParserState, x, parser, typarray);
|
|
1098
1098
|
};
|
|
@@ -1149,7 +1149,7 @@ var fromPascal = (x) => (x.slice(0, 1) + x.slice(1).replace(/([A-Z])/g, "_$1")).
|
|
|
1149
1149
|
var fromKebab = (x) => x.replace(/-/g, "_");
|
|
1150
1150
|
function createJsonTransform(fn) {
|
|
1151
1151
|
return function jsonTransform(x, column) {
|
|
1152
|
-
return typeof x === "object" && x !== null && (column.type === 114 || column.type === 3802) ? Array.isArray(x) ? x.map((
|
|
1152
|
+
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;
|
|
1153
1153
|
};
|
|
1154
1154
|
}
|
|
1155
1155
|
toCamel.column = { from: toCamel };
|
|
@@ -1196,23 +1196,23 @@ class Result extends Array {
|
|
|
1196
1196
|
var queue_default = Queue;
|
|
1197
1197
|
function Queue(initial = []) {
|
|
1198
1198
|
let xs = initial.slice();
|
|
1199
|
-
let
|
|
1199
|
+
let index = 0;
|
|
1200
1200
|
return {
|
|
1201
1201
|
get length() {
|
|
1202
|
-
return xs.length -
|
|
1202
|
+
return xs.length - index;
|
|
1203
1203
|
},
|
|
1204
1204
|
remove: (x) => {
|
|
1205
|
-
const
|
|
1206
|
-
return
|
|
1205
|
+
const index = xs.indexOf(x);
|
|
1206
|
+
return index === -1 ? null : (xs.splice(index, 1), x);
|
|
1207
1207
|
},
|
|
1208
1208
|
push: (x) => (xs.push(x), x),
|
|
1209
1209
|
shift: () => {
|
|
1210
|
-
const out = xs[
|
|
1211
|
-
if (
|
|
1212
|
-
|
|
1210
|
+
const out = xs[index++];
|
|
1211
|
+
if (index === xs.length) {
|
|
1212
|
+
index = 0;
|
|
1213
1213
|
xs = [];
|
|
1214
1214
|
} else {
|
|
1215
|
-
xs[
|
|
1215
|
+
xs[index - 1] = undefined;
|
|
1216
1216
|
}
|
|
1217
1217
|
return out;
|
|
1218
1218
|
}
|
|
@@ -1335,7 +1335,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1335
1335
|
host,
|
|
1336
1336
|
port,
|
|
1337
1337
|
database,
|
|
1338
|
-
parsers
|
|
1338
|
+
parsers,
|
|
1339
1339
|
transform,
|
|
1340
1340
|
onnotice,
|
|
1341
1341
|
onnotify,
|
|
@@ -1347,11 +1347,11 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1347
1347
|
} = options;
|
|
1348
1348
|
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);
|
|
1349
1349
|
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;
|
|
1350
|
-
const
|
|
1350
|
+
const connection = {
|
|
1351
1351
|
queue: queues.closed,
|
|
1352
1352
|
idleTimer,
|
|
1353
|
-
connect(
|
|
1354
|
-
initial =
|
|
1353
|
+
connect(query) {
|
|
1354
|
+
initial = query;
|
|
1355
1355
|
reconnect();
|
|
1356
1356
|
},
|
|
1357
1357
|
terminate,
|
|
@@ -1361,8 +1361,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1361
1361
|
count: 0,
|
|
1362
1362
|
id
|
|
1363
1363
|
};
|
|
1364
|
-
queues.closed && queues.closed.push(
|
|
1365
|
-
return
|
|
1364
|
+
queues.closed && queues.closed.push(connection);
|
|
1365
|
+
return connection;
|
|
1366
1366
|
async function createSocket() {
|
|
1367
1367
|
let x;
|
|
1368
1368
|
try {
|
|
@@ -1382,8 +1382,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1382
1382
|
await connect();
|
|
1383
1383
|
socket.once("error", reject);
|
|
1384
1384
|
socket.once("close", resolve);
|
|
1385
|
-
} catch (
|
|
1386
|
-
reject(
|
|
1385
|
+
} catch (error) {
|
|
1386
|
+
reject(error);
|
|
1387
1387
|
}
|
|
1388
1388
|
}
|
|
1389
1389
|
function execute(q) {
|
|
@@ -1397,10 +1397,10 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1397
1397
|
q.state = backend;
|
|
1398
1398
|
query ? sent.push(q) : (query = q, query.active = true);
|
|
1399
1399
|
build(q);
|
|
1400
|
-
return write(toBuffer(q)) && !q.describeFirst && !q.cursorFn && sent.length < max_pipeline && (!q.options.onexecute || q.options.onexecute(
|
|
1401
|
-
} catch (
|
|
1400
|
+
return write(toBuffer(q)) && !q.describeFirst && !q.cursorFn && sent.length < max_pipeline && (!q.options.onexecute || q.options.onexecute(connection));
|
|
1401
|
+
} catch (error) {
|
|
1402
1402
|
sent.length === 0 && write(Sync);
|
|
1403
|
-
errored(
|
|
1403
|
+
errored(error);
|
|
1404
1404
|
return true;
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
@@ -1429,18 +1429,18 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1429
1429
|
]);
|
|
1430
1430
|
}
|
|
1431
1431
|
function build(q) {
|
|
1432
|
-
const parameters = [],
|
|
1433
|
-
const string = stringify(q, q.strings[0], q.args[0], parameters,
|
|
1434
|
-
!q.tagged && q.args.forEach((x) => handleValue(x, parameters,
|
|
1432
|
+
const parameters = [], types = [];
|
|
1433
|
+
const string = stringify(q, q.strings[0], q.args[0], parameters, types, options);
|
|
1434
|
+
!q.tagged && q.args.forEach((x) => handleValue(x, parameters, types, options));
|
|
1435
1435
|
q.prepare = options.prepare && ("prepare" in q.options ? q.options.prepare : true);
|
|
1436
1436
|
q.string = string;
|
|
1437
|
-
q.signature = q.prepare &&
|
|
1437
|
+
q.signature = q.prepare && types + string;
|
|
1438
1438
|
q.onlyDescribe && delete statements[q.signature];
|
|
1439
1439
|
q.parameters = q.parameters || parameters;
|
|
1440
1440
|
q.prepared = q.prepare && q.signature in statements;
|
|
1441
1441
|
q.describeFirst = q.onlyDescribe || parameters.length && !q.prepared;
|
|
1442
|
-
q.statement = q.prepared ? statements[q.signature] : { string, types
|
|
1443
|
-
typeof options.debug === "function" && options.debug(id, string, parameters,
|
|
1442
|
+
q.statement = q.prepared ? statements[q.signature] : { string, types, name: q.prepare ? statementId + statementCount++ : "" };
|
|
1443
|
+
typeof options.debug === "function" && options.debug(id, string, parameters, types);
|
|
1444
1444
|
}
|
|
1445
1445
|
function write(x, fn) {
|
|
1446
1446
|
chunk = chunk ? Buffer.concat([chunk, x]) : Buffer.from(x);
|
|
@@ -1466,25 +1466,25 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1466
1466
|
if (!canSSL && ssl === "prefer")
|
|
1467
1467
|
return connected();
|
|
1468
1468
|
}
|
|
1469
|
-
const
|
|
1469
|
+
const options = {
|
|
1470
1470
|
socket,
|
|
1471
1471
|
servername: net.isIP(socket.host) ? undefined : socket.host
|
|
1472
1472
|
};
|
|
1473
1473
|
if (sslnegotiation === "direct")
|
|
1474
|
-
|
|
1474
|
+
options.ALPNProtocols = ["postgresql"];
|
|
1475
1475
|
if (ssl === "require" || ssl === "allow" || ssl === "prefer")
|
|
1476
|
-
|
|
1476
|
+
options.rejectUnauthorized = false;
|
|
1477
1477
|
else if (typeof ssl === "object")
|
|
1478
|
-
Object.assign(
|
|
1478
|
+
Object.assign(options, ssl);
|
|
1479
1479
|
socket.removeAllListeners();
|
|
1480
|
-
socket = tls.connect(
|
|
1480
|
+
socket = tls.connect(options);
|
|
1481
1481
|
socket.on("secureConnect", connected);
|
|
1482
1482
|
socket.on("error", error);
|
|
1483
1483
|
socket.on("close", closed);
|
|
1484
1484
|
socket.on("drain", drain);
|
|
1485
1485
|
}
|
|
1486
1486
|
function drain() {
|
|
1487
|
-
!query && onopen(
|
|
1487
|
+
!query && onopen(connection);
|
|
1488
1488
|
}
|
|
1489
1489
|
function data(x) {
|
|
1490
1490
|
if (incomings) {
|
|
@@ -1549,7 +1549,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1549
1549
|
}
|
|
1550
1550
|
}
|
|
1551
1551
|
function error(err) {
|
|
1552
|
-
if (
|
|
1552
|
+
if (connection.queue === queues.connecting && options.host[retries + 1])
|
|
1553
1553
|
return;
|
|
1554
1554
|
errored(err);
|
|
1555
1555
|
while (sent.length)
|
|
@@ -1560,23 +1560,23 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1560
1560
|
query && queryError(query, err);
|
|
1561
1561
|
initial && (queryError(initial, err), initial = null);
|
|
1562
1562
|
}
|
|
1563
|
-
function queryError(
|
|
1564
|
-
if (
|
|
1565
|
-
return
|
|
1563
|
+
function queryError(query, err) {
|
|
1564
|
+
if (query.reserve)
|
|
1565
|
+
return query.reject(err);
|
|
1566
1566
|
if (!err || typeof err !== "object")
|
|
1567
1567
|
err = new Error(err);
|
|
1568
1568
|
"query" in err || "parameters" in err || Object.defineProperties(err, {
|
|
1569
|
-
stack: { value: err.stack +
|
|
1569
|
+
stack: { value: err.stack + query.origin.replace(/.*\n/, `
|
|
1570
1570
|
`), enumerable: options.debug },
|
|
1571
|
-
query: { value:
|
|
1572
|
-
parameters: { value:
|
|
1573
|
-
args: { value:
|
|
1574
|
-
types: { value:
|
|
1571
|
+
query: { value: query.string, enumerable: options.debug },
|
|
1572
|
+
parameters: { value: query.parameters, enumerable: options.debug },
|
|
1573
|
+
args: { value: query.args, enumerable: options.debug },
|
|
1574
|
+
types: { value: query.statement && query.statement.types, enumerable: options.debug }
|
|
1575
1575
|
});
|
|
1576
|
-
|
|
1576
|
+
query.reject(err);
|
|
1577
1577
|
}
|
|
1578
1578
|
function end() {
|
|
1579
|
-
return ending || (!
|
|
1579
|
+
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));
|
|
1580
1580
|
}
|
|
1581
1581
|
function terminate() {
|
|
1582
1582
|
terminated = true;
|
|
@@ -1608,22 +1608,22 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1608
1608
|
closedTime = performance.now();
|
|
1609
1609
|
hadError && options.shared.retries++;
|
|
1610
1610
|
delay = (typeof backoff === "function" ? backoff(options.shared.retries) : backoff) * 1000;
|
|
1611
|
-
onclose(
|
|
1611
|
+
onclose(connection, Errors.connection("CONNECTION_CLOSED", options, socket));
|
|
1612
1612
|
}
|
|
1613
1613
|
function handle(xs, x = xs[0]) {
|
|
1614
1614
|
(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);
|
|
1615
1615
|
}
|
|
1616
1616
|
function DataRow(x) {
|
|
1617
|
-
let
|
|
1618
|
-
let
|
|
1617
|
+
let index = 7;
|
|
1618
|
+
let length;
|
|
1619
1619
|
let column;
|
|
1620
1620
|
let value;
|
|
1621
1621
|
const row = query.isRaw ? new Array(query.statement.columns.length) : {};
|
|
1622
1622
|
for (let i = 0;i < query.statement.columns.length; i++) {
|
|
1623
1623
|
column = query.statement.columns[i];
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
value =
|
|
1624
|
+
length = x.readInt32BE(index);
|
|
1625
|
+
index += 4;
|
|
1626
|
+
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));
|
|
1627
1627
|
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;
|
|
1628
1628
|
}
|
|
1629
1629
|
query.forEachFn ? query.forEachFn(transform.row.from ? transform.row.from(row) : row, result) : result[rows++] = transform.row.from ? transform.row.from(row) : row;
|
|
@@ -1669,7 +1669,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1669
1669
|
Connection(options).cancel(query.state, query.cancelled.resolve, query.cancelled.reject);
|
|
1670
1670
|
if (query)
|
|
1671
1671
|
return;
|
|
1672
|
-
|
|
1672
|
+
connection.reserved ? !connection.reserved.release && x[5] === 73 ? ending ? terminate() : (connection.reserved = null, onopen(connection)) : connection.reserved() : ending ? terminate() : onopen(connection);
|
|
1673
1673
|
}
|
|
1674
1674
|
function CommandComplete(x) {
|
|
1675
1675
|
rows = 0;
|
|
@@ -1683,7 +1683,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1683
1683
|
}
|
|
1684
1684
|
}
|
|
1685
1685
|
final && (final(), final = null);
|
|
1686
|
-
if (result.command === "BEGIN" && max !== 1 && !
|
|
1686
|
+
if (result.command === "BEGIN" && max !== 1 && !connection.reserved)
|
|
1687
1687
|
return errored(Errors.generic("UNSAFE_TRANSACTION", "Only use sql.begin, sql.reserved or max: 1"));
|
|
1688
1688
|
if (query.options.simple)
|
|
1689
1689
|
return BindComplete();
|
|
@@ -1700,8 +1700,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1700
1700
|
result.columns = query.statement.columns;
|
|
1701
1701
|
}
|
|
1702
1702
|
function ParameterDescription(x) {
|
|
1703
|
-
const
|
|
1704
|
-
for (let i = 0;i <
|
|
1703
|
+
const length = x.readUInt16BE(5);
|
|
1704
|
+
for (let i = 0;i < length; ++i)
|
|
1705
1705
|
!query.statement.types[i] && (query.statement.types[i] = x.readUInt32BE(7 + i * 4));
|
|
1706
1706
|
query.prepare && (statements[query.signature] = query.statement);
|
|
1707
1707
|
query.describeFirst && !query.onlyDescribe && (write(prepared(query)), query.describeFirst = false);
|
|
@@ -1713,25 +1713,25 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1713
1713
|
result.count = null;
|
|
1714
1714
|
query.statement.columns = null;
|
|
1715
1715
|
}
|
|
1716
|
-
const
|
|
1717
|
-
let
|
|
1716
|
+
const length = x.readUInt16BE(5);
|
|
1717
|
+
let index = 7;
|
|
1718
1718
|
let start;
|
|
1719
|
-
query.statement.columns = Array(
|
|
1720
|
-
for (let i = 0;i <
|
|
1721
|
-
start =
|
|
1722
|
-
while (x[
|
|
1719
|
+
query.statement.columns = Array(length);
|
|
1720
|
+
for (let i = 0;i < length; ++i) {
|
|
1721
|
+
start = index;
|
|
1722
|
+
while (x[index++] !== 0)
|
|
1723
1723
|
;
|
|
1724
|
-
const table = x.readUInt32BE(
|
|
1725
|
-
const number = x.readUInt16BE(
|
|
1726
|
-
const type = x.readUInt32BE(
|
|
1724
|
+
const table = x.readUInt32BE(index);
|
|
1725
|
+
const number = x.readUInt16BE(index + 4);
|
|
1726
|
+
const type = x.readUInt32BE(index + 6);
|
|
1727
1727
|
query.statement.columns[i] = {
|
|
1728
|
-
name: transform.column.from ? transform.column.from(x.toString("utf8", start,
|
|
1729
|
-
parser:
|
|
1728
|
+
name: transform.column.from ? transform.column.from(x.toString("utf8", start, index - 1)) : x.toString("utf8", start, index - 1),
|
|
1729
|
+
parser: parsers[type],
|
|
1730
1730
|
table,
|
|
1731
1731
|
number,
|
|
1732
1732
|
type
|
|
1733
1733
|
};
|
|
1734
|
-
|
|
1734
|
+
index += 18;
|
|
1735
1735
|
}
|
|
1736
1736
|
result.statement = query.statement;
|
|
1737
1737
|
if (query.onlyDescribe)
|
|
@@ -1758,7 +1758,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1758
1758
|
write(bytes_default.inc(4).str("n,,n=*,r=" + nonce).i32(bytes_default.i - i - 4, i).end());
|
|
1759
1759
|
}
|
|
1760
1760
|
async function SASLContinue(x) {
|
|
1761
|
-
const res = x.toString("utf8", 9).split(",").reduce((acc,
|
|
1761
|
+
const res = x.toString("utf8", 9).split(",").reduce((acc, x) => (acc[x[0]] = x.slice(2), acc), {});
|
|
1762
1762
|
const saltedPassword = await crypto.pbkdf2Sync(await Pass(), Buffer.from(res.s, "base64"), parseInt(res.i), 32, "sha256");
|
|
1763
1763
|
const clientKey = await hmac(saltedPassword, "Client Key");
|
|
1764
1764
|
const auth = "n=*,r=" + nonce + "," + "r=" + res.r + ",s=" + res.s + ",i=" + res.i + ",c=biws,r=" + res.r;
|
|
@@ -1787,7 +1787,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1787
1787
|
}
|
|
1788
1788
|
async function fetchArrayTypes() {
|
|
1789
1789
|
needsTypes = false;
|
|
1790
|
-
const
|
|
1790
|
+
const types = await new Query([`
|
|
1791
1791
|
select b.oid, b.typarray
|
|
1792
1792
|
from pg_catalog.pg_type a
|
|
1793
1793
|
left join pg_catalog.pg_type b on b.oid = a.typelem
|
|
@@ -1795,7 +1795,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1795
1795
|
group by b.oid, b.typarray
|
|
1796
1796
|
order by b.oid
|
|
1797
1797
|
`], [], execute);
|
|
1798
|
-
|
|
1798
|
+
types.forEach(({ oid, typarray }) => addArrayType(oid, typarray));
|
|
1799
1799
|
}
|
|
1800
1800
|
function addArrayType(oid, typarray) {
|
|
1801
1801
|
if (!!options.parsers[typarray] && !!options.serializers[typarray])
|
|
@@ -1810,15 +1810,15 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1810
1810
|
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];
|
|
1811
1811
|
}
|
|
1812
1812
|
function fetchState() {
|
|
1813
|
-
const
|
|
1813
|
+
const query = new Query([`
|
|
1814
1814
|
show transaction_read_only;
|
|
1815
1815
|
select pg_catalog.pg_is_in_recovery()
|
|
1816
1816
|
`], [], execute, null, { simple: true });
|
|
1817
|
-
|
|
1817
|
+
query.resolve = ([[a], [b]]) => {
|
|
1818
1818
|
backendParameters.default_transaction_read_only = a.transaction_read_only;
|
|
1819
|
-
backendParameters.in_hot_standby =
|
|
1819
|
+
backendParameters.in_hot_standby = b.pg_is_in_recovery ? "on" : "off";
|
|
1820
1820
|
};
|
|
1821
|
-
|
|
1821
|
+
query.execute();
|
|
1822
1822
|
}
|
|
1823
1823
|
function ErrorResponse(x) {
|
|
1824
1824
|
if (query) {
|
|
@@ -1828,18 +1828,18 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1828
1828
|
errored(Errors.postgres(parseError(x)));
|
|
1829
1829
|
}
|
|
1830
1830
|
}
|
|
1831
|
-
function retry(q,
|
|
1831
|
+
function retry(q, error) {
|
|
1832
1832
|
delete statements[q.signature];
|
|
1833
|
-
q.retried =
|
|
1833
|
+
q.retried = error;
|
|
1834
1834
|
execute(q);
|
|
1835
1835
|
}
|
|
1836
1836
|
function NotificationResponse(x) {
|
|
1837
1837
|
if (!onnotify)
|
|
1838
1838
|
return;
|
|
1839
|
-
let
|
|
1840
|
-
while (x[
|
|
1839
|
+
let index = 9;
|
|
1840
|
+
while (x[index++] !== 0)
|
|
1841
1841
|
;
|
|
1842
|
-
onnotify(x.toString("utf8", 9,
|
|
1842
|
+
onnotify(x.toString("utf8", 9, index - 1), x.toString("utf8", index, x.length - 1));
|
|
1843
1843
|
}
|
|
1844
1844
|
async function PortalSuspended() {
|
|
1845
1845
|
try {
|
|
@@ -1858,12 +1858,12 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1858
1858
|
function CopyInResponse() {
|
|
1859
1859
|
stream = new Stream.Writable({
|
|
1860
1860
|
autoDestroy: true,
|
|
1861
|
-
write(
|
|
1862
|
-
socket.write(bytes_default().d().raw(
|
|
1861
|
+
write(chunk, encoding, callback) {
|
|
1862
|
+
socket.write(bytes_default().d().raw(chunk).end(), callback);
|
|
1863
1863
|
},
|
|
1864
|
-
destroy(
|
|
1865
|
-
callback(
|
|
1866
|
-
socket.write(bytes_default().f().str(
|
|
1864
|
+
destroy(error, callback) {
|
|
1865
|
+
callback(error);
|
|
1866
|
+
socket.write(bytes_default().f().str(error + bytes_default.N).end());
|
|
1867
1867
|
stream = null;
|
|
1868
1868
|
},
|
|
1869
1869
|
final(callback) {
|
|
@@ -1888,12 +1888,12 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1888
1888
|
read() {
|
|
1889
1889
|
socket.resume();
|
|
1890
1890
|
},
|
|
1891
|
-
write(
|
|
1892
|
-
socket.write(bytes_default().d().raw(
|
|
1891
|
+
write(chunk, encoding, callback) {
|
|
1892
|
+
socket.write(bytes_default().d().raw(chunk).end(), callback);
|
|
1893
1893
|
},
|
|
1894
|
-
destroy(
|
|
1895
|
-
callback(
|
|
1896
|
-
socket.write(bytes_default().f().str(
|
|
1894
|
+
destroy(error, callback) {
|
|
1895
|
+
callback(error);
|
|
1896
|
+
socket.write(bytes_default().f().str(error + bytes_default.N).end());
|
|
1897
1897
|
stream = null;
|
|
1898
1898
|
},
|
|
1899
1899
|
final(callback) {
|
|
@@ -1926,13 +1926,13 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1926
1926
|
function UnknownAuth(x, type) {
|
|
1927
1927
|
console.error("Postgres.js : Unknown Auth:", type);
|
|
1928
1928
|
}
|
|
1929
|
-
function Bind(parameters,
|
|
1929
|
+
function Bind(parameters, types, statement = "", portal = "") {
|
|
1930
1930
|
let prev, type;
|
|
1931
1931
|
bytes_default().B().str(portal + bytes_default.N).str(statement + bytes_default.N).i16(0).i16(parameters.length);
|
|
1932
1932
|
parameters.forEach((x, i) => {
|
|
1933
1933
|
if (x === null)
|
|
1934
1934
|
return bytes_default.i32(4294967295);
|
|
1935
|
-
type =
|
|
1935
|
+
type = types[i];
|
|
1936
1936
|
parameters[i] = x = type in options.serializers ? options.serializers[type](x) : "" + x;
|
|
1937
1937
|
prev = bytes_default.i;
|
|
1938
1938
|
bytes_default.inc(4).str(x).i32(bytes_default.i - prev - 4, prev);
|
|
@@ -1940,17 +1940,17 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1940
1940
|
bytes_default.i16(0);
|
|
1941
1941
|
return bytes_default.end();
|
|
1942
1942
|
}
|
|
1943
|
-
function Parse(str, parameters,
|
|
1943
|
+
function Parse(str, parameters, types, name = "") {
|
|
1944
1944
|
bytes_default().P().str(name + bytes_default.N).str(str + bytes_default.N).i16(parameters.length);
|
|
1945
|
-
parameters.forEach((x, i) => bytes_default.i32(
|
|
1945
|
+
parameters.forEach((x, i) => bytes_default.i32(types[i] || 0));
|
|
1946
1946
|
return bytes_default.end();
|
|
1947
1947
|
}
|
|
1948
1948
|
function Describe(x, name = "") {
|
|
1949
1949
|
return bytes_default().D().str(x).str(name + bytes_default.N).end();
|
|
1950
1950
|
}
|
|
1951
|
-
function Execute(portal = "",
|
|
1951
|
+
function Execute(portal = "", rows = 0) {
|
|
1952
1952
|
return Buffer.concat([
|
|
1953
|
-
bytes_default().E().str(portal + bytes_default.N).i32(
|
|
1953
|
+
bytes_default().E().str(portal + bytes_default.N).i32(rows).end(),
|
|
1954
1954
|
Flush
|
|
1955
1955
|
]);
|
|
1956
1956
|
}
|
|
@@ -1988,39 +1988,39 @@ function hmac(key, x) {
|
|
|
1988
1988
|
function sha256(x) {
|
|
1989
1989
|
return crypto.createHash("sha256").update(x).digest();
|
|
1990
1990
|
}
|
|
1991
|
-
function xor(a,
|
|
1992
|
-
const length = Math.max(a.length,
|
|
1993
|
-
const
|
|
1991
|
+
function xor(a, b) {
|
|
1992
|
+
const length = Math.max(a.length, b.length);
|
|
1993
|
+
const buffer = Buffer.allocUnsafe(length);
|
|
1994
1994
|
for (let i = 0;i < length; i++)
|
|
1995
|
-
|
|
1996
|
-
return
|
|
1995
|
+
buffer[i] = a[i] ^ b[i];
|
|
1996
|
+
return buffer;
|
|
1997
1997
|
}
|
|
1998
1998
|
function timer(fn, seconds) {
|
|
1999
1999
|
seconds = typeof seconds === "function" ? seconds() : seconds;
|
|
2000
2000
|
if (!seconds)
|
|
2001
2001
|
return { cancel: noop, start: noop };
|
|
2002
|
-
let
|
|
2002
|
+
let timer;
|
|
2003
2003
|
return {
|
|
2004
2004
|
cancel() {
|
|
2005
|
-
|
|
2005
|
+
timer && (clearTimeout(timer), timer = null);
|
|
2006
2006
|
},
|
|
2007
2007
|
start() {
|
|
2008
|
-
|
|
2009
|
-
|
|
2008
|
+
timer && clearTimeout(timer);
|
|
2009
|
+
timer = setTimeout(done, seconds * 1000, arguments);
|
|
2010
2010
|
}
|
|
2011
2011
|
};
|
|
2012
2012
|
function done(args) {
|
|
2013
2013
|
fn.apply(null, args);
|
|
2014
|
-
|
|
2014
|
+
timer = null;
|
|
2015
2015
|
}
|
|
2016
2016
|
}
|
|
2017
2017
|
|
|
2018
2018
|
// ../../node_modules/.bun/postgres@3.4.9/node_modules/postgres/src/subscribe.js
|
|
2019
2019
|
var noop2 = () => {};
|
|
2020
|
-
function Subscribe(
|
|
2020
|
+
function Subscribe(postgres, options) {
|
|
2021
2021
|
const subscribers = new Map, slot = "postgresjs_" + Math.random().toString(36).slice(2), state = {};
|
|
2022
|
-
let
|
|
2023
|
-
const
|
|
2022
|
+
let connection, stream, ended = false;
|
|
2023
|
+
const sql = subscribe.sql = postgres({
|
|
2024
2024
|
...options,
|
|
2025
2025
|
transform: { column: {}, value: {}, row: {} },
|
|
2026
2026
|
max: 1,
|
|
@@ -2036,37 +2036,37 @@ function Subscribe(postgres2, options) {
|
|
|
2036
2036
|
return;
|
|
2037
2037
|
stream = null;
|
|
2038
2038
|
state.pid = state.secret = undefined;
|
|
2039
|
-
connected(await init(
|
|
2039
|
+
connected(await init(sql, slot, options.publications));
|
|
2040
2040
|
subscribers.forEach((event) => event.forEach(({ onsubscribe }) => onsubscribe()));
|
|
2041
2041
|
},
|
|
2042
2042
|
no_subscribe: true
|
|
2043
2043
|
});
|
|
2044
|
-
const { end, close } =
|
|
2045
|
-
|
|
2044
|
+
const { end, close } = sql;
|
|
2045
|
+
sql.end = async () => {
|
|
2046
2046
|
ended = true;
|
|
2047
2047
|
stream && await new Promise((r) => (stream.once("close", r), stream.end()));
|
|
2048
2048
|
return end();
|
|
2049
2049
|
};
|
|
2050
|
-
|
|
2050
|
+
sql.close = async () => {
|
|
2051
2051
|
stream && await new Promise((r) => (stream.once("close", r), stream.end()));
|
|
2052
2052
|
return close();
|
|
2053
2053
|
};
|
|
2054
2054
|
return subscribe;
|
|
2055
2055
|
async function subscribe(event, fn, onsubscribe = noop2, onerror = noop2) {
|
|
2056
2056
|
event = parseEvent(event);
|
|
2057
|
-
if (!
|
|
2058
|
-
|
|
2057
|
+
if (!connection)
|
|
2058
|
+
connection = init(sql, slot, options.publications);
|
|
2059
2059
|
const subscriber = { fn, onsubscribe };
|
|
2060
2060
|
const fns = subscribers.has(event) ? subscribers.get(event).add(subscriber) : subscribers.set(event, new Set([subscriber])).get(event);
|
|
2061
2061
|
const unsubscribe = () => {
|
|
2062
2062
|
fns.delete(subscriber);
|
|
2063
2063
|
fns.size === 0 && subscribers.delete(event);
|
|
2064
2064
|
};
|
|
2065
|
-
return
|
|
2065
|
+
return connection.then((x) => {
|
|
2066
2066
|
connected(x);
|
|
2067
2067
|
onsubscribe();
|
|
2068
2068
|
stream && stream.on("error", onerror);
|
|
2069
|
-
return { unsubscribe, state, sql
|
|
2069
|
+
return { unsubscribe, state, sql };
|
|
2070
2070
|
});
|
|
2071
2071
|
}
|
|
2072
2072
|
function connected(x) {
|
|
@@ -2074,74 +2074,74 @@ function Subscribe(postgres2, options) {
|
|
|
2074
2074
|
state.pid = x.state.pid;
|
|
2075
2075
|
state.secret = x.state.secret;
|
|
2076
2076
|
}
|
|
2077
|
-
async function init(
|
|
2077
|
+
async function init(sql, slot, publications) {
|
|
2078
2078
|
if (!publications)
|
|
2079
2079
|
throw new Error("Missing publication names");
|
|
2080
|
-
const xs = await
|
|
2080
|
+
const xs = await sql.unsafe(`CREATE_REPLICATION_SLOT ${slot} TEMPORARY LOGICAL pgoutput NOEXPORT_SNAPSHOT`);
|
|
2081
2081
|
const [x] = xs;
|
|
2082
|
-
const
|
|
2083
|
-
const
|
|
2084
|
-
lsn: Buffer.concat(x.consistent_point.split("/").map((
|
|
2082
|
+
const stream = await sql.unsafe(`START_REPLICATION SLOT ${slot} LOGICAL ${x.consistent_point} (proto_version '1', publication_names '${publications}')`).writable();
|
|
2083
|
+
const state = {
|
|
2084
|
+
lsn: Buffer.concat(x.consistent_point.split("/").map((x) => Buffer.from(("00000000" + x).slice(-8), "hex")))
|
|
2085
2085
|
};
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
return { stream
|
|
2086
|
+
stream.on("data", data);
|
|
2087
|
+
stream.on("error", error);
|
|
2088
|
+
stream.on("close", sql.close);
|
|
2089
|
+
return { stream, state: xs.state };
|
|
2090
2090
|
function error(e) {
|
|
2091
2091
|
console.error("Unexpected error during logical streaming - reconnecting", e);
|
|
2092
2092
|
}
|
|
2093
|
-
function data(
|
|
2094
|
-
if (
|
|
2095
|
-
parse(
|
|
2096
|
-
} else if (
|
|
2097
|
-
|
|
2093
|
+
function data(x) {
|
|
2094
|
+
if (x[0] === 119) {
|
|
2095
|
+
parse(x.subarray(25), state, sql.options.parsers, handle, options.transform);
|
|
2096
|
+
} else if (x[0] === 107 && x[17]) {
|
|
2097
|
+
state.lsn = x.subarray(1, 9);
|
|
2098
2098
|
pong();
|
|
2099
2099
|
}
|
|
2100
2100
|
}
|
|
2101
|
-
function handle(a,
|
|
2102
|
-
const path =
|
|
2103
|
-
call("*", a,
|
|
2104
|
-
call("*:" + path, a,
|
|
2105
|
-
|
|
2106
|
-
call(
|
|
2107
|
-
call(
|
|
2108
|
-
|
|
2101
|
+
function handle(a, b) {
|
|
2102
|
+
const path = b.relation.schema + "." + b.relation.table;
|
|
2103
|
+
call("*", a, b);
|
|
2104
|
+
call("*:" + path, a, b);
|
|
2105
|
+
b.relation.keys.length && call("*:" + path + "=" + b.relation.keys.map((x) => a[x.name]), a, b);
|
|
2106
|
+
call(b.command, a, b);
|
|
2107
|
+
call(b.command + ":" + path, a, b);
|
|
2108
|
+
b.relation.keys.length && call(b.command + ":" + path + "=" + b.relation.keys.map((x) => a[x.name]), a, b);
|
|
2109
2109
|
}
|
|
2110
2110
|
function pong() {
|
|
2111
|
-
const
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2111
|
+
const x = Buffer.alloc(34);
|
|
2112
|
+
x[0] = 114;
|
|
2113
|
+
x.fill(state.lsn, 1);
|
|
2114
|
+
x.writeBigInt64BE(BigInt(Date.now() - Date.UTC(2000, 0, 1)) * BigInt(1000), 25);
|
|
2115
|
+
stream.write(x);
|
|
2116
2116
|
}
|
|
2117
2117
|
}
|
|
2118
|
-
function call(x, a,
|
|
2119
|
-
subscribers.has(x) && subscribers.get(x).forEach(({ fn }) => fn(a,
|
|
2118
|
+
function call(x, a, b) {
|
|
2119
|
+
subscribers.has(x) && subscribers.get(x).forEach(({ fn }) => fn(a, b, x));
|
|
2120
2120
|
}
|
|
2121
2121
|
}
|
|
2122
2122
|
function Time(x) {
|
|
2123
2123
|
return new Date(Date.UTC(2000, 0, 1) + Number(x / BigInt(1000)));
|
|
2124
2124
|
}
|
|
2125
|
-
function parse(x, state,
|
|
2125
|
+
function parse(x, state, parsers, handle, transform) {
|
|
2126
2126
|
const char = (acc, [k, v]) => (acc[k.charCodeAt(0)] = v, acc);
|
|
2127
2127
|
Object.entries({
|
|
2128
|
-
R: (
|
|
2128
|
+
R: (x) => {
|
|
2129
2129
|
let i = 1;
|
|
2130
|
-
const r = state[
|
|
2131
|
-
schema:
|
|
2132
|
-
table:
|
|
2133
|
-
columns: Array(
|
|
2130
|
+
const r = state[x.readUInt32BE(i)] = {
|
|
2131
|
+
schema: x.toString("utf8", i += 4, i = x.indexOf(0, i)) || "pg_catalog",
|
|
2132
|
+
table: x.toString("utf8", i + 1, i = x.indexOf(0, i + 1)),
|
|
2133
|
+
columns: Array(x.readUInt16BE(i += 2)),
|
|
2134
2134
|
keys: []
|
|
2135
2135
|
};
|
|
2136
2136
|
i += 2;
|
|
2137
2137
|
let columnIndex = 0, column;
|
|
2138
|
-
while (i <
|
|
2138
|
+
while (i < x.length) {
|
|
2139
2139
|
column = r.columns[columnIndex++] = {
|
|
2140
|
-
key:
|
|
2141
|
-
name: transform.column.from ? transform.column.from(
|
|
2142
|
-
type:
|
|
2143
|
-
parser:
|
|
2144
|
-
atttypmod:
|
|
2140
|
+
key: x[i++],
|
|
2141
|
+
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)),
|
|
2142
|
+
type: x.readUInt32BE(i += 1),
|
|
2143
|
+
parser: parsers[x.readUInt32BE(i)],
|
|
2144
|
+
atttypmod: x.readUInt32BE(i += 4)
|
|
2145
2145
|
};
|
|
2146
2146
|
column.key && r.keys.push(column);
|
|
2147
2147
|
i += 4;
|
|
@@ -2149,38 +2149,38 @@ function parse(x, state, parsers2, handle, transform) {
|
|
|
2149
2149
|
},
|
|
2150
2150
|
Y: () => {},
|
|
2151
2151
|
O: () => {},
|
|
2152
|
-
B: (
|
|
2153
|
-
state.date = Time(
|
|
2154
|
-
state.lsn =
|
|
2152
|
+
B: (x) => {
|
|
2153
|
+
state.date = Time(x.readBigInt64BE(9));
|
|
2154
|
+
state.lsn = x.subarray(1, 9);
|
|
2155
2155
|
},
|
|
2156
|
-
I: (
|
|
2156
|
+
I: (x) => {
|
|
2157
2157
|
let i = 1;
|
|
2158
|
-
const relation = state[
|
|
2159
|
-
const { row } = tuples(
|
|
2158
|
+
const relation = state[x.readUInt32BE(i)];
|
|
2159
|
+
const { row } = tuples(x, relation.columns, i += 7, transform);
|
|
2160
2160
|
handle(row, {
|
|
2161
2161
|
command: "insert",
|
|
2162
2162
|
relation
|
|
2163
2163
|
});
|
|
2164
2164
|
},
|
|
2165
|
-
D: (
|
|
2165
|
+
D: (x) => {
|
|
2166
2166
|
let i = 1;
|
|
2167
|
-
const relation = state[
|
|
2167
|
+
const relation = state[x.readUInt32BE(i)];
|
|
2168
2168
|
i += 4;
|
|
2169
|
-
const key =
|
|
2170
|
-
handle(key ||
|
|
2169
|
+
const key = x[i] === 75;
|
|
2170
|
+
handle(key || x[i] === 79 ? tuples(x, relation.columns, i += 3, transform).row : null, {
|
|
2171
2171
|
command: "delete",
|
|
2172
2172
|
relation,
|
|
2173
2173
|
key
|
|
2174
2174
|
});
|
|
2175
2175
|
},
|
|
2176
|
-
U: (
|
|
2176
|
+
U: (x) => {
|
|
2177
2177
|
let i = 1;
|
|
2178
|
-
const relation = state[
|
|
2178
|
+
const relation = state[x.readUInt32BE(i)];
|
|
2179
2179
|
i += 4;
|
|
2180
|
-
const key =
|
|
2181
|
-
const xs = key ||
|
|
2180
|
+
const key = x[i] === 75;
|
|
2181
|
+
const xs = key || x[i] === 79 ? tuples(x, relation.columns, i += 3, transform) : null;
|
|
2182
2182
|
xs && (i = xs.i);
|
|
2183
|
-
const { row } = tuples(
|
|
2183
|
+
const { row } = tuples(x, relation.columns, i + 3, transform);
|
|
2184
2184
|
handle(row, {
|
|
2185
2185
|
command: "update",
|
|
2186
2186
|
relation,
|
|
@@ -2213,22 +2213,22 @@ function parseEvent(x) {
|
|
|
2213
2213
|
|
|
2214
2214
|
// ../../node_modules/.bun/postgres@3.4.9/node_modules/postgres/src/large.js
|
|
2215
2215
|
import Stream2 from "stream";
|
|
2216
|
-
function largeObject(
|
|
2216
|
+
function largeObject(sql, oid, mode = 131072 | 262144) {
|
|
2217
2217
|
return new Promise(async (resolve, reject) => {
|
|
2218
|
-
await
|
|
2218
|
+
await sql.begin(async (sql) => {
|
|
2219
2219
|
let finish;
|
|
2220
|
-
!oid && ([{ oid }] = await
|
|
2221
|
-
const [{ fd }] = await
|
|
2220
|
+
!oid && ([{ oid }] = await sql`select lo_creat(-1) as oid`);
|
|
2221
|
+
const [{ fd }] = await sql`select lo_open(${oid}, ${mode}) as fd`;
|
|
2222
2222
|
const lo = {
|
|
2223
2223
|
writable,
|
|
2224
2224
|
readable,
|
|
2225
|
-
close: () =>
|
|
2226
|
-
tell: () =>
|
|
2227
|
-
read: (x) =>
|
|
2228
|
-
write: (x) =>
|
|
2229
|
-
truncate: (x) =>
|
|
2230
|
-
seek: (x, whence = 0) =>
|
|
2231
|
-
size: () =>
|
|
2225
|
+
close: () => sql`select lo_close(${fd})`.then(finish),
|
|
2226
|
+
tell: () => sql`select lo_tell64(${fd})`,
|
|
2227
|
+
read: (x) => sql`select loread(${fd}, ${x}) as data`,
|
|
2228
|
+
write: (x) => sql`select lowrite(${fd}, ${x})`,
|
|
2229
|
+
truncate: (x) => sql`select lo_truncate64(${fd}, ${x})`,
|
|
2230
|
+
seek: (x, whence = 0) => sql`select lo_lseek64(${fd}, ${x}, ${whence})`,
|
|
2231
|
+
size: () => sql`
|
|
2232
2232
|
select
|
|
2233
2233
|
lo_lseek64(${fd}, location, 0) as position,
|
|
2234
2234
|
seek.size
|
|
@@ -2251,12 +2251,12 @@ function largeObject(sql2, oid, mode = 131072 | 262144) {
|
|
|
2251
2251
|
start && await lo.seek(start);
|
|
2252
2252
|
return new Stream2.Readable({
|
|
2253
2253
|
highWaterMark,
|
|
2254
|
-
async read(
|
|
2255
|
-
const l =
|
|
2256
|
-
max -=
|
|
2254
|
+
async read(size) {
|
|
2255
|
+
const l = size > max ? size - max : size;
|
|
2256
|
+
max -= size;
|
|
2257
2257
|
const [{ data }] = await lo.read(l);
|
|
2258
2258
|
this.push(data);
|
|
2259
|
-
if (data.length <
|
|
2259
|
+
if (data.length < size)
|
|
2260
2260
|
this.push(null);
|
|
2261
2261
|
}
|
|
2262
2262
|
});
|
|
@@ -2297,17 +2297,17 @@ Object.assign(Postgres, {
|
|
|
2297
2297
|
}
|
|
2298
2298
|
});
|
|
2299
2299
|
var src_default = Postgres;
|
|
2300
|
-
function Postgres(a,
|
|
2301
|
-
const options = parseOptions(a,
|
|
2300
|
+
function Postgres(a, b) {
|
|
2301
|
+
const options = parseOptions(a, b), subscribe = options.no_subscribe || Subscribe(Postgres, { ...options });
|
|
2302
2302
|
let ending = false;
|
|
2303
2303
|
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 };
|
|
2304
2304
|
const connections = [...Array(options.max)].map(() => connection_default(options, queues, { onopen, onend, onclose }));
|
|
2305
|
-
const
|
|
2306
|
-
Object.assign(
|
|
2305
|
+
const sql = Sql(handler);
|
|
2306
|
+
Object.assign(sql, {
|
|
2307
2307
|
get parameters() {
|
|
2308
2308
|
return options.parameters;
|
|
2309
2309
|
},
|
|
2310
|
-
largeObject: largeObject.bind(null,
|
|
2310
|
+
largeObject: largeObject.bind(null, sql),
|
|
2311
2311
|
subscribe,
|
|
2312
2312
|
CLOSE,
|
|
2313
2313
|
END: CLOSE,
|
|
@@ -2319,14 +2319,14 @@ function Postgres(a, b2) {
|
|
|
2319
2319
|
close,
|
|
2320
2320
|
end
|
|
2321
2321
|
});
|
|
2322
|
-
return
|
|
2323
|
-
function Sql(
|
|
2324
|
-
|
|
2322
|
+
return sql;
|
|
2323
|
+
function Sql(handler) {
|
|
2324
|
+
handler.debug = options.debug;
|
|
2325
2325
|
Object.entries(options.types).reduce((acc, [name, type]) => {
|
|
2326
2326
|
acc[name] = (x) => new Parameter(x, type.to);
|
|
2327
2327
|
return acc;
|
|
2328
2328
|
}, typed);
|
|
2329
|
-
Object.assign(
|
|
2329
|
+
Object.assign(sql, {
|
|
2330
2330
|
types: typed,
|
|
2331
2331
|
typed,
|
|
2332
2332
|
unsafe,
|
|
@@ -2335,51 +2335,51 @@ function Postgres(a, b2) {
|
|
|
2335
2335
|
json,
|
|
2336
2336
|
file
|
|
2337
2337
|
});
|
|
2338
|
-
return
|
|
2338
|
+
return sql;
|
|
2339
2339
|
function typed(value, type) {
|
|
2340
2340
|
return new Parameter(value, type);
|
|
2341
2341
|
}
|
|
2342
|
-
function
|
|
2343
|
-
const query = strings && Array.isArray(strings.raw) ? new Query(strings, args,
|
|
2342
|
+
function sql(strings, ...args) {
|
|
2343
|
+
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);
|
|
2344
2344
|
return query;
|
|
2345
2345
|
}
|
|
2346
|
-
function unsafe(string, args = [],
|
|
2347
|
-
arguments.length === 2 && !Array.isArray(args) && (
|
|
2348
|
-
const query = new Query([string], args,
|
|
2346
|
+
function unsafe(string, args = [], options = {}) {
|
|
2347
|
+
arguments.length === 2 && !Array.isArray(args) && (options = args, args = []);
|
|
2348
|
+
const query = new Query([string], args, handler, cancel, {
|
|
2349
2349
|
prepare: false,
|
|
2350
|
-
...
|
|
2351
|
-
simple: "simple" in
|
|
2350
|
+
...options,
|
|
2351
|
+
simple: "simple" in options ? options.simple : args.length === 0
|
|
2352
2352
|
});
|
|
2353
2353
|
return query;
|
|
2354
2354
|
}
|
|
2355
|
-
function file(path, args = [],
|
|
2356
|
-
arguments.length === 2 && !Array.isArray(args) && (
|
|
2357
|
-
const query = new Query([], args, (
|
|
2355
|
+
function file(path, args = [], options = {}) {
|
|
2356
|
+
arguments.length === 2 && !Array.isArray(args) && (options = args, args = []);
|
|
2357
|
+
const query = new Query([], args, (query) => {
|
|
2358
2358
|
fs.readFile(path, "utf8", (err, string) => {
|
|
2359
2359
|
if (err)
|
|
2360
|
-
return
|
|
2361
|
-
|
|
2362
|
-
|
|
2360
|
+
return query.reject(err);
|
|
2361
|
+
query.strings = [string];
|
|
2362
|
+
handler(query);
|
|
2363
2363
|
});
|
|
2364
2364
|
}, cancel, {
|
|
2365
|
-
...
|
|
2366
|
-
simple: "simple" in
|
|
2365
|
+
...options,
|
|
2366
|
+
simple: "simple" in options ? options.simple : args.length === 0
|
|
2367
2367
|
});
|
|
2368
2368
|
return query;
|
|
2369
2369
|
}
|
|
2370
2370
|
}
|
|
2371
2371
|
async function listen(name, fn, onlisten) {
|
|
2372
2372
|
const listener = { fn, onlisten };
|
|
2373
|
-
const
|
|
2373
|
+
const sql = listen.sql || (listen.sql = Postgres({
|
|
2374
2374
|
...options,
|
|
2375
2375
|
max: 1,
|
|
2376
2376
|
idle_timeout: null,
|
|
2377
2377
|
max_lifetime: null,
|
|
2378
2378
|
fetch_types: false,
|
|
2379
2379
|
onclose() {
|
|
2380
|
-
Object.entries(listen.channels).forEach(([
|
|
2381
|
-
delete listen.channels[
|
|
2382
|
-
Promise.all(listeners.map((l) => listen(
|
|
2380
|
+
Object.entries(listen.channels).forEach(([name, { listeners }]) => {
|
|
2381
|
+
delete listen.channels[name];
|
|
2382
|
+
Promise.all(listeners.map((l) => listen(name, l.fn, l.onlisten).catch(() => {})));
|
|
2383
2383
|
});
|
|
2384
2384
|
},
|
|
2385
2385
|
onnotify(c, x) {
|
|
@@ -2389,11 +2389,11 @@ function Postgres(a, b2) {
|
|
|
2389
2389
|
const channels = listen.channels || (listen.channels = {}), exists = name in channels;
|
|
2390
2390
|
if (exists) {
|
|
2391
2391
|
channels[name].listeners.push(listener);
|
|
2392
|
-
const
|
|
2392
|
+
const result = await channels[name].result;
|
|
2393
2393
|
listener.onlisten && listener.onlisten();
|
|
2394
|
-
return { state:
|
|
2394
|
+
return { state: result.state, unlisten };
|
|
2395
2395
|
}
|
|
2396
|
-
channels[name] = { result:
|
|
2396
|
+
channels[name] = { result: sql`listen ${sql.unsafe('"' + name.replace(/"/g, '""') + '"')}`, listeners: [listener] };
|
|
2397
2397
|
const result = await channels[name].result;
|
|
2398
2398
|
listener.onlisten && listener.onlisten();
|
|
2399
2399
|
return { state: result.state, unlisten };
|
|
@@ -2404,11 +2404,11 @@ function Postgres(a, b2) {
|
|
|
2404
2404
|
if (channels[name].listeners.length)
|
|
2405
2405
|
return;
|
|
2406
2406
|
delete channels[name];
|
|
2407
|
-
return
|
|
2407
|
+
return sql`unlisten ${sql.unsafe('"' + name.replace(/"/g, '""') + '"')}`;
|
|
2408
2408
|
}
|
|
2409
2409
|
}
|
|
2410
2410
|
async function notify(channel, payload) {
|
|
2411
|
-
return await
|
|
2411
|
+
return await sql`select pg_notify(${channel}, ${"" + payload})`;
|
|
2412
2412
|
}
|
|
2413
2413
|
async function reserve() {
|
|
2414
2414
|
const queue = queue_default();
|
|
@@ -2420,65 +2420,65 @@ function Postgres(a, b2) {
|
|
|
2420
2420
|
move(c, reserved);
|
|
2421
2421
|
c.reserved = () => queue.length ? c.execute(queue.shift()) : move(c, reserved);
|
|
2422
2422
|
c.reserved.release = true;
|
|
2423
|
-
const
|
|
2424
|
-
|
|
2423
|
+
const sql = Sql(handler);
|
|
2424
|
+
sql.release = () => {
|
|
2425
2425
|
c.reserved = null;
|
|
2426
2426
|
onopen(c);
|
|
2427
2427
|
};
|
|
2428
|
-
return
|
|
2429
|
-
function
|
|
2428
|
+
return sql;
|
|
2429
|
+
function handler(q) {
|
|
2430
2430
|
c.queue === full ? queue.push(q) : c.execute(q) || move(c, full);
|
|
2431
2431
|
}
|
|
2432
2432
|
}
|
|
2433
|
-
async function begin(
|
|
2434
|
-
!fn && (fn =
|
|
2435
|
-
const
|
|
2436
|
-
let savepoints = 0,
|
|
2433
|
+
async function begin(options, fn) {
|
|
2434
|
+
!fn && (fn = options, options = "");
|
|
2435
|
+
const queries = queue_default();
|
|
2436
|
+
let savepoints = 0, connection, prepare = null;
|
|
2437
2437
|
try {
|
|
2438
|
-
await
|
|
2438
|
+
await sql.unsafe("begin " + options.replace(/[^a-z ]/ig, ""), [], { onexecute }).execute();
|
|
2439
2439
|
return await Promise.race([
|
|
2440
|
-
scope(
|
|
2441
|
-
new Promise((_, reject) =>
|
|
2440
|
+
scope(connection, fn),
|
|
2441
|
+
new Promise((_, reject) => connection.onclose = reject)
|
|
2442
2442
|
]);
|
|
2443
2443
|
} catch (error) {
|
|
2444
2444
|
throw error;
|
|
2445
2445
|
}
|
|
2446
|
-
async function scope(c,
|
|
2447
|
-
const
|
|
2448
|
-
|
|
2449
|
-
|
|
2446
|
+
async function scope(c, fn, name) {
|
|
2447
|
+
const sql = Sql(handler);
|
|
2448
|
+
sql.savepoint = savepoint;
|
|
2449
|
+
sql.prepare = (x) => prepare = x.replace(/[^a-z0-9$-_. ]/gi);
|
|
2450
2450
|
let uncaughtError, result;
|
|
2451
|
-
name && await
|
|
2451
|
+
name && await sql`savepoint ${sql(name)}`;
|
|
2452
2452
|
try {
|
|
2453
2453
|
result = await new Promise((resolve, reject) => {
|
|
2454
|
-
const x =
|
|
2454
|
+
const x = fn(sql);
|
|
2455
2455
|
Promise.resolve(Array.isArray(x) ? Promise.all(x) : x).then(resolve, reject);
|
|
2456
2456
|
});
|
|
2457
2457
|
if (uncaughtError)
|
|
2458
2458
|
throw uncaughtError;
|
|
2459
2459
|
} catch (e) {
|
|
2460
|
-
await (name ?
|
|
2460
|
+
await (name ? sql`rollback to ${sql(name)}` : sql`rollback`);
|
|
2461
2461
|
throw e instanceof PostgresError && e.code === "25P02" && uncaughtError || e;
|
|
2462
2462
|
}
|
|
2463
2463
|
if (!name) {
|
|
2464
|
-
prepare ? await
|
|
2464
|
+
prepare ? await sql`prepare transaction '${sql.unsafe(prepare)}'` : await sql`commit`;
|
|
2465
2465
|
}
|
|
2466
2466
|
return result;
|
|
2467
|
-
function savepoint(
|
|
2468
|
-
if (
|
|
2469
|
-
return savepoint((
|
|
2470
|
-
arguments.length === 1 && (
|
|
2471
|
-
return scope(c,
|
|
2467
|
+
function savepoint(name, fn) {
|
|
2468
|
+
if (name && Array.isArray(name.raw))
|
|
2469
|
+
return savepoint((sql) => sql.apply(sql, arguments));
|
|
2470
|
+
arguments.length === 1 && (fn = name, name = null);
|
|
2471
|
+
return scope(c, fn, "s" + savepoints++ + (name ? "_" + name : ""));
|
|
2472
2472
|
}
|
|
2473
|
-
function
|
|
2473
|
+
function handler(q) {
|
|
2474
2474
|
q.catch((e) => uncaughtError || (uncaughtError = e));
|
|
2475
|
-
c.queue === full ?
|
|
2475
|
+
c.queue === full ? queries.push(q) : c.execute(q) || move(c, full);
|
|
2476
2476
|
}
|
|
2477
2477
|
}
|
|
2478
2478
|
function onexecute(c) {
|
|
2479
|
-
|
|
2479
|
+
connection = c;
|
|
2480
2480
|
move(c, reserved);
|
|
2481
|
-
c.reserved = () =>
|
|
2481
|
+
c.reserved = () => queries.length ? c.execute(queries.shift()) : move(c, reserved);
|
|
2482
2482
|
}
|
|
2483
2483
|
}
|
|
2484
2484
|
function move(c, queue) {
|
|
@@ -2517,11 +2517,11 @@ function Postgres(a, b2) {
|
|
|
2517
2517
|
if (ending)
|
|
2518
2518
|
return ending;
|
|
2519
2519
|
await 1;
|
|
2520
|
-
let
|
|
2520
|
+
let timer;
|
|
2521
2521
|
return ending = Promise.race([
|
|
2522
|
-
new Promise((r) => timeout !== null && (
|
|
2522
|
+
new Promise((r) => timeout !== null && (timer = setTimeout(destroy, timeout * 1000, r))),
|
|
2523
2523
|
Promise.all(connections.map((c) => c.end()).concat(listen.sql ? listen.sql.end({ timeout: 0 }) : [], subscribe.sql ? subscribe.sql.end({ timeout: 0 }) : []))
|
|
2524
|
-
]).then(() => clearTimeout(
|
|
2524
|
+
]).then(() => clearTimeout(timer));
|
|
2525
2525
|
}
|
|
2526
2526
|
async function close() {
|
|
2527
2527
|
await Promise.all(connections.map((c) => c.end()));
|
|
@@ -2560,10 +2560,10 @@ function Postgres(a, b2) {
|
|
|
2560
2560
|
queries.length && connect(c, queries.shift());
|
|
2561
2561
|
}
|
|
2562
2562
|
}
|
|
2563
|
-
function parseOptions(a,
|
|
2563
|
+
function parseOptions(a, b) {
|
|
2564
2564
|
if (a && a.shared)
|
|
2565
2565
|
return a;
|
|
2566
|
-
const env = process.env, o = (!a || typeof a === "string" ?
|
|
2566
|
+
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();
|
|
2567
2567
|
o.no_prepare && (o.prepare = false);
|
|
2568
2568
|
query.sslmode && (query.ssl = query.sslmode, delete query.sslmode);
|
|
2569
2569
|
"timeout" in o && (console.log("The timeout option is deprecated, use idle_timeout instead"), o.idle_timeout = o.timeout);
|
|
@@ -2672,6 +2672,13 @@ function osUsername() {
|
|
|
2672
2672
|
}
|
|
2673
2673
|
}
|
|
2674
2674
|
|
|
2675
|
+
// ../../backend/src/lib/collaboration-room-key.ts
|
|
2676
|
+
function createYjsRoomKey(input) {
|
|
2677
|
+
const scope = input.workspaceId ? `workspace:${input.workspaceId}` : `user:${input.userId}`;
|
|
2678
|
+
const base = `${scope}:document:${input.documentId}`;
|
|
2679
|
+
return input.restoreVersionId ? `${base}:restore:${input.restoreVersionId}` : base;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2675
2682
|
// ../../backend/src/lib/account-runtime-cleanup-core.ts
|
|
2676
2683
|
var YJS_DOCUMENT_PREFIX = "yjs:doc:";
|
|
2677
2684
|
var DOCUMENT_LIST_CACHE_PREFIX = "hiai-docs:cache:docs:list:";
|
|
@@ -2719,7 +2726,7 @@ function parseSnapshot(value, actorUserId) {
|
|
|
2719
2726
|
if (typeof parsed !== "object" || parsed === null || !("version" in parsed) || parsed.version !== 1 || !("actorUserId" in parsed) || parsed.actorUserId !== actorUserId || !("documents" in parsed) || !Array.isArray(parsed.documents)) {
|
|
2720
2727
|
throw new Error("account_runtime_cleanup_snapshot_invalid");
|
|
2721
2728
|
}
|
|
2722
|
-
const
|
|
2729
|
+
const documents = parsed.documents.map((document) => {
|
|
2723
2730
|
if (typeof document !== "object" || document === null || !("documentId" in document) || typeof document.documentId !== "string" || document.documentId.length === 0 || !("workspaceId" in document) || document.workspaceId !== null && typeof document.workspaceId !== "string") {
|
|
2724
2731
|
throw new Error("account_runtime_cleanup_snapshot_invalid");
|
|
2725
2732
|
}
|
|
@@ -2728,7 +2735,7 @@ function parseSnapshot(value, actorUserId) {
|
|
|
2728
2735
|
workspaceId: document.workspaceId
|
|
2729
2736
|
};
|
|
2730
2737
|
});
|
|
2731
|
-
return { version: 1, actorUserId, documents
|
|
2738
|
+
return { version: 1, actorUserId, documents };
|
|
2732
2739
|
}
|
|
2733
2740
|
function createAccountRuntimeCleanupWithDependencies(dependencies) {
|
|
2734
2741
|
const snapshots = new Map;
|
|
@@ -2739,9 +2746,9 @@ function createAccountRuntimeCleanupWithDependencies(dependencies) {
|
|
|
2739
2746
|
if (closed)
|
|
2740
2747
|
throw new Error("account_runtime_cleanup_closed");
|
|
2741
2748
|
}
|
|
2742
|
-
function cacheSnapshot(actorUserId,
|
|
2749
|
+
function cacheSnapshot(actorUserId, documents) {
|
|
2743
2750
|
snapshots.delete(actorUserId);
|
|
2744
|
-
snapshots.set(actorUserId,
|
|
2751
|
+
snapshots.set(actorUserId, documents);
|
|
2745
2752
|
while (snapshots.size > MAX_IN_MEMORY_SNAPSHOTS) {
|
|
2746
2753
|
const oldest = snapshots.keys().next().value;
|
|
2747
2754
|
if (typeof oldest !== "string")
|
|
@@ -2773,12 +2780,12 @@ function createAccountRuntimeCleanupWithDependencies(dependencies) {
|
|
|
2773
2780
|
try {
|
|
2774
2781
|
let snapshot = await loadDurableSnapshot(actorUserId, signal);
|
|
2775
2782
|
if (!snapshot) {
|
|
2776
|
-
const
|
|
2783
|
+
const documents = await dependencies.snapshotActorDocuments(actorUserId, signal);
|
|
2777
2784
|
throwIfAborted(signal);
|
|
2778
2785
|
const candidate = {
|
|
2779
2786
|
version: 1,
|
|
2780
2787
|
actorUserId,
|
|
2781
|
-
documents:
|
|
2788
|
+
documents: documents.map((document) => ({
|
|
2782
2789
|
documentId: document.documentId,
|
|
2783
2790
|
workspaceId: document.workspaceId
|
|
2784
2791
|
}))
|
|
@@ -2797,7 +2804,16 @@ function createAccountRuntimeCleanupWithDependencies(dependencies) {
|
|
|
2797
2804
|
}
|
|
2798
2805
|
cacheSnapshot(actorUserId, snapshot);
|
|
2799
2806
|
}
|
|
2800
|
-
|
|
2807
|
+
let deleted = await deleteExactKeys(dependencies.redis, snapshot.map((document) => `${YJS_DOCUMENT_PREFIX}${document.documentId}`), signal);
|
|
2808
|
+
for (const document of snapshot) {
|
|
2809
|
+
const roomKey = YJS_DOCUMENT_PREFIX + createYjsRoomKey({
|
|
2810
|
+
documentId: document.documentId,
|
|
2811
|
+
userId: actorUserId,
|
|
2812
|
+
workspaceId: document.workspaceId ?? undefined
|
|
2813
|
+
});
|
|
2814
|
+
deleted += await deleteExactKeys(dependencies.redis, [roomKey], signal);
|
|
2815
|
+
deleted += await deleteNamespacePattern(dependencies.redis, `${escapeRedisGlob(roomKey)}:restore:*`, signal);
|
|
2816
|
+
}
|
|
2801
2817
|
throwIfAborted(signal);
|
|
2802
2818
|
return deleted;
|
|
2803
2819
|
} finally {
|