@overmap-ai/core 1.0.60-sdk-refactor.1 → 1.0.60-sdk-refactor.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/dist/overmap-core.js +112 -115
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +112 -115
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/base.d.ts +4 -4
- package/dist/sdk/sdk.d.ts +2 -2
- package/dist/sdk/services/AuthService.d.ts +1 -2
- package/dist/sdk/services/FileService.d.ts +1 -1
- package/dist/sdk/typings.d.ts +1 -1
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -12187,23 +12187,6 @@ class APIError extends Error {
|
|
|
12187
12187
|
this.options = options;
|
|
12188
12188
|
}
|
|
12189
12189
|
}
|
|
12190
|
-
class BaseApiService {
|
|
12191
|
-
constructor(sdk) {
|
|
12192
|
-
__publicField(this, "client");
|
|
12193
|
-
this.client = sdk;
|
|
12194
|
-
}
|
|
12195
|
-
/**
|
|
12196
|
-
* Enqueues an API request to the offline outbox.
|
|
12197
|
-
* @param requestDetails An SDKRequest object containing the details of the request.
|
|
12198
|
-
* @protected
|
|
12199
|
-
*/
|
|
12200
|
-
async enqueueRequest(requestDetails) {
|
|
12201
|
-
return this.client.enqueueRequest(requestDetails, this.host);
|
|
12202
|
-
}
|
|
12203
|
-
dispatch(action) {
|
|
12204
|
-
this.client.store.dispatch(action);
|
|
12205
|
-
}
|
|
12206
|
-
}
|
|
12207
12190
|
var randomString = function randomString2() {
|
|
12208
12191
|
return Math.random().toString(36).substring(7).split("").join(".");
|
|
12209
12192
|
};
|
|
@@ -15371,6 +15354,118 @@ function retry(_action, _retries) {
|
|
|
15371
15354
|
getClientStore().dispatch(_setLatestRetryTime((/* @__PURE__ */ new Date()).getTime()));
|
|
15372
15355
|
return OUTBOX_RETRY_DELAY;
|
|
15373
15356
|
}
|
|
15357
|
+
class BaseSDK {
|
|
15358
|
+
constructor(store) {
|
|
15359
|
+
__publicField(this, "store");
|
|
15360
|
+
this.store = store;
|
|
15361
|
+
}
|
|
15362
|
+
/**
|
|
15363
|
+
* Enqueues an API request to the offline outbox.
|
|
15364
|
+
* @param requestDetails An SDKRequest object containing the details of the request.
|
|
15365
|
+
* @param host The base URL of the API to send the request to.
|
|
15366
|
+
* @protected
|
|
15367
|
+
*/
|
|
15368
|
+
async enqueueRequest(requestDetails, host) {
|
|
15369
|
+
return this._enqueueRequest(requestDetails, host).then((result) => {
|
|
15370
|
+
if (result instanceof APIError) {
|
|
15371
|
+
throw result;
|
|
15372
|
+
}
|
|
15373
|
+
return result;
|
|
15374
|
+
});
|
|
15375
|
+
}
|
|
15376
|
+
/**
|
|
15377
|
+
* Enqueues an API request to the Redux Offline outbox
|
|
15378
|
+
* @protected
|
|
15379
|
+
*/
|
|
15380
|
+
_enqueueRequest(requestDetails, host) {
|
|
15381
|
+
const promise = new DeferredPromise();
|
|
15382
|
+
const requestDetailsWithBaseUrl = { ...requestDetails, BASE_URL: host };
|
|
15383
|
+
if (requestDetails.immediate) {
|
|
15384
|
+
const requestWithUuid = {
|
|
15385
|
+
...requestDetailsWithBaseUrl,
|
|
15386
|
+
uuid: requestDetails.uuid ?? v4()
|
|
15387
|
+
};
|
|
15388
|
+
const fullOfflineAction = {
|
|
15389
|
+
payload: requestWithUuid,
|
|
15390
|
+
type: "",
|
|
15391
|
+
meta: {
|
|
15392
|
+
offline: {
|
|
15393
|
+
effect: {
|
|
15394
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15395
|
+
request: requestWithUuid,
|
|
15396
|
+
BASE_URL: host
|
|
15397
|
+
}
|
|
15398
|
+
}
|
|
15399
|
+
}
|
|
15400
|
+
};
|
|
15401
|
+
performRequest(fullOfflineAction, this).then((result) => {
|
|
15402
|
+
promise.resolve(result.body);
|
|
15403
|
+
}).catch((error2) => {
|
|
15404
|
+
discard(error2, fullOfflineAction);
|
|
15405
|
+
promise.reject(error2);
|
|
15406
|
+
});
|
|
15407
|
+
} else {
|
|
15408
|
+
const innerPromise = this.store.dispatch(
|
|
15409
|
+
enqueueRequest(requestDetailsWithBaseUrl)
|
|
15410
|
+
);
|
|
15411
|
+
const successOrUndefinedHandler = (response) => {
|
|
15412
|
+
if (response) {
|
|
15413
|
+
promise.resolve(response.body);
|
|
15414
|
+
} else {
|
|
15415
|
+
const error2 = new APIError({
|
|
15416
|
+
message: "Could not get a response from the server.",
|
|
15417
|
+
response,
|
|
15418
|
+
discard: true
|
|
15419
|
+
});
|
|
15420
|
+
promise.reject(error2);
|
|
15421
|
+
}
|
|
15422
|
+
};
|
|
15423
|
+
const errorHandler = (error2) => {
|
|
15424
|
+
if (error2 instanceof APIError) {
|
|
15425
|
+
error2.options.discard = true;
|
|
15426
|
+
} else {
|
|
15427
|
+
console.error(
|
|
15428
|
+
"Received an unexpected error while processing a request:",
|
|
15429
|
+
error2,
|
|
15430
|
+
"\nConverting error to APIError and discarding."
|
|
15431
|
+
);
|
|
15432
|
+
error2 = new APIError({
|
|
15433
|
+
message: "An error occurred while processing the request.",
|
|
15434
|
+
innerError: error2,
|
|
15435
|
+
discard: true
|
|
15436
|
+
});
|
|
15437
|
+
}
|
|
15438
|
+
promise.reject(error2);
|
|
15439
|
+
};
|
|
15440
|
+
innerPromise.then(successOrUndefinedHandler, errorHandler);
|
|
15441
|
+
}
|
|
15442
|
+
return promise;
|
|
15443
|
+
}
|
|
15444
|
+
// NOTE: these are currently expected to be present in the base SDK, not sure if that is desired
|
|
15445
|
+
}
|
|
15446
|
+
const initSDK = (store, sdk) => {
|
|
15447
|
+
const sdkInstance = new sdk(store);
|
|
15448
|
+
setClientSDK(sdkInstance);
|
|
15449
|
+
setClientStore(store);
|
|
15450
|
+
return sdkInstance;
|
|
15451
|
+
};
|
|
15452
|
+
class BaseApiService {
|
|
15453
|
+
constructor(sdk) {
|
|
15454
|
+
__publicField(this, "client");
|
|
15455
|
+
this.client = sdk;
|
|
15456
|
+
}
|
|
15457
|
+
/**
|
|
15458
|
+
* Enqueues an API request to the offline outbox.
|
|
15459
|
+
* @param requestDetails An SDKRequest object containing the details of the request.
|
|
15460
|
+
* @protected
|
|
15461
|
+
*/
|
|
15462
|
+
async enqueueRequest(requestDetails) {
|
|
15463
|
+
return this.client.enqueueRequest(requestDetails, this.host);
|
|
15464
|
+
}
|
|
15465
|
+
dispatch(action) {
|
|
15466
|
+
this.client.store.dispatch(action);
|
|
15467
|
+
}
|
|
15468
|
+
}
|
|
15374
15469
|
const EXPIRING_SOON_THRESHOLD = 1800;
|
|
15375
15470
|
function parseTokens(response) {
|
|
15376
15471
|
if (!response.access)
|
|
@@ -15382,7 +15477,6 @@ function parseTokens(response) {
|
|
|
15382
15477
|
class AuthService extends BaseApiService {
|
|
15383
15478
|
constructor() {
|
|
15384
15479
|
super(...arguments);
|
|
15385
|
-
__publicField(this, "host", {}.REACT_APP_API_URL);
|
|
15386
15480
|
__publicField(this, "_getAccessToken", () => this.client.store.getState().authReducer.accessToken);
|
|
15387
15481
|
__publicField(this, "_getRefreshToken", () => this.client.store.getState().authReducer.refreshToken);
|
|
15388
15482
|
// _getTokenPair and _getRenewedTokens don't need to use enqueueRequest from the BaseApiService because
|
|
@@ -18665,103 +18759,6 @@ class TeamService extends BaseApiService {
|
|
|
18665
18759
|
this.dispatch(setTeams(result));
|
|
18666
18760
|
}
|
|
18667
18761
|
}
|
|
18668
|
-
class BaseSDK {
|
|
18669
|
-
constructor(store) {
|
|
18670
|
-
__publicField(this, "store");
|
|
18671
|
-
// NOTE: these are currently expected to be present in the base SDK, not sure if that is desired
|
|
18672
|
-
__publicField(this, "files", new FileService(this));
|
|
18673
|
-
__publicField(this, "auth", new AuthService(this));
|
|
18674
|
-
this.store = store;
|
|
18675
|
-
}
|
|
18676
|
-
/**
|
|
18677
|
-
* Enqueues an API request to the offline outbox.
|
|
18678
|
-
* @param requestDetails An SDKRequest object containing the details of the request.
|
|
18679
|
-
* @param host The base URL of the API to send the request to.
|
|
18680
|
-
* @protected
|
|
18681
|
-
*/
|
|
18682
|
-
async enqueueRequest(requestDetails, host) {
|
|
18683
|
-
return this._enqueueRequest(requestDetails, host).then((result) => {
|
|
18684
|
-
if (result instanceof APIError) {
|
|
18685
|
-
throw result;
|
|
18686
|
-
}
|
|
18687
|
-
return result;
|
|
18688
|
-
});
|
|
18689
|
-
}
|
|
18690
|
-
/**
|
|
18691
|
-
* Enqueues an API request to the Redux Offline outbox
|
|
18692
|
-
* @protected
|
|
18693
|
-
*/
|
|
18694
|
-
_enqueueRequest(requestDetails, host) {
|
|
18695
|
-
const promise = new DeferredPromise();
|
|
18696
|
-
const requestDetailsWithBaseUrl = { ...requestDetails, BASE_URL: host };
|
|
18697
|
-
if (requestDetails.immediate) {
|
|
18698
|
-
const requestWithUuid = {
|
|
18699
|
-
...requestDetailsWithBaseUrl,
|
|
18700
|
-
uuid: requestDetails.uuid ?? v4()
|
|
18701
|
-
};
|
|
18702
|
-
const fullOfflineAction = {
|
|
18703
|
-
payload: requestWithUuid,
|
|
18704
|
-
type: "",
|
|
18705
|
-
meta: {
|
|
18706
|
-
offline: {
|
|
18707
|
-
effect: {
|
|
18708
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18709
|
-
request: requestWithUuid,
|
|
18710
|
-
BASE_URL: host
|
|
18711
|
-
}
|
|
18712
|
-
}
|
|
18713
|
-
}
|
|
18714
|
-
};
|
|
18715
|
-
performRequest(fullOfflineAction, this).then((result) => {
|
|
18716
|
-
promise.resolve(result.body);
|
|
18717
|
-
}).catch((error2) => {
|
|
18718
|
-
discard(error2, fullOfflineAction);
|
|
18719
|
-
promise.reject(error2);
|
|
18720
|
-
});
|
|
18721
|
-
} else {
|
|
18722
|
-
const innerPromise = this.store.dispatch(
|
|
18723
|
-
enqueueRequest(requestDetailsWithBaseUrl)
|
|
18724
|
-
);
|
|
18725
|
-
const successOrUndefinedHandler = (response) => {
|
|
18726
|
-
if (response) {
|
|
18727
|
-
promise.resolve(response.body);
|
|
18728
|
-
} else {
|
|
18729
|
-
const error2 = new APIError({
|
|
18730
|
-
message: "Could not get a response from the server.",
|
|
18731
|
-
response,
|
|
18732
|
-
discard: true
|
|
18733
|
-
});
|
|
18734
|
-
promise.reject(error2);
|
|
18735
|
-
}
|
|
18736
|
-
};
|
|
18737
|
-
const errorHandler = (error2) => {
|
|
18738
|
-
if (error2 instanceof APIError) {
|
|
18739
|
-
error2.options.discard = true;
|
|
18740
|
-
} else {
|
|
18741
|
-
console.error(
|
|
18742
|
-
"Received an unexpected error while processing a request:",
|
|
18743
|
-
error2,
|
|
18744
|
-
"\nConverting error to APIError and discarding."
|
|
18745
|
-
);
|
|
18746
|
-
error2 = new APIError({
|
|
18747
|
-
message: "An error occurred while processing the request.",
|
|
18748
|
-
innerError: error2,
|
|
18749
|
-
discard: true
|
|
18750
|
-
});
|
|
18751
|
-
}
|
|
18752
|
-
promise.reject(error2);
|
|
18753
|
-
};
|
|
18754
|
-
innerPromise.then(successOrUndefinedHandler, errorHandler);
|
|
18755
|
-
}
|
|
18756
|
-
return promise;
|
|
18757
|
-
}
|
|
18758
|
-
}
|
|
18759
|
-
const initSDK = (store, sdk) => {
|
|
18760
|
-
const sdkInstance = new sdk(store);
|
|
18761
|
-
setClientSDK(sdkInstance);
|
|
18762
|
-
setClientStore(store);
|
|
18763
|
-
return sdkInstance;
|
|
18764
|
-
};
|
|
18765
18762
|
export {
|
|
18766
18763
|
APIError,
|
|
18767
18764
|
AgentService,
|