generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* restructure * lint * test restructure+workflows * lint * add temporary workaround * remove log * change tsconfig setup * mock env in global setup * fix tsconfig.test * fix test * add core to canary release * add ignored packages to config.json * Update test-util/mock-http.ts Co-authored-by: Marika Marszalkowski <[email protected]> * Update packages/core/src/context.test.ts Co-authored-by: Marika Marszalkowski <[email protected]> * review * fix: Changes from lint * update docs * docs * fix: Changes from lint --------- Co-authored-by: Tom Frenken <[email protected]> Co-authored-by: Marika Marszalkowski <[email protected]> Co-authored-by: cloud-sdk-js <[email protected]>
- Loading branch information
1 parent
5bf34b5
commit 8bde567
Showing
53 changed files
with
453 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,9 +52,7 @@ jobs: | |
done | ||
wget -qO- -S --content-on-error localhost:8080 | ||
- name: "Execute E2E Tests" | ||
working-directory: ./tests/e2e-tests | ||
run: | | ||
pnpm run e2e-test | ||
run: pnpm test:e2e | ||
- name: "Slack Notification" | ||
if: failure() | ||
uses: slackapi/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* This file is used to mock the environment variables that are required for the tests. | ||
*/ | ||
export default async function mockAiCoreEnvVariable(): Promise<void> { | ||
const aiCoreServiceCredentials = { | ||
clientid: 'clientid', | ||
clientsecret: 'clientsecret', | ||
url: 'https://example.authentication.eu12.hana.ondemand.com', | ||
serviceurls: { | ||
AI_API_URL: 'https://api.ai.ml.hana.ondemand.com' | ||
} | ||
}; | ||
process.env['aicore'] = JSON.stringify(aiCoreServiceCredentials); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* This file is used to run code after all tests have been run. | ||
*/ | ||
export default async function tearDown(): Promise<void> { | ||
delete process.env.aicore; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import config from '../../jest.config.mjs'; | ||
const aiCoreConfig = { | ||
export default { | ||
...config, | ||
displayName: 'ai-core', | ||
}; | ||
|
||
export default aiCoreConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# @sap-ai-sdk/core | ||
|
||
This package contains core utility functions that we reuse in the SDK to set the context and execute HTTP requests. | ||
They are primarily designed for internal usage. | ||
|
||
### Installation | ||
|
||
``` | ||
$ npm install @sap-ai-sdk/core | ||
``` | ||
|
||
### Usage | ||
|
||
The core package is not intended for direct usage. | ||
|
||
## License | ||
|
||
The SAP AI SDK is released under the [Apache License Version 2.0.](http://www.apache.org/licenses/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import config from '../../jest.config.mjs'; | ||
export default { | ||
...config, | ||
displayName: 'core', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "@sap-ai-sdk/core", | ||
"version": "0.0.0", | ||
"description": "", | ||
"license": "Apache-2.0", | ||
"keywords": [ | ||
"sap-ai-sdk", | ||
"ai-core" | ||
], | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist/**/*.js", | ||
"dist/**/*.js.map", | ||
"dist/**/*.d.ts", | ||
"dist/**/*.d.ts.map" | ||
], | ||
"scripts": { | ||
"compile": "tsc", | ||
"test": "NODE_OPTIONS=--experimental-vm-modules jest", | ||
"lint": "eslint . && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -c", | ||
"lint:fix": "eslint . --fix && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -w --log-level error" | ||
}, | ||
"dependencies": { | ||
"@sap-cloud-sdk/http-client": "^3.18.0", | ||
"@sap-cloud-sdk/connectivity": "^3.18.0", | ||
"@sap-cloud-sdk/util": "^3.18.0" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.5.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import nock from 'nock'; | ||
import { mockClientCredentialsGrantCall } from '../../../test-util/mock-http.js'; | ||
import { getAiCoreDestination } from './context.js'; | ||
|
||
describe('context', () => { | ||
afterEach(() => { | ||
nock.cleanAll(); | ||
}); | ||
|
||
it('should throw if client credentials are not fetched', async () => { | ||
mockClientCredentialsGrantCall( | ||
{ | ||
error: 'unauthorized', | ||
error_description: 'Bad credentials' | ||
}, | ||
401 | ||
); | ||
await expect(getAiCoreDestination()).rejects.toThrow( | ||
/Could not fetch client credentials token for service of type "aicore"/ | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export { | ||
executeRequest, | ||
BaseLlmParametersWithDeploymentId, | ||
BaseLlmParameters, | ||
CustomRequestConfig | ||
} from './http-client.js'; | ||
export { getAiCoreDestination } from './context.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist", | ||
"tsBuildInfoFile": "./dist/.tsbuildinfo", | ||
"composite": true | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["dist/**/*", "**/*.test.ts", "node_modules/**/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.