@kinetis/vector-ui 0.12.5 → 0.13.0
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/CHANGELOG.md +88 -3
- package/README.md +13 -5
- package/app/components/Vx/Cell/Markdown.vue +1 -1
- package/app/components/Vx/Cell/RichText.vue +1 -1
- package/app/components/Vx/CommandPalette.vue +16 -2
- package/app/components/Vx/FieldsForm.vue +10 -2
- package/app/components/Vx/Input/KeyValue.vue +2 -2
- package/app/components/Vx/Input/Markdown.vue +5 -0
- package/app/components/Vx/Input/Money.vue +1 -1
- package/app/components/Vx/Input/RichText.vue +6 -1
- package/app/components/Vx/Input/Text.vue +18 -2
- package/app/components/Vx/Input/Textarea.vue +19 -2
- package/app/components/Vx/InputAddons.vue +45 -0
- package/app/components/Vx/Layout.vue +1 -1
- package/app/components/Vx/List/Pager.vue +1 -1
- package/app/components/Vx/List/ViewMenu.vue +1 -1
- package/app/components/Vx/Queues/Failed.vue +2 -2
- package/app/components/Vx/Queues/FailedDetail.vue +2 -2
- package/app/components/Vx/Queues/Metrics.vue +1 -1
- package/app/components/Vx/Queues/Overview.vue +2 -2
- package/app/components/Vx/Resource/Audit.vue +4 -0
- package/app/components/Vx/Resource/Form.vue +9 -1
- package/app/components/Vx/Resource/RelationPanel.vue +1 -1
- package/app/components/Vx/Resource/Table.vue +25 -2
- package/app/components/Vx/Widget/Card.vue +2 -2
- package/app/components/VxAi/ApprovalCard.vue +115 -0
- package/app/components/VxAi/Assistant.vue +190 -0
- package/app/components/VxAi/Credentials.vue +111 -0
- package/app/components/VxAi/FilterAsk.vue +176 -0
- package/app/components/VxAi/WritingAddon.vue +127 -0
- package/app/components/VxAi/WritingMenu.vue +91 -0
- package/app/components/VxAi/WritingResult.vue +48 -0
- package/app/components/VxAi/WritingToolbarItem.vue +189 -0
- package/app/composables/useConfirm.ts +1 -1
- package/app/composables/useVectorApi.ts +4 -4
- package/app/composables/useVectorAssistant.ts +318 -0
- package/app/composables/useVectorAuthStore.ts +1 -1
- package/app/composables/useVectorExtend.ts +157 -0
- package/app/composables/useVectorExtensions.ts +64 -6
- package/app/composables/useVectorFields.ts +1 -1
- package/app/composables/useVectorIdle.ts +1 -1
- package/app/composables/useVectorLocale.ts +2 -2
- package/app/composables/useVectorSchema.ts +1 -1
- package/app/composables/useVectorVersion.ts +2 -2
- package/app/composables/useVectorWriting.ts +72 -0
- package/app/i18n/ar/ai.ts +93 -0
- package/app/i18n/ar/index.ts +2 -1
- package/app/i18n/ar/record.ts +4 -0
- package/app/i18n/ar/shell.ts +1 -0
- package/app/i18n/de/ai.ts +93 -0
- package/app/i18n/de/index.ts +2 -1
- package/app/i18n/de/record.ts +4 -0
- package/app/i18n/de/shell.ts +1 -0
- package/app/i18n/en/ai.ts +93 -0
- package/app/i18n/en/index.ts +2 -1
- package/app/i18n/en/record.ts +4 -0
- package/app/i18n/en/shell.ts +1 -0
- package/app/i18n/es/ai.ts +93 -0
- package/app/i18n/es/index.ts +2 -1
- package/app/i18n/es/record.ts +4 -0
- package/app/i18n/es/shell.ts +1 -0
- package/app/i18n/fr/ai.ts +93 -0
- package/app/i18n/fr/index.ts +2 -1
- package/app/i18n/fr/record.ts +4 -0
- package/app/i18n/fr/shell.ts +1 -0
- package/app/i18n/he/ai.ts +93 -0
- package/app/i18n/he/index.ts +2 -1
- package/app/i18n/he/record.ts +4 -0
- package/app/i18n/he/shell.ts +1 -0
- package/app/i18n/index.ts +1 -1
- package/app/i18n/it/ai.ts +93 -0
- package/app/i18n/it/index.ts +2 -1
- package/app/i18n/it/record.ts +4 -0
- package/app/i18n/it/shell.ts +1 -0
- package/app/i18n/ja/ai.ts +93 -0
- package/app/i18n/ja/index.ts +2 -1
- package/app/i18n/ja/record.ts +4 -0
- package/app/i18n/ja/shell.ts +1 -0
- package/app/i18n/ko/ai.ts +93 -0
- package/app/i18n/ko/index.ts +2 -1
- package/app/i18n/ko/record.ts +4 -0
- package/app/i18n/ko/shell.ts +1 -0
- package/app/i18n/nl/ai.ts +93 -0
- package/app/i18n/nl/index.ts +2 -1
- package/app/i18n/nl/record.ts +4 -0
- package/app/i18n/nl/shell.ts +1 -0
- package/app/i18n/pl/ai.ts +93 -0
- package/app/i18n/pl/index.ts +2 -1
- package/app/i18n/pl/record.ts +4 -0
- package/app/i18n/pl/shell.ts +1 -0
- package/app/i18n/pt/ai.ts +93 -0
- package/app/i18n/pt/index.ts +2 -1
- package/app/i18n/pt/record.ts +4 -0
- package/app/i18n/pt/shell.ts +1 -0
- package/app/i18n/pt-BR/ai.ts +93 -0
- package/app/i18n/pt-BR/index.ts +2 -1
- package/app/i18n/pt-BR/record.ts +4 -0
- package/app/i18n/pt-BR/shell.ts +1 -0
- package/app/i18n/ru/ai.ts +93 -0
- package/app/i18n/ru/index.ts +2 -1
- package/app/i18n/ru/record.ts +4 -0
- package/app/i18n/ru/shell.ts +1 -0
- package/app/i18n/tr/ai.ts +93 -0
- package/app/i18n/tr/index.ts +2 -1
- package/app/i18n/tr/record.ts +4 -0
- package/app/i18n/tr/shell.ts +1 -0
- package/app/i18n/uk/ai.ts +93 -0
- package/app/i18n/uk/index.ts +2 -1
- package/app/i18n/uk/record.ts +4 -0
- package/app/i18n/uk/shell.ts +1 -0
- package/app/i18n/zh-Hans/ai.ts +93 -0
- package/app/i18n/zh-Hans/index.ts +2 -1
- package/app/i18n/zh-Hans/record.ts +4 -0
- package/app/i18n/zh-Hans/shell.ts +1 -0
- package/app/layouts/vector.vue +4 -1
- package/app/pages/settings.vue +7 -1
- package/app/plugins/vector-ai.client.ts +54 -0
- package/app/plugins/vector-extensions.client.ts +28 -37
- package/app/types/vector.ts +40 -3
- package/app/utils/aiAvailability.ts +55 -0
- package/app/utils/assistantBody.ts +69 -0
- package/app/utils/assistantStream.ts +133 -0
- package/app/utils/assistantTools.ts +45 -0
- package/app/utils/followScroll.ts +110 -0
- package/app/utils/format.ts +3 -3
- package/app/utils/internal/paths.ts +1 -1
- package/app/utils/queues.ts +1 -1
- package/app/utils/recordLinks.ts +45 -0
- package/app/utils/richtext.ts +3 -3
- package/app/utils/translate.ts +2 -2
- package/dist/static/200.html +1 -1
- package/dist/static/404.html +1 -1
- package/dist/static/_nuxt/-ksGenLl.js +1 -0
- package/dist/static/_nuxt/{DDJY3JL5.js → 0Q9tQaGZ.js} +1 -1
- package/dist/static/_nuxt/2mrvZCJz.js +3 -0
- package/dist/static/_nuxt/{C2PH7r9_.js → 2u7wMpR1.js} +1 -1
- package/dist/static/_nuxt/72BATg3-.js +1 -0
- package/dist/static/_nuxt/{BKtgreqG.js → 7hLwEPpo.js} +1 -1
- package/dist/static/_nuxt/{D5vg-NJ4.js → 7rwxDW6j.js} +1 -1
- package/dist/static/_nuxt/{Pj99sh0X.js → AbcTnLPe.js} +1 -1
- package/dist/static/_nuxt/B-b861aP.js +1 -0
- package/dist/static/_nuxt/{Cuw0JSbz.js → B2rZ5lwu.js} +1 -1
- package/dist/static/_nuxt/B4hfz7cN.js +1 -0
- package/dist/static/_nuxt/B65UlNtP.js +1 -0
- package/dist/static/_nuxt/{oThorgNS.js → B8JL5gwX.js} +1 -1
- package/dist/static/_nuxt/{D5Woe3YR.js → B8wNbnS0.js} +1 -1
- package/dist/static/_nuxt/{BDM1yKDf.js → B9FqenNL.js} +1 -1
- package/dist/static/_nuxt/{wLSd0d84.js → B9s6vEby.js} +1 -1
- package/dist/static/_nuxt/BE6e_jlD.js +1 -0
- package/dist/static/_nuxt/{Dx8sj9kP.js → BFZfZyte.js} +1 -1
- package/dist/static/_nuxt/{Dnl_Q9LX.js → BJSRjsBt.js} +1 -1
- package/dist/static/_nuxt/{lRmDd_Kx.js → BJh6qVAK.js} +1 -1
- package/dist/static/_nuxt/{DBmDhhWl.js → BJxaGigr.js} +1 -1
- package/dist/static/_nuxt/{CmoDOC5e.js → BL2SeM_r.js} +1 -1
- package/dist/static/_nuxt/BPT7yI6j.js +1 -0
- package/dist/static/_nuxt/BQ47h6Wh.js +1 -0
- package/dist/static/_nuxt/{CalcRVj7.js → BQitPbA5.js} +1 -1
- package/dist/static/_nuxt/{D9unnd4n.js → BSj4WTjT.js} +1 -1
- package/dist/static/_nuxt/{D3cKZbMy.js → BVrihF-G.js} +1 -1
- package/dist/static/_nuxt/BW9qBvMR.js +1 -0
- package/dist/static/_nuxt/{DU1KpHiJ.js → BWscDCZb.js} +1 -1
- package/dist/static/_nuxt/{JGAhx20W.js → BXnWvqRw.js} +1 -1
- package/dist/static/_nuxt/BcSEGymu.js +2 -0
- package/dist/static/_nuxt/Bj-QksVr.js +2 -0
- package/dist/static/_nuxt/{CvMhFq5K.js → Bl4F_9Di.js} +1 -1
- package/dist/static/_nuxt/{BRbbmSpl.js → BowgCQje.js} +1 -1
- package/dist/static/_nuxt/{DgVB5umK.js → BuTE4a2w.js} +1 -1
- package/dist/static/_nuxt/Bw6FrC2B.js +1 -0
- package/dist/static/_nuxt/{Cv0_BbF0.js → Byf6uyFv.js} +1 -1
- package/dist/static/_nuxt/Bzvft7RG.js +1 -0
- package/dist/static/_nuxt/C1y0neXX.js +1 -0
- package/dist/static/_nuxt/{BUF7Jq4U.js → C48zuAYh.js} +1 -1
- package/dist/static/_nuxt/{DJFQLDk5.js → C52FYB-5.js} +1 -1
- package/dist/static/_nuxt/CAXk9Oc1.js +1 -0
- package/dist/static/_nuxt/{C7fSyjDf.js → CD5zJmlk.js} +1 -1
- package/dist/static/_nuxt/CDnV5Q2S.js +2 -0
- package/dist/static/_nuxt/{CzTUD5Qk.js → CE5HzlKJ.js} +1 -1
- package/dist/static/_nuxt/{7K6MnLUx.js → CF_C4t63.js} +1 -1
- package/dist/static/_nuxt/CFuvN8kq.js +1 -0
- package/dist/static/_nuxt/{CqMf6Lsu.js → CHIGMs2v.js} +1 -1
- package/dist/static/_nuxt/CIcNJyjb.js +1 -0
- package/dist/static/_nuxt/{Dyz4VrUP.js → CLJSzUt5.js} +1 -1
- package/dist/static/_nuxt/CQvUQgZO.js +2 -0
- package/dist/static/_nuxt/{N6Uxr2YO.js → CRAHgjs4.js} +1 -1
- package/dist/static/_nuxt/{B6NDob-m.js → CSezMYzn.js} +1 -1
- package/dist/static/_nuxt/{B7CwuqHQ.js → CSgLLbCN.js} +1 -1
- package/dist/static/_nuxt/{1EmobxKy.js → CTHBH7-N.js} +1 -1
- package/dist/static/_nuxt/CVGEoUmj.js +1 -0
- package/dist/static/_nuxt/{bm6plv74.js → CVePRzEp.js} +1 -1
- package/dist/static/_nuxt/{R3rw3hPp.js → CWfptrnU.js} +1 -1
- package/dist/static/_nuxt/{C1djf5sc.js → CXSf4TOH.js} +1 -1
- package/dist/static/_nuxt/CbOoWXps.js +1 -0
- package/dist/static/_nuxt/Cf2NM87n.js +1 -0
- package/dist/static/_nuxt/{ycmL3bWs.js → CjYmnU-l.js} +1 -1
- package/dist/static/_nuxt/Ckm05LT2.js +1 -0
- package/dist/static/_nuxt/{DHtEcXUO.js → Cl2jXKkl.js} +1 -1
- package/dist/static/_nuxt/{CF1K6UXb.js → Clx69IQe.js} +1 -1
- package/dist/static/_nuxt/{BZDOVMsw.js → CmJ0ekjX.js} +1 -1
- package/dist/static/_nuxt/{DkCRR-Zt.js → Cpel4vlt.js} +1 -1
- package/dist/static/_nuxt/{CUAnR2FD.js → CrYfHi9E.js} +1 -1
- package/dist/static/_nuxt/CvTgOEOS.js +1 -0
- package/dist/static/_nuxt/CvVbTdaI.js +1 -0
- package/dist/static/_nuxt/{DoNlTJTo.js → D2ovGjnz.js} +1 -1
- package/dist/static/_nuxt/{BOHl_j0c.js → D3cIKCPa.js} +1 -1
- package/dist/static/_nuxt/{CvtjhXJ1.js → D3jC5ZAK.js} +1 -1
- package/dist/static/_nuxt/{FzhpMR1D.js → D3xofh1k.js} +1 -1
- package/dist/static/_nuxt/{BfuFZvSA.js → D7dC5VYH.js} +1 -1
- package/dist/static/_nuxt/{DfVLYfcR.js → D7eR_J9I.js} +1 -1
- package/dist/static/_nuxt/DAXm0JlI.js +1 -0
- package/dist/static/_nuxt/DDsQjoa8.js +1 -0
- package/dist/static/_nuxt/DFIqxsd4.js +1 -0
- package/dist/static/_nuxt/DGQrzV9s.js +1 -0
- package/dist/static/_nuxt/{1_Uuyt8D.js → DHNZ4ANp.js} +1 -1
- package/dist/static/_nuxt/{AXpHq_M6.js → DKOyYUi8.js} +1 -1
- package/dist/static/_nuxt/DOEj9Txc.js +1 -0
- package/dist/static/_nuxt/{CJepLjEa.js → DOq2YmIE.js} +1 -1
- package/dist/static/_nuxt/DOxWca9k.js +1 -0
- package/dist/static/_nuxt/{D7JW3pi_.js → DVyeIIya.js} +1 -1
- package/dist/static/_nuxt/{DT1zmKvw.js → DW3p59oX.js} +1 -1
- package/dist/static/_nuxt/{ERkvasWH.js → DXZAXwNd.js} +1 -1
- package/dist/static/_nuxt/{5VLAMAEq.js → DYPYEI74.js} +1 -1
- package/dist/static/_nuxt/D_hQWjK3.js +1 -0
- package/dist/static/_nuxt/{ZNfE-M4g.js → Dao3p0cp.js} +1 -1
- package/dist/static/_nuxt/{D3xqGGYp.js → DcC5rHQt.js} +1 -1
- package/dist/static/_nuxt/DdYMnBKs.js +1 -0
- package/dist/static/_nuxt/{DOOLWZFN.js → DeZyAt_3.js} +1 -1
- package/dist/static/_nuxt/DfApYreK.js +10 -0
- package/dist/static/_nuxt/{BEcvuouq.js → DjRWYJ_r.js} +1 -1
- package/dist/static/_nuxt/{DqVTouT1.js → DllQuWrz.js} +1 -1
- package/dist/static/_nuxt/DpWwaWd-.js +185 -0
- package/dist/static/_nuxt/DryMzf1V.js +1 -0
- package/dist/static/_nuxt/{BEu939QZ.js → DsLys5JK.js} +1 -1
- package/dist/static/_nuxt/DvEvjhbF.js +1 -0
- package/dist/static/_nuxt/{B1lIMV_o.js → Dw7WalTb.js} +1 -1
- package/dist/static/_nuxt/{DYm7SUSn.js → DwpSsR4l.js} +1 -1
- package/dist/static/_nuxt/FfebEZGy.js +1 -0
- package/dist/static/_nuxt/{DPDZkh6Z.js → GdAHGVsW.js} +1 -1
- package/dist/static/_nuxt/{qFGHTGtX.js → HdAGfEVj.js} +1 -1
- package/dist/static/_nuxt/{CsakM5cG.js → IxgCkjBe.js} +1 -1
- package/dist/static/_nuxt/{BJiySRJW.js → Jl8QPdwt.js} +1 -1
- package/dist/static/_nuxt/{4_OCizmC.js → KWfizXHd.js} +1 -1
- package/dist/static/_nuxt/KeyValue.CWzmqYlQ.css +1 -0
- package/dist/static/_nuxt/Notifications.CAlaWnJg.css +1 -0
- package/dist/static/_nuxt/PqTF-5Vs.js +1 -0
- package/dist/static/_nuxt/SacKuioS.js +65 -0
- package/dist/static/_nuxt/TlyrWgih.js +1 -0
- package/dist/static/_nuxt/{oj_DzV60.js → WAarVmAq.js} +1 -1
- package/dist/static/_nuxt/{DcWEOxVe.js → XnbMqODk.js} +1 -1
- package/dist/static/_nuxt/{R_5D07UV.js → Y2iAEIYr.js} +1 -1
- package/dist/static/_nuxt/_resource_.Q2lVCG-n.css +1 -0
- package/dist/static/_nuxt/{BSj7_50x.js → b2bdl3qT.js} +1 -1
- package/dist/static/_nuxt/bNqxxQg2.js +1 -0
- package/dist/static/_nuxt/builds/latest.json +1 -1
- package/dist/static/_nuxt/builds/meta/f78103ad-2489-4aee-b300-160bb1a81e35.json +1 -0
- package/dist/static/_nuxt/{yO0LqdZ2.js → e2dpeiRT.js} +1 -1
- package/dist/static/_nuxt/{entry.DmwuXgFN.css → entry.CANiyyNa.css} +1 -1
- package/dist/static/_nuxt/error-404.D5YWHu6f.css +1 -0
- package/dist/static/_nuxt/error-500.BP1eYUQR.css +1 -0
- package/dist/static/_nuxt/{CB-gmtNU.js → fLsGnP3B.js} +1 -1
- package/dist/static/_nuxt/gYmJEXHP.js +1 -0
- package/dist/static/_nuxt/{B-nBg1Xv.js → jI4JB4sB.js} +1 -1
- package/dist/static/_nuxt/{DebXB2Xn.js → qoAbHCOq.js} +1 -1
- package/dist/static/_nuxt/rYfJ_RlJ.js +1 -0
- package/dist/static/_nuxt/{CrGsoVt3.js → tGXqY3hN.js} +1 -1
- package/dist/static/_nuxt/{Bk4XXIda.js → tv5vSe5Y.js} +1 -1
- package/dist/static/_nuxt/vector.NgmG3ZDn.css +1 -0
- package/dist/static/_nuxt/{BEX0oVSL.js → wSbLQ3i5.js} +2 -2
- package/dist/static/_nuxt/{0Vkqk5K3.js → y5gvPoD3.js} +1 -1
- package/dist/static/_nuxt/{DyweGZi4.js → yIw8BzU6.js} +1 -1
- package/dist/static/_nuxt/{NTQyXsYJ.js → zA0zNamO.js} +1 -1
- package/dist/static/index.html +1 -1
- package/dist/static/jobs/index.html +1 -1
- package/dist/static/login/index.html +1 -1
- package/dist/static/queues/index.html +1 -1
- package/dist/static/settings/index.html +1 -1
- package/dist/static/vector-bundle.json +148 -152
- package/package.json +19 -18
- package/dist/static/_nuxt/B6S9Z6WQ.js +0 -1
- package/dist/static/_nuxt/BDNMzG2s.js +0 -1
- package/dist/static/_nuxt/BDhmmehP.js +0 -2
- package/dist/static/_nuxt/BJhRZpbP.js +0 -1
- package/dist/static/_nuxt/BZXFBS4d.js +0 -1
- package/dist/static/_nuxt/Baf8k6rK.js +0 -1
- package/dist/static/_nuxt/BlcK9t0n.js +0 -1
- package/dist/static/_nuxt/Bp1wYuAu.js +0 -2
- package/dist/static/_nuxt/BqIYBnn1.js +0 -1
- package/dist/static/_nuxt/BzcHWzF1.js +0 -1
- package/dist/static/_nuxt/C-dF6TjJ.js +0 -1
- package/dist/static/_nuxt/C0BqlrB-.js +0 -1
- package/dist/static/_nuxt/C5lrJzwj.js +0 -67
- package/dist/static/_nuxt/C6kvBrux.js +0 -1
- package/dist/static/_nuxt/C9pCrKWL.js +0 -1
- package/dist/static/_nuxt/CBIdPVBN.js +0 -1
- package/dist/static/_nuxt/CE4w7ySf.js +0 -1
- package/dist/static/_nuxt/CIIjiec-.js +0 -1
- package/dist/static/_nuxt/CJUKNdMD.js +0 -1
- package/dist/static/_nuxt/CL8kR7Jl.js +0 -1
- package/dist/static/_nuxt/CTQUNAVB.js +0 -1
- package/dist/static/_nuxt/CTqdSnzX.js +0 -1
- package/dist/static/_nuxt/ChHwRItD.js +0 -1
- package/dist/static/_nuxt/ClGaGEq-.js +0 -1
- package/dist/static/_nuxt/ClTuaRRz.js +0 -1
- package/dist/static/_nuxt/CojXjKit.js +0 -1
- package/dist/static/_nuxt/CpCuvz_Q.js +0 -1
- package/dist/static/_nuxt/Cv4Z1VpR.js +0 -65
- package/dist/static/_nuxt/D1s1ZPEA.js +0 -2
- package/dist/static/_nuxt/D8p7N22I.js +0 -1
- package/dist/static/_nuxt/DBXnb1tR.js +0 -1
- package/dist/static/_nuxt/DCZnllp3.js +0 -1
- package/dist/static/_nuxt/DL237dS3.js +0 -1
- package/dist/static/_nuxt/DPH3RfAz.js +0 -1
- package/dist/static/_nuxt/DVKVuUv9.js +0 -1
- package/dist/static/_nuxt/Djb5b_0H.js +0 -1
- package/dist/static/_nuxt/DlpIJgqB.js +0 -1
- package/dist/static/_nuxt/DrEHkKjX.js +0 -10
- package/dist/static/_nuxt/DuYZsH0p.js +0 -1
- package/dist/static/_nuxt/DujOg9oz.js +0 -2
- package/dist/static/_nuxt/IhWbQWqt.js +0 -1
- package/dist/static/_nuxt/KeyValue.CczYMB-Q.css +0 -1
- package/dist/static/_nuxt/NOtHifBs.js +0 -105
- package/dist/static/_nuxt/Notifications.AEytcgEO.css +0 -1
- package/dist/static/_nuxt/OyqHv1Hk.js +0 -1
- package/dist/static/_nuxt/Pe8cg_oY.js +0 -1
- package/dist/static/_nuxt/QTRQ5bvA.js +0 -1
- package/dist/static/_nuxt/Un35xD_q.js +0 -1
- package/dist/static/_nuxt/UoJt16Vw.js +0 -1
- package/dist/static/_nuxt/VSpacer.DfbUir7X.css +0 -1
- package/dist/static/_nuxt/_resource_.CZ-hvn3L.css +0 -1
- package/dist/static/_nuxt/builds/meta/3c8a90b7-4dbd-4b44-8b52-44303c3d88d5.json +0 -1
- package/dist/static/_nuxt/error-404.DIb-VIQ0.css +0 -1
- package/dist/static/_nuxt/error-500.BvRwBykK.css +0 -1
- package/dist/static/_nuxt/vector.ClRRJOjR.css +0 -1
- package/dist/static/_nuxt/wlpNGAAZ.js +0 -3
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { approvalFrame, approvalOf, readDataStream, recordOfToolOutput, type ApprovalFrame, type DataStreamFrame } from '../utils/assistantStream'
|
|
2
|
+
import { ASSISTANT_MAX_MESSAGE_CHARS, fitAssistantMessages, messageChars, type AssistantMessage } from '../utils/assistantBody'
|
|
3
|
+
import { toolCallsOf, type AssistantToolCall } from '../utils/assistantTools'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Where a proposed change stands, as the drawer shows it: the server's
|
|
7
|
+
* own statuses, `deciding` while a decision is on its way, and `gone`
|
|
8
|
+
* when the server knows no such proposal for this admin (404).
|
|
9
|
+
*/
|
|
10
|
+
export type ApprovalState = 'pending' | 'deciding' | 'executed' | 'failed' | 'rejected' | 'expired' | 'gone'
|
|
11
|
+
|
|
12
|
+
/** A change the assistant proposed, as its card shows it. */
|
|
13
|
+
export interface ApprovalCard {
|
|
14
|
+
frame: ApprovalFrame
|
|
15
|
+
/** The record as a `vector_get` of the same run read it, to show each field's value before the change; null when the run did not read it. */
|
|
16
|
+
before: Record<string, unknown> | null
|
|
17
|
+
state: ApprovalState
|
|
18
|
+
/** What the approval executed answered, or why it failed. */
|
|
19
|
+
result: unknown
|
|
20
|
+
/** Why a decision could not be made, to show on the card; null when it was. */
|
|
21
|
+
error: string | null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** One message of the conversation, as the drawer shows it. */
|
|
25
|
+
export interface AssistantTurn {
|
|
26
|
+
id: string
|
|
27
|
+
/** `approval` is the admin's decision on a proposal: not shown, but sent so the model hears the outcome. */
|
|
28
|
+
role: 'user' | 'assistant' | 'approval'
|
|
29
|
+
content: string
|
|
30
|
+
/** The tools the assistant called for this answer, in order, each with whether it answered. */
|
|
31
|
+
tools: AssistantToolCall[]
|
|
32
|
+
/** The changes this answer proposed, in order. */
|
|
33
|
+
approvals: ApprovalCard[]
|
|
34
|
+
/** For an `approval` turn, the proposal decided on. */
|
|
35
|
+
approvalId?: string
|
|
36
|
+
/** Why the answer failed, to show beside a Retry; null when it did not. */
|
|
37
|
+
failed: string | null
|
|
38
|
+
streaming: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** What the server answers with `Accept: application/json`: `toolCalls` as `{name, ok}`, or as bare names. */
|
|
42
|
+
interface WholeAnswer { text: string, toolCalls: unknown, approvals?: unknown[] }
|
|
43
|
+
|
|
44
|
+
/** What a decision answers: `{status, result}`, or for a 409 `{error, status, result?}`. */
|
|
45
|
+
interface Decision { status?: unknown, result?: unknown, error?: unknown }
|
|
46
|
+
|
|
47
|
+
/** The tool calls of one run as its frames tell them: each call's tool, its input as it streamed, and the records `vector_get` read, by `resource#id`. */
|
|
48
|
+
interface RunReads {
|
|
49
|
+
calls: Map<string, { tool: string, input: string }>
|
|
50
|
+
records: Map<string, Record<string, unknown>>
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** What an answer that proposed changes without saying anything is sent as. */
|
|
54
|
+
export const PROPOSED_ONLY = '(Proposed the changes shown for approval.)'
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* After an approved change ran, refreshes the pages that show what it
|
|
58
|
+
* changed: the resource's list, a record's show page and its history, by
|
|
59
|
+
* the keys vector-ui loads them under. A key no mounted page uses
|
|
60
|
+
* refreshes nothing, and the edit page's key is left alone, so a form
|
|
61
|
+
* being typed into is kept.
|
|
62
|
+
*/
|
|
63
|
+
export function refreshChanged(frame: ApprovalFrame): Promise<void> {
|
|
64
|
+
if (frame.resource === null) return Promise.resolve()
|
|
65
|
+
const ids = new Set<string>()
|
|
66
|
+
if (frame.recordId !== null) ids.add(frame.recordId)
|
|
67
|
+
const listed = frame.arguments.ids
|
|
68
|
+
if (Array.isArray(listed)) listed.forEach(id => (typeof id === 'string' || typeof id === 'number') && ids.add(String(id)))
|
|
69
|
+
return refreshNuxtData([`vector.list.${frame.resource}`, ...[...ids].flatMap(id => [`vector.${frame.resource}.${id}`, `vector.audit.${frame.resource}.${id}`])])
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function newConversation(): string {
|
|
73
|
+
return `c_${crypto.randomUUID().replaceAll('-', '')}`
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function newId(): string {
|
|
77
|
+
return crypto.randomUUID()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The assistant's conversation: the browser's own, replayed to POST
|
|
82
|
+
* /vector/ai/assistant on every turn (the user's and the assistant's text
|
|
83
|
+
* only), and kept in shared state so the drawer survives navigation,
|
|
84
|
+
* for one signed-in user: the AI plugin
|
|
85
|
+
* forgets it when the user changes or signs out. A turn streams in the Vercel AI SDK
|
|
86
|
+
* data-stream protocol; where the runtime cannot stream (501) the same
|
|
87
|
+
* turn is asked again for the whole answer as JSON.
|
|
88
|
+
*/
|
|
89
|
+
export function useVectorAssistant() {
|
|
90
|
+
const open = useState('vector-ai.assistant.open', () => false)
|
|
91
|
+
const draft = useState('vector-ai.assistant.draft', () => '')
|
|
92
|
+
const turns = useState<AssistantTurn[]>('vector-ai.assistant.turns', () => [])
|
|
93
|
+
const conversationId = useState('vector-ai.assistant.conversation', newConversation)
|
|
94
|
+
const busy = useState('vector-ai.assistant.busy', () => false)
|
|
95
|
+
/** Why the last message was not sent, to show above the input; null when it was. */
|
|
96
|
+
const refused = useState<string | null>('vector-ai.assistant.refused', () => null)
|
|
97
|
+
const api = useVectorApi()
|
|
98
|
+
const host = useVectorHost()
|
|
99
|
+
const { t } = useVectorT()
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The conversation as the server takes it: settled text, and the
|
|
103
|
+
* proposals decided on, by id only: the server reads the outcome
|
|
104
|
+
* from its own row, newest last. An answer that only
|
|
105
|
+
* proposed changes, with no text, is kept with PROPOSED_ONLY in its
|
|
106
|
+
* place, so its proposals' outcomes do not follow the question directly.
|
|
107
|
+
*/
|
|
108
|
+
function history(): AssistantMessage[] {
|
|
109
|
+
return turns.value
|
|
110
|
+
.filter(turn => turn.role === 'approval' || (turn.failed === null && !turn.streaming && (turn.content.trim() !== '' || turn.approvals.length > 0)))
|
|
111
|
+
.map(turn => turn.role === 'approval'
|
|
112
|
+
? { role: 'approval' as const, id: turn.approvalId ?? '' }
|
|
113
|
+
: { role: turn.role, content: turn.content.trim() === '' ? PROPOSED_ONLY : turn.content })
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function card(frame: ApprovalFrame, reads: RunReads | null): ApprovalCard {
|
|
117
|
+
const before = frame.resource !== null && frame.recordId !== null ? reads?.records.get(`${frame.resource}#${frame.recordId}`) ?? null : null
|
|
118
|
+
return { frame, before, state: 'pending', result: null, error: null }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function apply(reply: AssistantTurn, frame: DataStreamFrame, reads: RunReads) {
|
|
122
|
+
const callId = typeof frame.toolCallId === 'string' ? frame.toolCallId : null
|
|
123
|
+
if (frame.type === 'text-delta' && typeof frame.delta === 'string') reply.content += frame.delta
|
|
124
|
+
else if (frame.type === 'tool-input-start' && typeof frame.toolName === 'string') {
|
|
125
|
+
reply.tools.push({ id: callId, name: frame.toolName, ok: null })
|
|
126
|
+
if (callId !== null) reads.calls.set(callId, { tool: frame.toolName, input: '' })
|
|
127
|
+
} else if (frame.type === 'tool-input-delta' && callId !== null && typeof frame.inputTextDelta === 'string') {
|
|
128
|
+
const call = reads.calls.get(callId)
|
|
129
|
+
if (call) call.input += frame.inputTextDelta
|
|
130
|
+
} else if (frame.type === 'tool-output-available' && callId !== null) {
|
|
131
|
+
settle(reply, callId, true)
|
|
132
|
+
remember(reads, callId, frame.output)
|
|
133
|
+
} else if (frame.type === 'tool-output-error' && callId !== null) settle(reply, callId, false)
|
|
134
|
+
else if (frame.type === 'error') reply.failed = typeof frame.errorText === 'string' ? frame.errorText : t('ai.assistant.failed')
|
|
135
|
+
else {
|
|
136
|
+
const approval = approvalFrame(frame)
|
|
137
|
+
if (approval !== null) reply.approvals.push(card(approval, reads))
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Whether call $callId of the reply answered ($ok), or was a tool error. */
|
|
142
|
+
function settle(reply: AssistantTurn, callId: string, ok: boolean) {
|
|
143
|
+
const call = reply.tools.find(tool => tool.id === callId)
|
|
144
|
+
if (call) call.ok = ok
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** What a `vector_get` of the run read, by `resource#id`, for a later proposal's "before". */
|
|
148
|
+
function remember(reads: RunReads, callId: string, output: unknown) {
|
|
149
|
+
const call = reads.calls.get(callId)
|
|
150
|
+
if (call?.tool !== 'vector_get') return
|
|
151
|
+
let input: { resource?: unknown, id?: unknown }
|
|
152
|
+
try {
|
|
153
|
+
input = JSON.parse(call.input) as { resource?: unknown, id?: unknown }
|
|
154
|
+
} catch {
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
const record = recordOfToolOutput(output)
|
|
158
|
+
if (record !== null && typeof input.resource === 'string' && (typeof input.id === 'string' || typeof input.id === 'number')) {
|
|
159
|
+
reads.records.set(`${input.resource}#${input.id}`, record)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function run() {
|
|
164
|
+
const ctx = host.context()
|
|
165
|
+
const build = (messages: AssistantMessage[]) => ({
|
|
166
|
+
conversationId: conversationId.value,
|
|
167
|
+
messages,
|
|
168
|
+
context: { path: ctx.path, resource: ctx.resource ?? null, recordId: ctx.recordId ?? null },
|
|
169
|
+
})
|
|
170
|
+
// within the server's caps, measured as the body it is sent as, and opening with the user
|
|
171
|
+
const body = build(fitAssistantMessages(history(), build))
|
|
172
|
+
turns.value.push({ id: newId(), role: 'assistant', content: '', tools: [], approvals: [], failed: null, streaming: true })
|
|
173
|
+
// the reactive copy in the list, so every change shows as it streams
|
|
174
|
+
const reply = turns.value[turns.value.length - 1]!
|
|
175
|
+
const reads: RunReads = { calls: new Map(), records: new Map() }
|
|
176
|
+
busy.value = true
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
const stream = await api<ReadableStream<Uint8Array>>('/vector/ai/assistant', { method: 'POST', body, responseType: 'stream', headers: { Accept: 'text/event-stream' } })
|
|
180
|
+
await readDataStream(stream, frame => apply(reply, frame, reads))
|
|
181
|
+
if (reply.content === '' && reply.approvals.length === 0 && reply.failed === null) reply.failed = t('ai.assistant.failed')
|
|
182
|
+
} catch (error) {
|
|
183
|
+
if (aiStatusOf(error) === 501) {
|
|
184
|
+
// the runtime cannot stream: the same turn, answered whole
|
|
185
|
+
try {
|
|
186
|
+
const answer = await api<WholeAnswer>('/vector/ai/assistant', { method: 'POST', body, headers: { Accept: 'application/json' } })
|
|
187
|
+
reply.content = answer.text
|
|
188
|
+
reply.tools = toolCallsOf(answer.toolCalls)
|
|
189
|
+
reply.approvals = (answer.approvals ?? []).map(approvalOf).filter(frame => frame !== null).map(frame => card(frame, null))
|
|
190
|
+
} catch (whole) {
|
|
191
|
+
reply.failed = await describe(whole)
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
reply.failed = await describe(error)
|
|
195
|
+
}
|
|
196
|
+
} finally {
|
|
197
|
+
reply.streaming = false
|
|
198
|
+
busy.value = false
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Sends $text as the user's next message. One longer than the server
|
|
204
|
+
* takes (ASSISTANT_MAX_MESSAGE_CHARS, counted in code points as the
|
|
205
|
+
* server counts it) is not sent and not added to the conversation
|
|
206
|
+
* (every later turn would replay it and be refused) but left in the
|
|
207
|
+
* input to shorten, saying why.
|
|
208
|
+
*/
|
|
209
|
+
async function send(text: string) {
|
|
210
|
+
const content = text.trim()
|
|
211
|
+
if (content === '' || busy.value) return
|
|
212
|
+
if (messageChars(content) > ASSISTANT_MAX_MESSAGE_CHARS) {
|
|
213
|
+
draft.value = content
|
|
214
|
+
refused.value = t('ai.assistant.tooLong', { max: ASSISTANT_MAX_MESSAGE_CHARS.toLocaleString() })
|
|
215
|
+
return
|
|
216
|
+
}
|
|
217
|
+
refused.value = null
|
|
218
|
+
turns.value.push({ id: newId(), role: 'user', content, tools: [], approvals: [], failed: null, streaming: false })
|
|
219
|
+
draft.value = ''
|
|
220
|
+
await run()
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Approves or rejects a proposal: POST /vector/ai/approvals/{id}/{verb},
|
|
225
|
+
* with no body; the server executes its own stored arguments. A
|
|
226
|
+
* decision that stands (executed, failed or rejected, also when the
|
|
227
|
+
* server answers 409 with a decision made before) is appended to the
|
|
228
|
+
* conversation, once, and the next turn is sent so the assistant says
|
|
229
|
+
* what happened; an expired (410) or unknown (404) proposal only says
|
|
230
|
+
* so on its card.
|
|
231
|
+
*/
|
|
232
|
+
async function decide(approval: ApprovalCard, verb: 'approve' | 'reject') {
|
|
233
|
+
if (busy.value || approval.state !== 'pending') return
|
|
234
|
+
approval.state = 'deciding'
|
|
235
|
+
approval.error = null
|
|
236
|
+
let decided: Decision | null = null
|
|
237
|
+
|
|
238
|
+
try {
|
|
239
|
+
decided = await api<Decision>(`/vector/ai/approvals/${encodeURIComponent(approval.frame.id)}/${verb}`, { method: 'POST' })
|
|
240
|
+
} catch (error) {
|
|
241
|
+
const status = aiStatusOf(error)
|
|
242
|
+
const data = (error as { data?: unknown } | null)?.data
|
|
243
|
+
if (status === 409 && data !== null && typeof data === 'object') decided = data as Decision
|
|
244
|
+
else if (status === 410) approval.state = 'expired'
|
|
245
|
+
else if (status === 404) approval.state = 'gone'
|
|
246
|
+
else {
|
|
247
|
+
approval.state = 'pending'
|
|
248
|
+
approval.error = await describe(error)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (decided === null) return
|
|
253
|
+
const status = decided.status
|
|
254
|
+
// another request is executing it right now: its outcome is that request's to tell,
|
|
255
|
+
// so the card goes back to waiting, saying so, and asking again later shows the outcome
|
|
256
|
+
if (status === 'executing') {
|
|
257
|
+
approval.state = 'pending'
|
|
258
|
+
approval.error = t('ai.assistant.approval.inProgress')
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
approval.state = status === 'executed' || status === 'failed' || status === 'rejected' || status === 'expired' ? status : 'gone'
|
|
262
|
+
approval.result = decided.result ?? null
|
|
263
|
+
if (approval.state === 'expired' || approval.state === 'gone') return
|
|
264
|
+
if (approval.state === 'executed') void refreshChanged(approval.frame)
|
|
265
|
+
|
|
266
|
+
if (turns.value.some(turn => turn.role === 'approval' && turn.approvalId === approval.frame.id)) return
|
|
267
|
+
turns.value.push({ id: newId(), role: 'approval', content: '', tools: [], approvals: [], approvalId: approval.frame.id, failed: null, streaming: false })
|
|
268
|
+
await run()
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Asks again for the answer that failed: the last one. */
|
|
272
|
+
async function retry() {
|
|
273
|
+
const last = turns.value[turns.value.length - 1]
|
|
274
|
+
if (busy.value || last === undefined || last.role !== 'assistant' || last.failed === null) return
|
|
275
|
+
turns.value.pop()
|
|
276
|
+
await run()
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** A new conversation: nothing of the last one is sent again. */
|
|
280
|
+
function reset() {
|
|
281
|
+
if (busy.value) return
|
|
282
|
+
turns.value = []
|
|
283
|
+
draft.value = ''
|
|
284
|
+
refused.value = null
|
|
285
|
+
conversationId.value = newConversation()
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Forgets the conversation and closes the drawer, even mid-answer:
|
|
290
|
+
* someone else, or nobody, is signed in now, and nothing of the last
|
|
291
|
+
* person's conversation may be shown or sent again. A turn still
|
|
292
|
+
* streaming finishes into a reply no longer shown.
|
|
293
|
+
*/
|
|
294
|
+
function forget() {
|
|
295
|
+
turns.value = []
|
|
296
|
+
draft.value = ''
|
|
297
|
+
refused.value = null
|
|
298
|
+
conversationId.value = newConversation()
|
|
299
|
+
open.value = false
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** A failure in words: a spent budget says when it renews, when Retry-After can be read; otherwise the server's reason. */
|
|
303
|
+
async function describe(error: unknown): Promise<string> {
|
|
304
|
+
// a streamed request's error body is still a stream: read it for the reason
|
|
305
|
+
let data = (error as { data?: unknown } | null)?.data
|
|
306
|
+
if (data instanceof ReadableStream) {
|
|
307
|
+
try {
|
|
308
|
+
data = JSON.parse(await new Response(data).text())
|
|
309
|
+
} catch {
|
|
310
|
+
data = null
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return aiFailureMessage(error, t('ai.assistant.failed'), data)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return { open, draft, turns, busy, refused, conversationId, send, retry, reset, forget, decide }
|
|
318
|
+
}
|
|
@@ -39,7 +39,7 @@ const MAX_DELAY = 2 ** 31 - 1
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Bearer-mode session. The access token lives in memory for the tab and
|
|
42
|
-
* is mirrored to sessionStorage
|
|
42
|
+
* is mirrored to sessionStorage (never localStorage) beside the refresh
|
|
43
43
|
* token when the application issues one (`/auth/login` answering
|
|
44
44
|
* `refreshToken`). The session renews itself through `POST /auth/refresh`
|
|
45
45
|
* when the access token has under two minutes left, and once more on a
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { markRaw, readonly, type Component, type DeepReadonly, type Ref } from 'vue'
|
|
2
|
+
import type { AnyExtension } from '@tiptap/core'
|
|
3
|
+
import {
|
|
4
|
+
VAlert, VAutocomplete, VBadge, VBtn, VCard, VCheckbox, VChip, VDialog, VDivider, VExpansionPanel, VExpansionPanels, VExpansionPanelText,
|
|
5
|
+
VExpansionPanelTitle, VIcon, VList, VListItem, VMenu, VNavigationDrawer, VPagination, VProgressCircular, VProgressLinear, VRating, VSelect,
|
|
6
|
+
VSkeletonLoader, VSwitch, VTab, VTable, VTabs, VTabsWindow, VTabsWindowItem, VTextField, VTextarea, VToolbar, VTooltip,
|
|
7
|
+
} from 'vuetify/components'
|
|
8
|
+
import type { VectorSchema } from '../types/vector'
|
|
9
|
+
import { INPUT_ADDON_PLACEMENTS, type VectorInputAddonPlacement, type VectorPageLabel, type VectorPaletteCommand } from './useVectorExtensions'
|
|
10
|
+
import { markdownHtml, sanitizeHtml } from '../utils/richtext'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Every Vuetify component an extension can reach without a bundler of its
|
|
14
|
+
* own: tree-shaking keeps only what is imported here. VTable for a custom
|
|
15
|
+
* page's tables, VNavigationDrawer, VToolbar, VProgressCircular and VBadge
|
|
16
|
+
* for a shell action's side panel.
|
|
17
|
+
*/
|
|
18
|
+
export const VECTOR_VUETIFY: Record<string, Component> = {
|
|
19
|
+
VAlert, VAutocomplete, VBadge, VBtn, VCard, VCheckbox, VChip, VDialog, VDivider, VExpansionPanel, VExpansionPanels, VExpansionPanelText,
|
|
20
|
+
VExpansionPanelTitle, VIcon, VList, VListItem, VMenu, VNavigationDrawer, VPagination, VProgressCircular, VProgressLinear, VRating, VSelect,
|
|
21
|
+
VSkeletonLoader, VSwitch, VTab, VTable, VTabs, VTabsWindow, VTabsWindowItem, VTextField, VTextarea, VToolbar, VTooltip,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Where the admin is: the path under its base path, and the resource and record a page is about. */
|
|
25
|
+
export interface VectorContext {
|
|
26
|
+
path: string
|
|
27
|
+
resource?: string
|
|
28
|
+
recordId?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** What the admin lends an extension: its descriptor, where it is, its language and its HTML helpers. */
|
|
32
|
+
export interface VectorHost {
|
|
33
|
+
/** The loaded descriptor, null before the first load; read-only. */
|
|
34
|
+
schema: DeepReadonly<Ref<VectorSchema | null>>
|
|
35
|
+
context: () => VectorContext
|
|
36
|
+
/** The language the admin is shown in, a BCP 47 tag. */
|
|
37
|
+
locale: () => string
|
|
38
|
+
/** Markdown rendered to sanitized HTML, as the admin renders a markdown field. */
|
|
39
|
+
markdownHtml: (text: string) => string
|
|
40
|
+
/** HTML with everything the admin would not render removed. */
|
|
41
|
+
sanitizeHtml: (html: string) => string
|
|
42
|
+
vuetify: Record<string, Component>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const NAME = /^[a-z0-9][a-z0-9-]*$/
|
|
46
|
+
|
|
47
|
+
function checkName(kind: string, name: string): void {
|
|
48
|
+
if (!NAME.test(name)) throw new Error(`Vector ${kind} name "${name}" must be lowercase letters, digits and dashes.`)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The admin's host services, for a layer or a runtime extension. Call it
|
|
53
|
+
* where Nuxt composables work (setup, a plugin); what it returns may then
|
|
54
|
+
* be used anywhere.
|
|
55
|
+
*/
|
|
56
|
+
export function useVectorHost(): VectorHost {
|
|
57
|
+
const { schema } = useVectorSchema()
|
|
58
|
+
const router = useRouter()
|
|
59
|
+
const appConfig = useAppConfig()
|
|
60
|
+
const language = useVectorLocale()
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
schema: readonly(schema),
|
|
64
|
+
context: () => {
|
|
65
|
+
const route = router.currentRoute.value
|
|
66
|
+
const base = appConfig.vector.basePath
|
|
67
|
+
const path = base !== '' && route.path.startsWith(base) ? route.path.slice(base.length) || '/' : route.path
|
|
68
|
+
const param = (name: string) => {
|
|
69
|
+
const value = route.params[name]
|
|
70
|
+
return typeof value === 'string' && value !== '' ? value : undefined
|
|
71
|
+
}
|
|
72
|
+
const resource = param('resource')
|
|
73
|
+
const recordId = resource === undefined ? undefined : param('id')
|
|
74
|
+
|
|
75
|
+
return { path, ...(resource === undefined ? {} : { resource }), ...(recordId === undefined ? {} : { recordId }) }
|
|
76
|
+
},
|
|
77
|
+
locale: () => language.current.value,
|
|
78
|
+
markdownHtml,
|
|
79
|
+
sanitizeHtml,
|
|
80
|
+
vuetify: VECTOR_VUETIFY,
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The registration points of `window.Vector` version 2, for a layer's
|
|
86
|
+
* own code as much as for a runtime extension: the same registries, the
|
|
87
|
+
* same rules. Every name is lowercase letters, digits and dashes;
|
|
88
|
+
* registering a name again replaces what it named.
|
|
89
|
+
*/
|
|
90
|
+
export function useVectorExtend() {
|
|
91
|
+
const registries = useVectorExtensions()
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
// version 1
|
|
95
|
+
defineCell: (name: string, component: Component) => registries.cells.set(name, markRaw(component)),
|
|
96
|
+
defineInput: (name: string, component: Component) => registries.inputs.set(name, markRaw(component)),
|
|
97
|
+
defineWidget: (type: string, component: Component) => registries.widgets.set(type, markRaw(component)),
|
|
98
|
+
/**
|
|
99
|
+
* A rich-text node or mark type (a Tiptap extension) a field's `features` may then name. The server
|
|
100
|
+
* accepts it only when the application registered the same name with Document::extend().
|
|
101
|
+
*/
|
|
102
|
+
defineRichTextExtension: (name: string, extension: AnyExtension) => registries.richText.set(name, markRaw(extension)),
|
|
103
|
+
/**
|
|
104
|
+
* A custom page at `/p/{name}`, listed in the menu: definePage('stock', { title: 'Stock', icon: 'mdi-warehouse', component }).
|
|
105
|
+
* `title` and `group` may be functions, `() => t('stock.title')`, called each time they are shown, so they follow the language.
|
|
106
|
+
*/
|
|
107
|
+
definePage: (name: string, page: { title: VectorPageLabel, icon?: string, group?: VectorPageLabel, component: Component }) => {
|
|
108
|
+
checkName('page', name)
|
|
109
|
+
registries.pages.set(name, { ...page, component: markRaw(page.component) })
|
|
110
|
+
},
|
|
111
|
+
// version 2
|
|
112
|
+
/**
|
|
113
|
+
* A component in the app bar, before the notifications inbox. It takes no props; it may teleport a
|
|
114
|
+
* dialog or an end-side navigation drawer of its own.
|
|
115
|
+
*/
|
|
116
|
+
defineShellAction: (name: string, component: Component) => {
|
|
117
|
+
checkName('shell action', name)
|
|
118
|
+
registries.shellActions.set(name, markRaw(component))
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* A component in a list's toolbar, beside the search: props `{ resource, filters, groups, advanced, search }`,
|
|
122
|
+
* emitting `update:filters`, `update:groups`, `update:advanced` and `update:search` to change the list.
|
|
123
|
+
*/
|
|
124
|
+
defineListToolbarItem: (name: string, component: Component) => {
|
|
125
|
+
checkName('list toolbar item', name)
|
|
126
|
+
registries.listToolbar.set(name, markRaw(component))
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* A component with every form input of the given field types: props `{ field, resource, record, modelValue,
|
|
130
|
+
* disabled }`, emitting `update:modelValue` to change the field's value. `placement` is `below` (the default),
|
|
131
|
+
* in a row under the input, or `inner`, inside a text or textarea input at its inline end.
|
|
132
|
+
*/
|
|
133
|
+
defineInputAddon: (name: string, addon: { types: string[], component: Component, placement?: VectorInputAddonPlacement }) => {
|
|
134
|
+
checkName('input addon', name)
|
|
135
|
+
if (!Array.isArray(addon.types) || addon.types.some(t => typeof t !== 'string')) throw new Error(`Vector input addon "${name}" needs types: string[].`)
|
|
136
|
+
const placement = addon.placement ?? 'below'
|
|
137
|
+
if (!INPUT_ADDON_PLACEMENTS.includes(placement)) throw new Error(`Vector input addon "${name}" needs placement: ${INPUT_ADDON_PLACEMENTS.join(' | ')}.`)
|
|
138
|
+
registries.inputAddons.set(name, { types: [...addon.types], component: markRaw(addon.component), placement })
|
|
139
|
+
},
|
|
140
|
+
/** A component in the toolbar of the rich-text and Markdown editors: props `{ editor, field }`, the live Tiptap editor. */
|
|
141
|
+
defineEditorToolbarItem: (name: string, component: Component) => {
|
|
142
|
+
checkName('editor toolbar item', name)
|
|
143
|
+
registries.editorToolbar.set(name, markRaw(component))
|
|
144
|
+
},
|
|
145
|
+
/** An entry in the command palette, under "Commands": run(query) is called with what was typed. */
|
|
146
|
+
definePaletteCommand: (name: string, command: VectorPaletteCommand) => {
|
|
147
|
+
checkName('palette command', name)
|
|
148
|
+
if (typeof command.run !== 'function') throw new Error(`Vector palette command "${name}" needs run(query).`)
|
|
149
|
+
registries.paletteCommands.set(name, { ...command })
|
|
150
|
+
},
|
|
151
|
+
/** A component under a settings group's form, on the Settings page: props `{ group }`, the group's name. */
|
|
152
|
+
defineSettingsAddon: (group: string, component: Component) => {
|
|
153
|
+
checkName('settings group', group)
|
|
154
|
+
registries.settingsAddons.set(group, markRaw(component))
|
|
155
|
+
},
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { AnyExtension } from '@tiptap/core'
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A custom page's title or menu section: a string, or a function returning
|
|
6
|
-
* one
|
|
6
|
+
* one, `() => t('stock.title')`, called each time it is shown, so it
|
|
7
7
|
* follows a change of language.
|
|
8
8
|
*/
|
|
9
9
|
export type VectorPageLabel = string | (() => string)
|
|
@@ -24,11 +24,40 @@ export function pageLabel(label: VectorPageLabel | undefined): string | undefine
|
|
|
24
24
|
return typeof label === 'function' ? label() : label
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/** Where an input addon renders: in a row under the input, or inside the input at its inline end. */
|
|
28
|
+
export type VectorInputAddonPlacement = 'below' | 'inner'
|
|
29
|
+
|
|
30
|
+
/** The placements defineInputAddon() accepts. */
|
|
31
|
+
export const INPUT_ADDON_PLACEMENTS: readonly VectorInputAddonPlacement[] = ['below', 'inner']
|
|
32
|
+
|
|
33
|
+
/** An addon rendered with every form input of the listed field types. */
|
|
34
|
+
export interface VectorInputAddon {
|
|
35
|
+
/** Field types (`string`, `text`, `richtext`, …) whose inputs get the addon. */
|
|
36
|
+
types: string[]
|
|
37
|
+
component: Component
|
|
38
|
+
/**
|
|
39
|
+
* `below` (the default): in a row under the input, in the record form and a loose field list.
|
|
40
|
+
* `inner`: inside the input itself, at its inline end (Vuetify's `append-inner`); only the
|
|
41
|
+
* text and textarea inputs render it.
|
|
42
|
+
*/
|
|
43
|
+
placement: VectorInputAddonPlacement
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A command palette entry under "Commands": run() is given what was typed. */
|
|
47
|
+
export interface VectorPaletteCommand {
|
|
48
|
+
title: VectorPageLabel
|
|
49
|
+
icon?: string
|
|
50
|
+
run: (query: string) => unknown
|
|
51
|
+
}
|
|
52
|
+
|
|
27
53
|
/**
|
|
28
|
-
* The registries runtime extensions fill through
|
|
29
|
-
* cells, inputs, widget renderers
|
|
30
|
-
*
|
|
31
|
-
*
|
|
54
|
+
* The registries runtime extensions and layers fill through
|
|
55
|
+
* `window.Vector` or useVectorExtend(): cells, inputs, widget renderers
|
|
56
|
+
* and custom pages by name (v1), and the shell's own slots (v2): app-bar
|
|
57
|
+
* actions, list-toolbar items, input and editor-toolbar addons, palette
|
|
58
|
+
* commands and settings-group addons. Reactive, so something registered
|
|
59
|
+
* after boot shows up without a reload. `ready` turns true once every
|
|
60
|
+
* extension module has loaded (or failed to).
|
|
32
61
|
*/
|
|
33
62
|
export function useVectorExtensions() {
|
|
34
63
|
const cells = useState<Map<string, Component>>('vector.ext.cells', () => shallowReactive(new Map()))
|
|
@@ -37,9 +66,38 @@ export function useVectorExtensions() {
|
|
|
37
66
|
const pages = useState<Map<string, VectorPageDefinition>>('vector.ext.pages', () => shallowReactive(new Map()))
|
|
38
67
|
// rich-text node and mark types, by the feature name a field's `features` uses
|
|
39
68
|
const richText = useState<Map<string, AnyExtension>>('vector.ext.richText', () => shallowReactive(new Map()))
|
|
69
|
+
const shellActions = useState<Map<string, Component>>('vector.ext.shellActions', () => shallowReactive(new Map()))
|
|
70
|
+
const listToolbar = useState<Map<string, Component>>('vector.ext.listToolbar', () => shallowReactive(new Map()))
|
|
71
|
+
const inputAddons = useState<Map<string, VectorInputAddon>>('vector.ext.inputAddons', () => shallowReactive(new Map()))
|
|
72
|
+
const editorToolbar = useState<Map<string, Component>>('vector.ext.editorToolbar', () => shallowReactive(new Map()))
|
|
73
|
+
const paletteCommands = useState<Map<string, VectorPaletteCommand>>('vector.ext.paletteCommands', () => shallowReactive(new Map()))
|
|
74
|
+
// by settings group name: one addon each, rendered under the group's form
|
|
75
|
+
const settingsAddons = useState<Map<string, Component>>('vector.ext.settingsAddons', () => shallowReactive(new Map()))
|
|
40
76
|
const ready = useState<boolean>('vector.ext.ready', () => false)
|
|
41
77
|
|
|
42
|
-
return {
|
|
78
|
+
return {
|
|
79
|
+
cells: cells.value,
|
|
80
|
+
inputs: inputs.value,
|
|
81
|
+
widgets: widgets.value,
|
|
82
|
+
pages: pages.value,
|
|
83
|
+
richText: richText.value,
|
|
84
|
+
shellActions: shellActions.value,
|
|
85
|
+
listToolbar: listToolbar.value,
|
|
86
|
+
inputAddons: inputAddons.value,
|
|
87
|
+
editorToolbar: editorToolbar.value,
|
|
88
|
+
paletteCommands: paletteCommands.value,
|
|
89
|
+
settingsAddons: settingsAddons.value,
|
|
90
|
+
ready,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The input addons for one field type at one placement (`below` by default), in registration order. */
|
|
95
|
+
export function useVectorInputAddons(type: () => string, placement: () => VectorInputAddonPlacement = () => 'below') {
|
|
96
|
+
const { inputAddons } = useVectorExtensions()
|
|
97
|
+
|
|
98
|
+
return computed(() => [...inputAddons.entries()]
|
|
99
|
+
.filter(([, addon]) => addon.types.includes(type()) && addon.placement === placement())
|
|
100
|
+
.map(([name, addon]) => ({ name, component: addon.component })))
|
|
43
101
|
}
|
|
44
102
|
|
|
45
103
|
/**
|
|
@@ -5,7 +5,7 @@ import type { VectorField } from '#vector/app/types/vector'
|
|
|
5
5
|
* The field registry: a descriptor field resolves to the component that
|
|
6
6
|
* renders it as a table cell or a show-page value.
|
|
7
7
|
*
|
|
8
|
-
* Built-in cells are imported explicitly
|
|
8
|
+
* Built-in cells are imported explicitly; a dynamic `<component :is>`
|
|
9
9
|
* defeats template-time auto-import, so nothing here relies on it. A
|
|
10
10
|
* consuming app adds or replaces entries through `app.config.vector.fields`
|
|
11
11
|
* (keyed by a field's explicit `component` name or by its `type`), naming
|
|
@@ -5,7 +5,7 @@ import { useEventListener, useIdle } from '@vueuse/core'
|
|
|
5
5
|
* session otherwise never ends on its own: the store renews the token
|
|
6
6
|
* before it runs out and the shell polls badges and the inbox, so an open
|
|
7
7
|
* tab stays signed in for as long as it is open. This watches for a real
|
|
8
|
-
* person
|
|
8
|
+
* person (a pointer, a key, a touch, a scroll) and, once app config
|
|
9
9
|
* `vector.idleMinutes` have passed without one, calls `onIdle` exactly
|
|
10
10
|
* once. A tab that comes back into view after sleeping is checked at
|
|
11
11
|
* that moment too, since a timer may not have fired meanwhile.
|
|
@@ -49,8 +49,8 @@ export function useVectorLocale() {
|
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* The user picks a language: remembered as their preference, then applied
|
|
52
|
-
*
|
|
53
|
-
* again, and the server answers in the preference it has
|
|
52
|
+
*(in that order, since applying it makes every page fetch its labels
|
|
53
|
+
* again, and the server answers in the preference it has) and the
|
|
54
54
|
* descriptor reloaded in it.
|
|
55
55
|
*/
|
|
56
56
|
async function choose(code: string): Promise<void> {
|
|
@@ -5,7 +5,7 @@ import type { VectorResource, VectorSchema } from '#vector/app/types/vector'
|
|
|
5
5
|
let latestLoad = 0
|
|
6
6
|
|
|
7
7
|
/** The descriptor contract this UI reads: the `version` kinetis/vector publishes (VectorRegistry::VERSION). */
|
|
8
|
-
export const DESCRIPTOR_VERSION =
|
|
8
|
+
export const DESCRIPTOR_VERSION = 6
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* The descriptor, loaded once per session and shared by every page. The
|
|
@@ -23,8 +23,8 @@ export function vectorUiRemedy(expected: string | null, hosted: boolean): string
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* This UI's own release
|
|
27
|
-
* the build
|
|
26
|
+
* This UI's own release (the layer's package.json version, baked into
|
|
27
|
+
* the build) against the one the descriptor says kinetis/vector pins.
|
|
28
28
|
* A mismatch is a warning, not a stop: the descriptor contract is what
|
|
29
29
|
* must match (useVectorSchema refuses another), the release only should.
|
|
30
30
|
* No pin on the server is no expectation, and no warning.
|