@uplab/vendure-plugin-exchange-rates 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +12 -8
- package/dist/api/admin.resolver.d.ts +11 -0
- package/dist/api/admin.resolver.d.ts.map +1 -1
- package/dist/api/admin.resolver.js +29 -1
- package/dist/api/admin.resolver.js.map +1 -1
- package/dist/entities/currency-exchange-rate.entity.d.ts +2 -1
- package/dist/entities/currency-exchange-rate.entity.d.ts.map +1 -1
- package/dist/entities/currency-exchange-rate.entity.js.map +1 -1
- package/dist/exchange-rates.plugin.d.ts.map +1 -1
- package/dist/exchange-rates.plugin.js +17 -2
- package/dist/exchange-rates.plugin.js.map +1 -1
- package/dist/services/currency-exchange-rate-sync.service.d.ts +13 -4
- package/dist/services/currency-exchange-rate-sync.service.d.ts.map +1 -1
- package/dist/services/currency-exchange-rate-sync.service.js +40 -16
- package/dist/services/currency-exchange-rate-sync.service.js.map +1 -1
- package/package.json +14 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @uplab/vendure-plugin-exchange-rates
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#41](https://github.com/Uplab/uplab-vendure-plugins/pull/41) [`31d5deb`](https://github.com/Uplab/uplab-vendure-plugins/commit/31d5deba10edce2aef108da53358fafbb5ff7fae) Thanks [@brmk](https://github.com/brmk)! - Ship the LICENSE file in the package.
|
|
8
|
+
|
|
9
|
+
## 0.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#33](https://github.com/Uplab/uplab-vendure-plugins/pull/33) [`c586872`](https://github.com/Uplab/uplab-vendure-plugins/commit/c586872710e16bdcccd1be7a45c614905d7c6a4b) Thanks [@brmk](https://github.com/brmk)! - Rows from before the `baseCurrency` column are now also adopted when MySQL filled the column with `''`, and until they are, the Admin API lists them with the base they will get instead of failing the whole list on a null.
|
|
14
|
+
|
|
15
|
+
An adoption publishes a `synced` event; to see the one on boot, subscribe in `onModuleInit` (the README example now does).
|
|
16
|
+
|
|
17
|
+
The worker adopts such rows on bootstrap too, so it no longer depends on the server booting first, and the boot backfill no longer throws on a database error.
|
|
18
|
+
|
|
3
19
|
## 0.1.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Uplab Software
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -312,20 +312,23 @@ Turning on `useCustomRate` without a positive `customRate` is rejected.
|
|
|
312
312
|
## Event
|
|
313
313
|
|
|
314
314
|
`CurrencyExchangeRateEvent` is published once the transaction has committed: `type: 'synced'` when a sync
|
|
315
|
-
changed anything,
|
|
316
|
-
admin saved. Use it to drop caches
|
|
317
|
-
|
|
315
|
+
changed anything, or when the plugin adopts rows without a base on boot, with every rate now stored in the
|
|
316
|
+
base currency; `'updated'` with the one rate an admin saved. Use it to drop caches that embed the rates —
|
|
317
|
+
subscribe in `onModuleInit`, which runs before any plugin's bootstrap, so the boot event is not missed.
|
|
318
|
+
Events stay in the process that published them: a scheduled sync publishes in the worker, the boot adoption
|
|
319
|
+
in whichever process adopted the rows. Register the subscriber in both, and keep a cache it must drop
|
|
320
|
+
shared between them (e.g. Redis), or let it expire:
|
|
318
321
|
|
|
319
322
|
```ts
|
|
320
|
-
import {
|
|
323
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
321
324
|
import { EventBus, PluginCommonModule, VendurePlugin } from '@vendure/core';
|
|
322
325
|
import { CurrencyExchangeRateEvent } from '@uplab/vendure-plugin-exchange-rates';
|
|
323
326
|
|
|
324
327
|
@VendurePlugin({ imports: [PluginCommonModule] })
|
|
325
|
-
export class RatesCachePlugin implements
|
|
328
|
+
export class RatesCachePlugin implements OnModuleInit {
|
|
326
329
|
constructor(private readonly eventBus: EventBus) {}
|
|
327
330
|
|
|
328
|
-
|
|
331
|
+
onModuleInit() {
|
|
329
332
|
this.eventBus.ofType(CurrencyExchangeRateEvent).subscribe(() => {
|
|
330
333
|
// drop whatever caches the rates, e.g. a cached Shop API response
|
|
331
334
|
});
|
|
@@ -346,8 +349,9 @@ One table, `currency_exchange_rate`:
|
|
|
346
349
|
| `useCustomRate` | boolean, default `false` |
|
|
347
350
|
| `customRate` | decimal(19, 8), nullable |
|
|
348
351
|
|
|
349
|
-
¹ Nullable so that a generated migration can add it to a filled table
|
|
350
|
-
rows without one the current base, keeping their custom rates
|
|
352
|
+
¹ Nullable so that a generated migration can add it to a filled table. On the next boot (and in every
|
|
353
|
+
sync) the plugin gives rows without one the current base, keeping their custom rates — it assumes they are
|
|
354
|
+
already in that base, so change the base only after the upgrade has booted once.
|
|
351
355
|
|
|
352
356
|
A sync updates `rate` and inserts new currencies, in one transaction; on a [base change](#base-currency) it
|
|
353
357
|
also rewrites `baseCurrency`, clears custom rates and deletes the currencies the new base does not cover.
|
|
@@ -13,4 +13,15 @@ export declare class CurrencyExchangeRateAdminResolver {
|
|
|
13
13
|
}): Promise<CurrencyExchangeRate | null>;
|
|
14
14
|
updateCurrencyExchangeRate(ctx: RequestContext, args: MutationUpdateCurrencyExchangeRateArgs): Promise<CurrencyExchangeRate>;
|
|
15
15
|
}
|
|
16
|
+
export declare class CurrencyExchangeRateAdminFieldResolver {
|
|
17
|
+
private currencyExchangeRateService;
|
|
18
|
+
constructor(currencyExchangeRateService: CurrencyExchangeRateService);
|
|
19
|
+
/**
|
|
20
|
+
* A row from before the `baseCurrency` column is adopted on boot and in every sync; one that is listed
|
|
21
|
+
* before that (e.g. while an older instance still runs a rolling deploy) shows the base it will get,
|
|
22
|
+
* instead of failing the whole non-null list. Filtering and sorting on `baseCurrency` still see the
|
|
23
|
+
* stored value until then.
|
|
24
|
+
*/
|
|
25
|
+
baseCurrency(ctx: RequestContext, row: CurrencyExchangeRate): Promise<import("@vendure/core").CurrencyCode>;
|
|
26
|
+
}
|
|
16
27
|
//# sourceMappingURL=admin.resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.resolver.d.ts","sourceRoot":"","sources":["../../src/api/admin.resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,EAAE,EACF,gBAAgB,EAChB,aAAa,EAEb,cAAc,EAEf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;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BAAoB,GAAG,IAAI,CAAC;IAOhH,0BAA0B,CACjB,GAAG,EAAE,cAAc,EAClB,IAAI,EAAE,sCAAsC,GACnD,OAAO,CAAC,oBAAoB,CAAC;CAGjC;AAED,qBACa,sCAAsC;IACrC,OAAO,CAAC,2BAA2B;gBAA3B,2BAA2B,EAAE,2BAA2B;IAE5E;;;;;OAKG;IAEG,YAAY,CAAQ,GAAG,EAAE,cAAc,EAAY,GAAG,EAAE,oBAAoB;CAGnF"}
|
|
@@ -12,9 +12,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CurrencyExchangeRateAdminResolver = void 0;
|
|
15
|
+
exports.CurrencyExchangeRateAdminFieldResolver = exports.CurrencyExchangeRateAdminResolver = void 0;
|
|
16
16
|
const graphql_1 = require("@nestjs/graphql");
|
|
17
17
|
const core_1 = require("@vendure/core");
|
|
18
|
+
const currency_exchange_rate_entity_1 = require("../entities/currency-exchange-rate.entity");
|
|
18
19
|
const currency_exchange_rate_service_1 = require("../services/currency-exchange-rate.service");
|
|
19
20
|
let CurrencyExchangeRateAdminResolver = class CurrencyExchangeRateAdminResolver {
|
|
20
21
|
constructor(currencyExchangeRateService) {
|
|
@@ -63,4 +64,31 @@ exports.CurrencyExchangeRateAdminResolver = CurrencyExchangeRateAdminResolver =
|
|
|
63
64
|
(0, graphql_1.Resolver)(),
|
|
64
65
|
__metadata("design:paramtypes", [currency_exchange_rate_service_1.CurrencyExchangeRateService])
|
|
65
66
|
], CurrencyExchangeRateAdminResolver);
|
|
67
|
+
let CurrencyExchangeRateAdminFieldResolver = class CurrencyExchangeRateAdminFieldResolver {
|
|
68
|
+
constructor(currencyExchangeRateService) {
|
|
69
|
+
this.currencyExchangeRateService = currencyExchangeRateService;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A row from before the `baseCurrency` column is adopted on boot and in every sync; one that is listed
|
|
73
|
+
* before that (e.g. while an older instance still runs a rolling deploy) shows the base it will get,
|
|
74
|
+
* instead of failing the whole non-null list. Filtering and sorting on `baseCurrency` still see the
|
|
75
|
+
* stored value until then.
|
|
76
|
+
*/
|
|
77
|
+
async baseCurrency(ctx, row) {
|
|
78
|
+
return row.baseCurrency || this.currencyExchangeRateService.getBaseCurrency(ctx);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.CurrencyExchangeRateAdminFieldResolver = CurrencyExchangeRateAdminFieldResolver;
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, graphql_1.ResolveField)(),
|
|
84
|
+
__param(0, (0, core_1.Ctx)()),
|
|
85
|
+
__param(1, (0, graphql_1.Parent)()),
|
|
86
|
+
__metadata("design:type", Function),
|
|
87
|
+
__metadata("design:paramtypes", [core_1.RequestContext, currency_exchange_rate_entity_1.CurrencyExchangeRate]),
|
|
88
|
+
__metadata("design:returntype", Promise)
|
|
89
|
+
], CurrencyExchangeRateAdminFieldResolver.prototype, "baseCurrency", null);
|
|
90
|
+
exports.CurrencyExchangeRateAdminFieldResolver = CurrencyExchangeRateAdminFieldResolver = __decorate([
|
|
91
|
+
(0, graphql_1.Resolver)('CurrencyExchangeRate'),
|
|
92
|
+
__metadata("design:paramtypes", [currency_exchange_rate_service_1.CurrencyExchangeRateService])
|
|
93
|
+
], CurrencyExchangeRateAdminFieldResolver);
|
|
66
94
|
//# sourceMappingURL=admin.resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.resolver.js","sourceRoot":"","sources":["../../src/api/admin.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"admin.resolver.js","sourceRoot":"","sources":["../../src/api/admin.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAwF;AACxF,wCASuB;AACvB,6FAAiF;AACjF,+FAAyF;A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CAAsC,GAA5C,MAAM,sCAAsC;IACjD,YAAoB,2BAAwD;QAAxD,gCAA2B,GAA3B,2BAA2B,CAA6B;IAAG,CAAC;IAEhF;;;;;OAKG;IAEG,AAAN,KAAK,CAAC,YAAY,CAAQ,GAAmB,EAAY,GAAyB;QAChF,OAAO,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC,2BAA2B,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IACnF,CAAC;CACF,CAAA;AAbY,wFAAsC;AAU3C;IADL,IAAA,sBAAY,GAAE;IACK,WAAA,IAAA,UAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,gBAAM,GAAE,CAAA;;qCAAzB,qBAAc,EAAiB,oDAAoB;;0EAEjF;iDAZU,sCAAsC;IADlD,IAAA,kBAAQ,EAAC,sBAAsB,CAAC;qCAEkB,4DAA2B;GADjE,sCAAsC,CAalD"}
|
|
@@ -4,7 +4,8 @@ export declare class CurrencyExchangeRate extends VendureEntity {
|
|
|
4
4
|
code: CurrencyCode;
|
|
5
5
|
/**
|
|
6
6
|
* The currency `rate` and `customRate` are expressed in. Nullable only so that a host's generated
|
|
7
|
-
* migration can add the column to a filled table; the plugin fills it
|
|
7
|
+
* migration can add the column to a filled table; the plugin fills it on bootstrap and in every sync.
|
|
8
|
+
* Code that reads the table itself before the plugin's bootstrap can still see `null` (or `''`).
|
|
8
9
|
*/
|
|
9
10
|
baseCurrency: CurrencyCode;
|
|
10
11
|
enabled: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency-exchange-rate.entity.d.ts","sourceRoot":"","sources":["../../src/entities/currency-exchange-rate.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AASzE,qBACa,oBAAqB,SAAQ,aAAa;gBACzC,KAAK,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC;IAMrD,IAAI,EAAE,YAAY,CAAC;IAEnB
|
|
1
|
+
{"version":3,"file":"currency-exchange-rate.entity.d.ts","sourceRoot":"","sources":["../../src/entities/currency-exchange-rate.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AASzE,qBACa,oBAAqB,SAAQ,aAAa;gBACzC,KAAK,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC;IAMrD,IAAI,EAAE,YAAY,CAAC;IAEnB;;;;OAIG;IAEH,YAAY,EAAE,YAAY,CAAC;IAG3B,OAAO,EAAE,OAAO,CAAC;IAEjB,kFAAkF;IAElF,IAAI,EAAE,MAAM,CAAC;IAGb,aAAa,EAAE,OAAO,CAAC;IAGvB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency-exchange-rate.entity.js","sourceRoot":"","sources":["../../src/entities/currency-exchange-rate.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAyE;AACzE,qCAAkE;AAElE,yFAAyF;AACzF,MAAM,eAAe,GAAqB;IACxC,EAAE,EAAE,CAAC,KAAgC,EAAE,EAAE,CAAC,KAAK;IAC/C,IAAI,EAAE,CAAC,KAA6B,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;CACjF,CAAC;AAGK,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,oBAAa;IACrD,YAAY,KAAyC;QACnD,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;
|
|
1
|
+
{"version":3,"file":"currency-exchange-rate.entity.js","sourceRoot":"","sources":["../../src/entities/currency-exchange-rate.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAyE;AACzE,qCAAkE;AAElE,yFAAyF;AACzF,MAAM,eAAe,GAAqB;IACx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plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"exchange-rates.plugin.d.ts","sourceRoot":"","sources":["../src/exchange-rates.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAKL,cAAc,EAEd,qBAAqB,EACrB,IAAI,EAEL,MAAM,eAAe,CAAC;AAOvB,OAAO,EAAE,+BAA+B,EAAE,MAAM,gDAAgD,CAAC;AAEjG,OAAO,EAAE,0BAA0B,EAAE,kCAAkC,EAAE,MAAM,SAAS,CAAC;AAgBzF;;;;;GAKG;AACH,qBA+Ba,mBAAoB,YAAW,sBAAsB,EAAE,qBAAqB;IAKrF,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAP9B,gBAAgB;IAChB,MAAM,CAAC,OAAO,EAAE,kCAAkC,CAAC;gBAGhC,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,qBAAqB,EAAE,qBAAqB,EAC5C,WAAW,EAAE,+BAA+B;IAG/D,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAAC,mBAAmB,CAAC;IAMrE,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBvC,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7C"}
|
|
@@ -55,8 +55,20 @@ let ExchangeRatesPlugin = class ExchangeRatesPlugin {
|
|
|
55
55
|
// Source first: the backfill needs it.
|
|
56
56
|
async onApplicationBootstrap() {
|
|
57
57
|
await ExchangeRatesPlugin_1.options.source.init?.(new core_2.Injector(this.moduleRef));
|
|
58
|
+
let ctx;
|
|
59
|
+
try {
|
|
60
|
+
ctx = await this.requestContextService.create({ apiType: 'admin' });
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
core_2.Logger.warn(`Could not check the stored exchange rates: ${e.message}`, constants_1.loggerCtx);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
58
66
|
if (this.processContext.isServer) {
|
|
59
|
-
await this.syncService.backfillIfEmpty(
|
|
67
|
+
await this.syncService.backfillIfEmpty(ctx);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// The worker converts too (feeds, jobs): it must not depend on the server having booted first.
|
|
71
|
+
await this.syncService.adoptRowsWithoutBase(ctx);
|
|
60
72
|
}
|
|
61
73
|
}
|
|
62
74
|
async onApplicationShutdown() {
|
|
@@ -72,7 +84,10 @@ exports.ExchangeRatesPlugin = ExchangeRatesPlugin = ExchangeRatesPlugin_1 = __de
|
|
|
72
84
|
resolvers: [shop_resolver_1.CurrencyExchangeRateShopResolver, shop_resolver_1.CurrencyExchangeRateShopFieldResolver],
|
|
73
85
|
schema: api_extensions_1.shopApiExtensions,
|
|
74
86
|
},
|
|
75
|
-
adminApiExtensions: {
|
|
87
|
+
adminApiExtensions: {
|
|
88
|
+
resolvers: [admin_resolver_1.CurrencyExchangeRateAdminResolver, admin_resolver_1.CurrencyExchangeRateAdminFieldResolver],
|
|
89
|
+
schema: api_extensions_1.adminApiExtensions,
|
|
90
|
+
},
|
|
76
91
|
// Resolved relative to the compiled plugin file; the sources are copied to `dist/dashboard/`.
|
|
77
92
|
dashboard: './dashboard/index.tsx',
|
|
78
93
|
providers: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange-rates.plugin.js","sourceRoot":"","sources":["../src/exchange-rates.plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,u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AC;YACtF,MAAM,EAAE,mCAAkB;SAC3B;QACD,8FAA8F;QAC9F,SAAS,EAAE,uBAAuB;QAClC,SAAS,EAAE;YACT,EAAE,OAAO,EAAE,yCAA6B,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,OAAO,EAAE;YACzF,4DAA2B;YAC3B,qEAA+B;SAChC;QACD,OAAO,EAAE,CAAC,4DAA2B,EAAE,qEAA+B,CAAC;QACvE,aAAa,EAAE,QAAQ;QACvB,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE;YACxB,MAAM,EAAE,IAAI,EAAE,GAAG,mBAAmB,CAAC,OAAO,CAAC;YAC7C,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,CAAC,gBAAgB,CAAC,KAAK,GAAG;oBAC9B,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC;oBACxC,IAAA,oDAA0B,EAAC,IAAI,CAAC,QAAQ,CAAC;iBAC1C,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;qCAM8B,gBAAS;QACJ,qBAAc;QACP,4BAAqB;QAC/B,qEAA+B;GARpD,mBAAmB,CAqC/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventBus, RequestContext, TransactionalConnection } from '@vendure/core';
|
|
1
|
+
import { CurrencyCode, EventBus, RequestContext, TransactionalConnection } from '@vendure/core';
|
|
2
2
|
import { CurrencyExchangeRateService } from './currency-exchange-rate.service';
|
|
3
3
|
import { CurrencyExchangeRate } from '../entities/currency-exchange-rate.entity';
|
|
4
4
|
import { ResolvedExchangeRatesPluginOptions } from '../types';
|
|
@@ -22,9 +22,18 @@ export declare class CurrencyExchangeRateSyncService {
|
|
|
22
22
|
*/
|
|
23
23
|
syncRates(ctx: RequestContext): Promise<CurrencyExchangeRate[]>;
|
|
24
24
|
/**
|
|
25
|
-
* Gives rows from before the `baseCurrency` column the current base,
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
* Gives rows from before the `baseCurrency` column the current base, and announces them: they only now
|
|
26
|
+
* show on the Shop API and in `getRate`. Run on bootstrap in every process, so neither depends on the
|
|
27
|
+
* other having booted first. Returns the base, or `undefined` when the database could not be read; never
|
|
28
|
+
* throws.
|
|
29
|
+
*
|
|
30
|
+
* @internal the plugin runs it on bootstrap; there is no need to call it.
|
|
31
|
+
*/
|
|
32
|
+
adoptRowsWithoutBase(ctx: RequestContext): Promise<CurrencyCode | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* {@link CurrencyExchangeRateSyncService.adoptRowsWithoutBase}, then syncs when no rate is stored in the
|
|
35
|
+
* current base: on the first boot, and after a restart that changed the base. Never throws: neither a
|
|
36
|
+
* source outage nor a database hiccup may stop the server.
|
|
28
37
|
*/
|
|
29
38
|
backfillIfEmpty(ctx: RequestContext): Promise<void>;
|
|
30
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency-exchange-rate-sync.service.d.ts","sourceRoot":"","sources":["../../src/services/currency-exchange-rate-sync.service.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"currency-exchange-rate-sync.service.d.ts","sourceRoot":"","sources":["../../src/services/currency-exchange-rate-sync.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAU,cAAc,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExG,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAG/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAqB,kCAAkC,EAAE,MAAM,UAAU,CAAC;AAgCjF;;;;;;GAMG;AACH,qBACa,+BAA+B;IAED,OAAO,CAAC,QAAQ,CAAC,OAAO;IAC/D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAH4B,OAAO,EAAE,kCAAkC,EAClF,UAAU,EAAE,uBAAuB,EACnC,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,2BAA2B;IAG3D;;;;OAIG;IACG,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAqErE;;;;;;;OAOG;IACG,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAelF;;;;OAIG;IACG,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB1D"}
|
|
@@ -31,13 +31,18 @@ function lastPerCode(quotes) {
|
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* A row without a base predates the `baseCurrency` column. Its rates are in the base the shop used then,
|
|
34
|
-
* taken to be the current one, so it keeps its custom rate.
|
|
34
|
+
* taken to be the current one, so it keeps its custom rate. "Without" is NULL, or `''` where MySQL filled
|
|
35
|
+
* a NOT NULL column added to a filled table. Returns how many rows it adopted.
|
|
35
36
|
*/
|
|
36
|
-
async function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
async function fillMissingBase(repository, baseCurrency) {
|
|
38
|
+
let adopted = 0;
|
|
39
|
+
for (const missing of [(0, typeorm_1.IsNull)(), '']) {
|
|
40
|
+
adopted += (await repository.update({ baseCurrency: missing }, { baseCurrency })).affected ?? 0;
|
|
40
41
|
}
|
|
42
|
+
if (adopted) {
|
|
43
|
+
core_1.Logger.info(`Took ${adopted} stored rates without a base currency to be in ${baseCurrency}`, constants_1.loggerCtx);
|
|
44
|
+
}
|
|
45
|
+
return adopted;
|
|
41
46
|
}
|
|
42
47
|
/**
|
|
43
48
|
* @description
|
|
@@ -74,7 +79,7 @@ let CurrencyExchangeRateSyncService = class CurrencyExchangeRateSyncService {
|
|
|
74
79
|
// One transaction: a failure part-way leaves every rate as it was, not half of them refreshed.
|
|
75
80
|
const { rows, changed } = await this.connection.withTransaction(ctx, async (txCtx) => {
|
|
76
81
|
const repository = this.connection.getRepository(txCtx, currency_exchange_rate_entity_1.CurrencyExchangeRate);
|
|
77
|
-
await
|
|
82
|
+
const adopted = await fillMissingBase(repository, baseCurrency);
|
|
78
83
|
const stored = await repository.find();
|
|
79
84
|
const storedByCode = new Map(stored.map((r) => [r.code, r]));
|
|
80
85
|
const rebased = [];
|
|
@@ -117,7 +122,7 @@ let CurrencyExchangeRateSyncService = class CurrencyExchangeRateSyncService {
|
|
|
117
122
|
return {
|
|
118
123
|
// Read back, so `updatedAt` and the rest are what the database now holds.
|
|
119
124
|
rows: await repository.find({ where: { baseCurrency }, order: { code: 'ASC' } }),
|
|
120
|
-
changed: created.length > 0 || updated > 0 || deleted,
|
|
125
|
+
changed: adopted > 0 || created.length > 0 || updated > 0 || deleted,
|
|
121
126
|
};
|
|
122
127
|
});
|
|
123
128
|
core_1.Logger.verbose(`Synced ${rows.length} rates in ${baseCurrency} from ${source.name} (base ${base})`, constants_1.loggerCtx);
|
|
@@ -127,23 +132,42 @@ let CurrencyExchangeRateSyncService = class CurrencyExchangeRateSyncService {
|
|
|
127
132
|
return rows;
|
|
128
133
|
}
|
|
129
134
|
/**
|
|
130
|
-
* Gives rows from before the `baseCurrency` column the current base,
|
|
131
|
-
*
|
|
132
|
-
*
|
|
135
|
+
* Gives rows from before the `baseCurrency` column the current base, and announces them: they only now
|
|
136
|
+
* show on the Shop API and in `getRate`. Run on bootstrap in every process, so neither depends on the
|
|
137
|
+
* other having booted first. Returns the base, or `undefined` when the database could not be read; never
|
|
138
|
+
* throws.
|
|
139
|
+
*
|
|
140
|
+
* @internal the plugin runs it on bootstrap; there is no need to call it.
|
|
133
141
|
*/
|
|
134
|
-
async
|
|
135
|
-
const baseCurrency = await this.rateService.getBaseCurrency(ctx);
|
|
136
|
-
const repository = this.connection.getRepository(ctx, currency_exchange_rate_entity_1.CurrencyExchangeRate);
|
|
142
|
+
async adoptRowsWithoutBase(ctx) {
|
|
137
143
|
try {
|
|
138
|
-
await
|
|
144
|
+
const baseCurrency = await this.rateService.getBaseCurrency(ctx);
|
|
145
|
+
const repository = this.connection.getRepository(ctx, currency_exchange_rate_entity_1.CurrencyExchangeRate);
|
|
146
|
+
if (await fillMissingBase(repository, baseCurrency)) {
|
|
147
|
+
const rows = await repository.find({ where: { baseCurrency }, order: { code: 'ASC' } });
|
|
148
|
+
await this.eventBus.publish(new currency_exchange_rate_event_1.CurrencyExchangeRateEvent(ctx, rows, 'synced'));
|
|
149
|
+
}
|
|
150
|
+
return baseCurrency;
|
|
139
151
|
}
|
|
140
152
|
catch (e) {
|
|
141
|
-
core_1.Logger.warn(`Could not
|
|
153
|
+
core_1.Logger.warn(`Could not check the stored exchange rates: ${e.message}`, constants_1.loggerCtx);
|
|
154
|
+
return undefined;
|
|
142
155
|
}
|
|
143
|
-
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* {@link CurrencyExchangeRateSyncService.adoptRowsWithoutBase}, then syncs when no rate is stored in the
|
|
159
|
+
* current base: on the first boot, and after a restart that changed the base. Never throws: neither a
|
|
160
|
+
* source outage nor a database hiccup may stop the server.
|
|
161
|
+
*/
|
|
162
|
+
async backfillIfEmpty(ctx) {
|
|
163
|
+
const baseCurrency = await this.adoptRowsWithoutBase(ctx);
|
|
164
|
+
if (!baseCurrency) {
|
|
144
165
|
return;
|
|
145
166
|
}
|
|
146
167
|
try {
|
|
168
|
+
if ((await this.connection.getRepository(ctx, currency_exchange_rate_entity_1.CurrencyExchangeRate).count({ where: { baseCurrency } })) > 0) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
147
171
|
const persisted = await this.syncRates(ctx);
|
|
148
172
|
core_1.Logger.info(`Loaded ${persisted.length} exchange rates from ${this.options.source.name}`, constants_1.loggerCtx);
|
|
149
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency-exchange-rate-sync.service.js","sourceRoot":"","sources":["../../src/services/currency-exchange-rate-sync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,wCAAwG;AACxG,qCAAkD;AAClD,qFAA+E;AAC/E,4CAAwE;AACxE,kDAA8C;AAC9C,6FAAiF;AACjF,yFAAmF;AAGnF,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,mBAAY,CAAC,CAAC,CAAC;AAE1E,SAAS,QAAQ,CAAC,KAAwB;IACxC,OAAO,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;AACvG,CAAC;AAED,yFAAyF;AACzF,SAAS,WAAW,CAAC,MAA2B;IAC9C,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"currency-exchange-rate-sync.service.js","sourceRoot":"","sources":["../../src/services/currency-exchange-rate-sync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,wCAAwG;AACxG,qCAAkD;AAClD,qFAA+E;AAC/E,4CAAwE;AACxE,kDAA8C;AAC9C,6FAAiF;AACjF,yFAAmF;AAGnF,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,mBAAY,CAAC,CAAC,CAAC;AAE1E,SAAS,QAAQ,CAAC,KAAwB;IACxC,OAAO,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,MAAM,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|
4
4
|
"description": "Exchange rates for Vendure in any base currency, from the ECB, Frankfurter, Monobank, the NBU or your own source, overridable per currency in the dashboard",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Uplab",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"files": [
|
|
41
41
|
"dist",
|
|
42
42
|
"README.md",
|
|
43
|
-
"CHANGELOG.md"
|
|
43
|
+
"CHANGELOG.md",
|
|
44
|
+
"LICENSE"
|
|
44
45
|
],
|
|
45
46
|
"scripts": {
|
|
46
47
|
"build": "rimraf dist && tsc -p tsconfig.build.json && node ../../scripts/copy-dashboard.mjs",
|
|
@@ -74,20 +75,26 @@
|
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
77
|
"@lingui/react": "^5.9.5",
|
|
77
|
-
"@nestjs/common": "^11.
|
|
78
|
+
"@nestjs/common": "^11.2.1",
|
|
78
79
|
"@nestjs/core": "^11.2.1",
|
|
79
|
-
"@nestjs/graphql": "^13.
|
|
80
|
-
"@
|
|
80
|
+
"@nestjs/graphql": "^13.1.0",
|
|
81
|
+
"@testing-library/dom": "^10.4.2",
|
|
82
|
+
"@testing-library/react": "^16.3.3",
|
|
83
|
+
"@types/react": "19.3.0",
|
|
84
|
+
"@types/react-dom": "19.2.4",
|
|
81
85
|
"@vendure/core": "3.7.2",
|
|
82
86
|
"@vendure/dashboard": "3.7.2",
|
|
83
87
|
"@vendure/testing": "3.7.2",
|
|
84
88
|
"graphql": "^16.11.0",
|
|
85
|
-
"
|
|
89
|
+
"jsdom": "^26.1.0",
|
|
90
|
+
"react": "^19.3.0",
|
|
91
|
+
"react-dom": "^19.3.0",
|
|
92
|
+
"react-hook-form": "^7.86.0",
|
|
86
93
|
"rimraf": "^6.0.1",
|
|
87
94
|
"rxjs": "^7.8.1",
|
|
88
95
|
"typeorm": "^0.3.21",
|
|
89
96
|
"typescript": "^5.8.3",
|
|
90
|
-
"unplugin-swc": "^1.
|
|
97
|
+
"unplugin-swc": "^1.6.0",
|
|
91
98
|
"vitest": "^4.0.0"
|
|
92
99
|
},
|
|
93
100
|
"engines": {
|