@api-client/core 0.18.36 → 0.18.38
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-client/core",
|
|
3
3
|
"description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.38",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./browser.js": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@pawel-up/csv": "^0.2.0",
|
|
93
93
|
"@pawel-up/data-mock": "^0.4.0",
|
|
94
94
|
"@pawel-up/jexl": "^4.0.1",
|
|
95
|
-
"@types/sinon": "^
|
|
95
|
+
"@types/sinon": "^21.0.0",
|
|
96
96
|
"@xmldom/xmldom": "^0.8.11",
|
|
97
97
|
"amf-json-ld-lib": "^0.0.15",
|
|
98
98
|
"chalk": "^5.4.1",
|
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
"@japa/runner": "^4.2.0",
|
|
117
117
|
"@pawel-up/semver": "^0.1.4",
|
|
118
118
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
119
|
+
"@types/chai-as-promised": "^8.0.2",
|
|
119
120
|
"@types/cors": "^2.8.12",
|
|
120
121
|
"@types/express-ntlm": "^2.3.3",
|
|
121
122
|
"@types/jsdom": "^27.0.0",
|
|
@@ -128,6 +129,7 @@
|
|
|
128
129
|
"@web/test-runner-playwright": "^0.11.0",
|
|
129
130
|
"amf-client-js": "^5.9.1-3",
|
|
130
131
|
"c8": "^10.1.3",
|
|
132
|
+
"chai-as-promised": "^8.0.2",
|
|
131
133
|
"conventional-changelog-cli": "^5.0.0",
|
|
132
134
|
"cors": "^2.8.5",
|
|
133
135
|
"eslint": "^9.20.1",
|
package/src/sdk/SdkMock.ts
CHANGED
|
@@ -368,36 +368,13 @@ export class SdkMock {
|
|
|
368
368
|
return this.createStub('user', 'me', () => {
|
|
369
369
|
const defaultData = this.generateUser()
|
|
370
370
|
if (options?.status !== undefined && options.status !== 200) {
|
|
371
|
-
throw new Exception(
|
|
371
|
+
throw new Exception(`Mocked error. Status: ${options.status}`, { status: options.status })
|
|
372
372
|
}
|
|
373
373
|
return (options?.data ?? defaultData) as unknown
|
|
374
374
|
})
|
|
375
375
|
},
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
/**
|
|
379
|
-
* Auth API mocks.
|
|
380
|
-
*/
|
|
381
|
-
auth = {
|
|
382
|
-
/**
|
|
383
|
-
* Mocks the `auth.oauthRedirect()` method.
|
|
384
|
-
* This method returns `null` by default as it performs window navigation.
|
|
385
|
-
* @param options Optional response customization.
|
|
386
|
-
* @returns A stub reference that can be used to restore the original behavior.
|
|
387
|
-
*/
|
|
388
|
-
oauthRedirect: (options?: MockResponseOptions): StubReference => {
|
|
389
|
-
return this.createStub(
|
|
390
|
-
'auth',
|
|
391
|
-
'oauthRedirect',
|
|
392
|
-
() => {
|
|
393
|
-
const defaultData = options?.data ?? null
|
|
394
|
-
return defaultData
|
|
395
|
-
},
|
|
396
|
-
true
|
|
397
|
-
)
|
|
398
|
-
},
|
|
399
|
-
}
|
|
400
|
-
|
|
401
378
|
/**
|
|
402
379
|
* Files API mocks.
|
|
403
380
|
*/
|
|
@@ -723,8 +700,7 @@ export class SdkMock {
|
|
|
723
700
|
| 'organizations.invitations'
|
|
724
701
|
| 'organizations.users',
|
|
725
702
|
method: string,
|
|
726
|
-
implementation: () => unknown
|
|
727
|
-
sync?: boolean
|
|
703
|
+
implementation: () => unknown
|
|
728
704
|
): StubReference {
|
|
729
705
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
730
706
|
let target: any = this.sdk
|
|
@@ -741,10 +717,8 @@ export class SdkMock {
|
|
|
741
717
|
throw new Error(`Method '${method}' not found in ${api} API`)
|
|
742
718
|
}
|
|
743
719
|
|
|
744
|
-
//
|
|
745
|
-
const stub =
|
|
746
|
-
? sinon.stub(target, method).callsFake(() => implementation())
|
|
747
|
-
: sinon.stub(target, method).callsFake(async () => implementation())
|
|
720
|
+
// Create stub using sinon
|
|
721
|
+
const stub = sinon.stub(target, method).callsFake(async () => implementation())
|
|
748
722
|
|
|
749
723
|
const stubRef: StubReference = {
|
|
750
724
|
restore: () => {
|
|
@@ -762,19 +736,6 @@ export class SdkMock {
|
|
|
762
736
|
return stubRef
|
|
763
737
|
}
|
|
764
738
|
|
|
765
|
-
/**
|
|
766
|
-
* Creates a response object from data and options.
|
|
767
|
-
* @param defaultData Default data to return if not overridden.
|
|
768
|
-
* @param options Response options.
|
|
769
|
-
* @returns The final data to return (for non-HTTP responses) or IStoreResponse (for HTTP responses).
|
|
770
|
-
*/
|
|
771
|
-
private createResponse(defaultData: unknown, options?: MockResponseOptions): unknown {
|
|
772
|
-
// For SDK-level stubs we return plain data. Status and headers are
|
|
773
|
-
// accepted but not propagated, since high-level SDK methods return data.
|
|
774
|
-
const data = options?.data !== undefined ? options.data : defaultData
|
|
775
|
-
return data
|
|
776
|
-
}
|
|
777
|
-
|
|
778
739
|
/**
|
|
779
740
|
* Generates a random organization object.
|
|
780
741
|
*/
|