@enfuce/nextgen-sdk 0.0.4 → 0.0.6

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.
Files changed (112) hide show
  1. package/README.md +28 -3
  2. package/dist/authorisation-control/client.d.ts +47 -0
  3. package/dist/authorisation-control/client.js +80 -0
  4. package/dist/authorisation-control/index.d.ts +1 -0
  5. package/dist/authorisation-control/index.js +1 -0
  6. package/dist/card/client.d.ts +57 -0
  7. package/dist/card/client.js +100 -0
  8. package/dist/card/index.d.ts +1 -0
  9. package/dist/card/index.js +1 -0
  10. package/dist/cardholder/client.d.ts +53 -0
  11. package/dist/cardholder/client.js +92 -0
  12. package/dist/cardholder/index.d.ts +1 -0
  13. package/dist/cardholder/index.js +1 -0
  14. package/dist/cards/client.d.ts +47 -0
  15. package/dist/cards/client.js +80 -0
  16. package/dist/cards/index.d.ts +1 -0
  17. package/dist/cards/index.js +1 -0
  18. package/dist/esm/authorisation-control/client.d.ts +47 -0
  19. package/dist/esm/authorisation-control/client.js +75 -0
  20. package/dist/esm/authorisation-control/index.d.ts +1 -0
  21. package/dist/esm/authorisation-control/index.js +1 -0
  22. package/dist/esm/card/client.d.ts +57 -0
  23. package/dist/esm/card/client.js +95 -0
  24. package/dist/esm/card/index.d.ts +1 -0
  25. package/dist/esm/card/index.js +1 -0
  26. package/dist/esm/cardholder/client.d.ts +53 -0
  27. package/dist/esm/cardholder/client.js +87 -0
  28. package/dist/esm/cardholder/index.d.ts +1 -0
  29. package/dist/esm/cardholder/index.js +1 -0
  30. package/dist/esm/cards/client.d.ts +47 -0
  31. package/dist/esm/cards/client.js +75 -0
  32. package/dist/esm/cards/index.d.ts +1 -0
  33. package/dist/esm/cards/index.js +1 -0
  34. package/dist/esm/exchange-rate/client.d.ts +51 -0
  35. package/dist/esm/exchange-rate/client.js +83 -0
  36. package/dist/esm/exchange-rate/index.d.ts +1 -0
  37. package/dist/esm/exchange-rate/index.js +1 -0
  38. package/dist/esm/issuer-events/client.d.ts +47 -0
  39. package/dist/esm/issuer-events/client.js +75 -0
  40. package/dist/esm/issuer-events/index.d.ts +1 -0
  41. package/dist/esm/issuer-events/index.js +1 -0
  42. package/dist/esm/oauth/axios.d.ts +10 -4
  43. package/dist/esm/oauth/axios.js +15 -4
  44. package/dist/esm/oauth/index.js +5 -2
  45. package/dist/esm/pin/client.d.ts +49 -0
  46. package/dist/esm/pin/client.js +79 -0
  47. package/dist/esm/pin/index.d.ts +1 -0
  48. package/dist/esm/pin/index.js +1 -0
  49. package/dist/esm/threeds/client.d.ts +47 -0
  50. package/dist/esm/threeds/client.js +75 -0
  51. package/dist/esm/threeds/index.d.ts +1 -0
  52. package/dist/esm/threeds/index.js +1 -0
  53. package/dist/esm/threeds-oob/client.d.ts +47 -0
  54. package/dist/esm/threeds-oob/client.js +75 -0
  55. package/dist/esm/threeds-oob/index.d.ts +1 -0
  56. package/dist/esm/threeds-oob/index.js +1 -0
  57. package/dist/esm/wallet/client.d.ts +61 -0
  58. package/dist/esm/wallet/client.js +103 -0
  59. package/dist/esm/wallet/index.d.ts +1 -0
  60. package/dist/esm/wallet/index.js +1 -0
  61. package/dist/exchange-rate/client.d.ts +51 -0
  62. package/dist/exchange-rate/client.js +88 -0
  63. package/dist/exchange-rate/index.d.ts +1 -0
  64. package/dist/exchange-rate/index.js +1 -0
  65. package/dist/issuer-events/client.d.ts +47 -0
  66. package/dist/issuer-events/client.js +80 -0
  67. package/dist/issuer-events/index.d.ts +1 -0
  68. package/dist/issuer-events/index.js +1 -0
  69. package/dist/oauth/axios.d.ts +10 -4
  70. package/dist/oauth/axios.js +15 -4
  71. package/dist/oauth/index.js +5 -2
  72. package/dist/pin/client.d.ts +49 -0
  73. package/dist/pin/client.js +84 -0
  74. package/dist/pin/index.d.ts +1 -0
  75. package/dist/pin/index.js +1 -0
  76. package/dist/threeds/client.d.ts +47 -0
  77. package/dist/threeds/client.js +80 -0
  78. package/dist/threeds/index.d.ts +1 -0
  79. package/dist/threeds/index.js +1 -0
  80. package/dist/threeds-oob/client.d.ts +47 -0
  81. package/dist/threeds-oob/client.js +80 -0
  82. package/dist/threeds-oob/index.d.ts +1 -0
  83. package/dist/threeds-oob/index.js +1 -0
  84. package/dist/wallet/client.d.ts +61 -0
  85. package/dist/wallet/client.js +108 -0
  86. package/dist/wallet/index.d.ts +1 -0
  87. package/dist/wallet/index.js +1 -0
  88. package/package.json +1 -1
  89. package/src/authorisation-control/client.ts +86 -0
  90. package/src/authorisation-control/index.ts +2 -0
  91. package/src/card/client.ts +116 -0
  92. package/src/card/index.ts +2 -0
  93. package/src/cardholder/client.ts +104 -0
  94. package/src/cardholder/index.ts +2 -0
  95. package/src/cards/client.ts +86 -0
  96. package/src/cards/index.ts +2 -0
  97. package/src/exchange-rate/client.ts +98 -0
  98. package/src/exchange-rate/index.ts +2 -0
  99. package/src/issuer-events/client.ts +86 -0
  100. package/src/issuer-events/index.ts +2 -0
  101. package/src/oauth/axios.ts +16 -4
  102. package/src/oauth/index.ts +5 -2
  103. package/src/pin/client.ts +92 -0
  104. package/src/pin/index.ts +2 -0
  105. package/src/threeds/client.ts +86 -0
  106. package/src/threeds/index.ts +2 -0
  107. package/src/threeds-oob/client.ts +86 -0
  108. package/src/threeds-oob/index.ts +2 -0
  109. package/src/wallet/client.ts +128 -0
  110. package/src/wallet/index.ts +2 -0
  111. package/test/exchange-rate-client.test.ts +36 -0
  112. package/test/oauth.test.ts +19 -0
@@ -0,0 +1,86 @@
1
+ /*
2
+ * Enfuce nextgen SDK — fluent module client.
3
+ *
4
+ * GENERATED by scripts/generate.sh from a custom template (generator-templates/typescript). One per
5
+ * API module: wires an OAuth-enabled axios instance (bearer token on every request + reactive 401
6
+ * retry) to the module's Configuration and exposes each API. Nothing is shared across modules.
7
+ */
8
+ import globalAxios, { type AxiosInstance } from 'axios';
9
+ import { createOAuthAxios, type TokenManager } from '../oauth';
10
+ import { Configuration } from './configuration';
11
+ import {
12
+ AuthorisationRequestAPIApi,
13
+ } from './api';
14
+
15
+ /**
16
+ * Fluent entry point for this module. Build one with {@link AuthorisationControlClient.builder}:
17
+ *
18
+ * ```ts
19
+ * const client = AuthorisationControlClient.builder()
20
+ * .baseUrl('https://api.example.com/...')
21
+ * .oauth(tokens)
22
+ * .build();
23
+ * ```
24
+ */
25
+ export class AuthorisationControlClient {
26
+
27
+ constructor(
28
+ /** The axios instance — OAuth interceptors and any customizations already applied. */
29
+ readonly http: AxiosInstance,
30
+ /** The module configuration — base path applied. */
31
+ readonly configuration: Configuration,
32
+ ) {}
33
+
34
+ /** Build any API in this module bound to this client (for APIs without a named getter). */
35
+ api<T>(factory: (configuration: Configuration, http: AxiosInstance) => T): T {
36
+ return factory(this.configuration, this.http);
37
+ }
38
+
39
+ /** {@link AuthorisationRequestAPIApi} bound to this client. */
40
+ authorisationRequestAPIApi(): AuthorisationRequestAPIApi {
41
+ return new AuthorisationRequestAPIApi(this.configuration, undefined, this.http);
42
+ }
43
+
44
+ static builder(): AuthorisationControlClientBuilder {
45
+ return new AuthorisationControlClientBuilder();
46
+ }
47
+ }
48
+
49
+ /** Builds a {@link AuthorisationControlClient}: base URL + optional OAuth + transport customization. */
50
+ export class AuthorisationControlClientBuilder {
51
+
52
+ private _baseUrl?: string;
53
+ private _tokens?: TokenManager;
54
+ private _customizers: Array<(http: AxiosInstance) => void> = [];
55
+
56
+ /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
57
+ baseUrl(baseUrl: string): this {
58
+ this._baseUrl = baseUrl;
59
+ return this;
60
+ }
61
+
62
+ /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
63
+ oauth(tokens: TokenManager): this {
64
+ this._tokens = tokens;
65
+ return this;
66
+ }
67
+
68
+ /**
69
+ * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
70
+ * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
71
+ * calls run in order.
72
+ */
73
+ configure(customizer: (http: AxiosInstance) => void): this {
74
+ this._customizers.push(customizer);
75
+ return this;
76
+ }
77
+
78
+ build(): AuthorisationControlClient {
79
+ const http = this._tokens ? createOAuthAxios(this._tokens) : globalAxios.create();
80
+ for (const customizer of this._customizers) {
81
+ customizer(http);
82
+ }
83
+ const configuration = new Configuration({ basePath: this._baseUrl });
84
+ return new AuthorisationControlClient(http, configuration);
85
+ }
86
+ }
@@ -16,3 +16,5 @@
16
16
  export * from "./api";
17
17
  export * from "./configuration";
18
18
 
19
+
20
+ export * from './client';
@@ -0,0 +1,116 @@
1
+ /*
2
+ * Enfuce nextgen SDK — fluent module client.
3
+ *
4
+ * GENERATED by scripts/generate.sh from a custom template (generator-templates/typescript). One per
5
+ * API module: wires an OAuth-enabled axios instance (bearer token on every request + reactive 401
6
+ * retry) to the module's Configuration and exposes each API. Nothing is shared across modules.
7
+ */
8
+ import globalAxios, { type AxiosInstance } from 'axios';
9
+ import { createOAuthAxios, type TokenManager } from '../oauth';
10
+ import { Configuration } from './configuration';
11
+ import {
12
+ CreateCardApi,
13
+ CreatePINControlAccessTokenApi,
14
+ GetCardApi,
15
+ GetCardPaymentInfoApi,
16
+ GetPlasticManufacturingHistoryApi,
17
+ UpdateCardApi,
18
+ } from './api';
19
+
20
+ /**
21
+ * Fluent entry point for this module. Build one with {@link CardClient.builder}:
22
+ *
23
+ * ```ts
24
+ * const client = CardClient.builder()
25
+ * .baseUrl('https://api.example.com/...')
26
+ * .oauth(tokens)
27
+ * .build();
28
+ * ```
29
+ */
30
+ export class CardClient {
31
+
32
+ constructor(
33
+ /** The axios instance — OAuth interceptors and any customizations already applied. */
34
+ readonly http: AxiosInstance,
35
+ /** The module configuration — base path applied. */
36
+ readonly configuration: Configuration,
37
+ ) {}
38
+
39
+ /** Build any API in this module bound to this client (for APIs without a named getter). */
40
+ api<T>(factory: (configuration: Configuration, http: AxiosInstance) => T): T {
41
+ return factory(this.configuration, this.http);
42
+ }
43
+
44
+ /** {@link CreateCardApi} bound to this client. */
45
+ createCardApi(): CreateCardApi {
46
+ return new CreateCardApi(this.configuration, undefined, this.http);
47
+ }
48
+
49
+ /** {@link CreatePINControlAccessTokenApi} bound to this client. */
50
+ createPINControlAccessTokenApi(): CreatePINControlAccessTokenApi {
51
+ return new CreatePINControlAccessTokenApi(this.configuration, undefined, this.http);
52
+ }
53
+
54
+ /** {@link GetCardApi} bound to this client. */
55
+ getCardApi(): GetCardApi {
56
+ return new GetCardApi(this.configuration, undefined, this.http);
57
+ }
58
+
59
+ /** {@link GetCardPaymentInfoApi} bound to this client. */
60
+ getCardPaymentInfoApi(): GetCardPaymentInfoApi {
61
+ return new GetCardPaymentInfoApi(this.configuration, undefined, this.http);
62
+ }
63
+
64
+ /** {@link GetPlasticManufacturingHistoryApi} bound to this client. */
65
+ getPlasticManufacturingHistoryApi(): GetPlasticManufacturingHistoryApi {
66
+ return new GetPlasticManufacturingHistoryApi(this.configuration, undefined, this.http);
67
+ }
68
+
69
+ /** {@link UpdateCardApi} bound to this client. */
70
+ updateCardApi(): UpdateCardApi {
71
+ return new UpdateCardApi(this.configuration, undefined, this.http);
72
+ }
73
+
74
+ static builder(): CardClientBuilder {
75
+ return new CardClientBuilder();
76
+ }
77
+ }
78
+
79
+ /** Builds a {@link CardClient}: base URL + optional OAuth + transport customization. */
80
+ export class CardClientBuilder {
81
+
82
+ private _baseUrl?: string;
83
+ private _tokens?: TokenManager;
84
+ private _customizers: Array<(http: AxiosInstance) => void> = [];
85
+
86
+ /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
87
+ baseUrl(baseUrl: string): this {
88
+ this._baseUrl = baseUrl;
89
+ return this;
90
+ }
91
+
92
+ /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
93
+ oauth(tokens: TokenManager): this {
94
+ this._tokens = tokens;
95
+ return this;
96
+ }
97
+
98
+ /**
99
+ * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
100
+ * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
101
+ * calls run in order.
102
+ */
103
+ configure(customizer: (http: AxiosInstance) => void): this {
104
+ this._customizers.push(customizer);
105
+ return this;
106
+ }
107
+
108
+ build(): CardClient {
109
+ const http = this._tokens ? createOAuthAxios(this._tokens) : globalAxios.create();
110
+ for (const customizer of this._customizers) {
111
+ customizer(http);
112
+ }
113
+ const configuration = new Configuration({ basePath: this._baseUrl });
114
+ return new CardClient(http, configuration);
115
+ }
116
+ }
package/src/card/index.ts CHANGED
@@ -16,3 +16,5 @@
16
16
  export * from "./api";
17
17
  export * from "./configuration";
18
18
 
19
+
20
+ export * from './client';
@@ -0,0 +1,104 @@
1
+ /*
2
+ * Enfuce nextgen SDK — fluent module client.
3
+ *
4
+ * GENERATED by scripts/generate.sh from a custom template (generator-templates/typescript). One per
5
+ * API module: wires an OAuth-enabled axios instance (bearer token on every request + reactive 401
6
+ * retry) to the module's Configuration and exposes each API. Nothing is shared across modules.
7
+ */
8
+ import globalAxios, { type AxiosInstance } from 'axios';
9
+ import { createOAuthAxios, type TokenManager } from '../oauth';
10
+ import { Configuration } from './configuration';
11
+ import {
12
+ CreateCardholderApi,
13
+ GetCardholderApi,
14
+ GetCardsByCardholderIdApi,
15
+ UpdateCardholderApi,
16
+ } from './api';
17
+
18
+ /**
19
+ * Fluent entry point for this module. Build one with {@link CardholderClient.builder}:
20
+ *
21
+ * ```ts
22
+ * const client = CardholderClient.builder()
23
+ * .baseUrl('https://api.example.com/...')
24
+ * .oauth(tokens)
25
+ * .build();
26
+ * ```
27
+ */
28
+ export class CardholderClient {
29
+
30
+ constructor(
31
+ /** The axios instance — OAuth interceptors and any customizations already applied. */
32
+ readonly http: AxiosInstance,
33
+ /** The module configuration — base path applied. */
34
+ readonly configuration: Configuration,
35
+ ) {}
36
+
37
+ /** Build any API in this module bound to this client (for APIs without a named getter). */
38
+ api<T>(factory: (configuration: Configuration, http: AxiosInstance) => T): T {
39
+ return factory(this.configuration, this.http);
40
+ }
41
+
42
+ /** {@link CreateCardholderApi} bound to this client. */
43
+ createCardholderApi(): CreateCardholderApi {
44
+ return new CreateCardholderApi(this.configuration, undefined, this.http);
45
+ }
46
+
47
+ /** {@link GetCardholderApi} bound to this client. */
48
+ getCardholderApi(): GetCardholderApi {
49
+ return new GetCardholderApi(this.configuration, undefined, this.http);
50
+ }
51
+
52
+ /** {@link GetCardsByCardholderIdApi} bound to this client. */
53
+ getCardsByCardholderIdApi(): GetCardsByCardholderIdApi {
54
+ return new GetCardsByCardholderIdApi(this.configuration, undefined, this.http);
55
+ }
56
+
57
+ /** {@link UpdateCardholderApi} bound to this client. */
58
+ updateCardholderApi(): UpdateCardholderApi {
59
+ return new UpdateCardholderApi(this.configuration, undefined, this.http);
60
+ }
61
+
62
+ static builder(): CardholderClientBuilder {
63
+ return new CardholderClientBuilder();
64
+ }
65
+ }
66
+
67
+ /** Builds a {@link CardholderClient}: base URL + optional OAuth + transport customization. */
68
+ export class CardholderClientBuilder {
69
+
70
+ private _baseUrl?: string;
71
+ private _tokens?: TokenManager;
72
+ private _customizers: Array<(http: AxiosInstance) => void> = [];
73
+
74
+ /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
75
+ baseUrl(baseUrl: string): this {
76
+ this._baseUrl = baseUrl;
77
+ return this;
78
+ }
79
+
80
+ /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
81
+ oauth(tokens: TokenManager): this {
82
+ this._tokens = tokens;
83
+ return this;
84
+ }
85
+
86
+ /**
87
+ * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
88
+ * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
89
+ * calls run in order.
90
+ */
91
+ configure(customizer: (http: AxiosInstance) => void): this {
92
+ this._customizers.push(customizer);
93
+ return this;
94
+ }
95
+
96
+ build(): CardholderClient {
97
+ const http = this._tokens ? createOAuthAxios(this._tokens) : globalAxios.create();
98
+ for (const customizer of this._customizers) {
99
+ customizer(http);
100
+ }
101
+ const configuration = new Configuration({ basePath: this._baseUrl });
102
+ return new CardholderClient(http, configuration);
103
+ }
104
+ }
@@ -16,3 +16,5 @@
16
16
  export * from "./api";
17
17
  export * from "./configuration";
18
18
 
19
+
20
+ export * from './client';
@@ -0,0 +1,86 @@
1
+ /*
2
+ * Enfuce nextgen SDK — fluent module client.
3
+ *
4
+ * GENERATED by scripts/generate.sh from a custom template (generator-templates/typescript). One per
5
+ * API module: wires an OAuth-enabled axios instance (bearer token on every request + reactive 401
6
+ * retry) to the module's Configuration and exposes each API. Nothing is shared across modules.
7
+ */
8
+ import globalAxios, { type AxiosInstance } from 'axios';
9
+ import { createOAuthAxios, type TokenManager } from '../oauth';
10
+ import { Configuration } from './configuration';
11
+ import {
12
+ CardsApi,
13
+ } from './api';
14
+
15
+ /**
16
+ * Fluent entry point for this module. Build one with {@link CardsClient.builder}:
17
+ *
18
+ * ```ts
19
+ * const client = CardsClient.builder()
20
+ * .baseUrl('https://api.example.com/...')
21
+ * .oauth(tokens)
22
+ * .build();
23
+ * ```
24
+ */
25
+ export class CardsClient {
26
+
27
+ constructor(
28
+ /** The axios instance — OAuth interceptors and any customizations already applied. */
29
+ readonly http: AxiosInstance,
30
+ /** The module configuration — base path applied. */
31
+ readonly configuration: Configuration,
32
+ ) {}
33
+
34
+ /** Build any API in this module bound to this client (for APIs without a named getter). */
35
+ api<T>(factory: (configuration: Configuration, http: AxiosInstance) => T): T {
36
+ return factory(this.configuration, this.http);
37
+ }
38
+
39
+ /** {@link CardsApi} bound to this client. */
40
+ cardsApi(): CardsApi {
41
+ return new CardsApi(this.configuration, undefined, this.http);
42
+ }
43
+
44
+ static builder(): CardsClientBuilder {
45
+ return new CardsClientBuilder();
46
+ }
47
+ }
48
+
49
+ /** Builds a {@link CardsClient}: base URL + optional OAuth + transport customization. */
50
+ export class CardsClientBuilder {
51
+
52
+ private _baseUrl?: string;
53
+ private _tokens?: TokenManager;
54
+ private _customizers: Array<(http: AxiosInstance) => void> = [];
55
+
56
+ /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
57
+ baseUrl(baseUrl: string): this {
58
+ this._baseUrl = baseUrl;
59
+ return this;
60
+ }
61
+
62
+ /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
63
+ oauth(tokens: TokenManager): this {
64
+ this._tokens = tokens;
65
+ return this;
66
+ }
67
+
68
+ /**
69
+ * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
70
+ * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
71
+ * calls run in order.
72
+ */
73
+ configure(customizer: (http: AxiosInstance) => void): this {
74
+ this._customizers.push(customizer);
75
+ return this;
76
+ }
77
+
78
+ build(): CardsClient {
79
+ const http = this._tokens ? createOAuthAxios(this._tokens) : globalAxios.create();
80
+ for (const customizer of this._customizers) {
81
+ customizer(http);
82
+ }
83
+ const configuration = new Configuration({ basePath: this._baseUrl });
84
+ return new CardsClient(http, configuration);
85
+ }
86
+ }
@@ -16,3 +16,5 @@
16
16
  export * from "./api";
17
17
  export * from "./configuration";
18
18
 
19
+
20
+ export * from './client';
@@ -0,0 +1,98 @@
1
+ /*
2
+ * Enfuce nextgen SDK — fluent module client.
3
+ *
4
+ * GENERATED by scripts/generate.sh from a custom template (generator-templates/typescript). One per
5
+ * API module: wires an OAuth-enabled axios instance (bearer token on every request + reactive 401
6
+ * retry) to the module's Configuration and exposes each API. Nothing is shared across modules.
7
+ */
8
+ import globalAxios, { type AxiosInstance } from 'axios';
9
+ import { createOAuthAxios, type TokenManager } from '../oauth';
10
+ import { Configuration } from './configuration';
11
+ import {
12
+ GetECBExchangeRateApi,
13
+ GetECBSupportedCurrenciesApi,
14
+ GetFXExchangeRatesApi,
15
+ } from './api';
16
+
17
+ /**
18
+ * Fluent entry point for this module. Build one with {@link ExchangeRateClient.builder}:
19
+ *
20
+ * ```ts
21
+ * const client = ExchangeRateClient.builder()
22
+ * .baseUrl('https://api.example.com/...')
23
+ * .oauth(tokens)
24
+ * .build();
25
+ * ```
26
+ */
27
+ export class ExchangeRateClient {
28
+
29
+ constructor(
30
+ /** The axios instance — OAuth interceptors and any customizations already applied. */
31
+ readonly http: AxiosInstance,
32
+ /** The module configuration — base path applied. */
33
+ readonly configuration: Configuration,
34
+ ) {}
35
+
36
+ /** Build any API in this module bound to this client (for APIs without a named getter). */
37
+ api<T>(factory: (configuration: Configuration, http: AxiosInstance) => T): T {
38
+ return factory(this.configuration, this.http);
39
+ }
40
+
41
+ /** {@link GetECBExchangeRateApi} bound to this client. */
42
+ getECBExchangeRateApi(): GetECBExchangeRateApi {
43
+ return new GetECBExchangeRateApi(this.configuration, undefined, this.http);
44
+ }
45
+
46
+ /** {@link GetECBSupportedCurrenciesApi} bound to this client. */
47
+ getECBSupportedCurrenciesApi(): GetECBSupportedCurrenciesApi {
48
+ return new GetECBSupportedCurrenciesApi(this.configuration, undefined, this.http);
49
+ }
50
+
51
+ /** {@link GetFXExchangeRatesApi} bound to this client. */
52
+ getFXExchangeRatesApi(): GetFXExchangeRatesApi {
53
+ return new GetFXExchangeRatesApi(this.configuration, undefined, this.http);
54
+ }
55
+
56
+ static builder(): ExchangeRateClientBuilder {
57
+ return new ExchangeRateClientBuilder();
58
+ }
59
+ }
60
+
61
+ /** Builds a {@link ExchangeRateClient}: base URL + optional OAuth + transport customization. */
62
+ export class ExchangeRateClientBuilder {
63
+
64
+ private _baseUrl?: string;
65
+ private _tokens?: TokenManager;
66
+ private _customizers: Array<(http: AxiosInstance) => void> = [];
67
+
68
+ /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
69
+ baseUrl(baseUrl: string): this {
70
+ this._baseUrl = baseUrl;
71
+ return this;
72
+ }
73
+
74
+ /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
75
+ oauth(tokens: TokenManager): this {
76
+ this._tokens = tokens;
77
+ return this;
78
+ }
79
+
80
+ /**
81
+ * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
82
+ * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
83
+ * calls run in order.
84
+ */
85
+ configure(customizer: (http: AxiosInstance) => void): this {
86
+ this._customizers.push(customizer);
87
+ return this;
88
+ }
89
+
90
+ build(): ExchangeRateClient {
91
+ const http = this._tokens ? createOAuthAxios(this._tokens) : globalAxios.create();
92
+ for (const customizer of this._customizers) {
93
+ customizer(http);
94
+ }
95
+ const configuration = new Configuration({ basePath: this._baseUrl });
96
+ return new ExchangeRateClient(http, configuration);
97
+ }
98
+ }
@@ -16,3 +16,5 @@
16
16
  export * from "./api";
17
17
  export * from "./configuration";
18
18
 
19
+
20
+ export * from './client';
@@ -0,0 +1,86 @@
1
+ /*
2
+ * Enfuce nextgen SDK — fluent module client.
3
+ *
4
+ * GENERATED by scripts/generate.sh from a custom template (generator-templates/typescript). One per
5
+ * API module: wires an OAuth-enabled axios instance (bearer token on every request + reactive 401
6
+ * retry) to the module's Configuration and exposes each API. Nothing is shared across modules.
7
+ */
8
+ import globalAxios, { type AxiosInstance } from 'axios';
9
+ import { createOAuthAxios, type TokenManager } from '../oauth';
10
+ import { Configuration } from './configuration';
11
+ import {
12
+ IssuerEventWebhooksApi,
13
+ } from './api';
14
+
15
+ /**
16
+ * Fluent entry point for this module. Build one with {@link IssuerEventsClient.builder}:
17
+ *
18
+ * ```ts
19
+ * const client = IssuerEventsClient.builder()
20
+ * .baseUrl('https://api.example.com/...')
21
+ * .oauth(tokens)
22
+ * .build();
23
+ * ```
24
+ */
25
+ export class IssuerEventsClient {
26
+
27
+ constructor(
28
+ /** The axios instance — OAuth interceptors and any customizations already applied. */
29
+ readonly http: AxiosInstance,
30
+ /** The module configuration — base path applied. */
31
+ readonly configuration: Configuration,
32
+ ) {}
33
+
34
+ /** Build any API in this module bound to this client (for APIs without a named getter). */
35
+ api<T>(factory: (configuration: Configuration, http: AxiosInstance) => T): T {
36
+ return factory(this.configuration, this.http);
37
+ }
38
+
39
+ /** {@link IssuerEventWebhooksApi} bound to this client. */
40
+ issuerEventWebhooksApi(): IssuerEventWebhooksApi {
41
+ return new IssuerEventWebhooksApi(this.configuration, undefined, this.http);
42
+ }
43
+
44
+ static builder(): IssuerEventsClientBuilder {
45
+ return new IssuerEventsClientBuilder();
46
+ }
47
+ }
48
+
49
+ /** Builds a {@link IssuerEventsClient}: base URL + optional OAuth + transport customization. */
50
+ export class IssuerEventsClientBuilder {
51
+
52
+ private _baseUrl?: string;
53
+ private _tokens?: TokenManager;
54
+ private _customizers: Array<(http: AxiosInstance) => void> = [];
55
+
56
+ /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
57
+ baseUrl(baseUrl: string): this {
58
+ this._baseUrl = baseUrl;
59
+ return this;
60
+ }
61
+
62
+ /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
63
+ oauth(tokens: TokenManager): this {
64
+ this._tokens = tokens;
65
+ return this;
66
+ }
67
+
68
+ /**
69
+ * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
70
+ * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
71
+ * calls run in order.
72
+ */
73
+ configure(customizer: (http: AxiosInstance) => void): this {
74
+ this._customizers.push(customizer);
75
+ return this;
76
+ }
77
+
78
+ build(): IssuerEventsClient {
79
+ const http = this._tokens ? createOAuthAxios(this._tokens) : globalAxios.create();
80
+ for (const customizer of this._customizers) {
81
+ customizer(http);
82
+ }
83
+ const configuration = new Configuration({ basePath: this._baseUrl });
84
+ return new IssuerEventsClient(http, configuration);
85
+ }
86
+ }
@@ -16,3 +16,5 @@
16
16
  export * from "./api";
17
17
  export * from "./configuration";
18
18
 
19
+
20
+ export * from './client';
@@ -19,19 +19,31 @@ function stripBearer(header: string): string {
19
19
  }
20
20
 
21
21
  /**
22
- * Returns an {@link AxiosInstance} with a response interceptor that, on a `401`,
23
- * forces a token refresh and retries the request exactly once with the new bearer
24
- * token. Pass it as the third argument of a generated API class:
22
+ * Returns an {@link AxiosInstance} with OAuth bearer-token handling built in:
23
+ *
24
+ * - **Proactive:** a request interceptor attaches a fresh bearer token (from the
25
+ * {@link TokenManager}) to *every* request. This authenticates API modules whose spec declares no
26
+ * security scheme (e.g. exchange-rate), so no `accessToken` on the `Configuration` is required.
27
+ * - **Reactive:** a response interceptor, on a `401`, forces a token refresh and retries the request
28
+ * exactly once with the new bearer token.
29
+ *
30
+ * Pass it as the third argument of a generated API class:
25
31
  *
26
32
  * ```ts
27
33
  * const http = createOAuthAxios(tokens);
28
- * const config = new card.Configuration({ accessToken: () => tokens.getToken() });
34
+ * const config = new card.Configuration({ basePath });
29
35
  * const api = new card.CardApi(config, undefined, http);
30
36
  * ```
31
37
  */
32
38
  export function createOAuthAxios(manager: TokenManager, instance?: AxiosInstance): AxiosInstance {
33
39
  const http = instance ?? axios.create();
34
40
 
41
+ // Proactive: attach a fresh bearer token to every outgoing request.
42
+ http.interceptors.request.use(async (config) => {
43
+ config.headers.set('Authorization', BEARER_PREFIX + (await manager.getToken()));
44
+ return config;
45
+ });
46
+
35
47
  http.interceptors.response.use(undefined, async (error: AxiosError) => {
36
48
  const response = error.response;
37
49
  const original = error.config as RetriableConfig | undefined;
@@ -13,10 +13,13 @@
13
13
  * clientSecret: 'my-secret',
14
14
  * scopes: ['cards:read'],
15
15
  * });
16
- * const http = oauth.createOAuthAxios(tokens);
17
- * const config = new card.Configuration({ accessToken: () => tokens.getToken() });
16
+ * const http = oauth.createOAuthAxios(tokens); // attaches the token + retries on 401
17
+ * const config = new card.Configuration({ basePath: 'https://api.example.com' });
18
18
  * const api = new card.CardApi(config, undefined, http);
19
19
  *
20
+ * The same `http` instance authenticates every API module, including ones whose spec declares no
21
+ * security scheme (e.g. exchange-rate) — no `accessToken` on the `Configuration` is required.
22
+ *
20
23
  * Server-side only — a client secret must never ship to a browser.
21
24
  */
22
25
  export { AccessToken, TokenFetcher, TokenManager } from './tokenManager';