@lobu/runtime-server 24.8.0 → 24.9.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/dist/catalogs/connectors.json +83 -6
- package/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/README.md +6 -2
- package/dist/connectors/github.ts +16 -3
- package/dist/connectors/market_quotes.ts +388 -91
- package/dist/connectors/postgres.ts +21 -14
- package/dist/connectors/x-dm-adapter.js +55 -21
- package/dist/connectors/x.ts +1 -1
- package/dist/db/migrations/20261109010000_workspace_navigation.sql +14 -0
- package/dist/db/migrations/20261110010000_view_resources.sql +11 -0
- package/dist/dependencies.bun.lock +61 -61
- package/dist/owletto/dist/assets/_-B2C9B2RM.js +2 -0
- package/dist/owletto/dist/assets/_-CjyiGzwB.js +3 -0
- package/dist/owletto/dist/assets/_agentId-DKHXGvS2.js +2 -0
- package/dist/owletto/dist/assets/_agentId-bna2tPsW.js +2 -0
- package/dist/owletto/dist/assets/_automationId-CowRFD4E.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-dE6im18z.js +2 -0
- package/dist/owletto/dist/assets/{_connectorKey.index-DM5MTO8c.js → _connectorKey.index-DqwSv8Zs.js} +2 -2
- package/dist/owletto/dist/assets/{_conversationId-OJrZjd0o.js → _conversationId-zcs-S3dY.js} +2 -2
- package/dist/owletto/dist/assets/_eventId-BVOVizs4.js +2 -0
- package/dist/owletto/dist/assets/_owner-DsvIC94q.js +3 -0
- package/dist/owletto/dist/assets/_shape-CWjpzcvv.js +2 -0
- package/dist/owletto/dist/assets/_slug-DuCxYsJk.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-BqVeHB6Z.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-DzyOCG5U.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-BC-ZIsrf.js → accept-invitation-k1u3zBcn.js} +2 -2
- package/dist/owletto/dist/assets/activity-route-view-jTBMW7a9.js +2 -0
- package/dist/owletto/dist/assets/{agent-connect-pages-CdDjrHjn.js → agent-connect-pages-D3mVM_q4.js} +4 -4
- package/dist/owletto/dist/assets/{agent-editor-form-CDAHRNWl.js → agent-editor-form-Bnc_q5WD.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-BupiSjR-.js → agent-loading-shells-xteN-pyK.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-ju7L2M0l.js → agent-permissions-matrix-C_ayr0pd.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-B0ZYVE3n.js → agent-skill-context-r0O0BVOu.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-ByU0xhXn.js → agent-subpage-shell-C2KpYdu3.js} +2 -2
- package/dist/owletto/dist/assets/{agent-thread-DiVKn1WX.js → agent-thread-Bv_chdPy.js} +3 -3
- package/dist/owletto/dist/assets/{app._appId-BQWElSoP.js → app._appId-BUcNaSMS.js} +2 -2
- package/dist/owletto/dist/assets/{assist-composer-igTXq3DL.js → assist-composer-B1LykXpD.js} +2 -2
- package/dist/owletto/dist/assets/automation-run-now-CjkJIkaZ.js +2 -0
- package/dist/owletto/dist/assets/{callback-Dmaio9CX.js → callback-kSLa4n5s.js} +2 -2
- package/dist/owletto/dist/assets/{card-rE4Ctuy6.js → card-C01y1O-W.js} +2 -2
- package/dist/owletto/dist/assets/{claim-BN17CPYh.js → claim-Dnux9Lqf.js} +2 -2
- package/dist/owletto/dist/assets/{client-activity-scopes-B7xVaUA-.js → client-activity-scopes-BBIq16tG.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows-B3LULJxW.js → client-rows-DGh1O-Fu.js} +2 -2
- package/dist/owletto/dist/assets/{clients-CydgUHrc.js → clients-BCvjAJDT.js} +2 -2
- package/dist/owletto/dist/assets/{code-editor-UppEMWpt.js → code-editor-BdRMYojw.js} +2 -2
- package/dist/owletto/dist/assets/connect-DZeFSGIH.js +2 -0
- package/dist/owletto/dist/assets/connect-menu-D4w-JhJW.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-IZEMQJ64.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId-CaF-ZWlZ.js → connected._clientId-BsDzltNz.js} +2 -2
- package/dist/owletto/dist/assets/{connection-D8ZAMHBT.js → connection-C7glVpPE.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-CJYqryAV.js → connection-feed-detail-CJju0qiw.js} +2 -2
- package/dist/owletto/dist/assets/{connector-page-shell-C23dWdKz.js → connector-page-shell-BeuyjiB2.js} +2 -2
- package/dist/owletto/dist/assets/{connector-provenance-CW4CXtCz.js → connector-provenance-B2C2cjBg.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-Bp08_KPq.js → connectors-DSQ5AWPf.js} +2 -2
- package/dist/owletto/dist/assets/{consent-_PpYI1cT.js → consent-B6Aw_89N.js} +2 -2
- package/dist/owletto/dist/assets/{copy-button-1ALlvZU1.js → copy-button-BhXeXLIm.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-6koO33th.js → core.esm-CJUp2aNZ.js} +3 -3
- package/dist/owletto/dist/assets/create-CWcza8NT.js +2 -0
- package/dist/owletto/dist/assets/{create-kUevP9Xx.js → create-DUlRsFNn.js} +2 -2
- package/dist/owletto/dist/assets/{create-automation-form-BhujNbRr.js → create-automation-form-D141prEG.js} +3 -3
- package/dist/owletto/dist/assets/{create-Drx9tcnG.js → create-bGOYifof.js} +2 -2
- package/dist/owletto/dist/assets/create._connectorKey-Ds4tpwHP.js +2 -0
- package/dist/owletto/dist/assets/{custom-guardrail-edits-B_aCgvoZ.js → custom-guardrail-edits-DuQ28xv3.js} +2 -2
- package/dist/owletto/dist/assets/{definition-comparison-3zKUSTt8.js → definition-comparison-BUDNuAN_.js} +2 -2
- package/dist/owletto/dist/assets/{detail-page-skeleton-BmxqqIsH.js → detail-page-skeleton-BRHaq5Sj.js} +2 -2
- package/dist/owletto/dist/assets/{device-D2eUt_nr.js → device-D3fzoIrM.js} +2 -2
- package/dist/owletto/dist/assets/{device-pin-tombstone-BFPbTM_o.js → device-pin-tombstone-BIM-ziCH.js} +2 -2
- package/dist/owletto/dist/assets/{device._deviceId-Dqtmb1Xp.js → device._deviceId-BnPqTgK1.js} +2 -2
- package/dist/owletto/dist/assets/{dynamic-schema-form-D3KnzCsW.js → dynamic-schema-form-OkIZImgp.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-CpeX7iiX.js +2 -0
- package/dist/owletto/dist/assets/entity-page-Cjc8oXA2.js +2 -0
- package/dist/owletto/dist/assets/{entity-pages-DJNSQrfB.js → entity-pages-18xSANrS.js} +2 -2
- package/dist/owletto/dist/assets/entity-schema-graph-uwZ-P0t8.js +2 -0
- package/dist/owletto/dist/assets/{entity-type-page-CouHZbc9.js → entity-type-page-MgZ7_0oh.js} +2 -2
- package/dist/owletto/dist/assets/event-detail-D6AH6a2C.js +2 -0
- package/dist/owletto/dist/assets/events-feed-BI7wNRUY.js +2 -0
- package/dist/owletto/dist/assets/filter-editors-DDTwyYt0.js +3 -0
- package/dist/owletto/dist/assets/{full-page-spinner-B7A6Ycyi.js → full-page-spinner-DWo519BU.js} +2 -2
- package/dist/owletto/dist/assets/index-9tTjJo_J.css +1 -0
- package/dist/owletto/dist/assets/{index-B-dZruj6.js → index-BW7IFKXC.js} +2 -2
- package/dist/owletto/dist/assets/{index-C7QM3aqU.js → index-BYcFrinP.js} +2 -2
- package/dist/owletto/dist/assets/index-BhJsTy-C.js +2 -0
- package/dist/owletto/dist/assets/index-CEcsgXDj.js +2 -0
- package/dist/owletto/dist/assets/index-CPscKk2u.js +2 -0
- package/dist/owletto/dist/assets/{index-DXfYVs5m.js → index-Cd8jMsz8.js} +2 -2
- package/dist/owletto/dist/assets/index-CdDNNAx2.js +7906 -0
- package/dist/owletto/dist/assets/index-CfJ2-EpK.js +2 -0
- package/dist/owletto/dist/assets/{index-BztXeLBN.js → index-D1UCJQl1.js} +2 -2
- package/dist/owletto/dist/assets/index-D5DM4g2w.js +2 -0
- package/dist/owletto/dist/assets/index-DmqnKGqW.js +2 -0
- package/dist/owletto/dist/assets/index-DznAbTOF.js +2 -0
- package/dist/owletto/dist/assets/{json-diff-CJK-gzCt.js → json-diff-C-WQqyIf.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-bQAZ0hQp.js → list-skeleton-0B1bTrAK.js} +2 -2
- package/dist/owletto/dist/assets/{login-DLqL54Rk.js → login-CH7P2AyR.js} +2 -2
- package/dist/owletto/dist/assets/{logout-H0F3IfiO.js → logout-D474YsYQ.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-Doic_6qX.js → member-scope-gate-CH_0jHiM.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-Ba4aYavw.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-BrfaDwIg.js → model-selector-XYmk7Iru.js} +2 -2
- package/dist/owletto/dist/assets/needs-you-list-Bd4iiiqm.js +2 -0
- package/dist/owletto/dist/assets/new-BOsrRqp8.js +2 -0
- package/dist/owletto/dist/assets/{new-5GkxlOuQ.js → new-CJ6TF3Vc.js} +2 -2
- package/dist/owletto/dist/assets/{new-BiA4DGoN.js → new-DGPOjak2.js} +2 -2
- package/dist/owletto/dist/assets/new-Q0XqiZq2.js +2 -0
- package/dist/owletto/dist/assets/{organization-CLrcmgNK.js → organization-hD_Z6TSd.js} +2 -2
- package/dist/owletto/dist/assets/peek-pane-content-Cc8YX1oy.js +2 -0
- package/dist/owletto/dist/assets/{pending-seed-DYYOoCvj.js → pending-seed-D7-ld7as.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-BVwOMoq9.js → proposal-review-shell-BWRJidwb.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-CRyAZATw.js +2 -0
- package/dist/owletto/dist/assets/record-activity-9ux6SfCd.js +2 -0
- package/dist/owletto/dist/assets/{record-session-KuEDuF3S.js → record-session-ClKBr1_C.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-ucwCQmBk.js → renderer-DZ0w2k2r.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-BkiAmXZW.js → reset-password-D2RfrEVZ.js} +2 -2
- package/dist/owletto/dist/assets/{run-initiator-8vdkq-3o.js → run-initiator-B8IRlRd-.js} +2 -2
- package/dist/owletto/dist/assets/runs-CuC7WMtd.js +2 -0
- package/dist/owletto/dist/assets/runs-list-8gUPWjP4.js +2 -0
- package/dist/owletto/dist/assets/{schema-value-CefbtPIY.js → schema-value-k19Ata7u.js} +3 -3
- package/dist/owletto/dist/assets/scoped-feed-bar-L7h-Ca4u.js +2 -0
- package/dist/owletto/dist/assets/{settings-DvzkRYQy.js → settings-BZqntV3E.js} +2 -2
- package/dist/owletto/dist/assets/{source-record-panels-LJIWGtHb.js → source-record-panels-C4UItfdk.js} +2 -2
- package/dist/owletto/dist/assets/{status-variants-BxHtpMOj.js → status-variants-BR_iGWN5.js} +2 -2
- package/dist/owletto/dist/assets/subDays-hOwerOLo.js +2 -0
- package/dist/owletto/dist/assets/{table-1O-ik4_O.js → table-C3DMoL4K.js} +2 -2
- package/dist/owletto/dist/assets/use-automations-CdtiVLCv.js +2 -0
- package/dist/owletto/dist/assets/{use-login-redirect-CfCbEeJR.js → use-login-redirect-CYlVkAhE.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-CA-evCDf.js → use-mention-search-CtbixPEE.js} +2 -2
- package/dist/owletto/dist/assets/view-param-filters-BdN8OU35.js +2 -0
- package/dist/owletto/dist/assets/{views-access-required-BerT4Z1d.js → views-access-required-CvIIxdS_.js} +2 -2
- package/dist/owletto/dist/index.html +19 -12
- package/dist/server-main.bundle.mjs +4245 -2432
- package/npm-shrinkwrap.json +328 -328
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +23 -2
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/classify-error.d.ts +3 -4
- package/vendor/core/dist/classify-error.js +8 -8
- package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +17 -1
- package/vendor/core/dist/contracts/tools/collection-presentation.js +27 -3
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +39 -0
- package/vendor/core/dist/contracts/tools/manage-automations.js +11 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +249 -7
- package/vendor/core/dist/contracts/tools/manage-views.js +83 -21
- package/vendor/core/dist/contracts/tools/navigation.d.ts +248 -0
- package/vendor/core/dist/contracts/tools/navigation.js +284 -0
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +7 -0
- package/vendor/core/dist/contracts/tools/view-attach.js +15 -0
- package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +4 -1
- package/vendor/core/dist/contracts/tools/view-content-hash.js +4 -2
- package/vendor/core/dist/contracts/tools/view-definition.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/view-definition.js +52 -0
- package/vendor/core/dist/contracts/tools/view-host.d.ts +68 -0
- package/vendor/core/dist/contracts/tools/view-host.js +28 -1
- package/vendor/core/dist/contracts/tools/view-scope.d.ts +31 -0
- package/vendor/core/dist/contracts/tools/view-scope.js +45 -0
- package/vendor/core/dist/errors.d.ts +17 -24
- package/vendor/core/dist/errors.js +17 -24
- package/vendor/core/dist/types.d.ts +0 -6
- package/vendor/core/package.json +11 -1
- package/vendor/views/dist/api.d.ts +30 -5
- package/vendor/views/dist/api.js +22 -8
- package/vendor/views/dist/bridge.d.ts +17 -0
- package/vendor/views/dist/bridge.js +49 -1
- package/vendor/views/dist/components.d.ts +27 -5
- package/vendor/views/dist/components.js +57 -7
- package/vendor/views/dist/embed.d.ts +98 -0
- package/vendor/views/dist/embed.js +418 -0
- package/vendor/views/dist/index.d.ts +3 -1
- package/vendor/views/dist/index.js +1 -0
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-B0tmXZ86.js +0 -2
- package/dist/owletto/dist/assets/_-DwXULq4r.js +0 -3
- package/dist/owletto/dist/assets/_agentId-B1dNkhnr.js +0 -2
- package/dist/owletto/dist/assets/_agentId-sYjvnBaB.js +0 -2
- package/dist/owletto/dist/assets/_automationId-Bnw_CnT_.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-D7Z8DQ-B.js +0 -2
- package/dist/owletto/dist/assets/_eventId-CfB0_2zK.js +0 -2
- package/dist/owletto/dist/assets/_owner-BDvTUY0a.js +0 -3
- package/dist/owletto/dist/assets/_shape-BZidoJMB.js +0 -2
- package/dist/owletto/dist/assets/_slug-R989vOiM.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-BDUSrpe5.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-BnFqh5-t.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-CN2dOiCD.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-BJwRU6qT.js +0 -2
- package/dist/owletto/dist/assets/connect-OdHpIVV9.js +0 -2
- package/dist/owletto/dist/assets/connect-menu-B9u86bb2.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-EI1tcdSE.js +0 -2
- package/dist/owletto/dist/assets/connector-boxes-BWPXijAk.js +0 -2
- package/dist/owletto/dist/assets/create-DULVO0HS.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-N6fhcIPy.js +0 -2
- package/dist/owletto/dist/assets/entity-options-IUdQ-64R.js +0 -2
- package/dist/owletto/dist/assets/entity-page-B3Im65EI.js +0 -2
- package/dist/owletto/dist/assets/event-detail-CvaRN1qB.js +0 -2
- package/dist/owletto/dist/assets/events-feed-DwOkLk6A.js +0 -2
- package/dist/owletto/dist/assets/filter-editors-DQ5V4Cvh.js +0 -2
- package/dist/owletto/dist/assets/home-stream-Bg97PUBJ.js +0 -2
- package/dist/owletto/dist/assets/home-toolbar-CpCcHA6z.js +0 -2
- package/dist/owletto/dist/assets/index-9PGnv4-5.js +0 -2
- package/dist/owletto/dist/assets/index-C2TCKJDP.js +0 -7901
- package/dist/owletto/dist/assets/index-CWn46a4y.js +0 -2
- package/dist/owletto/dist/assets/index-CxJONizf.js +0 -2
- package/dist/owletto/dist/assets/index-DJhb3li3.js +0 -2
- package/dist/owletto/dist/assets/index-DY-YGnCe.js +0 -2
- package/dist/owletto/dist/assets/index-j3v7ITPb.js +0 -2
- package/dist/owletto/dist/assets/index-oiy6ygaI.js +0 -2
- package/dist/owletto/dist/assets/index-pEgtAY1t.js +0 -2
- package/dist/owletto/dist/assets/index-xAvK3IyQ.css +0 -1
- package/dist/owletto/dist/assets/memory-browse-page-CUea2Llz.js +0 -74
- package/dist/owletto/dist/assets/new-M-MX_T5C.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-B29OcHwm.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-BbjPgh3k.js +0 -2
- package/dist/owletto/dist/assets/record-activity-BCpNKaUo.js +0 -2
- package/dist/owletto/dist/assets/runs-B_iywKWb.js +0 -2
- package/dist/owletto/dist/assets/runs-list-CJJFRhTl.js +0 -2
- package/dist/owletto/dist/assets/schema-type-editor-panel-C4e8pq1A.js +0 -2
- package/dist/owletto/dist/assets/scoped-feed-bar-CapleZvS.js +0 -2
- package/dist/owletto/dist/assets/subDays-DwIOMzYC.js +0 -2
- package/dist/owletto/dist/assets/use-automations-lV8PuE8L.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-Bp84PUMd.js +0 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Credential-free market marks for deterministic portfolio valuation.
|
|
3
3
|
*
|
|
4
|
-
* This connector exposes
|
|
5
|
-
*
|
|
4
|
+
* This connector exposes two read-only actions and no feeds: `quote` for the
|
|
5
|
+
* current mark and `history` for daily closes over a date range. Results are
|
|
6
|
+
* returned to the caller and are never persisted as raw market-price events.
|
|
6
7
|
*/
|
|
7
8
|
import {
|
|
8
9
|
type ActionContext,
|
|
@@ -37,6 +38,29 @@ type QuoteUnavailable = {
|
|
|
37
38
|
|
|
38
39
|
type QuoteRow = QuoteOk | QuoteUnavailable;
|
|
39
40
|
|
|
41
|
+
type HistoryClose = { date: string; close: number };
|
|
42
|
+
|
|
43
|
+
type HistorySeries = {
|
|
44
|
+
status: "history";
|
|
45
|
+
id: string;
|
|
46
|
+
symbol: string;
|
|
47
|
+
provider_symbol: string;
|
|
48
|
+
currency: string;
|
|
49
|
+
closes: HistoryClose[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type HistoryUnavailable = {
|
|
53
|
+
status: "history_unavailable";
|
|
54
|
+
id: string;
|
|
55
|
+
symbol: string;
|
|
56
|
+
provider_symbol: string | null;
|
|
57
|
+
reason: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type HistoryRow = HistorySeries | HistoryUnavailable;
|
|
61
|
+
|
|
62
|
+
type HistoryRange = { from: string; to: string };
|
|
63
|
+
|
|
40
64
|
type QuoteSymbolInput = {
|
|
41
65
|
market?: string;
|
|
42
66
|
symbol?: string;
|
|
@@ -53,6 +77,9 @@ const YAHOO_CHART_URL = "https://query2.finance.yahoo.com/v8/finance/chart";
|
|
|
53
77
|
const QUOTE_TIMEOUT_MS = 8_000;
|
|
54
78
|
const STALE_AFTER_MS = 24 * 60 * 60 * 1_000;
|
|
55
79
|
const MAX_CONCURRENT_QUOTES = 5;
|
|
80
|
+
const MAX_SYMBOLS = 50;
|
|
81
|
+
const MAX_HISTORY_YEARS = 10;
|
|
82
|
+
const DAY_SECONDS = 24 * 60 * 60;
|
|
56
83
|
|
|
57
84
|
export function toProviderSymbol(market: string, symbol: string): string {
|
|
58
85
|
const normalizedMarket = market.trim().toUpperCase();
|
|
@@ -158,19 +185,109 @@ export function parseYahooChartBody(
|
|
|
158
185
|
};
|
|
159
186
|
}
|
|
160
187
|
|
|
161
|
-
|
|
188
|
+
/** The calendar date of a bar in the exchange's own timezone (UTC fallback). */
|
|
189
|
+
function exchangeDateFormatter(
|
|
190
|
+
timezone: string | undefined
|
|
191
|
+
): Intl.DateTimeFormat {
|
|
192
|
+
const options: Intl.DateTimeFormatOptions = {
|
|
193
|
+
year: "numeric",
|
|
194
|
+
month: "2-digit",
|
|
195
|
+
day: "2-digit",
|
|
196
|
+
};
|
|
197
|
+
const zone = timezone?.trim();
|
|
198
|
+
if (zone) {
|
|
199
|
+
try {
|
|
200
|
+
return new Intl.DateTimeFormat("en-US", { ...options, timeZone: zone });
|
|
201
|
+
} catch {
|
|
202
|
+
// Unknown IANA name: fall through to UTC.
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return new Intl.DateTimeFormat("en-US", { ...options, timeZone: "UTC" });
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function formatExchangeDate(
|
|
209
|
+
formatter: Intl.DateTimeFormat,
|
|
210
|
+
epochSeconds: number
|
|
211
|
+
): string {
|
|
212
|
+
const parts = Object.fromEntries(
|
|
213
|
+
formatter
|
|
214
|
+
.formatToParts(new Date(epochSeconds * 1_000))
|
|
215
|
+
.map((part) => [part.type, part.value])
|
|
216
|
+
);
|
|
217
|
+
return `${parts.year}-${parts.month}-${parts.day}`;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function parseYahooHistoryBody(
|
|
221
|
+
body: unknown,
|
|
162
222
|
providerSymbol: string,
|
|
163
|
-
|
|
164
|
-
):
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
223
|
+
range: HistoryRange
|
|
224
|
+
): { currency: string; closes: HistoryClose[] } | { error: string } {
|
|
225
|
+
const chart = body as {
|
|
226
|
+
chart?: {
|
|
227
|
+
result?: Array<{
|
|
228
|
+
meta?: { currency?: string; exchangeTimezoneName?: string };
|
|
229
|
+
timestamp?: unknown[];
|
|
230
|
+
indicators?: { quote?: Array<{ close?: unknown[] }> };
|
|
231
|
+
}>;
|
|
232
|
+
error?: { description?: string; code?: string };
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
if (chart.chart?.error) {
|
|
236
|
+
return {
|
|
237
|
+
error:
|
|
238
|
+
chart.chart.error.description ??
|
|
239
|
+
chart.chart.error.code ??
|
|
240
|
+
`history provider error for ${providerSymbol}`,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
const result = chart.chart?.result?.[0];
|
|
244
|
+
if (!result) {
|
|
245
|
+
return { error: `no history for ${providerSymbol}` };
|
|
246
|
+
}
|
|
247
|
+
const currency = result.meta?.currency?.trim().toUpperCase();
|
|
248
|
+
if (!currency) {
|
|
249
|
+
return { error: `no quote currency for ${providerSymbol}` };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const timestamps = result.timestamp ?? [];
|
|
253
|
+
const closeValues = result.indicators?.quote?.[0]?.close ?? [];
|
|
254
|
+
const formatter = exchangeDateFormatter(result.meta?.exchangeTimezoneName);
|
|
255
|
+
const closes: HistoryClose[] = [];
|
|
256
|
+
for (let i = 0; i < timestamps.length; i++) {
|
|
257
|
+
const timestamp = timestamps[i];
|
|
258
|
+
const close = closeValues[i];
|
|
259
|
+
if (
|
|
260
|
+
typeof timestamp !== "number" ||
|
|
261
|
+
!Number.isFinite(timestamp) ||
|
|
262
|
+
typeof close !== "number" ||
|
|
263
|
+
!Number.isFinite(close) ||
|
|
264
|
+
close <= 0
|
|
265
|
+
) {
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
const date = formatExchangeDate(formatter, timestamp);
|
|
269
|
+
if (date < range.from || date > range.to) continue;
|
|
270
|
+
// Yahoo can repeat the latest bar; keep one close per exchange date.
|
|
271
|
+
if (closes.at(-1)?.date === date) {
|
|
272
|
+
closes[closes.length - 1] = { date, close };
|
|
273
|
+
} else {
|
|
274
|
+
closes.push({ date, close });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return { currency, closes };
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async function requestYahooChart(
|
|
281
|
+
providerSymbol: string,
|
|
282
|
+
query: string,
|
|
283
|
+
fetchImpl: FetchLike
|
|
284
|
+
): Promise<{ ok: true; body: unknown } | { ok: false; reason: string }> {
|
|
168
285
|
if (!providerSymbol) {
|
|
169
286
|
return { ok: false, reason: "missing symbol" };
|
|
170
287
|
}
|
|
171
288
|
const url = `${YAHOO_CHART_URL}/${encodeURIComponent(
|
|
172
289
|
providerSymbol
|
|
173
|
-
)}
|
|
290
|
+
)}?${query}`;
|
|
174
291
|
try {
|
|
175
292
|
const response = await fetchImpl(url, {
|
|
176
293
|
headers: {
|
|
@@ -182,16 +299,7 @@ async function fetchYahooQuote(
|
|
|
182
299
|
if (!response.ok) {
|
|
183
300
|
return { ok: false, reason: `quote provider HTTP ${response.status}` };
|
|
184
301
|
}
|
|
185
|
-
|
|
186
|
-
if ("error" in parsed) {
|
|
187
|
-
return { ok: false, reason: parsed.error };
|
|
188
|
-
}
|
|
189
|
-
return {
|
|
190
|
-
ok: true,
|
|
191
|
-
price: parsed.price,
|
|
192
|
-
currency: parsed.currency,
|
|
193
|
-
asOf: parsed.asOf,
|
|
194
|
-
};
|
|
302
|
+
return { ok: true, body: await response.json() };
|
|
195
303
|
} catch (error) {
|
|
196
304
|
return {
|
|
197
305
|
ok: false,
|
|
@@ -200,6 +308,49 @@ async function fetchYahooQuote(
|
|
|
200
308
|
}
|
|
201
309
|
}
|
|
202
310
|
|
|
311
|
+
async function fetchYahooQuote(
|
|
312
|
+
providerSymbol: string,
|
|
313
|
+
fetchImpl: FetchLike = fetch
|
|
314
|
+
): Promise<
|
|
315
|
+
| { ok: true; price: number; currency: string; asOf: string }
|
|
316
|
+
| { ok: false; reason: string }
|
|
317
|
+
> {
|
|
318
|
+
const chart = await requestYahooChart(
|
|
319
|
+
providerSymbol,
|
|
320
|
+
"interval=1d&range=1d",
|
|
321
|
+
fetchImpl
|
|
322
|
+
);
|
|
323
|
+
if (!chart.ok) return chart;
|
|
324
|
+
const parsed = parseYahooChartBody(chart.body, providerSymbol);
|
|
325
|
+
if ("error" in parsed) {
|
|
326
|
+
return { ok: false, reason: parsed.error };
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
ok: true,
|
|
330
|
+
price: parsed.price,
|
|
331
|
+
currency: parsed.currency,
|
|
332
|
+
asOf: parsed.asOf,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Run `task` for every index with at most MAX_CONCURRENT_QUOTES in flight. */
|
|
337
|
+
async function forEachConcurrently(
|
|
338
|
+
count: number,
|
|
339
|
+
task: (index: number) => Promise<void>
|
|
340
|
+
): Promise<void> {
|
|
341
|
+
let nextIndex = 0;
|
|
342
|
+
const worker = async (): Promise<void> => {
|
|
343
|
+
while (nextIndex < count) {
|
|
344
|
+
await task(nextIndex++);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
await Promise.all(
|
|
348
|
+
Array.from({ length: Math.min(MAX_CONCURRENT_QUOTES, count) }, () =>
|
|
349
|
+
worker()
|
|
350
|
+
)
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
203
354
|
export async function quoteMany(
|
|
204
355
|
inputs: Array<QuoteSymbolInput | string>,
|
|
205
356
|
options?: { fetchImpl?: FetchLike; now?: Date }
|
|
@@ -208,96 +359,201 @@ export async function quoteMany(
|
|
|
208
359
|
const now = options?.now ?? new Date();
|
|
209
360
|
const normalized = inputs.map(normalizeSymbolInput);
|
|
210
361
|
const results = new Array<QuoteRow>(normalized.length);
|
|
211
|
-
let nextIndex = 0;
|
|
212
362
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const quote = await fetchYahooQuote(item.provider_symbol, fetchImpl);
|
|
231
|
-
if (!quote.ok) {
|
|
232
|
-
results[index] = {
|
|
233
|
-
status: "quote_unavailable",
|
|
234
|
-
id: item.id,
|
|
235
|
-
market: item.market,
|
|
236
|
-
symbol: item.symbol,
|
|
237
|
-
provider_symbol: item.provider_symbol,
|
|
238
|
-
provider: "yahoo",
|
|
239
|
-
reason: quote.reason,
|
|
240
|
-
};
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
363
|
+
await forEachConcurrently(normalized.length, async (index) => {
|
|
364
|
+
const item = normalized[index];
|
|
365
|
+
if (!item?.symbol || !item.provider_symbol) {
|
|
366
|
+
results[index] = {
|
|
367
|
+
status: "quote_unavailable",
|
|
368
|
+
id: item?.id ?? "UNKNOWN",
|
|
369
|
+
market: item?.market ?? "",
|
|
370
|
+
symbol: item?.symbol ?? "",
|
|
371
|
+
provider_symbol: item?.provider_symbol || null,
|
|
372
|
+
provider: "yahoo",
|
|
373
|
+
reason: "missing symbol",
|
|
374
|
+
};
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const quote = await fetchYahooQuote(item.provider_symbol, fetchImpl);
|
|
379
|
+
if (!quote.ok) {
|
|
243
380
|
results[index] = {
|
|
244
|
-
status: "
|
|
381
|
+
status: "quote_unavailable",
|
|
245
382
|
id: item.id,
|
|
246
383
|
market: item.market,
|
|
247
384
|
symbol: item.symbol,
|
|
248
385
|
provider_symbol: item.provider_symbol,
|
|
249
|
-
price: quote.price,
|
|
250
|
-
currency: quote.currency,
|
|
251
|
-
as_of: quote.asOf,
|
|
252
|
-
stale: now.getTime() - new Date(quote.asOf).getTime() > STALE_AFTER_MS,
|
|
253
|
-
tier: "delayed",
|
|
254
386
|
provider: "yahoo",
|
|
387
|
+
reason: quote.reason,
|
|
255
388
|
};
|
|
389
|
+
return;
|
|
256
390
|
}
|
|
257
|
-
|
|
391
|
+
results[index] = {
|
|
392
|
+
status: "quoted",
|
|
393
|
+
id: item.id,
|
|
394
|
+
market: item.market,
|
|
395
|
+
symbol: item.symbol,
|
|
396
|
+
provider_symbol: item.provider_symbol,
|
|
397
|
+
price: quote.price,
|
|
398
|
+
currency: quote.currency,
|
|
399
|
+
as_of: quote.asOf,
|
|
400
|
+
stale: now.getTime() - new Date(quote.asOf).getTime() > STALE_AFTER_MS,
|
|
401
|
+
tier: "delayed",
|
|
402
|
+
provider: "yahoo",
|
|
403
|
+
};
|
|
404
|
+
});
|
|
405
|
+
return results;
|
|
406
|
+
}
|
|
258
407
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
)
|
|
408
|
+
/** Midnight UTC of a strict `YYYY-MM-DD` calendar date, or null. */
|
|
409
|
+
function parseCalendarDate(value: unknown): Date | null {
|
|
410
|
+
if (typeof value !== "string") return null;
|
|
411
|
+
const date = new Date(`${value}T00:00:00Z`);
|
|
412
|
+
if (!Number.isFinite(date.getTime())) return null;
|
|
413
|
+
// Round-tripping rejects non-padded forms and impossible days (2024-02-30).
|
|
414
|
+
return date.toISOString().slice(0, 10) === value ? date : null;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export function validateHistoryRange(
|
|
418
|
+
from: unknown,
|
|
419
|
+
to: unknown
|
|
420
|
+
): HistoryRange | { error: string } {
|
|
421
|
+
const fromDate = parseCalendarDate(from);
|
|
422
|
+
const toDate = parseCalendarDate(to);
|
|
423
|
+
if (!fromDate || !toDate) {
|
|
424
|
+
return { error: "history requires from and to as YYYY-MM-DD dates" };
|
|
425
|
+
}
|
|
426
|
+
if (fromDate > toDate) {
|
|
427
|
+
return { error: "history requires from to be on or before to" };
|
|
428
|
+
}
|
|
429
|
+
const limit = new Date(fromDate);
|
|
430
|
+
limit.setUTCFullYear(limit.getUTCFullYear() + MAX_HISTORY_YEARS);
|
|
431
|
+
if (toDate > limit) {
|
|
432
|
+
return {
|
|
433
|
+
error: `history spans at most ${MAX_HISTORY_YEARS} years between from and to`,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
return { from: from as string, to: to as string };
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export async function historyMany(
|
|
440
|
+
inputs: Array<QuoteSymbolInput | string>,
|
|
441
|
+
range: HistoryRange,
|
|
442
|
+
options?: { fetchImpl?: FetchLike }
|
|
443
|
+
): Promise<HistoryRow[]> {
|
|
444
|
+
const fetchImpl = options?.fetchImpl ?? fetch;
|
|
445
|
+
const normalized = inputs.map(normalizeSymbolInput);
|
|
446
|
+
const results = new Array<HistoryRow>(normalized.length);
|
|
447
|
+
// Widen the window by a day on each side so every exchange timezone's local
|
|
448
|
+
// `from`..`to` days are fully covered; bars are then filtered by local date.
|
|
449
|
+
const period1 = Date.parse(`${range.from}T00:00:00Z`) / 1_000 - DAY_SECONDS;
|
|
450
|
+
const period2 = Date.parse(`${range.to}T00:00:00Z`) / 1_000 + 2 * DAY_SECONDS;
|
|
451
|
+
const query = `interval=1d&period1=${period1}&period2=${period2}`;
|
|
452
|
+
|
|
453
|
+
await forEachConcurrently(normalized.length, async (index) => {
|
|
454
|
+
const item = normalized[index];
|
|
455
|
+
const unavailable = (reason: string): HistoryUnavailable => ({
|
|
456
|
+
status: "history_unavailable",
|
|
457
|
+
id: item?.id ?? "UNKNOWN",
|
|
458
|
+
symbol: item?.symbol ?? "",
|
|
459
|
+
provider_symbol: item?.provider_symbol || null,
|
|
460
|
+
reason,
|
|
461
|
+
});
|
|
462
|
+
if (!item?.symbol || !item.provider_symbol) {
|
|
463
|
+
results[index] = unavailable("missing symbol");
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
const chart = await requestYahooChart(
|
|
467
|
+
item.provider_symbol,
|
|
468
|
+
query,
|
|
469
|
+
fetchImpl
|
|
470
|
+
);
|
|
471
|
+
if (!chart.ok) {
|
|
472
|
+
results[index] = unavailable(chart.reason);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
const parsed = parseYahooHistoryBody(
|
|
476
|
+
chart.body,
|
|
477
|
+
item.provider_symbol,
|
|
478
|
+
range
|
|
479
|
+
);
|
|
480
|
+
if ("error" in parsed) {
|
|
481
|
+
results[index] = unavailable(parsed.error);
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
results[index] = {
|
|
485
|
+
status: "history",
|
|
486
|
+
id: item.id,
|
|
487
|
+
symbol: item.symbol,
|
|
488
|
+
provider_symbol: item.provider_symbol,
|
|
489
|
+
currency: parsed.currency,
|
|
490
|
+
closes: parsed.closes,
|
|
491
|
+
};
|
|
492
|
+
});
|
|
265
493
|
return results;
|
|
266
494
|
}
|
|
267
495
|
|
|
496
|
+
const symbolsSchema = {
|
|
497
|
+
type: "array",
|
|
498
|
+
minItems: 1,
|
|
499
|
+
maxItems: MAX_SYMBOLS,
|
|
500
|
+
items: {
|
|
501
|
+
oneOf: [
|
|
502
|
+
{ type: "string" },
|
|
503
|
+
{
|
|
504
|
+
type: "object",
|
|
505
|
+
properties: {
|
|
506
|
+
market: { type: "string" },
|
|
507
|
+
symbol: { type: "string" },
|
|
508
|
+
id: { type: "string" },
|
|
509
|
+
provider_symbol: { type: "string" },
|
|
510
|
+
},
|
|
511
|
+
},
|
|
512
|
+
],
|
|
513
|
+
},
|
|
514
|
+
} as const;
|
|
515
|
+
|
|
268
516
|
const quoteInputSchema = {
|
|
269
517
|
type: "object",
|
|
270
518
|
required: ["symbols"],
|
|
519
|
+
properties: { symbols: symbolsSchema },
|
|
520
|
+
} as const;
|
|
521
|
+
|
|
522
|
+
const historyInputSchema = {
|
|
523
|
+
type: "object",
|
|
524
|
+
required: ["symbols", "from", "to"],
|
|
271
525
|
properties: {
|
|
272
|
-
symbols:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
properties: {
|
|
282
|
-
market: { type: "string" },
|
|
283
|
-
symbol: { type: "string" },
|
|
284
|
-
id: { type: "string" },
|
|
285
|
-
provider_symbol: { type: "string" },
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
],
|
|
289
|
-
},
|
|
526
|
+
symbols: symbolsSchema,
|
|
527
|
+
from: {
|
|
528
|
+
type: "string",
|
|
529
|
+
description: "First calendar day (YYYY-MM-DD), inclusive.",
|
|
530
|
+
},
|
|
531
|
+
to: {
|
|
532
|
+
type: "string",
|
|
533
|
+
description:
|
|
534
|
+
"Last calendar day (YYYY-MM-DD), inclusive; at most 10 years after from.",
|
|
290
535
|
},
|
|
291
536
|
},
|
|
292
537
|
} as const;
|
|
293
538
|
|
|
539
|
+
/** Shared symbols-array guard for both actions; null when acceptable. */
|
|
540
|
+
function symbolsError(action: string, symbols: unknown): string | null {
|
|
541
|
+
if (!Array.isArray(symbols) || symbols.length === 0) {
|
|
542
|
+
return `${action} requires a non-empty symbols array`;
|
|
543
|
+
}
|
|
544
|
+
if (symbols.length > MAX_SYMBOLS) {
|
|
545
|
+
return `${action} accepts at most ${MAX_SYMBOLS} symbols`;
|
|
546
|
+
}
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
|
|
294
550
|
export default class MarketQuotesConnector extends ConnectorRuntime {
|
|
295
551
|
readonly definition: ConnectorDefinition = {
|
|
296
552
|
key: "market.quotes",
|
|
297
553
|
name: "Market Quotes",
|
|
298
554
|
description:
|
|
299
|
-
"Credential-free current market marks returned on demand without a price feed.",
|
|
300
|
-
version: "1.
|
|
555
|
+
"Credential-free current market marks and daily close history returned on demand without a price feed.",
|
|
556
|
+
version: "1.1.0",
|
|
301
557
|
faviconDomain: "finance.yahoo.com",
|
|
302
558
|
authSchema: { methods: [{ type: "none" }] },
|
|
303
559
|
actions: {
|
|
@@ -324,6 +580,27 @@ export default class MarketQuotesConnector extends ConnectorRuntime {
|
|
|
324
580
|
},
|
|
325
581
|
},
|
|
326
582
|
},
|
|
583
|
+
history: {
|
|
584
|
+
key: "history",
|
|
585
|
+
kind: "read",
|
|
586
|
+
name: "Daily close history",
|
|
587
|
+
description:
|
|
588
|
+
"Return daily closes between from and to (inclusive, exchange-local dates) as a history or history_unavailable entry for every requested symbol.",
|
|
589
|
+
annotations: {
|
|
590
|
+
readOnlyHint: true,
|
|
591
|
+
idempotentHint: true,
|
|
592
|
+
openWorldHint: true,
|
|
593
|
+
},
|
|
594
|
+
inputSchema: historyInputSchema as unknown as Record<string, unknown>,
|
|
595
|
+
outputSchema: {
|
|
596
|
+
type: "object",
|
|
597
|
+
required: ["provider", "series"],
|
|
598
|
+
properties: {
|
|
599
|
+
provider: { type: "string" },
|
|
600
|
+
series: { type: "array", items: { type: "object" } },
|
|
601
|
+
},
|
|
602
|
+
},
|
|
603
|
+
},
|
|
327
604
|
},
|
|
328
605
|
optionsSchema: { type: "object", properties: {} },
|
|
329
606
|
};
|
|
@@ -331,18 +608,16 @@ export default class MarketQuotesConnector extends ConnectorRuntime {
|
|
|
331
608
|
fetchImpl: FetchLike = fetch;
|
|
332
609
|
|
|
333
610
|
async execute(ctx: ActionContext): Promise<ActionResult> {
|
|
611
|
+
if (ctx.actionKey === "history") {
|
|
612
|
+
return this.history(ctx.input);
|
|
613
|
+
}
|
|
334
614
|
if (ctx.actionKey !== "quote") {
|
|
335
615
|
return { success: false, error: `Unknown action: ${ctx.actionKey}` };
|
|
336
616
|
}
|
|
337
617
|
const symbols = (ctx.input as { symbols?: unknown }).symbols;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
error: "quote requires a non-empty symbols array",
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
if (symbols.length > 50) {
|
|
345
|
-
return { success: false, error: "quote accepts at most 50 symbols" };
|
|
618
|
+
const invalid = symbolsError("quote", symbols);
|
|
619
|
+
if (invalid) {
|
|
620
|
+
return { success: false, error: invalid };
|
|
346
621
|
}
|
|
347
622
|
|
|
348
623
|
const quotes = await quoteMany(
|
|
@@ -361,4 +636,26 @@ export default class MarketQuotesConnector extends ConnectorRuntime {
|
|
|
361
636
|
},
|
|
362
637
|
};
|
|
363
638
|
}
|
|
639
|
+
|
|
640
|
+
private async history(input: ActionContext["input"]): Promise<ActionResult> {
|
|
641
|
+
const { symbols, from, to } = input as {
|
|
642
|
+
symbols?: unknown;
|
|
643
|
+
from?: unknown;
|
|
644
|
+
to?: unknown;
|
|
645
|
+
};
|
|
646
|
+
const invalid = symbolsError("history", symbols);
|
|
647
|
+
if (invalid) {
|
|
648
|
+
return { success: false, error: invalid };
|
|
649
|
+
}
|
|
650
|
+
const range = validateHistoryRange(from, to);
|
|
651
|
+
if ("error" in range) {
|
|
652
|
+
return { success: false, error: range.error };
|
|
653
|
+
}
|
|
654
|
+
const series = await historyMany(
|
|
655
|
+
symbols as Array<QuoteSymbolInput | string>,
|
|
656
|
+
range,
|
|
657
|
+
{ fetchImpl: this.fetchImpl }
|
|
658
|
+
);
|
|
659
|
+
return { success: true, output: { provider: "yahoo", series } };
|
|
660
|
+
}
|
|
364
661
|
}
|
|
@@ -387,7 +387,7 @@ export default class PostgresConnector extends ConnectorRuntime {
|
|
|
387
387
|
description:
|
|
388
388
|
'Bring your own PostgreSQL database as memory, read a configured feed directly, or run governed connection-level SQL.',
|
|
389
389
|
version: '1.1.0',
|
|
390
|
-
queryCapabilities: { exactMatch: true, verbatimExactMatch: true, selection: true },
|
|
390
|
+
queryCapabilities: { exactMatch: true, verbatimExactMatch: true, exactMatchAny: true, selection: true },
|
|
391
391
|
faviconDomain: 'postgresql.org',
|
|
392
392
|
authSchema: {
|
|
393
393
|
methods: [
|
|
@@ -563,8 +563,10 @@ export default class PostgresConnector extends ConnectorRuntime {
|
|
|
563
563
|
const bind = (value: string) => { params.push(value); return `$${params.length}::text`; };
|
|
564
564
|
let where = '';
|
|
565
565
|
if (ctx.exactMatch) {
|
|
566
|
-
const { columns,
|
|
566
|
+
const { columns, verbatim } = ctx.exactMatch;
|
|
567
|
+
const values = ctx.exactMatch.values ?? [ctx.exactMatch.value];
|
|
567
568
|
if (!columns.length) throw new Error('exactMatch.columns must not be empty');
|
|
569
|
+
if (!values.length) throw new Error('exactMatch.values must not be empty');
|
|
568
570
|
for (const column of columns) assertIdentifier(column, 'exactMatch.column');
|
|
569
571
|
const projection = await tx.unsafe(`SELECT * FROM (\n${baseSql}\n) q LIMIT 0`);
|
|
570
572
|
const projected = projection.columns as Array<{ name: string; type: number; parser?: { array?: boolean } }>;
|
|
@@ -574,11 +576,15 @@ export default class PostgresConnector extends ConnectorRuntime {
|
|
|
574
576
|
if (!candidates.some(isScalar)) {
|
|
575
577
|
throw Object.assign(new Error('Exact-match identity must be a scalar; project a text key in the source query'), { status: 400 });
|
|
576
578
|
}
|
|
579
|
+
// One bound array literal per comparison: a page of keys stays one statement.
|
|
580
|
+
const bindArray = (items: string[]) =>
|
|
581
|
+
bind(`{${items.map((item) => `"${item.replaceAll('\\', '\\\\').replaceAll('"', '\\"')}"`).join(',')}}`);
|
|
577
582
|
const textMatch = (ref: string) => verbatim
|
|
578
|
-
? `${ref} = ${
|
|
579
|
-
: `btrim(${ref}, ${bind('\t\n\v\f\r \u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff')}) = ${
|
|
580
|
-
const
|
|
581
|
-
|
|
583
|
+
? `${ref} = ANY(${bindArray(values)}::text[])`
|
|
584
|
+
: `btrim(${ref}, ${bind('\t\n\v\f\r \u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff')}) = ANY(${bindArray(values)}::text[])`;
|
|
585
|
+
const numbers = values.filter((value) => Number.isFinite(Number(value)) && String(Number(value)) === value);
|
|
586
|
+
const numberMatch = (ref: string, cast: string) => numbers.length
|
|
587
|
+
? `${ref} = ANY(${bindArray(numbers)}::${cast}[])` : 'FALSE';
|
|
582
588
|
const cases = candidates.map((column) => {
|
|
583
589
|
const ref = `q.${quoteIdent(column.name)}`;
|
|
584
590
|
const jsonType = [114, 3802].includes(column.type) ? `${column.type === 114 ? 'json' : 'jsonb'}_typeof(${ref})` : undefined;
|
|
@@ -602,20 +608,21 @@ export default class PostgresConnector extends ConnectorRuntime {
|
|
|
602
608
|
} else if ([1082, 1114, 1184].includes(column.type)) {
|
|
603
609
|
// The driver returns Date values; the isolate serializes them as ISO.
|
|
604
610
|
present = `isfinite(${ref})`;
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
+
const dateMatches = values.flatMap((value) => {
|
|
612
|
+
const date = new Date(value);
|
|
613
|
+
if (!Number.isFinite(date.getTime()) || date.toISOString() !== value) return [];
|
|
614
|
+
if (column.type === 1082) {
|
|
615
|
+
return value.endsWith('T00:00:00.000Z') ? [`${ref} = ${bind(value.slice(0, 10))}::date`] : [];
|
|
616
|
+
}
|
|
611
617
|
// Timestamp without zone is parsed in the worker's local zone.
|
|
612
618
|
const key = column.type === 1114
|
|
613
619
|
? new Date(date.getTime() - date.getTimezoneOffset() * 60_000).toISOString().slice(0, -1)
|
|
614
620
|
: value;
|
|
615
621
|
const bound = `${bind(key)}::${PG_OID[column.type].cast}`;
|
|
616
622
|
// Date drops source microseconds, so retain its full millisecond.
|
|
617
|
-
|
|
618
|
-
}
|
|
623
|
+
return [`(${ref} >= ${bound} AND ${ref} < ${bound} + INTERVAL '1 millisecond')`];
|
|
624
|
+
});
|
|
625
|
+
match = dateMatches.length ? dateMatches.join(' OR ') : 'FALSE';
|
|
619
626
|
} else {
|
|
620
627
|
match = textMatch(`${ref}::text`);
|
|
621
628
|
}
|