Skip to content

Commit

Permalink
chore: Split into multi-module structure (#10)
Browse files Browse the repository at this point in the history
* split

* Update adr/002-project-structure.md

Co-authored-by: Junjie Tang <[email protected]>

* fix naming

* update lock

* fix test

* remove poc

* lint

* lint command

* fix

* fix path

* fix: Changes from lint

---------

Co-authored-by: Junjie Tang <[email protected]>
Co-authored-by: cloud-sdk-js <[email protected]>
  • Loading branch information
3 people authored Jul 8, 2024
1 parent 324f662 commit 7c3c5aa
Show file tree
Hide file tree
Showing 359 changed files with 1,311 additions and 2,997 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-fix-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ jobs:
if [ ! -z "$diff" ]; then
git config --global user.email "[email protected]"
git config --global user.name "cloud-sdk-js"
git commit -m "Changes from lint:fix" -a
git commit -m "fix: Changes from lint" -a
git push
fi
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
node-version: ${{ vars.DEFAULT_NODE_VERSION }}
cache: 'pnpm'
- run: pnpm i --frozen-lockfile
- run: pnpm compile
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }}
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
dist/
coverage/
pnpm-lock.yaml
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"endOfLine": "lf",
"overrides": [
{
"files": "jest.config.ts",
"files": "jest.config.mjs",
"options": {
"trailingComma": "all"
}
Expand Down
17 changes: 17 additions & 0 deletions adr/002-project-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Project Structure of the SAP AI SDK for JS

## Modules

- @sap-ai-sdk/ai-core
- AI Core generated client + types
- Utility functions (if any)
- @sap-ai-sdk/gen-ai-hub
- Orchestration generated client
- Wrappers/Utility functions
- Client for LLM Access (Azure Openai and its types (Chat/Embeddings))
- Depend on @sap-ai-sdk/ai-core for fetching deploymentID (+other cases) in the future
- Common Http client code + types
- Get ai-core service binding logic



4 changes: 2 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import flatConfig from '@sap-cloud-sdk/eslint-config/flat-config.js';
export default [
...flatConfig,
{
ignores: ['dist/', 'poc/']
ignores: ['**/dist/**/*', '**/coverage/**/*', 'packages/ai-core/src/'],
},
{
files: ['test-util/**/*.ts'],
files: ['**/test-util/**/*.ts'],
rules: {
'jsdoc/require-jsdoc': 'off'
}
Expand Down
4 changes: 1 addition & 3 deletions jest.config.ts → jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* https://jestjs.io/docs/configuration.
*/

import type { JestConfigWithTsJest } from 'ts-jest';

const config: JestConfigWithTsJest = {
const config = {
// All imported modules in your tests should be mocked automatically
// automock: false,

Expand Down
20 changes: 7 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
{
"name": "ai-sdk-js",
"name": "sap-ai-sdk",
"version": "0.0.1",
"description": "",
"keywords": [],
"license": "Apache-2.0",
"repository": "github:SAP/ai-sdk-js",
"private": true,
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"types": "type-tests",
"tsd": {
"directory": "type-tests"
},
"files": [
"dist/**/*.js",
"dist/**/*.js.map",
"dist/**/*.d.ts",
"dist/**/*.d.ts.map"
],
"scripts": {
"postinstall": "pnpm compile",
"postinstall": "pnpm -r -w=false run compile",
"compile": "tsc",
"test": "jest",
"test": "pnpm -r run test",
"test:type": "tsd",
"lint": "eslint . && prettier . -c",
"lint:fix": "eslint . --fix && prettier . -w --log-level error"
"lint": "pnpm -r run lint",
"lint:fix": "pnpm -r run lint:fix"
},
"dependencies": {
"@sap-cloud-sdk/connectivity": "^3.16.0",
Expand Down
Empty file added packages/ai-core/README.md
Empty file.
7 changes: 7 additions & 0 deletions packages/ai-core/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import config from '../../jest.config.mjs';
const aiCoreConfig = {
...config,
displayName: 'ai-core',
};

export default aiCoreConfig;
31 changes: 31 additions & 0 deletions packages/ai-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@sap-ai-sdk/ai-core",
"version": "0.0.1",
"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": "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/openapi": "^3.16.0"
},
"devDependencies": {
"typescript": "^5.5.3"
}
}
File renamed without changes.
5 changes: 5 additions & 0 deletions packages/ai-core/src/ai-core.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('test', () => {
it('should work', () => {
expect(true).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
ArgoCDApplicationModificationResponse,
ArgoCDApplicationDeletionResponse,
ArgoCDApplicationRefreshResponse
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'ApplicationApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
ArtifactPostData,
ArtifactCreationResponse,
Artifact
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'ArtifactApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
ConfigurationBaseData,
ConfigurationCreationResponse,
Configuration
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'ConfigurationApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
DeploymentModificationResponse,
DeploymentDeletionResponse,
LogCommonResponse
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'DeploymentApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
DockerRegistrySecretStatusResponse,
Body1,
DockerRegistrySecretCreationResponse
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'DockerRegistrySecretApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type { ExecutableList, Executable } from './schema';
import type { ExecutableList, Executable } from './schema/index.js';
/**
* Representation of the 'ExecutableApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
ExecutionModificationResponse,
ExecutionDeletionResponse,
LogCommonResponse
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'ExecutionApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
ExecutionScheduleModificationRequest,
ExecutionScheduleModificationResponse,
ExecutionScheduleDeletionResponse
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'ExecutionScheduleApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type { FileCreationResponse } from './schema';
import type { FileCreationResponse } from './schema/index.js';
/**
* Representation of the 'FileApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
26 changes: 26 additions & 0 deletions packages/ai-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved.
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
export * from './artifact-api.js';
export * from './configuration-api.js';
export * from './deployment-api.js';
export * from './execution-api.js';
export * from './execution-schedule-api.js';
export * from './scenario-api.js';
export * from './executable-api.js';
export * from './meta-api.js';
export * from './metrics-api.js';
export * from './kpi-api.js';
export * from './file-api.js';
export * from './object-store-secret-api.js';
export * from './secret-api.js';
export * from './resource-group-api.js';
export * from './resource-api.js';
export * from './repository-api.js';
export * from './application-api.js';
export * from './docker-registry-secret-api.js';
export * from './service-api.js';
export * from './resource-quota-api.js';
export * from './schema/index.js';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type { ResultSet, ArrayOfColumnNames } from './schema';
import type { ResultSet, ArrayOfColumnNames } from './schema/index.js';
/**
* Representation of the 'KPIApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type { Capabilities } from './schema';
import type { Capabilities } from './schema/index.js';
/**
* Representation of the 'MetaApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
MetricSelectorPermissibleValues,
DeleteMetricsResponse,
ExecutionId2
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'MetricsApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
ObjectStoreSecretWithSensitiveDataRequest,
ObjectStoreSecretModificationResponse,
ObjectStoreSecretDeletionResponse
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'ObjectStoreSecretApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
ArgoCDRepositoryCredentials,
ArgoCDRepositoryModificationResponse,
ArgoCDRepositoryDeletionResponse
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'RepositoryApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
ResourceGetResponse,
ResourcePatchBody,
ResourcePatchResponse
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'ResourceApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
ResourceGroup,
ResourceGroupPatchRequest,
ResourceGroupDeletionResponse
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'ResourceGroupApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type {
CommonResourceQuotaResponse,
ExecutableResourceQuotaResponse
} from './schema';
} from './schema/index.js';
/**
* Representation of the 'ResourceQuotaApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type { ScenarioList, Scenario, VersionList } from './schema';
import type { ScenarioList, Scenario, VersionList } from './schema/index.js';
/**
* Representation of the 'ScenarioApi'.
* This API is part of the 'AI_CORE_API' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import type { AiApiCapabilitiesLogs } from './ai-api-capabilities-logs';
import type { AiApiCapabilitiesBulkUpdates } from './ai-api-capabilities-bulk-updates';
import type { AiApiCapabilitiesLogs } from './ai-api-capabilities-logs.js';
import type { AiApiCapabilitiesBulkUpdates } from './ai-api-capabilities-bulk-updates.js';
/**
* Representation of the 'AiApiCapabilities' schema.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import type { AiApiLimitsExecutions } from './ai-api-limits-executions';
import type { AiApiLimitsDeployments } from './ai-api-limits-deployments';
import type { AiApiLimitsTimeToLiveDeployments } from './ai-api-limits-time-to-live-deployments';
import type { AiApiLimitsExecutions } from './ai-api-limits-executions.js';
import type { AiApiLimitsDeployments } from './ai-api-limits-deployments.js';
import type { AiApiLimitsTimeToLiveDeployments } from './ai-api-limits-time-to-live-deployments.js';
/**
* Representation of the 'AiApiLimits' schema.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import type { Spec } from './spec';
import type { AiApiCapabilities } from './ai-api-capabilities';
import type { AiApiLimits } from './ai-api-limits';
import type { Spec } from './spec.js';
import type { AiApiCapabilities } from './ai-api-capabilities.js';
import type { AiApiLimits } from './ai-api-limits.js';
/**
* There are (currently) the following types of execution engines 1) complete runtimes that offer executions and deployments, 2) runtimes that do only batch inference and therefore don't support deployments 3) runtimes that allow deployments, but with predefined models and therefore don't need executions 4) runtimes that have fixed endpoints and therefore only need listing deployments
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import type { DetailsErrorResponse } from './details-error-response';
import type { DetailsErrorResponse } from './details-error-response.js';
/**
* Representation of the 'ApiError2' schema.
*/
Expand Down
Loading

0 comments on commit 7c3c5aa

Please sign in to comment.