@io-orkes/conductor-javascript 1.2.0-rc.1 → 1.2.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.mts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +53 -11
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +53 -11
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +55 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{types-e3d6bb0f.d.ts → types-7f82aacc.d.ts} +4 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2156,7 +2156,11 @@ var ConductorClient = class {
|
|
|
2156
2156
|
this.request = {
|
|
2157
2157
|
config: resolvedConfig,
|
|
2158
2158
|
request: (apiConfig) => {
|
|
2159
|
-
return requestHandler(
|
|
2159
|
+
return requestHandler(
|
|
2160
|
+
request,
|
|
2161
|
+
{ ...resolvedConfig, TOKEN: this.token },
|
|
2162
|
+
apiConfig
|
|
2163
|
+
);
|
|
2160
2164
|
}
|
|
2161
2165
|
};
|
|
2162
2166
|
this.token = config?.TOKEN;
|
|
@@ -2171,6 +2175,8 @@ var ConductorClient = class {
|
|
|
2171
2175
|
this.humanTask = new HumanTaskService(this.request);
|
|
2172
2176
|
this.humanTaskResource = new HumanTaskResourceService(this.request);
|
|
2173
2177
|
}
|
|
2178
|
+
stop() {
|
|
2179
|
+
}
|
|
2174
2180
|
};
|
|
2175
2181
|
|
|
2176
2182
|
// src/common/open-api/core/BaseHttpRequest.ts
|
|
@@ -3688,21 +3694,57 @@ var request2 = (config, options, fetchFn = fetch) => {
|
|
|
3688
3694
|
|
|
3689
3695
|
// src/orkes/BaseOrkesConductorClient.ts
|
|
3690
3696
|
var defaultRequestHandler2 = (request3, config, options) => request3(config, options);
|
|
3697
|
+
var REFRESH_TOKEN_IN_MILLISECONDS = 30 * 60 * 1e3;
|
|
3698
|
+
var AuthConductorClient = class extends ConductorClient {
|
|
3699
|
+
constructor(config, requestHandler = defaultRequestHandler2) {
|
|
3700
|
+
super(config, requestHandler);
|
|
3701
|
+
}
|
|
3702
|
+
/**
|
|
3703
|
+
* Stops the interval that refreshes the token
|
|
3704
|
+
*/
|
|
3705
|
+
stop() {
|
|
3706
|
+
if (this.intervalId != null) {
|
|
3707
|
+
clearInterval(this.intervalId);
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
};
|
|
3691
3711
|
var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHandler2) => {
|
|
3712
|
+
const requestTokenForKeySecret = (keyId, keySecret, tokenUrl) => fetchFn(tokenUrl, {
|
|
3713
|
+
headers: {
|
|
3714
|
+
"Content-Type": "application/json",
|
|
3715
|
+
Accept: "application/json"
|
|
3716
|
+
},
|
|
3717
|
+
body: JSON.stringify({ keyId, keySecret }),
|
|
3718
|
+
method: "POST"
|
|
3719
|
+
});
|
|
3692
3720
|
return async (config, requestHandler = baseRequestHandler) => {
|
|
3693
3721
|
if (config?.keySecret != null && config?.keyId != null) {
|
|
3694
|
-
const {
|
|
3722
|
+
const {
|
|
3723
|
+
serverUrl,
|
|
3724
|
+
keyId,
|
|
3725
|
+
keySecret,
|
|
3726
|
+
refreshTokenInterval = REFRESH_TOKEN_IN_MILLISECONDS
|
|
3727
|
+
} = config;
|
|
3695
3728
|
const tokenUrl = `${serverUrl}/token`;
|
|
3696
|
-
const res = await
|
|
3697
|
-
headers: {
|
|
3698
|
-
"Content-Type": "application/json",
|
|
3699
|
-
Accept: "application/json"
|
|
3700
|
-
},
|
|
3701
|
-
body: JSON.stringify({ keyId, keySecret }),
|
|
3702
|
-
method: "POST"
|
|
3703
|
-
});
|
|
3729
|
+
const res = await requestTokenForKeySecret(keyId, keySecret, tokenUrl);
|
|
3704
3730
|
const { token } = await res.json();
|
|
3705
|
-
|
|
3731
|
+
const conductorClientInstance = new AuthConductorClient(
|
|
3732
|
+
{ ...config, TOKEN: token },
|
|
3733
|
+
requestHandler
|
|
3734
|
+
);
|
|
3735
|
+
if (token != null && refreshTokenInterval > 0) {
|
|
3736
|
+
const intervalId = setInterval(async () => {
|
|
3737
|
+
const res2 = await requestTokenForKeySecret(
|
|
3738
|
+
keyId,
|
|
3739
|
+
keySecret,
|
|
3740
|
+
tokenUrl
|
|
3741
|
+
);
|
|
3742
|
+
const { token: token2 } = await res2.json();
|
|
3743
|
+
conductorClientInstance.token = token2;
|
|
3744
|
+
}, refreshTokenInterval);
|
|
3745
|
+
conductorClientInstance.intervalId = intervalId;
|
|
3746
|
+
}
|
|
3747
|
+
return conductorClientInstance;
|
|
3706
3748
|
} else {
|
|
3707
3749
|
return new ConductorClient(config, requestHandler);
|
|
3708
3750
|
}
|
|
@@ -3718,6 +3760,7 @@ var orkesConductorClient = baseOrkesConductorClient(
|
|
|
3718
3760
|
);
|
|
3719
3761
|
export {
|
|
3720
3762
|
ApiError,
|
|
3763
|
+
AuthConductorClient,
|
|
3721
3764
|
BaseHttpRequest,
|
|
3722
3765
|
CancelError,
|
|
3723
3766
|
CancelablePromise,
|