@aglyn/plugins-commerce 1.31.0 → 1.32.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/README.md +4 -0
- package/package.json +13 -13
- package/src/lib/components/cart.js +35 -15
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/commerce-console-page.js +6 -0
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/console/currencies-card.component.d.ts +21 -0
- package/src/lib/components/console/currencies-card.component.js +408 -0
- package/src/lib/components/console/currencies-card.component.js.map +1 -0
- package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
- package/src/lib/components/console/product-add-ons-fields.component.js +74 -2
- package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +42 -1
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-fixed-prices-fields.component.d.ts +25 -0
- package/src/lib/components/console/product-fixed-prices-fields.component.js +112 -0
- package/src/lib/components/console/product-fixed-prices-fields.component.js.map +1 -0
- package/src/lib/components/console/reservations-card.component.js +32 -15
- package/src/lib/components/console/reservations-card.component.js.map +1 -1
- package/src/lib/components/console/shipping-settings-card.component.js +100 -1
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
- package/src/lib/components/console/store-settings-card.component.js +1 -1
- package/src/lib/components/console/store-settings-card.component.js.map +1 -1
- package/src/lib/components/console/use-currency-setup.d.ts +20 -0
- package/src/lib/components/console/use-currency-setup.js +61 -0
- package/src/lib/components/console/use-currency-setup.js.map +1 -0
- package/src/lib/components/currency-selector.d.ts +36 -0
- package/src/lib/components/currency-selector.js +157 -0
- package/src/lib/components/currency-selector.js.map +1 -0
- package/src/lib/components/product-add-ons.d.ts +9 -1
- package/src/lib/components/product-add-ons.js +8 -4
- package/src/lib/components/product-add-ons.js.map +1 -1
- package/src/lib/components/product-choice-cards.d.ts +13 -1
- package/src/lib/components/product-choice-cards.js +5 -4
- package/src/lib/components/product-choice-cards.js.map +1 -1
- package/src/lib/components/product-detail.d.ts +8 -0
- package/src/lib/components/product-detail.js +38 -11
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.d.ts +2 -0
- package/src/lib/components/product-grid.js +22 -9
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/related-products.js +6 -2
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/components/shopper-currency.d.ts +108 -0
- package/src/lib/components/shopper-currency.js +262 -0
- package/src/lib/components/shopper-currency.js.map +1 -0
- package/src/lib/components/wishlist.js +7 -1
- package/src/lib/components/wishlist.js.map +1 -1
- package/src/lib/declarations.server.js +39 -0
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/commerce-currency-setup.d.ts +79 -0
- package/src/lib/model/commerce-currency-setup.js +124 -0
- package/src/lib/model/commerce-currency-setup.js.map +1 -0
- package/src/lib/model/commerce-currency.d.ts +215 -0
- package/src/lib/model/commerce-currency.js +511 -0
- package/src/lib/model/commerce-currency.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +17 -0
- package/src/lib/model/commerce-orders.js +10 -5
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-record-routes.js +26 -1
- package/src/lib/model/commerce-record-routes.js.map +1 -1
- package/src/lib/model/commerce-reservations.d.ts +6 -0
- package/src/lib/model/commerce-reservations.js.map +1 -1
- package/src/lib/model/commerce-shipping.d.ts +22 -1
- package/src/lib/model/commerce-shipping.js +31 -2
- package/src/lib/model/commerce-shipping.js.map +1 -1
- package/src/lib/model/commerce.d.ts +6 -0
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +2 -0
- package/src/lib/model/index.js +2 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/order-figures.js +9 -2
- package/src/lib/model/order-figures.js.map +1 -1
- package/src/lib/model/product-modifiers.d.ts +5 -0
- package/src/lib/model/product-modifiers.js.map +1 -1
- package/src/lib/server/billing-webhook.js +37 -24
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cart-checkout.js +67 -11
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/cart.d.ts +12 -0
- package/src/lib/server/cart.js +50 -4
- package/src/lib/server/cart.js.map +1 -1
- package/src/lib/server/catalog.d.ts +5 -0
- package/src/lib/server/catalog.js +7 -0
- package/src/lib/server/catalog.js.map +1 -1
- package/src/lib/server/checkout.js +48 -12
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/currency.d.ts +93 -0
- package/src/lib/server/currency.js +182 -0
- package/src/lib/server/currency.js.map +1 -0
- package/src/lib/server/order-notifications.js +4 -2
- package/src/lib/server/order-notifications.js.map +1 -1
- package/src/lib/server/product.d.ts +9 -0
- package/src/lib/server/product.js +12 -0
- package/src/lib/server/product.js.map +1 -1
- package/src/lib/server/refund.js +3 -3
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/site-chat-tools.d.ts +22 -0
- package/src/lib/server/site-chat-tools.js +369 -0
- package/src/lib/server/site-chat-tools.js.map +1 -0
- package/src/lib/server/site-chat-visitor.d.ts +24 -0
- package/src/lib/server/site-chat-visitor.js +39 -0
- package/src/lib/server/site-chat-visitor.js.map +1 -0
- package/src/lib/server/site-offers.d.ts +31 -0
- package/src/lib/server/site-offers.js +91 -0
- package/src/lib/server/site-offers.js.map +1 -0
- package/src/lib/server/stays-site-search.d.ts +20 -0
- package/src/lib/server/stays-site-search.js +78 -0
- package/src/lib/server/stays-site-search.js.map +1 -0
- package/src/lib/server.js +20 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/site-chat-tool-definitions.d.ts +26 -0
- package/src/lib/site-chat-tool-definitions.js +141 -0
- package/src/lib/site-chat-tool-definitions.js.map +1 -0
- package/src/lib/site.js +8 -0
- package/src/lib/site.js.map +1 -1
- package/src/lib/subprocessors.js +7 -0
- package/src/lib/subprocessors.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/commerce/src/lib/declarations.server.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// The seam from its own module, not the plugin-manager barrel: boot needs the\n// registry and nothing else, and the barrel reaches the client contexts.\nimport { registerOperatorAlerts } from '@aglyn/aglyn/plugin-manager/operator-alerts'\nimport { registerPluginEventHandler } from '@aglyn/aglyn/plugin-manager/plugin-events'\nimport {\n registerPluginRecordIndex,\n type PluginRecordIndex,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-index'\nimport {\n registerPluginShipmentRecords,\n type PluginShipmentRecords,\n} from '@aglyn/aglyn/plugin-manager/plugin-shipment-records'\nimport {\n registerPluginLocalDeliveryRecords,\n type PluginLocalDeliveryRecords,\n} from '@aglyn/aglyn/plugin-manager/plugin-local-deliveries'\nimport {\n registerPluginProductCatalog,\n type PluginProductCatalog,\n} from '@aglyn/aglyn/plugin-manager/plugin-product-catalog'\nimport {\n registerPluginSiteSearchSource,\n type PluginSiteSearchSource,\n} from '@aglyn/aglyn/plugin-manager/plugin-site-search'\nimport {\n registerPluginStockLevels,\n type PluginStockLevels,\n} from '@aglyn/aglyn/plugin-manager/plugin-stock-levels'\nimport {\n registerPluginChannelOrders,\n type PluginChannelOrders,\n} from '@aglyn/aglyn/plugin-manager/plugin-channel-orders'\nimport {\n registerPluginProductWriter,\n type PluginProductWriter,\n} from '@aglyn/aglyn/plugin-manager/plugin-product-writer'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { COMMERCE_OPERATOR_ALERTS } from './constants/operator-alerts'\nimport { registerCommerceEventTriggers } from './server/order-event-triggers'\n\n/**\n * The commerce plugin's server declarations: the light registrations core\n * reads at boot, before any surface loads — among them its orders as a label\n * buyer reads and writes them, through core's `core.shipment-records`.\n *\n * Its operator alerts (AGL-3377), so Staff → Operator alerts lists them and\n * staff can switch them before the first one is ever raised; and the indexes\n * of its products and categories, so another plugin reads them without\n * reaching for this plugin's collections.\n */\nexport function registerCommerceServerDeclarations(): void {\n registerOperatorAlerts(COMMERCE_OPERATOR_ALERTS, { pluginId: BUNDLE_ID })\n // Its order and return events (AGL-3611), and each as a workflow trigger.\n registerCommerceEventTriggers()\n // Products and categories, as another plugin reads them (AGL-3080). The\n // readers and the Admin SDK arrive with the first read, not with the boot.\n registerPluginRecordIndex('product', lazyIndex('productRecordIndex'), { pluginId: BUNDLE_ID })\n registerPluginRecordIndex('productCategory', lazyIndex('productCategoryRecordIndex'), {\n pluginId: BUNDLE_ID,\n })\n // Orders, as a label buyer reads and writes them (AGL-3612): read the\n // lines and the address, write a shipment, record tracking. The module and\n // the Admin SDK load with the first call.\n registerPluginShipmentRecords(lazyShipmentRecords, { pluginId: BUNDLE_ID })\n // Local deliveries, as a courier plugin reads and writes them (AGL-3695):\n // the drop's two ends, and the courier's run and the step it brings.\n registerPluginLocalDeliveryRecords(lazyLocalDeliveries, { pluginId: BUNDLE_ID })\n // A site's domains as Stripe payment method domains (AGL-3629), so Apple\n // Pay and the other wallets show on the merchant's own domain. The Stripe\n // calls arrive with the first event, not with the boot.\n registerPluginEventHandler(\n 'host.domain.attached',\n async (payload) =>\n (await import('./server/payment-method-domains')).onHostDomainAttached(payload),\n { pluginId: BUNDLE_ID },\n )\n registerPluginEventHandler(\n 'host.domain.released',\n async (payload) =>\n (await import('./server/payment-method-domains')).onHostDomainReleased(payload),\n { pluginId: BUNDLE_ID },\n )\n // A logo saved on the workspace's profile or brand reaches its stores'\n // card readers now (AGL-4048), once the save has answered; the\n // `pos-reader-splash-refresh` beat stays the backstop. The drawing and the\n // Stripe calls arrive with the first event, not with the boot.\n registerPluginEventHandler(\n 'org.logo.changed',\n async (payload) => {\n await (await import('./server/pos-reader-splash')).onOrgLogoChanged(payload)\n },\n { pluginId: BUNDLE_ID },\n )\n // The store's catalog, as a shopping-channel feed reads it (AGL-3637).\n registerPluginProductCatalog(lazyCatalog, { pluginId: BUNDLE_ID })\n // The store's products in the site's own search page: what the storefront\n // lists, linked to each product's page. The reads load with the first search.\n registerPluginSiteSearchSource(lazySiteSearch, { pluginId: BUNDLE_ID })\n // Counts another warehouse keeps, applied as a stock-take (AGL-3634): a\n // fulfillment network says how many it can ship and the products say so.\n registerPluginStockLevels(lazyStockLevels, { pluginId: BUNDLE_ID })\n // Products another plugin brings from a source of its own (AGL-3641),\n // written through the store's own rules.\n registerPluginProductWriter(lazyProductWriter, { pluginId: BUNDLE_ID })\n // Orders a marketplace sold (AGL-3638), recorded as this plugin's own:\n // numbered, their units off the same shelf in the same write, announced.\n registerPluginChannelOrders(lazyChannelOrders, { pluginId: BUNDLE_ID })\n}\n\n/** Outside orders, with the Admin SDK and the model arriving on the first call. */\nconst loadChannelOrders = async () => (await import('./server/channel-orders')).commerceChannelOrders\n\nconst lazyChannelOrders: PluginChannelOrders = {\n importOrder: async (order) => (await loadChannelOrders()).importOrder(order),\n cancelOrder: async (request) => (await loadChannelOrders()).cancelOrder(request),\n recordFees: async (request) => (await loadChannelOrders()).recordFees(request),\n}\n\n/** Stock counts, with the Admin SDK and the model arriving on the first call. */\nconst lazyStockLevels: PluginStockLevels = {\n setAvailable: async (request) => (await import('./server/stock-levels')).commerceStockLevels.setAvailable(request),\n}\n\n/** The writer, with the Admin SDK and the model arriving on the first write. */\nconst lazyProductWriter: PluginProductWriter = {\n upsertSourced: async (write) => (await import('./server/product-writer')).commerceProductWriter.upsertSourced(write),\n}\n\nconst loadShipmentRecords = async () =>\n (await import('./server/shipment-records')).commerceShipmentRecords\n\nconst lazyShipmentRecords: PluginShipmentRecords = {\n read: async (hostId, recordId) => (await loadShipmentRecords()).read(hostId, recordId),\n recordShipment: async (write) => (await loadShipmentRecords()).recordShipment(write),\n recordTracking: async (update) => (await loadShipmentRecords()).recordTracking(update),\n shipFromAddresses: async (hostId) => (await loadShipmentRecords()).shipFromAddresses(hostId),\n}\n\nconst loadLocalDeliveries = async () =>\n (await import('./server/local-delivery-records')).commerceLocalDeliveryRecords\n\nconst lazyLocalDeliveries: PluginLocalDeliveryRecords = {\n read: async (hostId, recordId) => (await loadLocalDeliveries()).read(hostId, recordId),\n recordCourier: async (write) => (await loadLocalDeliveries()).recordCourier(write),\n}\n\n/** The catalog, with the Admin SDK and the model arriving on the first read. */\nconst lazyCatalog: PluginProductCatalog = {\n store: async (hostId) => (await import('./server/product-catalog')).productCatalog.store(hostId),\n page: async (request) => (await import('./server/product-catalog')).productCatalog.page(request),\n}\n\n/** Site search, with the Admin SDK and the model arriving on the first search. */\nconst lazySiteSearch: PluginSiteSearchSource = {\n key: 'products',\n label: 'Products',\n items: async (request) => (await import('./server/site-search')).commerceSiteSearch.items(request),\n}\n\ntype IndexName = 'productRecordIndex' | 'productCategoryRecordIndex'\n\nfunction lazyIndex(name: IndexName): PluginRecordIndex {\n const load = async () => (await import('./server/product-record-index'))[name]\n return {\n list: async (request) => (await load()).list(request),\n get: async (request) => (await load()).get(request),\n }\n}\n"],"names":["registerOperatorAlerts","registerPluginEventHandler","registerPluginRecordIndex","registerPluginShipmentRecords","registerPluginLocalDeliveryRecords","registerPluginProductCatalog","registerPluginSiteSearchSource","registerPluginStockLevels","registerPluginChannelOrders","registerPluginProductWriter","BUNDLE_ID","COMMERCE_OPERATOR_ALERTS","registerCommerceEventTriggers","registerCommerceServerDeclarations","pluginId","lazyIndex","lazyShipmentRecords","lazyLocalDeliveries","payload","onHostDomainAttached","onHostDomainReleased","onOrgLogoChanged","lazyCatalog","lazySiteSearch","lazyStockLevels","lazyProductWriter","lazyChannelOrders","loadChannelOrders","commerceChannelOrders","importOrder","order","cancelOrder","request","recordFees","setAvailable","commerceStockLevels","upsertSourced","write","commerceProductWriter","loadShipmentRecords","commerceShipmentRecords","read","hostId","recordId","recordShipment","recordTracking","update","shipFromAddresses","loadLocalDeliveries","commerceLocalDeliveryRecords","recordCourier","store","productCatalog","page","key","label","items","commerceSiteSearch","name","load","list","get"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,8EAA8E;AAC9E,yEAAyE;AACzE,SAASA,sBAAsB,QAAQ,8CAA6C;AACpF,SAASC,0BAA0B,QAAQ,4CAA2C;AACtF,SACEC,yBAAyB,QAEpB,kDAAiD;AACxD,SACEC,6BAA6B,QAExB,sDAAqD;AAC5D,SACEC,kCAAkC,QAE7B,sDAAqD;AAC5D,SACEC,4BAA4B,QAEvB,qDAAoD;AAC3D,SACEC,8BAA8B,QAEzB,iDAAgD;AACvD,SACEC,yBAAyB,QAEpB,kDAAiD;AACxD,SACEC,2BAA2B,QAEtB,oDAAmD;AAC1D,SACEC,2BAA2B,QAEtB,oDAAmD;AAC1D,SAASC,SAAS,QAAQ,+BAA2B;AACrD,SAASC,wBAAwB,QAAQ,iCAA6B;AACtE,SAASC,6BAA6B,QAAQ,mCAA+B;AAE7E;;;;;;;;;CASC,GACD,OAAO,SAASC;IACdb,uBAAuBW,0BAA0B;QAAEG,UAAUJ;IAAU;IACvE,0EAA0E;IAC1EE;IACA,wEAAwE;IACxE,2EAA2E;IAC3EV,0BAA0B,WAAWa,UAAU,uBAAuB;QAAED,UAAUJ;IAAU;IAC5FR,0BAA0B,mBAAmBa,UAAU,+BAA+B;QACpFD,UAAUJ;IACZ;IACA,sEAAsE;IACtE,2EAA2E;IAC3E,0CAA0C;IAC1CP,8BAA8Ba,qBAAqB;QAAEF,UAAUJ;IAAU;IACzE,0EAA0E;IAC1E,qEAAqE;IACrEN,mCAAmCa,qBAAqB;QAAEH,UAAUJ;IAAU;IAC9E,yEAAyE;IACzE,0EAA0E;IAC1E,wDAAwD;IACxDT,2BACE,wBACA,OAAOiB,UACL,AA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,MAAM,MAAM,CAAC,0BAAsB,EAAGyB,kBAAkB,CAACD,KAAK,CAACxB;AAC5F;AAIA,SAASjB,UAAU2C,IAAe;IAChC,MAAMC,OAAO,UAAY,AAAC,CAAA,MAAM,MAAM,CAAC,mCAA+B,CAAE,CAACD,KAAK;IAC9E,OAAO;QACLE,MAAM,OAAO5B,UAAY,AAAC,CAAA,MAAM2B,MAAK,EAAGC,IAAI,CAAC5B;QAC7C6B,KAAK,OAAO7B,UAAY,AAAC,CAAA,MAAM2B,MAAK,EAAGE,GAAG,CAAC7B;IAC7C;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/commerce/src/lib/declarations.server.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// The seam from its own module, not the plugin-manager barrel: boot needs the\n// registry and nothing else, and the barrel reaches the client contexts.\nimport { registerOperatorAlerts } from '@aglyn/aglyn/plugin-manager/operator-alerts'\nimport { registerPluginEventHandler } from '@aglyn/aglyn/plugin-manager/plugin-events'\nimport {\n registerPluginRecordIndex,\n type PluginRecordIndex,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-index'\nimport {\n registerPluginShipmentRecords,\n type PluginShipmentRecords,\n} from '@aglyn/aglyn/plugin-manager/plugin-shipment-records'\nimport {\n registerPluginLocalDeliveryRecords,\n type PluginLocalDeliveryRecords,\n} from '@aglyn/aglyn/plugin-manager/plugin-local-deliveries'\nimport {\n registerPluginProductCatalog,\n type PluginProductCatalog,\n} from '@aglyn/aglyn/plugin-manager/plugin-product-catalog'\nimport {\n registerPluginSiteSearchSource,\n type PluginSiteSearchSource,\n} from '@aglyn/aglyn/plugin-manager/plugin-site-search'\nimport {\n registerPluginSiteOffer,\n type PluginSiteOfferSource,\n} from '@aglyn/aglyn/plugin-manager/plugin-site-offers'\nimport {\n registerPluginStockLevels,\n type PluginStockLevels,\n} from '@aglyn/aglyn/plugin-manager/plugin-stock-levels'\nimport {\n registerPluginChannelOrders,\n type PluginChannelOrders,\n} from '@aglyn/aglyn/plugin-manager/plugin-channel-orders'\nimport {\n registerPluginProductWriter,\n type PluginProductWriter,\n} from '@aglyn/aglyn/plugin-manager/plugin-product-writer'\nimport {\n registerPluginSiteChatTool,\n registerPluginSiteChatVisitorReader,\n} from '@aglyn/aglyn/plugin-manager/plugin-site-chat-tools'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { COMMERCE_SITE_CHAT_TOOLS } from './site-chat-tool-definitions'\nimport { COMMERCE_OPERATOR_ALERTS } from './constants/operator-alerts'\nimport { registerCommerceEventTriggers } from './server/order-event-triggers'\n\n/**\n * The commerce plugin's server declarations: the light registrations core\n * reads at boot, before any surface loads — among them its orders as a label\n * buyer reads and writes them, through core's `core.shipment-records`.\n *\n * Its operator alerts (AGL-3377), so Staff → Operator alerts lists them and\n * staff can switch them before the first one is ever raised; and the indexes\n * of its products and categories, so another plugin reads them without\n * reaching for this plugin's collections.\n */\nexport function registerCommerceServerDeclarations(): void {\n registerOperatorAlerts(COMMERCE_OPERATOR_ALERTS, { pluginId: BUNDLE_ID })\n // Its order and return events (AGL-3611), and each as a workflow trigger.\n registerCommerceEventTriggers()\n // Products and categories, as another plugin reads them (AGL-3080). The\n // readers and the Admin SDK arrive with the first read, not with the boot.\n registerPluginRecordIndex('product', lazyIndex('productRecordIndex'), { pluginId: BUNDLE_ID })\n registerPluginRecordIndex('productCategory', lazyIndex('productCategoryRecordIndex'), {\n pluginId: BUNDLE_ID,\n })\n // Orders, as a label buyer reads and writes them (AGL-3612): read the\n // lines and the address, write a shipment, record tracking. The module and\n // the Admin SDK load with the first call.\n registerPluginShipmentRecords(lazyShipmentRecords, { pluginId: BUNDLE_ID })\n // Local deliveries, as a courier plugin reads and writes them (AGL-3695):\n // the drop's two ends, and the courier's run and the step it brings.\n registerPluginLocalDeliveryRecords(lazyLocalDeliveries, { pluginId: BUNDLE_ID })\n // A site's domains as Stripe payment method domains (AGL-3629), so Apple\n // Pay and the other wallets show on the merchant's own domain. The Stripe\n // calls arrive with the first event, not with the boot.\n registerPluginEventHandler(\n 'host.domain.attached',\n async (payload) =>\n (await import('./server/payment-method-domains')).onHostDomainAttached(payload),\n { pluginId: BUNDLE_ID },\n )\n registerPluginEventHandler(\n 'host.domain.released',\n async (payload) =>\n (await import('./server/payment-method-domains')).onHostDomainReleased(payload),\n { pluginId: BUNDLE_ID },\n )\n // A logo saved on the workspace's profile or brand reaches its stores'\n // card readers now (AGL-4048), once the save has answered; the\n // `pos-reader-splash-refresh` beat stays the backstop. The drawing and the\n // Stripe calls arrive with the first event, not with the boot.\n registerPluginEventHandler(\n 'org.logo.changed',\n async (payload) => {\n await (await import('./server/pos-reader-splash')).onOrgLogoChanged(payload)\n },\n { pluginId: BUNDLE_ID },\n )\n // The store's catalog, as a shopping-channel feed reads it (AGL-3637).\n registerPluginProductCatalog(lazyCatalog, { pluginId: BUNDLE_ID })\n // The store's products in the site's own search page: what the storefront\n // lists, linked to each product's page. The reads load with the first search.\n registerPluginSiteSearchSource(lazySiteSearch, { pluginId: BUNDLE_ID })\n // Its stays (cabins, hookups, tent sites) beside them (AGL-4252), each\n // linked to the page its owner named for it.\n registerPluginSiteSearchSource(lazyStaysSearch, { pluginId: BUNDLE_ID })\n // A product as another plugin's button sells it (AGL-4252): an events\n // calendar's \"Get tickets\" puts it in the cart, with the event's day as its\n // use day when the product asks for one.\n registerPluginSiteOffer('product', lazyProductOffer, { pluginId: BUNDLE_ID })\n // Counts another warehouse keeps, applied as a stock-take (AGL-3634): a\n // fulfillment network says how many it can ship and the products say so.\n registerPluginStockLevels(lazyStockLevels, { pluginId: BUNDLE_ID })\n // Products another plugin brings from a source of its own (AGL-3641),\n // written through the store's own rules.\n registerPluginProductWriter(lazyProductWriter, { pluginId: BUNDLE_ID })\n // Orders a marketplace sold (AGL-3638), recorded as this plugin's own:\n // numbered, their units off the same shelf in the same write, announced.\n registerPluginChannelOrders(lazyChannelOrders, { pluginId: BUNDLE_ID })\n // The store's tools for the AI chat on its site (AGL-4250): product\n // details, a stay's dates, and the add-to-cart and reservation cards the\n // visitor confirms; and a signed-in member's first name for its greeting.\n // Definitions only at boot; the reads load with the first call.\n for (const definition of COMMERCE_SITE_CHAT_TOOLS) {\n registerPluginSiteChatTool(\n {\n ...definition,\n run: async (request) =>\n (await import('./server/site-chat-tools')).runCommerceSiteChatTool(definition.name, request),\n },\n { pluginId: BUNDLE_ID },\n )\n }\n registerPluginSiteChatVisitorReader(\n {\n readVisitor: async (request) =>\n (await import('./server/site-chat-visitor')).commerceSiteChatVisitor.readVisitor(request),\n },\n { pluginId: BUNDLE_ID },\n )\n}\n\n/** Outside orders, with the Admin SDK and the model arriving on the first call. */\nconst loadChannelOrders = async () => (await import('./server/channel-orders')).commerceChannelOrders\n\nconst lazyChannelOrders: PluginChannelOrders = {\n importOrder: async (order) => (await loadChannelOrders()).importOrder(order),\n cancelOrder: async (request) => (await loadChannelOrders()).cancelOrder(request),\n recordFees: async (request) => (await loadChannelOrders()).recordFees(request),\n}\n\n/** Stock counts, with the Admin SDK and the model arriving on the first call. */\nconst lazyStockLevels: PluginStockLevels = {\n setAvailable: async (request) => (await import('./server/stock-levels')).commerceStockLevels.setAvailable(request),\n}\n\n/** The writer, with the Admin SDK and the model arriving on the first write. */\nconst lazyProductWriter: PluginProductWriter = {\n upsertSourced: async (write) => (await import('./server/product-writer')).commerceProductWriter.upsertSourced(write),\n}\n\nconst loadShipmentRecords = async () =>\n (await import('./server/shipment-records')).commerceShipmentRecords\n\nconst lazyShipmentRecords: PluginShipmentRecords = {\n read: async (hostId, recordId) => (await loadShipmentRecords()).read(hostId, recordId),\n recordShipment: async (write) => (await loadShipmentRecords()).recordShipment(write),\n recordTracking: async (update) => (await loadShipmentRecords()).recordTracking(update),\n shipFromAddresses: async (hostId) => (await loadShipmentRecords()).shipFromAddresses(hostId),\n}\n\nconst loadLocalDeliveries = async () =>\n (await import('./server/local-delivery-records')).commerceLocalDeliveryRecords\n\nconst lazyLocalDeliveries: PluginLocalDeliveryRecords = {\n read: async (hostId, recordId) => (await loadLocalDeliveries()).read(hostId, recordId),\n recordCourier: async (write) => (await loadLocalDeliveries()).recordCourier(write),\n}\n\n/** The catalog, with the Admin SDK and the model arriving on the first read. */\nconst lazyCatalog: PluginProductCatalog = {\n store: async (hostId) => (await import('./server/product-catalog')).productCatalog.store(hostId),\n page: async (request) => (await import('./server/product-catalog')).productCatalog.page(request),\n}\n\n/** Site search, with the Admin SDK and the model arriving on the first search. */\nconst lazySiteSearch: PluginSiteSearchSource = {\n key: 'products',\n label: 'Products',\n items: async (request) => (await import('./server/site-search')).commerceSiteSearch.items(request),\n}\n\ntype IndexName = 'productRecordIndex' | 'productCategoryRecordIndex'\n\nfunction lazyIndex(name: IndexName): PluginRecordIndex {\n const load = async () => (await import('./server/product-record-index'))[name]\n return {\n list: async (request) => (await load()).list(request),\n get: async (request) => (await load()).get(request),\n }\n}\n\n/** Stays in site search, with the reads arriving on the first search. */\nconst lazyStaysSearch: PluginSiteSearchSource = {\n key: 'stays',\n label: 'Stays',\n items: async (request) =>\n (await import('./server/stays-site-search')).commerceStaysSiteSearch.items(request),\n}\n\n/** A product's offer, with the read arriving on the first ask. */\nconst lazyProductOffer: PluginSiteOfferSource = {\n resolve: async (request) =>\n (await import('./server/site-offers')).commerceProductSiteOffer.resolve(request),\n}\n"],"names":["registerOperatorAlerts","registerPluginEventHandler","registerPluginRecordIndex","registerPluginShipmentRecords","registerPluginLocalDeliveryRecords","registerPluginProductCatalog","registerPluginSiteSearchSource","registerPluginSiteOffer","registerPluginStockLevels","registerPluginChannelOrders","registerPluginProductWriter","registerPluginSiteChatTool","registerPluginSiteChatVisitorReader","BUNDLE_ID","COMMERCE_SITE_CHAT_TOOLS","COMMERCE_OPERATOR_ALERTS","registerCommerceEventTriggers","registerCommerceServerDeclarations","pluginId","lazyIndex","lazyShipmentRecords","lazyLocalDeliveries","payload","onHostDomainAttached","onHostDomainReleased","onOrgLogoChanged","lazyCatalog","lazySiteSearch","lazyStaysSearch","lazyProductOffer","lazyStockLevels","lazyProductWriter","lazyChannelOrders","definition","run","request","runCommerceSiteChatTool","name","readVisitor","commerceSiteChatVisitor","loadChannelOrders","commerceChannelOrders","importOrder","order","cancelOrder","recordFees","setAvailable","commerceStockLevels","upsertSourced","write","commerceProductWriter","loadShipmentRecords","commerceShipmentRecords","read","hostId","recordId","recordShipment","recordTracking","update","shipFromAddresses","loadLocalDeliveries","commerceLocalDeliveryRecords","recordCourier","store","productCatalog","page","key","label","items","commerceSiteSearch","load","list","get","commerceStaysSiteSearch","resolve","commerceProductSiteOffer"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,8EAA8E;AAC9E,yEAAyE;AACzE,SAASA,sBAAsB,QAAQ,8CAA6C;AACpF,SAASC,0BAA0B,QAAQ,4CAA2C;AACtF,SACEC,yBAAyB,QAEpB,kDAAiD;AACxD,SACEC,6BAA6B,QAExB,sDAAqD;AAC5D,SACEC,kCAAkC,QAE7B,sDAAqD;AAC5D,SACEC,4BAA4B,QAEvB,qDAAoD;AAC3D,SACEC,8BAA8B,QAEzB,iDAAgD;AACvD,SACEC,uBAAuB,QAElB,iDAAgD;AACvD,SACEC,yBAAyB,QAEpB,kDAAiD;AACxD,SACEC,2BAA2B,QAEtB,oDAAmD;AAC1D,SACEC,2BAA2B,QAEtB,oDAAmD;AAC1D,SACEC,0BAA0B,EAC1BC,mCAAmC,QAC9B,qDAAoD;AAC3D,SAASC,SAAS,QAAQ,+BAA2B;AACrD,SAASC,wBAAwB,QAAQ,kCAA8B;AACvE,SAASC,wBAAwB,QAAQ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,MAAMiC,OAAO,UAAY,AAAC,CAAA,MAAM,MAAM,CAAC,mCAA+B,CAAE,CAACjC,KAAK;IAC9E,OAAO;QACLkC,MAAM,OAAOpC,UAAY,AAAC,CAAA,MAAMmC,MAAK,EAAGC,IAAI,CAACpC;QAC7CqC,KAAK,OAAOrC,UAAY,AAAC,CAAA,MAAMmC,MAAK,EAAGE,GAAG,CAACrC;IAC7C;AACF;AAEA,uEAAuE,GACvE,MAAMP,kBAA0C;IAC9CsC,KAAK;IACLC,OAAO;IACPC,OAAO,OAAOjC,UACZ,AAAC,CAAA,MAAM,MAAM,CAAC,gCAA4B,EAAGsC,uBAAuB,CAACL,KAAK,CAACjC;AAC/E;AAEA,gEAAgE,GAChE,MAAMN,mBAA0C;IAC9C6C,SAAS,OAAOvC,UACd,AAAC,CAAA,MAAM,MAAM,CAAC,0BAAsB,EAAGwC,wBAAwB,CAACD,OAAO,CAACvC;AAC5E"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { type CurrencyRounding, type FxRates, type StoreCurrency, type StoreCurrencySettings } from './commerce-currency';
|
|
18
|
+
/**
|
|
19
|
+
* The merchant's side of multi-currency selling (AGL-4248): what the console's
|
|
20
|
+
* Currencies card, product editor, add-on editor and shipping rates need to
|
|
21
|
+
* set a store up, the way Shopify Markets lets a merchant do it from screens.
|
|
22
|
+
* Pure.
|
|
23
|
+
*/
|
|
24
|
+
/** What `GET commerce/currency?setup=1` answers the console with. */
|
|
25
|
+
export interface CurrencySetupAnswer {
|
|
26
|
+
base: string;
|
|
27
|
+
/** The store's saved settings, as stored. */
|
|
28
|
+
settings: StoreCurrencySettings | null;
|
|
29
|
+
/** Every rate the platform holds, so a currency not yet saved can be previewed. */
|
|
30
|
+
allRates: FxRates | null;
|
|
31
|
+
}
|
|
32
|
+
/** The currencies a store sells in besides its own (empty when off). */
|
|
33
|
+
export declare function otherStoreCurrencies(settings: StoreCurrencySettings | undefined | null, base: string): StoreCurrency[];
|
|
34
|
+
/** The currencies a merchant may still add: sellable, not the store's, not added. */
|
|
35
|
+
export declare function addableCurrencies(base: string, added: readonly string[]): string[];
|
|
36
|
+
/** "NZD · New Zealand dollar". */
|
|
37
|
+
export declare function currencyOptionLabel(code: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* A currency as the console adds it, the way Shopify Markets does: the daily
|
|
40
|
+
* rate, no rounding until the merchant turns it on, no price adjustment.
|
|
41
|
+
*/
|
|
42
|
+
export declare function newStoreCurrency(code: string): StoreCurrency;
|
|
43
|
+
/** The endings a merchant may round converted prices to, once rounding is on. */
|
|
44
|
+
export declare const CURRENCY_ROUNDING_ENDINGS: readonly Exclude<CurrencyRounding, 'none'>[];
|
|
45
|
+
/** A price adjustment as typed, kept within -90 to +100 percent; blank is none. */
|
|
46
|
+
export declare function clampAdjustmentInput(raw: string): number;
|
|
47
|
+
/** A manual exchange rate as typed: blank (or not a positive number) is the daily rate. */
|
|
48
|
+
export declare function parseManualRateInput(raw: string): number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* What rate a currency converts at, said on its card: "Daily rate 1.7041,
|
|
51
|
+
* updated Nov 25", "Manual rate 1.7500", or that no daily rate is in yet.
|
|
52
|
+
*/
|
|
53
|
+
export declare function currencyRateLabel(rates: FxRates | undefined | null, base: string, entry: StoreCurrency): string;
|
|
54
|
+
/** The daily rate alone, for a manual-rate field's helper text. */
|
|
55
|
+
export declare function dailyRateLabel(rates: FxRates | undefined | null, base: string, code: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* A price as typed in a currency's field: `undefined` for blank (converted
|
|
58
|
+
* automatically), `null` for something that is not a price.
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseMajorInput(raw: string): number | undefined | null;
|
|
61
|
+
/**
|
|
62
|
+
* A per-currency map with one currency set or cleared. A cleared one is
|
|
63
|
+
* dropped, and an empty map is `undefined`, so the caller removes the field
|
|
64
|
+
* instead of storing `undefined` (client-direct writes refuse one).
|
|
65
|
+
*/
|
|
66
|
+
export declare function withCurrencyAmount(map: Readonly<Record<string, number>> | undefined, code: string, value: number | undefined): Record<string, number> | undefined;
|
|
67
|
+
/** A minor amount as a field shows it in that currency: "449.00", "5400". */
|
|
68
|
+
export declare function minorToInput(minor: number | undefined, code: string): string;
|
|
69
|
+
/** A major amount as typed, in minor units of that currency. */
|
|
70
|
+
export declare function majorToMinor(major: number, code: string): number;
|
|
71
|
+
/** "Nov 25", in UTC, the day the reference rate was published. */
|
|
72
|
+
export declare function ratesAsOfLabel(rates: FxRates | undefined | null): string;
|
|
73
|
+
/**
|
|
74
|
+
* The line under each currency on the Currencies card:
|
|
75
|
+
* "$250.00 → NZ$426.03 (rate 1.7041, as of Nov 25)", or "(manual rate
|
|
76
|
+
* 1.7500)". The rate shown is the one in use; the price adjustment and
|
|
77
|
+
* rounding are what move the price from it.
|
|
78
|
+
*/
|
|
79
|
+
export declare function currencyPreviewText(sampleMinor: number, base: string, entry: StoreCurrency, rates: FxRates | undefined | null): string;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Aglyn LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/ import { convertMinor, crossRate, currencyRate, CURRENCY_NAMES, currencyMinorFactor, formatShopperMoney, SELLABLE_CURRENCIES, storeCurrencies } from "./commerce-currency.js";
|
|
18
|
+
/** The currencies a store sells in besides its own (empty when off). */ export function otherStoreCurrencies(settings, base) {
|
|
19
|
+
return storeCurrencies(settings != null ? settings : undefined, base).slice(1);
|
|
20
|
+
}
|
|
21
|
+
/** The currencies a merchant may still add: sellable, not the store's, not added. */ export function addableCurrencies(base, added) {
|
|
22
|
+
return SELLABLE_CURRENCIES.filter((code)=>code !== base && !added.includes(code));
|
|
23
|
+
}
|
|
24
|
+
/** "NZD · New Zealand dollar". */ export function currencyOptionLabel(code) {
|
|
25
|
+
const name = CURRENCY_NAMES[code];
|
|
26
|
+
return name ? `${code} · ${name}` : code;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A currency as the console adds it, the way Shopify Markets does: the daily
|
|
30
|
+
* rate, no rounding until the merchant turns it on, no price adjustment.
|
|
31
|
+
*/ export function newStoreCurrency(code) {
|
|
32
|
+
return {
|
|
33
|
+
code,
|
|
34
|
+
rounding: 'none',
|
|
35
|
+
bufferPct: 0
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** The endings a merchant may round converted prices to, once rounding is on. */ export const CURRENCY_ROUNDING_ENDINGS = [
|
|
39
|
+
'99',
|
|
40
|
+
'95',
|
|
41
|
+
'whole'
|
|
42
|
+
];
|
|
43
|
+
/** A price adjustment as typed, kept within -90 to +100 percent; blank is none. */ export function clampAdjustmentInput(raw) {
|
|
44
|
+
const value = Number(String(raw).trim().replace(',', '.'));
|
|
45
|
+
if (!Number.isFinite(value) || value === 0) return 0;
|
|
46
|
+
return Math.max(-90, Math.min(100, Math.round(value * 100) / 100));
|
|
47
|
+
}
|
|
48
|
+
/** A manual exchange rate as typed: blank (or not a positive number) is the daily rate. */ export function parseManualRateInput(raw) {
|
|
49
|
+
const value = Number(String(raw != null ? raw : '').trim().replace(',', '.'));
|
|
50
|
+
return Number.isFinite(value) && value > 0 ? value : undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What rate a currency converts at, said on its card: "Daily rate 1.7041,
|
|
54
|
+
* updated Nov 25", "Manual rate 1.7500", or that no daily rate is in yet.
|
|
55
|
+
*/ export function currencyRateLabel(rates, base, entry) {
|
|
56
|
+
if (entry.manualRate && entry.manualRate > 0) return `Manual rate ${entry.manualRate.toFixed(4)}`;
|
|
57
|
+
const daily = crossRate(rates != null ? rates : undefined, base, entry.code);
|
|
58
|
+
if (daily == null) return `No daily rate for ${entry.code} yet`;
|
|
59
|
+
const asOf = ratesAsOfLabel(rates);
|
|
60
|
+
return `Daily rate ${daily.toFixed(4)}${asOf ? `, updated ${asOf}` : ''}`;
|
|
61
|
+
}
|
|
62
|
+
/** The daily rate alone, for a manual-rate field's helper text. */ export function dailyRateLabel(rates, base, code) {
|
|
63
|
+
return currencyRateLabel(rates, base, {
|
|
64
|
+
code
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A price as typed in a currency's field: `undefined` for blank (converted
|
|
69
|
+
* automatically), `null` for something that is not a price.
|
|
70
|
+
*/ export function parseMajorInput(raw) {
|
|
71
|
+
const text = String(raw != null ? raw : '').trim().replace(',', '.');
|
|
72
|
+
if (text === '') return undefined;
|
|
73
|
+
const value = Number(text);
|
|
74
|
+
return Number.isFinite(value) && value >= 0 ? value : null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A per-currency map with one currency set or cleared. A cleared one is
|
|
78
|
+
* dropped, and an empty map is `undefined`, so the caller removes the field
|
|
79
|
+
* instead of storing `undefined` (client-direct writes refuse one).
|
|
80
|
+
*/ export function withCurrencyAmount(map, code, value) {
|
|
81
|
+
const next = _extends({}, map != null ? map : {});
|
|
82
|
+
if (value == null) delete next[code];
|
|
83
|
+
else next[code] = value;
|
|
84
|
+
return Object.keys(next).length ? next : undefined;
|
|
85
|
+
}
|
|
86
|
+
/** A minor amount as a field shows it in that currency: "449.00", "5400". */ export function minorToInput(minor, code) {
|
|
87
|
+
if (minor == null || !Number.isFinite(minor)) return '';
|
|
88
|
+
const factor = currencyMinorFactor(code);
|
|
89
|
+
return factor === 1 ? String(Math.round(minor)) : (minor / factor).toFixed(2);
|
|
90
|
+
}
|
|
91
|
+
/** A major amount as typed, in minor units of that currency. */ export function majorToMinor(major, code) {
|
|
92
|
+
return Math.round(major * currencyMinorFactor(code));
|
|
93
|
+
}
|
|
94
|
+
/** "Nov 25", in UTC, the day the reference rate was published. */ export function ratesAsOfLabel(rates) {
|
|
95
|
+
if (!(rates == null ? void 0 : rates.asOfMs)) return '';
|
|
96
|
+
return new Date(rates.asOfMs).toLocaleDateString('en-US', {
|
|
97
|
+
month: 'short',
|
|
98
|
+
day: 'numeric',
|
|
99
|
+
timeZone: 'UTC'
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The line under each currency on the Currencies card:
|
|
104
|
+
* "$250.00 → NZ$426.03 (rate 1.7041, as of Nov 25)", or "(manual rate
|
|
105
|
+
* 1.7500)". The rate shown is the one in use; the price adjustment and
|
|
106
|
+
* rounding are what move the price from it.
|
|
107
|
+
*/ export function currencyPreviewText(sampleMinor, base, entry, rates) {
|
|
108
|
+
const from = formatShopperMoney(sampleMinor, base);
|
|
109
|
+
const rate = currencyRate(rates != null ? rates : undefined, base, entry);
|
|
110
|
+
const converted = rate == null ? undefined : convertMinor(sampleMinor, base, entry, rates != null ? rates : undefined);
|
|
111
|
+
if (rate == null || converted == null) {
|
|
112
|
+
return `${from} → no rate for ${entry.code} yet; shoppers pay in ${base} until there is one`;
|
|
113
|
+
}
|
|
114
|
+
const to = formatShopperMoney(converted, entry.code, {
|
|
115
|
+
disambiguate: true
|
|
116
|
+
});
|
|
117
|
+
if (entry.manualRate && entry.manualRate > 0) {
|
|
118
|
+
return `${from} → ${to} (manual rate ${rate.toFixed(4)})`;
|
|
119
|
+
}
|
|
120
|
+
const asOf = ratesAsOfLabel(rates);
|
|
121
|
+
return `${from} → ${to} (rate ${rate.toFixed(4)}${asOf ? `, as of ${asOf}` : ''})`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=commerce-currency-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/commerce-currency-setup.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n convertMinor,\n crossRate,\n currencyRate,\n CURRENCY_NAMES,\n currencyMinorFactor,\n formatShopperMoney,\n SELLABLE_CURRENCIES,\n storeCurrencies,\n type CurrencyRounding,\n type FxRates,\n type StoreCurrency,\n type StoreCurrencySettings,\n} from './commerce-currency'\n\n/**\n * The merchant's side of multi-currency selling (AGL-4248): what the console's\n * Currencies card, product editor, add-on editor and shipping rates need to\n * set a store up, the way Shopify Markets lets a merchant do it from screens.\n * Pure.\n */\n\n/** What `GET commerce/currency?setup=1` answers the console with. */\nexport interface CurrencySetupAnswer {\n base: string\n /** The store's saved settings, as stored. */\n settings: StoreCurrencySettings | null\n /** Every rate the platform holds, so a currency not yet saved can be previewed. */\n allRates: FxRates | null\n}\n\n/** The currencies a store sells in besides its own (empty when off). */\nexport function otherStoreCurrencies(\n settings: StoreCurrencySettings | undefined | null,\n base: string,\n): StoreCurrency[] {\n return storeCurrencies(settings ?? undefined, base).slice(1)\n}\n\n/** The currencies a merchant may still add: sellable, not the store's, not added. */\nexport function addableCurrencies(base: string, added: readonly string[]): string[] {\n return SELLABLE_CURRENCIES.filter((code) => code !== base && !added.includes(code))\n}\n\n/** \"NZD · New Zealand dollar\". */\nexport function currencyOptionLabel(code: string): string {\n const name = CURRENCY_NAMES[code]\n return name ? `${code} · ${name}` : code\n}\n\n/**\n * A currency as the console adds it, the way Shopify Markets does: the daily\n * rate, no rounding until the merchant turns it on, no price adjustment.\n */\nexport function newStoreCurrency(code: string): StoreCurrency {\n return { code, rounding: 'none', bufferPct: 0 }\n}\n\n/** The endings a merchant may round converted prices to, once rounding is on. */\nexport const CURRENCY_ROUNDING_ENDINGS: readonly Exclude<CurrencyRounding, 'none'>[] = ['99', '95', 'whole']\n\n/** A price adjustment as typed, kept within -90 to +100 percent; blank is none. */\nexport function clampAdjustmentInput(raw: string): number {\n const value = Number(String(raw).trim().replace(',', '.'))\n if (!Number.isFinite(value) || value === 0) return 0\n return Math.max(-90, Math.min(100, Math.round(value * 100) / 100))\n}\n\n/** A manual exchange rate as typed: blank (or not a positive number) is the daily rate. */\nexport function parseManualRateInput(raw: string): number | undefined {\n const value = Number(String(raw ?? '').trim().replace(',', '.'))\n return Number.isFinite(value) && value > 0 ? value : undefined\n}\n\n/**\n * What rate a currency converts at, said on its card: \"Daily rate 1.7041,\n * updated Nov 25\", \"Manual rate 1.7500\", or that no daily rate is in yet.\n */\nexport function currencyRateLabel(\n rates: FxRates | undefined | null,\n base: string,\n entry: StoreCurrency,\n): string {\n if (entry.manualRate && entry.manualRate > 0) return `Manual rate ${entry.manualRate.toFixed(4)}`\n const daily = crossRate(rates ?? undefined, base, entry.code)\n if (daily == null) return `No daily rate for ${entry.code} yet`\n const asOf = ratesAsOfLabel(rates)\n return `Daily rate ${daily.toFixed(4)}${asOf ? `, updated ${asOf}` : ''}`\n}\n\n/** The daily rate alone, for a manual-rate field's helper text. */\nexport function dailyRateLabel(rates: FxRates | undefined | null, base: string, code: string): string {\n return currencyRateLabel(rates, base, { code })\n}\n\n/**\n * A price as typed in a currency's field: `undefined` for blank (converted\n * automatically), `null` for something that is not a price.\n */\nexport function parseMajorInput(raw: string): number | undefined | null {\n const text = String(raw ?? '').trim().replace(',', '.')\n if (text === '') return undefined\n const value = Number(text)\n return Number.isFinite(value) && value >= 0 ? value : null\n}\n\n/**\n * A per-currency map with one currency set or cleared. A cleared one is\n * dropped, and an empty map is `undefined`, so the caller removes the field\n * instead of storing `undefined` (client-direct writes refuse one).\n */\nexport function withCurrencyAmount(\n map: Readonly<Record<string, number>> | undefined,\n code: string,\n value: number | undefined,\n): Record<string, number> | undefined {\n const next = { ...(map ?? {}) }\n if (value == null) delete next[code]\n else next[code] = value\n return Object.keys(next).length ? next : undefined\n}\n\n/** A minor amount as a field shows it in that currency: \"449.00\", \"5400\". */\nexport function minorToInput(minor: number | undefined, code: string): string {\n if (minor == null || !Number.isFinite(minor)) return ''\n const factor = currencyMinorFactor(code)\n return factor === 1 ? String(Math.round(minor)) : (minor / factor).toFixed(2)\n}\n\n/** A major amount as typed, in minor units of that currency. */\nexport function majorToMinor(major: number, code: string): number {\n return Math.round(major * currencyMinorFactor(code))\n}\n\n/** \"Nov 25\", in UTC, the day the reference rate was published. */\nexport function ratesAsOfLabel(rates: FxRates | undefined | null): string {\n if (!rates?.asOfMs) return ''\n return new Date(rates.asOfMs).toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n timeZone: 'UTC',\n })\n}\n\n/**\n * The line under each currency on the Currencies card:\n * \"$250.00 → NZ$426.03 (rate 1.7041, as of Nov 25)\", or \"(manual rate\n * 1.7500)\". The rate shown is the one in use; the price adjustment and\n * rounding are what move the price from it.\n */\nexport function currencyPreviewText(\n sampleMinor: number,\n base: string,\n entry: StoreCurrency,\n rates: FxRates | undefined | null,\n): string {\n const from = formatShopperMoney(sampleMinor, base)\n const rate = currencyRate(rates ?? undefined, base, entry)\n const converted = rate == null ? undefined : convertMinor(sampleMinor, base, entry, rates ?? undefined)\n if (rate == null || converted == null) {\n return `${from} → no rate for ${entry.code} yet; shoppers pay in ${base} until there is one`\n }\n const to = formatShopperMoney(converted, entry.code, { disambiguate: true })\n if (entry.manualRate && entry.manualRate > 0) {\n return `${from} → ${to} (manual rate ${rate.toFixed(4)})`\n }\n const asOf = ratesAsOfLabel(rates)\n return `${from} → ${to} (rate ${rate.toFixed(4)}${asOf ? `, as of ${asOf}` : ''})`\n}\n"],"names":["convertMinor","crossRate","currencyRate","CURRENCY_NAMES","currencyMinorFactor","formatShopperMoney","SELLABLE_CURRENCIES","storeCurrencies","otherStoreCurrencies","settings","base","undefined","slice","addableCurrencies","added","filter","code","includes","currencyOptionLabel","name","newStoreCurrency","rounding","bufferPct","CURRENCY_ROUNDING_ENDINGS","clampAdjustmentInput","raw","value","Number","String","trim","replace","isFinite","Math","max","min","round","parseManualRateInput","currencyRateLabel","rates","entry","manualRate","toFixed","daily","asOf","ratesAsOfLabel","dailyRateLabel","parseMajorInput","text","withCurrencyAmount","map","next","Object","keys","length","minorToInput","minor","factor","majorToMinor","major","asOfMs","Date","toLocaleDateString","month","day","timeZone","currencyPreviewText","sampleMinor","from","rate","converted","to","disambiguate"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,YAAY,EACZC,SAAS,EACTC,YAAY,EACZC,cAAc,EACdC,mBAAmB,EACnBC,kBAAkB,EAClBC,mBAAmB,EACnBC,eAAe,QAKV,yBAAqB;AAkB5B,sEAAsE,GACtE,OAAO,SAASC,qBACdC,QAAkD,EAClDC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C,QAAQ,EAAEA,MAAM,GAAG,GAAG,CAAC,CAAC;AACpF"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Multi-currency selling (AGL-4248), the way Shopify Markets does it: a
|
|
19
|
+
* shopper sees, and is CHARGED in, their own currency (Stripe presentment
|
|
20
|
+
* currency on the merchant's account, settled in the store currency), picked
|
|
21
|
+
* from where they browse out of the currencies the merchant turned on, and can
|
|
22
|
+
* switch it themselves.
|
|
23
|
+
*
|
|
24
|
+
* Prices convert from the store currency at a daily reference rate, plus an
|
|
25
|
+
* optional buffer, then round the way the merchant chose (Shopify's
|
|
26
|
+
* "rounding" rule rounds UP to the chosen ending). A product or add-on may
|
|
27
|
+
* carry a fixed price in a currency instead, which wins over conversion.
|
|
28
|
+
*
|
|
29
|
+
* Pure. Settings live on `hosts/{hostId}/settings/store` under `currencies`;
|
|
30
|
+
* rates live on `platform/fxRates`, written by the commerce rates beat.
|
|
31
|
+
*/
|
|
32
|
+
/** How a converted price is rounded, always UP to the next allowed value. */
|
|
33
|
+
export type CurrencyRounding = 'none' | 'whole' | '99' | '95';
|
|
34
|
+
export declare const CURRENCY_ROUNDING_LABELS: Readonly<Record<CurrencyRounding, string>>;
|
|
35
|
+
/** One currency a store sells in besides its own. */
|
|
36
|
+
export interface StoreCurrency {
|
|
37
|
+
/** ISO 4217, upper case: 'NZD'. */
|
|
38
|
+
code: string;
|
|
39
|
+
/**
|
|
40
|
+
* Rounding of converted prices, OFF unless the merchant turns it on
|
|
41
|
+
* (Shopify's rule): converted prices round UP to the ending chosen.
|
|
42
|
+
*/
|
|
43
|
+
rounding?: CurrencyRounding;
|
|
44
|
+
/**
|
|
45
|
+
* Price adjustment, in percent (-90 to +100), on every converted price in
|
|
46
|
+
* this currency: Shopify's per-market adjustment. Positive covers Stripe's
|
|
47
|
+
* conversion fee, which the merchant pays otherwise.
|
|
48
|
+
*/
|
|
49
|
+
bufferPct?: number;
|
|
50
|
+
/**
|
|
51
|
+
* A manual exchange rate: units of this currency per one unit of the store
|
|
52
|
+
* currency. Set, it replaces the daily rate and never goes stale.
|
|
53
|
+
*/
|
|
54
|
+
manualRate?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Prices shown and charged in this currency INCLUDE tax (VAT/GST), the way
|
|
57
|
+
* shoppers in the UK, EU, Australia and New Zealand expect. Only meaningful
|
|
58
|
+
* with Stripe Tax registrations in those places.
|
|
59
|
+
*/
|
|
60
|
+
pricesIncludeTax?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface StoreCurrencySettings {
|
|
63
|
+
/** Selling in more than the store currency at all. */
|
|
64
|
+
enabled?: boolean;
|
|
65
|
+
currencies?: StoreCurrency[];
|
|
66
|
+
/** Pick the shopper's currency from their country (default on). */
|
|
67
|
+
autoDetect?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/** The daily reference rates, per 1 unit of `base`. */
|
|
70
|
+
export interface FxRates {
|
|
71
|
+
base: string;
|
|
72
|
+
rates: Record<string, number>;
|
|
73
|
+
asOfMs: number;
|
|
74
|
+
source?: string;
|
|
75
|
+
}
|
|
76
|
+
/** Fixed prices a product variant carries per currency, in major units (29.95). */
|
|
77
|
+
export type FixedPrices = Record<string, number>;
|
|
78
|
+
/**
|
|
79
|
+
* The currencies a store may sell in: the ones the European Central Bank
|
|
80
|
+
* publishes a daily reference rate for, that Stripe charges cards in, and
|
|
81
|
+
* that have two decimal places (every receipt and report formats cents).
|
|
82
|
+
*/
|
|
83
|
+
export declare const SELLABLE_CURRENCIES: readonly string[];
|
|
84
|
+
export declare const CURRENCY_NAMES: Readonly<Record<string, string>>;
|
|
85
|
+
/** Minor units per major unit: 100 for most, 1 for yen and won. */
|
|
86
|
+
export declare function currencyMinorFactor(code: string): number;
|
|
87
|
+
/**
|
|
88
|
+
* The currency a country's shoppers expect (ISO 4217), for the currencies a
|
|
89
|
+
* store can sell in. A country not listed shops in the store currency.
|
|
90
|
+
*/
|
|
91
|
+
export declare const COUNTRY_CURRENCY: Readonly<Record<string, string>>;
|
|
92
|
+
/** The store's own currency, upper case (`settings/store.currency`, default USD). */
|
|
93
|
+
export declare function storeBaseCurrency(store: {
|
|
94
|
+
currency?: unknown;
|
|
95
|
+
} | undefined): string;
|
|
96
|
+
/**
|
|
97
|
+
* The currencies this store sells in, the store currency first, each known
|
|
98
|
+
* and listed once. Off (or nothing added) is the store currency alone.
|
|
99
|
+
*/
|
|
100
|
+
export declare function storeCurrencies(settings: StoreCurrencySettings | undefined, base: string): StoreCurrency[];
|
|
101
|
+
/**
|
|
102
|
+
* The rate a store converts into `target` at: its manual rate when set,
|
|
103
|
+
* else the daily cross rate. `undefined` when neither covers it.
|
|
104
|
+
*/
|
|
105
|
+
export declare function currencyRate(rates: FxRates | undefined, base: string, target: StoreCurrency): number | undefined;
|
|
106
|
+
/** Whether `code` is a currency this store sells in. */
|
|
107
|
+
export declare function storeSellsIn(settings: StoreCurrencySettings | undefined, base: string, code: unknown): StoreCurrency | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* The currency a shopper sees: their own choice when the store sells in it,
|
|
110
|
+
* else the one their country uses when the store sells in that (and
|
|
111
|
+
* auto-detect is on), else the store currency.
|
|
112
|
+
*/
|
|
113
|
+
export declare function resolveShopperCurrency(input: {
|
|
114
|
+
settings: StoreCurrencySettings | undefined;
|
|
115
|
+
base: string;
|
|
116
|
+
country?: string | null;
|
|
117
|
+
chosen?: string | null;
|
|
118
|
+
}): string;
|
|
119
|
+
/** `rates[to] / rates[from]` through the rates' own base; undefined when unknown. */
|
|
120
|
+
export declare function crossRate(rates: FxRates | undefined, from: string, to: string): number | undefined;
|
|
121
|
+
/** Round a major amount UP to the ending the merchant chose. */
|
|
122
|
+
export declare function roundMajor(major: number, rounding: CurrencyRounding, code: string): number;
|
|
123
|
+
/**
|
|
124
|
+
* A store-currency amount (minor units) in a shopper currency (minor units):
|
|
125
|
+
* converted at the reference rate, plus the buffer, rounded as set.
|
|
126
|
+
* `undefined` when the rates do not cover the pair, and callers then sell in
|
|
127
|
+
* the store currency rather than guessing.
|
|
128
|
+
*/
|
|
129
|
+
export declare function convertMinor(amountMinor: number, from: string, target: StoreCurrency, rates: FxRates | undefined, options?: {
|
|
130
|
+
round?: boolean;
|
|
131
|
+
}): number | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* The price a shopper pays for a variant, in minor units of their currency:
|
|
134
|
+
* the variant's fixed price there when it has one, else its store price
|
|
135
|
+
* converted. `priceMajor` is the store price in major units (`priceUsd`).
|
|
136
|
+
*/
|
|
137
|
+
export declare function variantPriceMinor(variant: {
|
|
138
|
+
priceUsd?: number;
|
|
139
|
+
fixedPrices?: FixedPrices;
|
|
140
|
+
}, base: string, target: StoreCurrency, rates: FxRates | undefined): number | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* An add-on or fee amount in the shopper's currency: a fixed amount there
|
|
143
|
+
* when the merchant set one, else converted at the rate WITHOUT the ending
|
|
144
|
+
* rounding (a $5 add-on is NZ$8.61, not NZ$8.99: rounding is for prices a
|
|
145
|
+
* shopper reads on their own).
|
|
146
|
+
*/
|
|
147
|
+
export declare function amountMinorIn(baseMinor: number, base: string, target: StoreCurrency, rates: FxRates | undefined, fixedMinor?: Record<string, number>): number | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* Money for a shopper. Where two currencies a store sells in share a sign
|
|
150
|
+
* ($ for US, Australian and New Zealand dollars), each says which it is:
|
|
151
|
+
* US$29.00, A$45.00, NZ$49.00.
|
|
152
|
+
*/
|
|
153
|
+
export declare function formatShopperMoney(amountMinor: number, code: string, options?: {
|
|
154
|
+
disambiguate?: boolean;
|
|
155
|
+
locale?: string;
|
|
156
|
+
}): string;
|
|
157
|
+
/** Whether a store's currencies include two that share a sign. */
|
|
158
|
+
export declare function currenciesShareSign(codes: readonly string[]): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Money in a timeline line or notice for a sale in `currency` (lower or
|
|
161
|
+
* upper case). A USD sale keeps the exact text it always had (`$1234.50`);
|
|
162
|
+
* any other currency names itself (`NZ$449.00`).
|
|
163
|
+
*/
|
|
164
|
+
export declare function saleMoneyText(cents: number, currency: string | null | undefined): string;
|
|
165
|
+
/** The metadata keys a checkout writes the charged line units under (AGL-4248). */
|
|
166
|
+
export declare const CHARGE_UNITS_METADATA_PREFIX = "chargeUnits";
|
|
167
|
+
/** Line units as metadata entries, each under Stripe's 500-character value cap. */
|
|
168
|
+
export declare function encodeChargeUnitsMetadata(units: readonly number[]): Record<string, string>;
|
|
169
|
+
/** The line units back from session metadata, or undefined when absent. */
|
|
170
|
+
export declare function decodeChargeUnitsMetadata(metadata: Record<string, unknown> | null | undefined): number[] | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* The order's currency fields (AGL-4248) from a paid session: the charge
|
|
173
|
+
* currency Stripe reports and, when it is not the store's, the store
|
|
174
|
+
* currency, the rate and the totals there.
|
|
175
|
+
*/
|
|
176
|
+
export declare function orderCurrencyFields<T extends object>(session: {
|
|
177
|
+
currency?: unknown;
|
|
178
|
+
metadata?: Record<string, unknown> | null;
|
|
179
|
+
} | null | undefined, totals: T): {
|
|
180
|
+
currency?: string;
|
|
181
|
+
baseCurrency?: string;
|
|
182
|
+
fxRate?: number;
|
|
183
|
+
baseTotals?: T;
|
|
184
|
+
};
|
|
185
|
+
/** Rates older than this are not used to charge anyone: the store currency is. */
|
|
186
|
+
export declare const FX_RATES_MAX_AGE_MS: number;
|
|
187
|
+
export declare function ratesAreFresh(rates: FxRates | undefined, nowMs: number): boolean;
|
|
188
|
+
/** The ECB's daily reference rates (free, no key): per 1 EUR, about 16:00 CET. */
|
|
189
|
+
export declare const ECB_DAILY_URL = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";
|
|
190
|
+
/**
|
|
191
|
+
* Parse the European Central Bank's daily reference XML
|
|
192
|
+
* (`eurofxref-daily.xml`): `<Cube time="2026-11-25">` holding
|
|
193
|
+
* `<Cube currency="USD" rate="1.0521"/>` rows, per 1 EUR.
|
|
194
|
+
*/
|
|
195
|
+
export declare function parseEcbDailyXml(xml: string): FxRates | undefined;
|
|
196
|
+
/** What a storefront prices from (`GET commerce/currency`). */
|
|
197
|
+
export interface PublicCurrencyAnswer {
|
|
198
|
+
base: string;
|
|
199
|
+
/** The store currency first; only currencies the day's rates cover. */
|
|
200
|
+
currencies: StoreCurrency[];
|
|
201
|
+
autoDetect: boolean;
|
|
202
|
+
/** The rates for exactly those currencies, or null when selling in the store currency only. */
|
|
203
|
+
rates: FxRates | null;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The public answer, from a store's settings and the stored rates. A
|
|
207
|
+
* currency the rates do not cover, or rates older than
|
|
208
|
+
* {@link FX_RATES_MAX_AGE_MS}, drop out: checkout would refuse to charge in
|
|
209
|
+
* them, so the storefront must not show them.
|
|
210
|
+
*/
|
|
211
|
+
export declare function publicCurrencyAnswer(context: {
|
|
212
|
+
base: string;
|
|
213
|
+
settings: StoreCurrencySettings | undefined;
|
|
214
|
+
rates: FxRates | undefined;
|
|
215
|
+
}, nowMs: number): PublicCurrencyAnswer;
|