Author SHA1 Message Date
Stevan Freeborn 9810482eef feat: wip on getAllApps method 2026-03-27 08:10:07 -05:00
Stevan Freeborn 944e84802c chore: update package.json scripts 2026-03-27 08:08:30 -05:00
StevanFreeborn 321baac650 docs: update docs 2026-03-25 19:54:58 +00:00
Stevan Freeborn b2af266eb4 Merge pull request #28 from StevanFreeborn/stevanfreeborn/fix/address-vuln-deps
fix: update dependencies to address vulnerabilities
2026-03-25 14:53:11 -05:00
Stevan Freeborn d83403e88d fix: update dependencies to address vulnerabilities 2026-03-25 14:45:12 -05:00
5 changed files with 160 additions and 55 deletions
+1 -1
View File
@@ -215,7 +215,7 @@
<li>An ApiResponse<FileInfo>.</li> <li>An ApiResponse<FileInfo>.</li>
</ul> </ul>
<div class="tsd-comment tsd-typography"><h4>Method</h4><p>asFileInfoType - Converts the ApiResponse to an ApiResponse<FileInfo>.</p> <div class="tsd-comment tsd-typography"><h4>Method</h4><p>asFileInfoType - Converts the ApiResponse to an ApiResponse<FileInfo>.</p>
</div><aside class="tsd-sources"><ul><li>Defined in models/ApiResponse.ts:245</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="asFileType" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>as<wbr/>File<wbr/>Type</span><a href="#asFileType" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="asFileType.asFileType-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">as<wbr/>File<wbr/>Type</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">response</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="ApiResponse.html" class="tsd-signature-type tsd-kind-class">ApiResponse</a><span class="tsd-signature-symbol">&lt;</span><a href="File.html" class="tsd-signature-type tsd-kind-class">File</a><span class="tsd-signature-symbol">&gt;</span><a href="#asFileType.asFileType-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">response</span>: <span class="tsd-signature-type">AxiosResponse</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="ApiResponse.html" class="tsd-signature-type tsd-kind-class">ApiResponse</a><span class="tsd-signature-symbol">&lt;</span><a href="File.html" class="tsd-signature-type tsd-kind-class">File</a><span class="tsd-signature-symbol">&gt;</span></h4><ul> </div><aside class="tsd-sources"><ul><li>Defined in models/ApiResponse.ts:245</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="asFileType" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>as<wbr/>File<wbr/>Type</span><a href="#asFileType" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="asFileType.asFileType-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">as<wbr/>File<wbr/>Type</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">response</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="ApiResponse.html" class="tsd-signature-type tsd-kind-class">ApiResponse</a><span class="tsd-signature-symbol">&lt;</span><a href="File.html" class="tsd-signature-type tsd-kind-class">File</a><span class="tsd-signature-symbol">&gt;</span><a href="#asFileType.asFileType-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">response</span>: <span class="tsd-signature-type">AxiosResponse</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-symbol">{}</span><span class="tsd-signature-symbol">&gt;</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="ApiResponse.html" class="tsd-signature-type tsd-kind-class">ApiResponse</a><span class="tsd-signature-symbol">&lt;</span><a href="File.html" class="tsd-signature-type tsd-kind-class">File</a><span class="tsd-signature-symbol">&gt;</span></h4><ul>
<li>An ApiResponse<File>.</li> <li>An ApiResponse<File>.</li>
</ul> </ul>
<div class="tsd-comment tsd-typography"><h4>Method</h4><p>asFileType - Converts the ApiResponse to an ApiResponse<File>.</p> <div class="tsd-comment tsd-typography"><h4>Method</h4><p>asFileType - Converts the ApiResponse to an ApiResponse<File>.</p>
+50 -50
View File
@@ -9,8 +9,8 @@
"version": "0.0.0-semantic-release", "version": "0.0.0-semantic-release",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^1.12.2", "axios": "^1.13.6",
"form-data": "^4.0.4" "form-data": "^4.0.5"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^17.8.1", "@commitlint/cli": "^17.8.1",
@@ -678,9 +678,9 @@
} }
}, },
"node_modules/@eslint/eslintrc/node_modules/ajv": { "node_modules/@eslint/eslintrc/node_modules/ajv": {
"version": "6.12.6", "version": "6.14.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -791,9 +791,9 @@
} }
}, },
"node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": {
"version": "3.14.1", "version": "3.14.2",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz",
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -1380,9 +1380,9 @@
} }
}, },
"node_modules/ajv": { "node_modules/ajv": {
"version": "8.17.1", "version": "8.18.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz",
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -1679,13 +1679,13 @@
} }
}, },
"node_modules/axios": { "node_modules/axios": {
"version": "1.12.2", "version": "1.13.6",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.12.2.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.6.tgz",
"integrity": "sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==", "integrity": "sha512-ChTCHMouEe2kn713WHbQGcuYrr6fXTBiu460OTwWrWob16g1bXn4vtz07Ope7ewMozJAnEquLk5lWQWtBig9DQ==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"follow-redirects": "^1.15.6", "follow-redirects": "^1.15.11",
"form-data": "^4.0.4", "form-data": "^4.0.5",
"proxy-from-env": "^1.1.0" "proxy-from-env": "^1.1.0"
} }
}, },
@@ -2405,9 +2405,9 @@
} }
}, },
"node_modules/diff": { "node_modules/diff": {
"version": "5.2.0", "version": "5.2.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.2.tgz",
"integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "integrity": "sha512-vtcDfH3TOjP8UekytvnHH1o1P4FcUdt4eQ1Y+Abap1tk/OB2MWQvcwS2ClCd1zuIhc3JKOx6p3kod8Vfys3E+A==",
"dev": true, "dev": true,
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"engines": { "engines": {
@@ -3086,9 +3086,9 @@
} }
}, },
"node_modules/eslint/node_modules/ajv": { "node_modules/eslint/node_modules/ajv": {
"version": "6.12.6", "version": "6.14.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -3423,9 +3423,9 @@
} }
}, },
"node_modules/flatted": { "node_modules/flatted": {
"version": "3.3.3", "version": "3.4.2",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz",
"integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", "integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==",
"dev": true, "dev": true,
"license": "ISC" "license": "ISC"
}, },
@@ -3480,9 +3480,9 @@
} }
}, },
"node_modules/form-data": { "node_modules/form-data": {
"version": "4.0.4", "version": "4.0.5",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz",
"integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"asynckit": "^0.4.0", "asynckit": "^0.4.0",
@@ -3776,9 +3776,9 @@
} }
}, },
"node_modules/glob/node_modules/minimatch": { "node_modules/glob/node_modules/minimatch": {
"version": "5.1.6", "version": "5.1.9",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz",
"integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==",
"dev": true, "dev": true,
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
@@ -4820,9 +4820,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/js-yaml": { "node_modules/js-yaml": {
"version": "4.1.0", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -4998,9 +4998,9 @@
} }
}, },
"node_modules/lodash": { "node_modules/lodash": {
"version": "4.17.21", "version": "4.17.23",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
@@ -5308,9 +5308,9 @@
} }
}, },
"node_modules/minimatch": { "node_modules/minimatch": {
"version": "3.1.2", "version": "3.1.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
"dev": true, "dev": true,
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
@@ -5404,9 +5404,9 @@
} }
}, },
"node_modules/mocha/node_modules/minimatch": { "node_modules/mocha/node_modules/minimatch": {
"version": "5.1.6", "version": "5.1.9",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz",
"integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==",
"dev": true, "dev": true,
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
@@ -7546,9 +7546,9 @@
} }
}, },
"node_modules/ts-node/node_modules/diff": { "node_modules/ts-node/node_modules/diff": {
"version": "4.0.2", "version": "4.0.4",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.4.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==",
"dev": true, "dev": true,
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"engines": { "engines": {
@@ -7805,13 +7805,13 @@
} }
}, },
"node_modules/typedoc/node_modules/minimatch": { "node_modules/typedoc/node_modules/minimatch": {
"version": "9.0.5", "version": "9.0.9",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz",
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==",
"dev": true, "dev": true,
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"brace-expansion": "^2.0.1" "brace-expansion": "^2.0.2"
}, },
"engines": { "engines": {
"node": ">=16 || 14 >=14.17" "node": ">=16 || 14 >=14.17"
+3 -4
View File
@@ -53,9 +53,8 @@
"build:esm": "tsc --project tsconfig.esm.json", "build:esm": "tsc --project tsconfig.esm.json",
"build:cjs": "tsc --project tsconfig.cjs.json", "build:cjs": "tsc --project tsconfig.cjs.json",
"build:json": "node ./scripts/create_dist_package_json.js", "build:json": "node ./scripts/create_dist_package_json.js",
"test:unit": "mocha -r ts-node/register",
"test:integration": "mocha -r ts-node/register -r integrationTests/mochaRootHooks.ts",
"tests:unit": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts", "tests:unit": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts",
"tests:unit:watch": "mocha -w --watch-files . -R progress -r ts-node/register ./tests/**/*.spec.ts",
"tests:integration": "mocha -R progress -r ts-node/register -r integrationTests/mochaRootHooks.ts ./integrationTests/**/*.spec.ts", "tests:integration": "mocha -R progress -r ts-node/register -r integrationTests/mochaRootHooks.ts ./integrationTests/**/*.spec.ts",
"tests": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts && mocha -R progress -r ts-node/register -r integrationTests/mochaRootHooks.ts ./integrationTests/**/*.spec.ts", "tests": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts && mocha -R progress -r ts-node/register -r integrationTests/mochaRootHooks.ts ./integrationTests/**/*.spec.ts",
"test-coverage": "nyc npm run tests:unit", "test-coverage": "nyc npm run tests:unit",
@@ -93,7 +92,7 @@
"typescript": "^4.9.5" "typescript": "^4.9.5"
}, },
"dependencies": { "dependencies": {
"axios": "^1.12.2", "axios": "^1.13.6",
"form-data": "^4.0.4" "form-data": "^4.0.5"
} }
} }
+27
View File
@@ -111,6 +111,33 @@ export class OnspringClient {
return apiResponse.asGetPagedAppsResponseType(); return apiResponse.asGetPagedAppsResponseType();
} }
/**
* @method getAllApps - Gets an iterable that can be used to page through all.
* @param {PagingRequest} pagingRequest - The paging request that will be used to get the apps.
* @returns
**/
public async *getAllApps(
pagingRequest: PagingRequest = new PagingRequest(1, 50)
): AsyncGenerator<ApiResponse<GetPagedAppsResponse>, void, unknown> {
// TODO: We need to actually honor the page request
// the caller gave us. We will use the page number
// as our starting page number and we will use the
// page size as our page size
for await (const page of this.getAllPagesAsync<GetPagedAppsResponse>(
async (pr) => await this.getApps(pr)
)) {
yield page;
}
}
private async *getAllPagesAsync<T>(
callback: (pagingRequest: PagingRequest) => Promise<ApiResponse<T>>
): AsyncGenerator<ApiResponse<T>, void, unknown> {
const pagingRequest = new PagingRequest(1, 50);
const initialResponse = await callback(pagingRequest);
yield initialResponse;
}
/** /**
* @method getAppById - Gets an app by its id. * @method getAppById - Gets an app by its id.
* @param {number} appId - The id of the app to get. * @param {number} appId - The id of the app to get.
+79
View File
@@ -232,6 +232,85 @@ describe('OnspringClient', function () {
}); });
}); });
describe('getAllApps', function () {
it('should be define', function () {
expect(new OnspringClient(baseUrl, apiKey).getAllApps).to.not.be
.undefined;
});
it('should be a function', function () {
expect(new OnspringClient(baseUrl, apiKey).getAllApps).to.be.a(
'function'
);
});
it('should have 0 parameter', function () {
expect(new OnspringClient(baseUrl, apiKey).getAllApps).to.have.lengthOf(
0
);
});
it('should return a async generator', function () {
const result = new OnspringClient(baseUrl, apiKey).getAllApps();
expect(result).to.have.property(Symbol.asyncIterator);
expect(result[Symbol.asyncIterator]).to.be.a('function');
expect(result).to.have.property('next').that.is.a('function');
expect(result).to.have.property('return').that.is.a('function');
expect(result).to.have.property('throw').that.is.a('function');
});
it('should return a promise that resolves to an async iterable of paged response of apps when request is successful', async function () {
const client = new OnspringClient(baseUrl, apiKey);
const mockAxiosClient = axios.create({
baseURL: baseUrl,
headers: {
'x-apikey': apiKey,
'x-api-version': '2',
},
});
sinon.stub(mockAxiosClient, 'get').returns(
Promise.resolve({
status: 200,
statusText: 'OK',
data: {
pageNumber: 1,
pageSize: 2,
totalPages: 1,
totalRecords: 2,
items: [
{
href: 'https://api.onspring.dev/Apps/id/1',
id: '1',
name: 'Test App 1',
},
{
href: 'https://api.onspring.dev/Apps/id/2',
id: '2',
name: 'Test App 2',
},
],
},
headers: {},
config: {} as InternalAxiosRequestConfig,
} as AxiosResponse)
);
sinon.stub(client, '_client' as any).value(mockAxiosClient);
const collectedPages: Array<ApiResponse<GetPagedAppsResponse>> = [];
for await (const page of client.getAllApps()) {
collectedPages.push(page);
}
expect(collectedPages.length).to.equal(1);
});
});
describe('getApps', function () { describe('getApps', function () {
it('should be defined', function () { it('should be defined', function () {
expect(new OnspringClient(baseUrl, apiKey).getApps).to.not.be.undefined; expect(new OnspringClient(baseUrl, apiKey).getApps).to.not.be.undefined;