Skip to content

Commit da67ff4

Browse files
fix: sdk new package name and some small improvements (#1701)
* fix local sdk generation after introducing some new parameters on the backend and do some cleanup of appendToArrayField endpoint usage * bump sdk version and improve the local generation * rename the scicat-sdk-ts to scicat-sdk-ts-angular * fix linting issues * add some improvements in the dataset sharing process suggested by sourcery-ai * fix unit test types * fix failing tests and add some small improvements * try to revert the appendToDatasetArray changes * fix failing tests
1 parent 70d71d3 commit da67ff4

File tree

127 files changed

+209
-162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+209
-162
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@ngrx/router-store": "^16",
3636
"@ngrx/store": "^16",
3737
"@ngx-translate/core": "^16.0.4",
38-
"@scicatproject/scicat-sdk-ts": "^4.8.3",
38+
"@scicatproject/scicat-sdk-ts-angular": "^4.11.0",
3939
"autolinker": "^4.0.0",
4040
"deep-equal": "^2.0.5",
4141
"exceljs": "^4.3.0",

scripts/generate-nestjs-sdk.bash

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ USER=`who am i | cut -d\ -f1`
66
echo -e "\nUser running the script: ${USER}"
77

88
echo -e "\nCleanup old files..."
9-
rm -rf node_modules/@scicatproject/scicat-sdk-ts
10-
rm -rf @scicatproject/scicat-sdk-ts
9+
rm -rf node_modules/@scicatproject/scicat-sdk-ts-angular
10+
rm -rf @scicatproject/scicat-sdk-ts-angular
1111

1212
echo -e "\nGenerating the new sdk..."
1313
docker run \
@@ -17,8 +17,8 @@ docker run \
1717
openapitools/openapi-generator-cli:v7.9.0 generate \
1818
-i http://host.docker.internal:3000/explorer-json \
1919
-g typescript-angular \
20-
-o local/@scicatproject/scicat-sdk-ts \
21-
--additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true
20+
-o local/@scicatproject/scicat-sdk-ts-angular \
21+
--additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts-angular,supportsES6=true,npmVersion=10.8.2,withInterfaces=true
2222

2323
REMOVE_NPM_LINK=0
2424
if ! command -v npm 2>&1 1>/dev/null
@@ -38,16 +38,16 @@ then
3838
fi
3939

4040
echo -e "\nInstalling dependencies and building the sdk..."
41-
cd @scicatproject/scicat-sdk-ts
41+
cd @scicatproject/scicat-sdk-ts-angular
4242
npm install
4343
npm run build
4444

4545
echo -e "\nCopying the build files in node_modules..."
4646
cd ../..
47-
cp -rv @scicatproject/scicat-sdk-ts/dist node_modules/@scicatproject/scicat-sdk-ts
47+
cp -rv @scicatproject/scicat-sdk-ts-angular/dist node_modules/@scicatproject/scicat-sdk-ts-angular
4848

4949
echo -e "\nAdjusting ownership to user ${USER}"
50-
chown -Rv ${USER} node_modules/@scicatproject/scicat-sdk-ts
50+
chown -Rv ${USER} node_modules/@scicatproject/scicat-sdk-ts-angular
5151

5252
echo -e "\nFinal cleanup..."
5353
echo -e "Removing sdk folder"

scripts/generate-nestjs-sdk.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* NOTE: This file contains commands that generate new typescript-angular sdk against the running scicat backend
3-
* which overwrites the node_modules/@scicatproject/scicat-sdk-ts for development purpose
4-
* It should NOT be used in production because the real (@scicatproject/scicat-sdk-ts) npm package will be installed and used.
3+
* which overwrites the node_modules/@scicatproject/scicat-sdk-ts-angular for development purpose
4+
* It should NOT be used in production because the real (@scicatproject/scicat-sdk-ts-angular) npm package will be installed and used.
55
*/
66

77
const execSync = require("child_process").execSync;
@@ -20,31 +20,34 @@ function getCurrentDirectory() {
2020
}
2121

2222
if (isWindows()) {
23-
2423
// NOTE: First do some cleanup before starting the generation
2524
console.log("Cleanup old files...");
2625
execSync(
27-
"rm -rf node_modules/@scicatproject/scicat-sdk-ts && rm -rf @scicatproject/scicat-sdk-ts",
26+
"rm -rf node_modules/@scicatproject/scicat-sdk-ts-angular && rm -rf @scicatproject/scicat-sdk-ts-angular",
2827
{ encoding: "utf-8" },
2928
);
3029

3130
console.log("Generating the new sdk...");
31+
/**
32+
* NOTE: parameter --skip-validate-spec is passed to avoid some errors like not supporting the "content" in the @ApiQuery() parameter that we use in the dataset v4 controller.
33+
* This should not be a risk as after the generation we can get a feedback immediately if something is broken here when we run and test the frontend.
34+
*/
3235
const generationOutput = execSync(
33-
`docker run --rm --add-host host.docker.internal:host-gateway -v "${getCurrentDirectory()}:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i http://host.docker.internal:3000/explorer-json -g typescript-angular -o local/@scicatproject/scicat-sdk-ts --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true`,
36+
`docker run --rm --add-host host.docker.internal:host-gateway -v "${getCurrentDirectory()}:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i http://host.docker.internal:3000/explorer-json -g typescript-angular -o local/@scicatproject/scicat-sdk-ts-angular --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts-angular,supportsES6=true,npmVersion=10.8.2,withInterfaces=true,paramNaming=original,modelPropertyNaming=original,enumPropertyNaming=original --skip-validate-spec`,
3437
{ encoding: "utf-8" },
3538
);
3639
console.log(generationOutput);
3740

3841
console.log("Installing dependencies and building the sdk...");
3942
const installBuildOutput = execSync(
40-
"cd @scicatproject/scicat-sdk-ts && npm install && npm run build",
43+
"cd @scicatproject/scicat-sdk-ts-angular && npm install && npm run build",
4144
{ encoding: "utf-8" },
42-
);
45+
);
4346
console.log(installBuildOutput);
4447

4548
console.log("Copying the build files in node_modules...");
4649
const copyToNodeModulesOutput = execSync(
47-
"cp -r @scicatproject/scicat-sdk-ts/dist node_modules/@scicatproject/scicat-sdk-ts",
50+
"cp -r @scicatproject/scicat-sdk-ts-angular/dist node_modules/@scicatproject/scicat-sdk-ts-angular",
4851
{ encoding: "utf-8" },
4952
);
5053
console.log(copyToNodeModulesOutput);
@@ -55,14 +58,13 @@ if (isWindows()) {
5558
});
5659

5760
console.log("Local SDK generation completed");
58-
5961
} else {
6062
console.log("Your environment is a linux/unix");
6163
console.log("Please run the following command on your terminal:");
6264
console.log("> sudo -E ./scripts/generate-nestjs-sdk.bash");
6365
console.log("");
64-
console.log("IMPORTANT: the script runs under sudo. You will be asked your password.");
66+
console.log(
67+
"IMPORTANT: the script runs under sudo. You will be asked your password.",
68+
);
6569
console.log("");
66-
6770
}
68-

src/app/app-routing/auth.guard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ActivatedRouteSnapshot,
66
RouterStateSnapshot,
77
} from "@angular/router";
8-
import { UsersService } from "@scicatproject/scicat-sdk-ts";
8+
import { UsersService } from "@scicatproject/scicat-sdk-ts-angular";
99

1010
/**
1111
* Ensure that the current user is logged in

src/app/app.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { MockStore } from "./shared/MockStubs";
77
import { APP_CONFIG } from "./app-config.module";
88
import { MatProgressSpinnerModule } from "@angular/material/progress-spinner";
99
import { AppConfigService } from "app-config.service";
10-
import { Configuration } from "@scicatproject/scicat-sdk-ts";
10+
import { Configuration } from "@scicatproject/scicat-sdk-ts-angular";
1111

1212
describe("AppComponent", () => {
1313
const getConfig = () => ({

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
} from "state-management/selectors/user.selectors";
2525
import { MessageType } from "state-management/models";
2626
import { AppConfigService, AppConfig as Config } from "app-config.service";
27-
import { Configuration } from "@scicatproject/scicat-sdk-ts";
27+
import { Configuration } from "@scicatproject/scicat-sdk-ts-angular";
2828

2929
@Component({
3030
selector: "app-root",

src/app/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { HttpClientModule, HTTP_INTERCEPTORS } from "@angular/common/http";
99
import { APP_INITIALIZER, NgModule } from "@angular/core";
1010
import { ExtraOptions, RouterModule } from "@angular/router";
1111
import { StoreModule } from "@ngrx/store";
12-
import { ApiModule, Configuration } from "@scicatproject/scicat-sdk-ts";
12+
import { ApiModule, Configuration } from "@scicatproject/scicat-sdk-ts-angular";
1313
import { routerReducer } from "@ngrx/router-store";
1414
import { extModules } from "./build-specifics";
1515
import { MatNativeDateModule } from "@angular/material/core";

src/app/datasets/admin-tab/admin-tab.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { take } from "rxjs/operators";
66
import {
77
CreateJobDto,
88
OutputDatasetObsoleteDto,
9-
} from "@scicatproject/scicat-sdk-ts";
9+
} from "@scicatproject/scicat-sdk-ts-angular";
1010
import { submitJobAction } from "state-management/actions/jobs.actions";
1111
import {
1212
selectCurrentDatablocks,

src/app/datasets/archiving.service.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import {
1010
import { JobsState } from "state-management/state/jobs.store";
1111
import { ArchivingService } from "./archiving.service";
1212
import { createMock, mockDataset } from "shared/MockStubs";
13-
import { CreateJobDto, ReturnedUserDto } from "@scicatproject/scicat-sdk-ts";
13+
import {
14+
CreateJobDto,
15+
ReturnedUserDto,
16+
} from "@scicatproject/scicat-sdk-ts-angular";
1417

1518
describe("ArchivingService", () => {
1619
let service: ArchivingService;

0 commit comments

Comments
 (0)