diff --git a/.gitignore b/.gitignore index e073da107..f2e6073af 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /out-tsc # Only exists if Bazel was run /bazel-out +@scicatproject/ # dependencies /node_modules diff --git a/cypress.config.ts b/cypress.config.ts index 0e0788840..d2728dcc2 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -2,9 +2,9 @@ import { defineConfig } from "cypress"; export default defineConfig({ env: { - lbBaseUrl: "http://localhost:3000/api/v3", - lbLoginEndpoint: "/auth/login", - lbTokenPrefix: "Bearer ", + baseUrl: "http://localhost:3000/api/v3", + loginEndpoint: "/auth/login", + tokenPrefix: "Bearer", username: "admin", password: "27f5fd86ae68fe740eef42b8bbd1d7d5", secondaryUsername: "archiveManager", diff --git a/cypress/e2e/datasets/datasets-attachment.cy.js b/cypress/e2e/datasets/datasets-attachment.cy.js index 60b535f4f..674cf2fc9 100644 --- a/cypress/e2e/datasets/datasets-attachment.cy.js +++ b/cypress/e2e/datasets/datasets-attachment.cy.js @@ -4,7 +4,7 @@ describe("Dataset attachments", () => { beforeEach(() => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.intercept("POST", "/api/v3/Datasets/**/*").as("upload"); + cy.intercept("POST", "/api/v3/datasets/**/*").as("upload"); }); after(() => { diff --git a/cypress/e2e/datasets/datasets-datafiles.cy.js b/cypress/e2e/datasets/datasets-datafiles.cy.js index 980614a0b..baee6c5b6 100644 --- a/cypress/e2e/datasets/datasets-datafiles.cy.js +++ b/cypress/e2e/datasets/datasets-datafiles.cy.js @@ -1,7 +1,7 @@ describe("Dataset datafiles", () => { beforeEach(() => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.intercept("PATCH", "/api/v3/Datasets/**/*").as("change"); + cy.intercept("PATCH", "/api/v3/datasets/**/*").as("change"); cy.intercept("GET", "*").as("fetch"); }); diff --git a/cypress/e2e/datasets/datasets-keyword.cy.js b/cypress/e2e/datasets/datasets-keyword.cy.js index af633d877..ff464d669 100644 --- a/cypress/e2e/datasets/datasets-keyword.cy.js +++ b/cypress/e2e/datasets/datasets-keyword.cy.js @@ -2,7 +2,7 @@ describe("Datasets", () => { beforeEach(() => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.intercept("PATCH", "/api/v3/Datasets/**/*").as("keyword"); + cy.intercept("PATCH", "/api/v3/datasets/**/*").as("keyword"); cy.intercept("GET", "*").as("fetch"); }); diff --git a/cypress/e2e/datasets/datasets-metadata.cy.js b/cypress/e2e/datasets/datasets-metadata.cy.js index 0c476fd9d..59541194a 100644 --- a/cypress/e2e/datasets/datasets-metadata.cy.js +++ b/cypress/e2e/datasets/datasets-metadata.cy.js @@ -12,7 +12,7 @@ describe("Datasets", () => { beforeEach(() => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.intercept("PATCH", "/api/v3/Datasets/**/*").as("metadata"); + cy.intercept("PATCH", "/api/v3/datasets/**/*").as("metadata"); cy.intercept("GET", "*").as("fetch"); }); @@ -67,6 +67,8 @@ describe("Datasets", () => { cy.get("button[data-cy=save-changes-button]").click(); + cy.finishedLoading(); + cy.wait("@metadata").then(({ request, response }) => { expect(request.method).to.eq("PATCH"); expect(response.statusCode).to.eq(200); diff --git a/cypress/e2e/datasets/datasets-public.cy.js b/cypress/e2e/datasets/datasets-public.cy.js index e1b747e83..8932d28f3 100644 --- a/cypress/e2e/datasets/datasets-public.cy.js +++ b/cypress/e2e/datasets/datasets-public.cy.js @@ -4,7 +4,7 @@ describe("Datasets", () => { cy.createDataset("raw"); - cy.intercept("PATCH", "/api/v3/Datasets/**/*").as("change"); + cy.intercept("PATCH", "/api/v3/datasets/**/*").as("change"); cy.intercept("GET", "*").as("fetch"); }); diff --git a/cypress/e2e/datasets/datasets-reduce.cy.js b/cypress/e2e/datasets/datasets-reduce.cy.js index 8b55fa897..2b2512aa4 100644 --- a/cypress/e2e/datasets/datasets-reduce.cy.js +++ b/cypress/e2e/datasets/datasets-reduce.cy.js @@ -2,7 +2,7 @@ describe("Datasets", () => { beforeEach(() => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.intercept("PATCH", "/api/v3/Datasets/**/*").as("metadata"); + cy.intercept("PATCH", "/api/v3/datasets/**/*").as("metadata"); cy.intercept("GET", "*").as("fetch"); }); diff --git a/cypress/e2e/other/policy-delegate.cy.js b/cypress/e2e/other/policy-delegate.cy.js index 5d62b4859..9dce64d77 100644 --- a/cypress/e2e/other/policy-delegate.cy.js +++ b/cypress/e2e/other/policy-delegate.cy.js @@ -2,7 +2,7 @@ describe("Policies", () => { beforeEach(() => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.intercept("POST", "/api/v3/Policies/**/*").as("update"); + cy.intercept("POST", "/api/v3/policies/**/*").as("update"); cy.intercept("GET", "*").as("fetch"); }); diff --git a/cypress/e2e/other/users-login.cy.js b/cypress/e2e/other/users-login.cy.js index edaa2c59f..34a9bb05d 100644 --- a/cypress/e2e/other/users-login.cy.js +++ b/cypress/e2e/other/users-login.cy.js @@ -5,7 +5,7 @@ describe("Users Login", () => { const guestUsername = Cypress.env("guestUsername"); const guestPassword = Cypress.env("guestPassword"); - const loginEndpoint = Cypress.env("lbLoginEndpoint"); + const loginEndpoint = Cypress.env("loginEndpoint"); beforeEach(() => { cy.intercept("POST", "**/auth/msad").as("adLogin"); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index a90ce1d01..a20ebd915 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -1,8 +1,12 @@ import { testData } from "../fixtures/testData"; -const lbBaseUrl = Cypress.env("lbBaseUrl"); -const loginEndpoint = Cypress.env("lbLoginEndpoint"); -const accessTokenPrefix = Cypress.env("lbTokenPrefix"); +const lbBaseUrl = Cypress.env("baseUrl"); +const loginEndpoint = Cypress.env("loginEndpoint"); +const accessTokenPrefix = Cypress.env("tokenPrefix"); + +Cypress.Commands.add("getToken", () => { + return cy.getCookie("id").then((id) => `${accessTokenPrefix} ${id.value}`); +}); Cypress.Commands.add("login", (username, password) => { cy.request("POST", lbBaseUrl + loginEndpoint, { @@ -14,24 +18,19 @@ Cypress.Commands.add("login", (username, password) => { .as("user"); cy.get("@user").then((user) => { - cy.setCookie("$LoopBackSDK$created", user.created); - cy.setCookie("$LoopBackSDK$id", accessTokenPrefix + user.id); - cy.setCookie("$LoopBackSDK$ttl", user.ttl.toString()); - cy.setCookie( - "$LoopBackSDK$user", - encodeURIComponent(JSON.stringify(user.user)), - ); - cy.setCookie("$LoopBackSDK$userId", user.userId); + cy.setCookie("created", user.created); + cy.setCookie("id", user.id); + cy.setCookie("ttl", user.ttl.toString()); + cy.setCookie("user", encodeURIComponent(JSON.stringify(user.user))); + cy.setCookie("userId", user.userId); }); }); Cypress.Commands.add("createPolicy", (ownerGroup) => { - cy.getCookie("$LoopBackSDK$user").then((userCookie) => { + cy.getCookie("user").then((userCookie) => { const user = JSON.parse(decodeURIComponent(userCookie.value)); - cy.getCookie("$LoopBackSDK$id").then((idCookie) => { - const token = idCookie.value; - + cy.getToken().then((token) => { const policy = testData.policy; policy.manager = ["_cypress", user.email]; policy.ownerGroup = ownerGroup; @@ -52,9 +51,7 @@ Cypress.Commands.add("createPolicy", (ownerGroup) => { Cypress.Commands.add("removePolicies", () => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.getCookie("$LoopBackSDK$id").then((cookie) => { - const token = cookie.value; - + cy.getToken().then((token) => { const filter = { where: { ownerGroup: "cypress" } }; cy.request({ @@ -76,15 +73,14 @@ Cypress.Commands.add("removePolicies", () => { Cypress.env("secondaryUsername"), Cypress.env("secondaryPassword"), ); - cy.getCookie("$LoopBackSDK$id").then((deletionCookie) => { - const deletionToken = deletionCookie.value; + cy.getToken().then((token) => { cy.get("@policies").then((policies) => { policies.forEach((policy) => { cy.request({ method: "DELETE", url: lbBaseUrl + "/Policies/" + encodeURIComponent(policy.id), headers: { - Authorization: deletionToken, + Authorization: token, Accept: "application/json", "Content-Type": "application/json", }, @@ -113,12 +109,10 @@ Cypress.Commands.add("isLoading", (type) => { Cypress.Commands.add( "createDataset", (type, proposalId = "20170266", dataFileSize = "small") => { - cy.getCookie("$LoopBackSDK$user").then((userCookie) => { + cy.getCookie("user").then((userCookie) => { const user = JSON.parse(decodeURIComponent(userCookie.value)); - cy.getCookie("$LoopBackSDK$id").then((idCookie) => { - const token = idCookie.value; - + cy.getToken().then((token) => { if (type === "raw") { const dataset = testData.rawDataset; dataset.proposalId = proposalId; @@ -127,7 +121,7 @@ Cypress.Commands.add( cy.request({ method: "POST", - url: lbBaseUrl + "/Datasets", + url: lbBaseUrl + "/datasets", headers: { Authorization: token, Accept: "application/json", @@ -163,7 +157,7 @@ Cypress.Commands.add( cy.request({ method: "POST", - url: lbBaseUrl + "/Datasets", + url: lbBaseUrl + "/datasets", headers: { Authorization: token, Accept: "application/json", @@ -177,11 +171,10 @@ Cypress.Commands.add( }, ); Cypress.Commands.add("createProposal", (proposal) => { - return cy.getCookie("$LoopBackSDK$user").then((userCookie) => { + return cy.getCookie("user").then((userCookie) => { const user = JSON.parse(decodeURIComponent(userCookie.value)); - cy.getCookie("$LoopBackSDK$id").then((idCookie) => { - const token = idCookie.value; + cy.getToken().then((token) => { cy.log("Proposal: " + JSON.stringify(proposal, null, 2)); cy.log("User: " + JSON.stringify(user, null, 2)); @@ -199,11 +192,10 @@ Cypress.Commands.add("createProposal", (proposal) => { }); }); Cypress.Commands.add("updateProposal", (proposalId, updateProposalDto) => { - return cy.getCookie("$LoopBackSDK$user").then((userCookie) => { + return cy.getCookie("user").then((userCookie) => { const user = JSON.parse(decodeURIComponent(userCookie.value)); - cy.getCookie("$LoopBackSDK$id").then((idCookie) => { - const token = idCookie.value; + cy.getToken().then((token) => { cy.log( "Update proposal DTO: " + JSON.stringify(updateProposalDto, null, 2), ); @@ -224,9 +216,7 @@ Cypress.Commands.add("updateProposal", (proposalId, updateProposalDto) => { }); Cypress.Commands.add("deleteProposal", (id) => { - cy.getCookie("$LoopBackSDK$id").then((idCookie) => { - const token = idCookie.value; - + cy.getToken().then((token) => { cy.request({ method: "DELETE", url: lbBaseUrl + `/Proposals/${encodeURIComponent(id)}`, @@ -241,16 +231,14 @@ Cypress.Commands.add("deleteProposal", (id) => { Cypress.Commands.add("removeDatasets", () => { cy.login(Cypress.env("secondaryUsername"), Cypress.env("secondaryPassword")); - cy.getCookie("$LoopBackSDK$id").then((cookie) => { - const token = cookie.value; - + cy.getToken().then((token) => { const filter = { where: { datasetName: "Cypress Dataset" } }; cy.request({ method: "GET", url: lbBaseUrl + - "/Datasets?filter=" + + "/datasets?filter=" + encodeURIComponent(JSON.stringify(filter)), headers: { Authorization: token, @@ -265,7 +253,7 @@ Cypress.Commands.add("removeDatasets", () => { datasets.forEach((dataset) => { cy.request({ method: "DELETE", - url: lbBaseUrl + "/Datasets/" + encodeURIComponent(dataset.pid), + url: lbBaseUrl + "/datasets/" + encodeURIComponent(dataset.pid), headers: { Authorization: token, Accept: "application/json", @@ -279,9 +267,7 @@ Cypress.Commands.add("removeDatasets", () => { Cypress.Commands.add("removeProposals", () => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.getCookie("$LoopBackSDK$id").then((cookie) => { - const token = cookie.value; - + cy.getToken().then((token) => { const filter = { where: { title: testData.proposal.title } }; cy.request({ @@ -304,8 +290,7 @@ Cypress.Commands.add("removeProposals", () => { Cypress.env("secondaryUsername"), Cypress.env("secondaryPassword"), ); - cy.getCookie("$LoopBackSDK$id").then((cookie) => { - const archiveManagerToken = cookie.value; + cy.getToken().then((token) => { proposals.forEach((proposal) => { cy.request({ method: "DELETE", @@ -314,7 +299,7 @@ Cypress.Commands.add("removeProposals", () => { "/proposals/" + encodeURIComponent(proposal.proposalId), headers: { - Authorization: archiveManagerToken, + Authorization: token, Accept: "application/json", "Content-Type": "application/json", }, @@ -327,9 +312,7 @@ Cypress.Commands.add("removeProposals", () => { Cypress.Commands.add("removeSamples", () => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.getCookie("$LoopBackSDK$id").then((cookie) => { - const token = cookie.value; - + cy.getToken().then((token) => { const filter = { where: { description: "Cypress Sample" } }; cy.request({ @@ -351,15 +334,14 @@ Cypress.Commands.add("removeSamples", () => { Cypress.env("secondaryUsername"), Cypress.env("secondaryPassword"), ); - cy.getCookie("$LoopBackSDK$id").then((deletionCookie) => { - const deletionToken = deletionCookie.value; + cy.getToken().then((token) => { cy.get("@samples").then((samples) => { samples.forEach((sample) => { cy.request({ method: "DELETE", url: lbBaseUrl + "/Samples/" + sample.sampleId, headers: { - Authorization: deletionToken, + Authorization: token, Accept: "application/json", "Content-Type": "application/json", }, @@ -372,9 +354,7 @@ Cypress.Commands.add("removeSamples", () => { Cypress.Commands.add("initializeElasticSearch", (index) => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.getCookie("$LoopBackSDK$id").then((idCookie) => { - const token = idCookie.value; - + cy.getToken().then((token) => { cy.request({ method: "POST", url: lbBaseUrl + "/elastic-search" + "/create-index" + "?index=" + index, @@ -399,12 +379,10 @@ Cypress.Commands.add("initializeElasticSearch", (index) => { }); Cypress.Commands.add("createDatasetForElasticSearch", (datasetName) => { - cy.getCookie("$LoopBackSDK$user").then((userCookie) => { + cy.getCookie("user").then((userCookie) => { const user = JSON.parse(decodeURIComponent(userCookie.value)); - cy.getCookie("$LoopBackSDK$id").then((idCookie) => { - const token = idCookie.value; - + cy.getToken().then((token) => { const dataset = testData.rawDataset; dataset.datasetName = datasetName; cy.log("Raw Dataset 1: " + JSON.stringify(dataset, null, 2)); @@ -412,7 +390,7 @@ Cypress.Commands.add("createDatasetForElasticSearch", (datasetName) => { cy.request({ method: "POST", - url: lbBaseUrl + "/Datasets", + url: lbBaseUrl + "/datasets", headers: { Authorization: token, Accept: "application/json", @@ -426,8 +404,7 @@ Cypress.Commands.add("createDatasetForElasticSearch", (datasetName) => { Cypress.Commands.add("removeElasticSearchIndex", (index) => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.getCookie("$LoopBackSDK$id").then((idCookie) => { - const token = idCookie.value; + cy.getToken().then((token) => { cy.request({ method: "POST", url: lbBaseUrl + "/elastic-search" + "/delete-index" + "?index=" + index, @@ -442,16 +419,14 @@ Cypress.Commands.add("removeElasticSearchIndex", (index) => { Cypress.Commands.add("removeDatasetsForElasticSearch", (datasetName) => { cy.login(Cypress.env("username"), Cypress.env("password")); - cy.getCookie("$LoopBackSDK$id").then((cookie) => { - const token = cookie.value; - + cy.getToken().then((token) => { const filter = { where: { datasetName } }; cy.request({ method: "GET", url: lbBaseUrl + - "/Datasets?filter=" + + "/datasets?filter=" + encodeURIComponent(JSON.stringify(filter)), headers: { Authorization: token, @@ -466,13 +441,12 @@ Cypress.Commands.add("removeDatasetsForElasticSearch", (datasetName) => { Cypress.env("secondaryUsername"), Cypress.env("secondaryPassword"), ); - cy.getCookie("$LoopBackSDK$id").then((deletionCookie) => { - const token = deletionCookie.value; + cy.getToken().then((token) => { cy.get("@datasets").then((datasets) => { datasets.forEach((dataset) => { cy.request({ method: "DELETE", - url: lbBaseUrl + "/Datasets/" + encodeURIComponent(dataset.pid), + url: lbBaseUrl + "/datasets/" + encodeURIComponent(dataset.pid), headers: { Authorization: token, Accept: "application/json", diff --git a/package-lock.json b/package-lock.json index baec292e6..a2f428663 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "@ngrx/effects": "^16", "@ngrx/router-store": "^16", "@ngrx/store": "^16", + "@scicatproject/scicat-sdk-ts": "^4.7.2", "autolinker": "^4.0.0", "deep-equal": "^2.0.5", "exceljs": "^4.3.0", @@ -34,6 +35,7 @@ "lodash-es": "^4.17.21", "luxon": "^3.3.0", "mathjs": "^14.0.0", + "ngx-cookie-service": "^16.1.0", "ngx-json-viewer": "^3", "ngx-linky": "^4.0.0", "ngx-material-luxon": "^1.1.1", @@ -60,7 +62,7 @@ "@types/deep-equal": "^1.0.1", "@types/file-saver": "^2.0.2", "@types/jasmine": "^5.1.0", - "@types/lodash": "^4.14.172", + "@types/lodash-es": "^4.17.12", "@types/luxon": "^3.3.0", "@types/node": "^22.0.0", "@types/shortid": "2.2.0", @@ -4985,6 +4987,18 @@ "yarn": ">= 1.13.0" } }, + "node_modules/@scicatproject/scicat-sdk-ts": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/@scicatproject/scicat-sdk-ts/-/scicat-sdk-ts-4.7.2.tgz", + "integrity": "sha512-1WhHnL+YPY6hPxzWOHJf2A6eL0a6WmTar0zX8EQbG9ZUMbFwVjIdtTZGzJrCjd42d+b5lHI2aAB2ZAymN5Qczw==", + "dependencies": { + "tslib": "^2.3.0" + }, + "peerDependencies": { + "@angular/core": "^16.2.12", + "rxjs": "^7.4.0" + } + }, "node_modules/@sigstore/bundle": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@sigstore/bundle/-/bundle-1.1.0.tgz", @@ -5345,6 +5359,16 @@ "integrity": "sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg==", "dev": true }, + "node_modules/@types/lodash-es": { + "version": "4.17.12", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz", + "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/luxon": { "version": "3.4.2", "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.4.2.tgz", @@ -14312,6 +14336,19 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node_modules/ngx-cookie-service": { + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/ngx-cookie-service/-/ngx-cookie-service-16.1.0.tgz", + "integrity": "sha512-FrzMjsGCHZCd2sEucigMaGyzImBL0l6gwWn6jmLBhcNVx0D7P8Yvtgk9aUptlqBrVKy4c2upglSa3Ogv3679bw==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "@angular/common": "^16.0.0", + "@angular/core": "^16.0.0" + } + }, "node_modules/ngx-json-viewer": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ngx-json-viewer/-/ngx-json-viewer-3.2.1.tgz", diff --git a/package.json b/package.json index 71f9d15d1..53f936cb9 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "lint:fix": "ng lint --fix", "betterer": "betterer", "cypress:open": "cypress open", - "cypress:run": "cypress run" + "cypress:run": "cypress run", + "generate:sdk:local": "node scripts/generate-nestjs-sdk" }, "private": true, "dependencies": { @@ -33,6 +34,7 @@ "@ngrx/effects": "^16", "@ngrx/router-store": "^16", "@ngrx/store": "^16", + "@scicatproject/scicat-sdk-ts": "^4.7.2", "autolinker": "^4.0.0", "deep-equal": "^2.0.5", "exceljs": "^4.3.0", @@ -41,6 +43,7 @@ "lodash-es": "^4.17.21", "luxon": "^3.3.0", "mathjs": "^14.0.0", + "ngx-cookie-service": "^16.1.0", "ngx-json-viewer": "^3", "ngx-linky": "^4.0.0", "ngx-material-luxon": "^1.1.1", @@ -67,7 +70,7 @@ "@types/deep-equal": "^1.0.1", "@types/file-saver": "^2.0.2", "@types/jasmine": "^5.1.0", - "@types/lodash": "^4.14.172", + "@types/lodash-es": "^4.17.12", "@types/luxon": "^3.3.0", "@types/node": "^22.0.0", "@types/shortid": "2.2.0", diff --git a/scripts/generate-nestjs-sdk.bash b/scripts/generate-nestjs-sdk.bash new file mode 100755 index 000000000..bfa6ba726 --- /dev/null +++ b/scripts/generate-nestjs-sdk.bash @@ -0,0 +1,62 @@ +#!/bin/bash +# +# + +USER=`who am i | cut -d\ -f1` +echo -e "\nUser running the script: ${USER}" + +echo -e "\nCleanup old files..." +rm -rf node_modules/@scicatproject/scicat-sdk-ts +rm -rf @scicatproject/scicat-sdk-ts + +echo -e "\nGenerating the new sdk..." +docker run \ + --rm \ + --add-host host.docker.internal:host-gateway \ + -v "`pwd`:/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 + +REMOVE_NPM_LINK=0 +if ! command -v npm 2>&1 1>/dev/null +then + if [ "--`env | grep NVM_BIN`--" != "----" ] + then + echo -e "\nCreating links to npm and node versions" + ln -s "$NVM_BIN/npm" "/usr/local/bin/npm" + whereis npm + ln -s "$NVM_BIN/node" "/usr/local/bin/node" + whereis node + REMOVE_NPM_LINK=1 + else + echo -e "\nNo npm found!!!" + exit 1 + fi +fi + +echo -e "\nInstalling dependencies and building the sdk..." +cd @scicatproject/scicat-sdk-ts +npm install +npm run build + +echo -e "\nCopying the build files in node_modules..." +cd ../.. +cp -rv @scicatproject/scicat-sdk-ts/dist node_modules/@scicatproject/scicat-sdk-ts + +echo -e "\nAdjusting ownership to user ${USER}" +chown -Rv ${USER} node_modules/@scicatproject/scicat-sdk-ts + +echo -e "\nFinal cleanup..." +echo -e "Removing sdk folder" +rm -rfv @scicatproject + +if [ $REMOVE_NPM_LINK -eq 1 ]; +then + echo -e "\nRemoving links to npm and node" + rm -fv "/usr/local/bin/npm" + rm -fv "/usr/local/bin/node" +fi + diff --git a/scripts/generate-nestjs-sdk.js b/scripts/generate-nestjs-sdk.js new file mode 100644 index 000000000..738d73aa8 --- /dev/null +++ b/scripts/generate-nestjs-sdk.js @@ -0,0 +1,68 @@ +/** + * NOTE: This file contains commands that generate new typescript-angular sdk against the running scicat backend + * which overwrites the node_modules/@scicatproject/scicat-sdk-ts for development purpose + * It should NOT be used in production because the real (@scicatproject/scicat-sdk-ts) npm package will be installed and used. + */ + +const execSync = require("child_process").execSync; +const os = require("os"); + +function isWindows() { + return os.platform() === "win32"; +} + +function getCurrentDirectory() { + if (isWindows()) { + return "%cd%"; + } + + return "$(pwd)"; +} + +if (isWindows()) { + + // NOTE: First do some cleanup before starting the generation + console.log("Cleanup old files..."); + execSync( + "rm -rf node_modules/@scicatproject/scicat-sdk-ts && rm -rf @scicatproject/scicat-sdk-ts", + { encoding: "utf-8" }, + ); + + console.log("Generating the new sdk..."); + const generationOutput = execSync( + `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`, + { encoding: "utf-8" }, + ); + console.log(generationOutput); + + console.log("Installing dependencies and building the sdk..."); + const installBuildOutput = execSync( + "cd @scicatproject/scicat-sdk-ts && npm install && npm run build", + { encoding: "utf-8" }, + ); + console.log(installBuildOutput); + + console.log("Copying the build files in node_modules..."); + const copyToNodeModulesOutput = execSync( + "cp -r @scicatproject/scicat-sdk-ts/dist node_modules/@scicatproject/scicat-sdk-ts", + { encoding: "utf-8" }, + ); + console.log(copyToNodeModulesOutput); + + console.log("Final cleanup..."); + execSync("rm -rf @scicatproject", { + encoding: "utf-8", + }); + + console.log("Local SDK generation completed"); + +} else { + console.log("Your environment is a linux/unix"); + console.log("Please run the following command on your terminal:"); + console.log("> sudo -E ./scripts/generate-nestjs-sdk.bash"); + console.log(""); + console.log("IMPORTANT: the script runs under sudo. You will be asked your password."); + console.log(""); + +} + diff --git a/src/app/app-config.service.ts b/src/app/app-config.service.ts index acd6e3ea9..7dec6effd 100644 --- a/src/app/app-config.service.ts +++ b/src/app/app-config.service.ts @@ -111,14 +111,16 @@ export class AppConfigService { async loadAppConfig(): Promise { try { - this.appConfig = await this.http + const config = await this.http .get("/api/v3/admin/config") .pipe(timeout(2000)) .toPromise(); + this.appConfig = Object.assign({}, this.appConfig, config); } catch (err) { console.log("No config available in backend, trying with local config."); try { - this.appConfig = await this.http.get("/assets/config.json").toPromise(); + const config = await this.http.get("/assets/config.json").toPromise(); + this.appConfig = Object.assign({}, this.appConfig, config); } catch (err) { console.error("No config provided."); } diff --git a/src/app/app-routing/auth.guard.ts b/src/app/app-routing/auth.guard.ts index b1b464499..e4cba1249 100644 --- a/src/app/app-routing/auth.guard.ts +++ b/src/app/app-routing/auth.guard.ts @@ -5,7 +5,7 @@ import { ActivatedRouteSnapshot, RouterStateSnapshot, } from "@angular/router"; -import { UserApi } from "shared/sdk/services"; +import { UsersService } from "@scicatproject/scicat-sdk-ts"; /** * Ensure that the current user is logged in @@ -19,7 +19,7 @@ import { UserApi } from "shared/sdk/services"; }) export class AuthGuard implements CanActivate { constructor( - private us: UserApi, + private us: UsersService, private router: Router, ) {} @@ -31,7 +31,7 @@ export class AuthGuard implements CanActivate { state: RouterStateSnapshot, ): Promise { return this.us - .getCurrent() + .usersControllerGetMyUser() .toPromise() .catch(() => { this.router.navigate(["/login"], { diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 4d0b3a980..e8154f2e4 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -7,6 +7,7 @@ import { MockStore } from "./shared/MockStubs"; import { APP_CONFIG } from "./app-config.module"; import { MatProgressSpinnerModule } from "@angular/material/progress-spinner"; import { AppConfigService } from "app-config.service"; +import { Configuration } from "@scicatproject/scicat-sdk-ts"; describe("AppComponent", () => { const getConfig = () => ({ @@ -29,6 +30,10 @@ describe("AppComponent", () => { providers: [ { provide: Store, useClass: MockStore }, { provide: AppConfigService, useValue: { getConfig } }, + { + provide: Configuration, + useClass: Configuration, + }, { provide: APP_CONFIG, useValue: { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 579251bb7..ccdfd43be 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -9,7 +9,6 @@ import { ChangeDetectorRef, } from "@angular/core"; import { Store } from "@ngrx/store"; -import { LoopBackConfig } from "shared/sdk"; import { clearMessageAction, fetchCurrentUserAction, @@ -25,6 +24,7 @@ import { } from "state-management/selectors/user.selectors"; import { MessageType } from "state-management/models"; import { AppConfigService, AppConfig as Config } from "app-config.service"; +import { Configuration } from "@scicatproject/scicat-sdk-ts"; @Component({ selector: "app-root", @@ -45,6 +45,7 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewChecked { constructor( @Inject(APP_CONFIG) public appConfig: AppConfig, private appConfigService: AppConfigService, + private apiConfigService: Configuration, private cdRef: ChangeDetectorRef, private metaService: Meta, public snackBar: MatSnackBar, @@ -68,8 +69,8 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewChecked { * @memberof AppComponent */ ngOnInit() { - LoopBackConfig.setBaseURL(this.config.lbBaseURL); - console.log(LoopBackConfig.getPath()); + this.apiConfigService.basePath = this.config.lbBaseURL; + console.log(this.apiConfigService.basePath); this.store.dispatch(loadDefaultSettings({ config: this.config })); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 039a64785..093937260 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -8,9 +8,8 @@ import { EffectsModule } from "@ngrx/effects"; import { HttpClientModule, HTTP_INTERCEPTORS } from "@angular/common/http"; import { APP_INITIALIZER, NgModule } from "@angular/core"; import { ExtraOptions, RouterModule } from "@angular/router"; -import { SampleApi, SDKBrowserModule } from "shared/sdk/index"; import { StoreModule } from "@ngrx/store"; -import { UserApi } from "shared/sdk/services"; +import { ApiModule, Configuration } from "@scicatproject/scicat-sdk-ts"; import { routerReducer } from "@ngrx/router-store"; import { extModules } from "./build-specifics"; import { MatNativeDateModule } from "@angular/material/core"; @@ -26,6 +25,9 @@ import { LayoutModule } from "_layout/layout.module"; import { AppConfigService } from "app-config.service"; import { AppThemeService } from "app-theme.service"; import { SnackbarInterceptor } from "shared/interceptors/snackbar.interceptor"; +import { AuthService } from "shared/services/auth/auth.service"; +import { InternalStorage, SDKStorage } from "shared/services/auth/base.storage"; +import { CookieService } from "ngx-cookie-service"; const appConfigInitializerFn = (appConfig: AppConfigService) => { return () => appConfig.loadAppConfig(); @@ -35,6 +37,15 @@ const appThemeInitializerFn = (appTheme: AppThemeService) => { return () => appTheme.loadTheme(); }; +const apiConfigurationFn = ( + authService: AuthService, + configurationService: AppConfigService, +) => + new Configuration({ + basePath: configurationService.getConfig().lbBaseURL, + accessToken: authService.getToken().id, + }); + @NgModule({ declarations: [AppComponent], imports: [ @@ -49,7 +60,7 @@ const appThemeInitializerFn = (appTheme: AppThemeService) => { MatTabsModule, MatChipsModule, MatSnackBarModule, - SDKBrowserModule.forRoot(), + ApiModule, StoreModule.forRoot( { router: routerReducer, users: userReducer }, { @@ -93,11 +104,18 @@ const appThemeInitializerFn = (appTheme: AppThemeService) => { subscriptSizing: "dynamic", }, }, + AuthService, AppThemeService, - UserApi, - SampleApi, Title, MatNativeDateModule, + { provide: InternalStorage, useClass: CookieService }, + { provide: SDKStorage, useClass: CookieService }, + { + provide: Configuration, + useFactory: apiConfigurationFn, + deps: [AuthService, AppConfigService], + multi: false, + }, ], bootstrap: [AppComponent], }) diff --git a/src/app/datasets/admin-tab/admin-tab.component.html b/src/app/datasets/admin-tab/admin-tab.component.html index 6de050352..a20c63f4a 100644 --- a/src/app/datasets/admin-tab/admin-tab.component.html +++ b/src/app/datasets/admin-tab/admin-tab.component.html @@ -2,7 +2,7 @@

Datablocks: {{ datablocks.length }}

    -
  • {{ block.id }}
  • +
  • {{ block._id }}
    • {{ block.archiveId }}
    diff --git a/src/app/datasets/admin-tab/admin-tab.component.spec.ts b/src/app/datasets/admin-tab/admin-tab.component.spec.ts index 02911c781..e0b5d0d1e 100644 --- a/src/app/datasets/admin-tab/admin-tab.component.spec.ts +++ b/src/app/datasets/admin-tab/admin-tab.component.spec.ts @@ -1,9 +1,9 @@ -import { ComponentFixture, inject, TestBed } from "@angular/core/testing"; +import { TestBed } from "@angular/core/testing"; import { Store, StoreModule } from "@ngrx/store"; -import { Dataset } from "shared/sdk"; import { AdminTabComponent } from "./admin-tab.component"; import { MatCardModule } from "@angular/material/card"; import { of } from "rxjs"; +import { mockDataset } from "shared/MockStubs"; describe("AdminTabComponent", () => { let component: AdminTabComponent; @@ -36,12 +36,12 @@ describe("AdminTabComponent", () => { it("should return 'undefined' without confirmation", () => { spyOn(window, "confirm").and.returnValue(true); - const selectSpy = store.select.and.returnValue( + store.select.and.returnValue( of({ email: "test@example.com", username: "testuser" }), ); const dispatchSpy = store.dispatch as jasmine.Spy; const pipeSpy = store.select as jasmine.Spy; - component.dataset = new Dataset(); + component.dataset = mockDataset; const res = component.resetDataset(); expect(res).toBeUndefined(); diff --git a/src/app/datasets/admin-tab/admin-tab.component.ts b/src/app/datasets/admin-tab/admin-tab.component.ts index 468745310..19b77893c 100644 --- a/src/app/datasets/admin-tab/admin-tab.component.ts +++ b/src/app/datasets/admin-tab/admin-tab.component.ts @@ -3,7 +3,10 @@ import { Store } from "@ngrx/store"; import { FileObject } from "datasets/dataset-details-dashboard/dataset-details-dashboard.component"; import { Subscription } from "rxjs"; import { take } from "rxjs/operators"; -import { Dataset, Job } from "shared/sdk"; +import { + CreateJobDto, + OutputDatasetObsoleteDto, +} from "@scicatproject/scicat-sdk-ts"; import { submitJobAction } from "state-management/actions/jobs.actions"; import { selectCurrentDatablocks, @@ -22,7 +25,7 @@ import { }) export class AdminTabComponent implements OnInit, OnDestroy { private subscriptions: Subscription[] = []; - dataset: Dataset | undefined; + dataset: OutputDatasetObsoleteDto | undefined; datablocks$ = this.store.select(selectCurrentDatablocks); isAdmin$ = this.store.select(selectIsAdmin); loading$ = this.store.select(selectIsLoading); @@ -44,12 +47,13 @@ export class AdminTabComponent implements OnInit, OnDestroy { .pipe(take(1)) .subscribe((user) => { if (user && this.dataset) { - const job = new Job(); - job.emailJobInitiator = user.email; - job.jobParams = {}; + const job: CreateJobDto = { + emailJobInitiator: user.email, + type: "reset", + datasetList: [], + jobParams: {}, + }; job.jobParams["username"] = user.username; - job.creationTime = new Date(); - job.type = "reset"; const fileObj: FileObject = { pid: "", files: [], @@ -63,7 +67,6 @@ export class AdminTabComponent implements OnInit, OnDestroy { } fileObj.files = fileList; job.datasetList = [fileObj]; - console.log(job); this.store.dispatch(submitJobAction({ job })); } }); diff --git a/src/app/datasets/archiving.service.spec.ts b/src/app/datasets/archiving.service.spec.ts index f13153cc7..8d1598332 100644 --- a/src/app/datasets/archiving.service.spec.ts +++ b/src/app/datasets/archiving.service.spec.ts @@ -1,7 +1,6 @@ import { TestBed, waitForAsync } from "@angular/core/testing"; import { MockStore, provideMockStore } from "@ngrx/store/testing"; import { RetrieveDestinations } from "app-config.service"; -import { Dataset, Job, User } from "shared/sdk"; import { submitJobAction } from "state-management/actions/jobs.actions"; import { selectCurrentUser, @@ -10,6 +9,8 @@ import { } from "state-management/selectors/user.selectors"; import { JobsState } from "state-management/state/jobs.store"; import { ArchivingService } from "./archiving.service"; +import { createMock, mockDataset } from "shared/MockStubs"; +import { CreateJobDto, ReturnedUserDto } from "@scicatproject/scicat-sdk-ts"; describe("ArchivingService", () => { let service: ArchivingService; @@ -24,9 +25,11 @@ describe("ArchivingService", () => { selectors: [ { selector: selectCurrentUser, - value: new User({ + value: createMock({ email: "test@email.com", username: "testName", + authStrategy: "", + id: "", }), }, { selector: selectTapeCopies, value: "test" }, @@ -46,8 +49,13 @@ describe("ArchivingService", () => { describe("#createJob()", () => { it("should create a new object of type Job", () => { - const user = new User({ username: "testName", email: "test@email.com" }); - const datasets = [new Dataset()]; + const user = createMock({ + username: "testName", + email: "test@email.com", + authStrategy: "", + id: "", + }); + const datasets = [mockDataset]; const datasetList = datasets.map((dataset) => ({ pid: dataset.pid, files: [], @@ -62,7 +70,7 @@ describe("ArchivingService", () => { destinationPath, ); - expect(job).toBeInstanceOf(Job); + // expect(job).toBeInstanceOf(Job); expect(job["emailJobInitiator"]).toEqual("test@email.com"); expect(job["jobParams"]["username"]).toEqual("testName"); expect(job["datasetList"]).toEqual(datasetList); @@ -83,19 +91,26 @@ describe("ArchivingService", () => { xit("should call #createJob() and then dispatch a submitJobAction", () => { dispatchSpy = spyOn(store, "dispatch"); - const user = new User({ username: "testName", email: "test@email.com" }); - const datasets = [new Dataset()]; + const user = createMock({ + username: "testName", + email: "test@email.com", + authStrategy: "", + id: "", + }); + const datasets = [mockDataset]; const datasetList = datasets.map((dataset) => ({ pid: dataset.pid, files: [], })); const archive = true; - const job = new Job({ + const job = createMock({ jobParams: { username: user.username }, emailJobInitiator: user.email, - creationTime: new Date(), datasetList, type: "archive", + executionTime: "", + jobResultObject: {}, + jobStatusMessage: "", }); const createJobSpy = spyOn( service, @@ -120,7 +135,7 @@ describe("ArchivingService", () => { service, "archiveOrRetrieve", ); - const datasets = [new Dataset()]; + const datasets = [mockDataset]; service.archive(datasets); @@ -134,7 +149,7 @@ describe("ArchivingService", () => { service, "archiveOrRetrieve", ); - const datasets = [new Dataset()]; + const datasets = [mockDataset]; const destinationPath = { location: "/test/path/" }; service.retrieve(datasets, destinationPath); diff --git a/src/app/datasets/archiving.service.ts b/src/app/datasets/archiving.service.ts index 8913c3b9c..fcf68c4a1 100644 --- a/src/app/datasets/archiving.service.ts +++ b/src/app/datasets/archiving.service.ts @@ -2,7 +2,6 @@ import { Injectable } from "@angular/core"; import { Store } from "@ngrx/store"; import { combineLatest, Observable } from "rxjs"; import { first, map } from "rxjs/operators"; -import { Dataset, Job, User } from "state-management/models"; import { submitJobAction } from "state-management/actions/jobs.actions"; import { selectCurrentUser, @@ -10,6 +9,10 @@ import { selectProfile, } from "state-management/selectors/user.selectors"; import { RetrieveDestinations } from "app-config.service"; +import { + OutputDatasetObsoleteDto, + ReturnedUserDto, +} from "@scicatproject/scicat-sdk-ts"; @Injectable() export class ArchivingService { @@ -19,12 +22,12 @@ export class ArchivingService { constructor(private store: Store) {} private createJob( - user: User, - datasets: Dataset[], + user: ReturnedUserDto, + datasets: OutputDatasetObsoleteDto[], archive: boolean, destinationPath?: Record, // Do not specify tape copies here - ): Job { + ) { const extra = archive ? {} : destinationPath; const jobParams = { username: user.username, @@ -46,11 +49,11 @@ export class ArchivingService { type: archive ? "archive" : "retrieve", }; - return new Job(data); + return data; } private archiveOrRetrieve( - datasets: Dataset[], + datasets: OutputDatasetObsoleteDto[], archive: boolean, destPath?: Record, ): Observable { @@ -71,18 +74,18 @@ export class ArchivingService { const job = this.createJob(user, datasets, archive, destPath); - this.store.dispatch(submitJobAction({ job })); + this.store.dispatch(submitJobAction({ job: job as any })); } }), ); } - public archive(datasets: Dataset[]): Observable { + public archive(datasets: OutputDatasetObsoleteDto[]): Observable { return this.archiveOrRetrieve(datasets, true); } public retrieve( - datasets: Dataset[], + datasets: OutputDatasetObsoleteDto[], destinationPath: Record, ): Observable { return this.archiveOrRetrieve(datasets, false, destinationPath); diff --git a/src/app/datasets/batch-view/batch-view.component.spec.ts b/src/app/datasets/batch-view/batch-view.component.spec.ts index a68670d2a..d07b5ea0d 100644 --- a/src/app/datasets/batch-view/batch-view.component.spec.ts +++ b/src/app/datasets/batch-view/batch-view.component.spec.ts @@ -5,13 +5,16 @@ import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; import { BatchViewComponent } from "./batch-view.component"; import { NO_ERRORS_SCHEMA } from "@angular/core"; import { Router } from "@angular/router"; -import { MockArchivingService, MockDatasetApi } from "shared/MockStubs"; +import { + MockArchivingService, + MockDatasetApi, + mockDataset as dataset, +} from "shared/MockStubs"; import { ArchivingService } from "../archiving.service"; import { MatIconModule } from "@angular/material/icon"; import { MatButtonModule } from "@angular/material/button"; import { MatDialogModule } from "@angular/material/dialog"; -import { DatasetApi, Dataset } from "shared/sdk"; import { SharedScicatFrontendModule } from "shared/shared.module"; import { MatTableModule } from "@angular/material/table"; import { MockStore, provideMockStore } from "@ngrx/store/testing"; @@ -22,6 +25,7 @@ import { MatFormFieldModule } from "@angular/material/form-field"; import { MatChipsModule } from "@angular/material/chips"; import { MatInputModule } from "@angular/material/input"; import { AppConfigService } from "app-config.service"; +import { DatasetsService } from "@scicatproject/scicat-sdk-ts"; describe("BatchViewComponent", () => { let component: BatchViewComponent; @@ -64,7 +68,7 @@ describe("BatchViewComponent", () => { providers: [ { provide: ArchivingService, useClass: MockArchivingService }, { provide: Router, useValue: router }, - { provide: DatasetApi, useClass: MockDatasetApi }, + { provide: DatasetsService, useClass: MockDatasetApi }, { provide: AppConfigService, useValue: { getConfig } }, ], }, @@ -101,8 +105,6 @@ describe("BatchViewComponent", () => { describe("#onRemove()", () => { it("should dispatch a removeFromBatchAction", () => { dispatchSpy = spyOn(store, "dispatch"); - const dataset = new Dataset(); - component.onRemove(dataset); expect(dispatchSpy).toHaveBeenCalledOnceWith( diff --git a/src/app/datasets/batch-view/batch-view.component.ts b/src/app/datasets/batch-view/batch-view.component.ts index 89c03021b..613700bbe 100644 --- a/src/app/datasets/batch-view/batch-view.component.ts +++ b/src/app/datasets/batch-view/batch-view.component.ts @@ -10,7 +10,7 @@ import { removeFromBatchAction, storeBatchAction, } from "state-management/actions/datasets.actions"; -import { Dataset, Message, MessageType } from "state-management/models"; +import { Message, MessageType } from "state-management/models"; import { showMessageAction } from "state-management/actions/user.actions"; import { DialogComponent } from "shared/modules/dialog/dialog.component"; @@ -24,6 +24,7 @@ import { selectIsAdmin, selectProfile, } from "state-management/selectors/user.selectors"; +import { OutputDatasetObsoleteDto } from "@scicatproject/scicat-sdk-ts"; @Component({ selector: "batch-view", @@ -31,7 +32,9 @@ import { styleUrls: ["./batch-view.component.scss"], }) export class BatchViewComponent implements OnInit, OnDestroy { - batch$: Observable = this.store.select(selectDatasetsInBatch); + batch$: Observable = this.store.select( + selectDatasetsInBatch, + ); userProfile$ = this.store.select(selectProfile); isAdmin$ = this.store.select(selectIsAdmin); isAdmin = false; @@ -41,7 +44,7 @@ export class BatchViewComponent implements OnInit, OnDestroy { appConfig = this.appConfigService.getConfig(); shareEnabled = this.appConfig.shareEnabled; - datasetList: Dataset[] = []; + datasetList: OutputDatasetObsoleteDto[] = []; public hasBatch = false; visibleColumns: string[] = ["remove", "pid", "sourceFolder", "creationTime"]; @@ -57,7 +60,7 @@ export class BatchViewComponent implements OnInit, OnDestroy { this.store.dispatch(clearBatchAction()); } - private storeBatch(datasetUpdatedBatch: Dataset[]) { + private storeBatch(datasetUpdatedBatch: OutputDatasetObsoleteDto[]) { this.store.dispatch(storeBatchAction({ batch: datasetUpdatedBatch })); } @@ -69,7 +72,7 @@ export class BatchViewComponent implements OnInit, OnDestroy { } } - onRemove(dataset: Dataset) { + onRemove(dataset: OutputDatasetObsoleteDto) { this.store.dispatch(removeFromBatchAction({ dataset })); } @@ -127,7 +130,7 @@ export class BatchViewComponent implements OnInit, OnDestroy { this.store.dispatch( appendToDatasetArrayFieldAction({ - pid: encodeURIComponent(dataset.pid), + pid: dataset.pid, fieldName: "sharedWith", data: result.users, }), diff --git a/src/app/datasets/dashboard/dashboard.component.spec.ts b/src/app/datasets/dashboard/dashboard.component.spec.ts index 61183b685..6de49aaec 100644 --- a/src/app/datasets/dashboard/dashboard.component.spec.ts +++ b/src/app/datasets/dashboard/dashboard.component.spec.ts @@ -8,14 +8,18 @@ import { import { ActivatedRoute, Router } from "@angular/router"; import { Store, StoreModule } from "@ngrx/store"; -import { MockActivatedRoute, MockStore } from "shared/MockStubs"; +import { + MockActivatedRoute, + MockStore, + createMock, + mockDataset as dataset, +} from "shared/MockStubs"; import { DashboardComponent } from "./dashboard.component"; import { of } from "rxjs"; import { addDatasetAction, changePageAction, } from "state-management/actions/datasets.actions"; -import { User, Dataset, DerivedDataset } from "shared/sdk"; import { selectColumnAction, deselectColumnAction, @@ -36,6 +40,10 @@ import { MatCardModule } from "@angular/material/card"; import { MatIconModule } from "@angular/material/icon"; import { AppConfigService } from "app-config.service"; import { PageChangeEvent } from "shared/modules/table/table.component"; +import { + CreateDerivedDatasetObsoleteDto, + ReturnedUserDto, +} from "@scicatproject/scicat-sdk-ts"; class MockMatDialog { open() { @@ -208,7 +216,6 @@ describe("DashboardComponent", () => { describe("#onRowClick()", () => { it("should navigate to a dataset", () => { - const dataset = new Dataset(); component.onRowClick(dataset); expect(router.navigateByUrl).toHaveBeenCalledTimes(1); @@ -225,22 +232,19 @@ describe("DashboardComponent", () => { dispatchSpy = spyOn(store, "dispatch"); - const currentUser = new User({ + const currentUser = createMock({ id: "testId", username: "ldap.Test User", email: "test@email.com", realm: "test", emailVerified: true, - password: "testPassword", - accessTokens: [], - identities: [], - credentials: [], + authStrategy: "local", }); - const dataset = new DerivedDataset({ + const dataset: CreateDerivedDatasetObsoleteDto = { accessGroups: [], contactEmail: currentUser.email, - creationTime: new Date(), + creationTime: new Date().toString(), datasetName: "Test Name", description: "Test description", isPublished: false, @@ -256,7 +260,8 @@ describe("DashboardComponent", () => { investigator: currentUser.email, scientificMetadata: {}, usedSoftware: ["test software"], - }); + numberOfFilesArchived: 0, + }; component.currentUser = currentUser; component.userGroups = ["test"]; diff --git a/src/app/datasets/dashboard/dashboard.component.ts b/src/app/datasets/dashboard/dashboard.component.ts index a8f61ac02..7528f692f 100644 --- a/src/app/datasets/dashboard/dashboard.component.ts +++ b/src/app/datasets/dashboard/dashboard.component.ts @@ -4,7 +4,7 @@ import { Store, ActionsSubject } from "@ngrx/store"; import deepEqual from "deep-equal"; -import { DatasetFilters, User } from "state-management/models"; +import { DatasetFilters } from "state-management/models"; import { fetchDatasetsAction, @@ -35,7 +35,10 @@ import { selectColumns, selectIsLoggedIn, } from "state-management/selectors/user.selectors"; -import { Dataset, DerivedDataset } from "shared/sdk"; +import { + OutputDatasetObsoleteDto, + ReturnedUserDto, +} from "@scicatproject/scicat-sdk-ts"; import { selectColumnAction, deselectColumnAction, @@ -73,7 +76,8 @@ export class DashboardComponent implements OnInit, OnDestroy { subscriptions: Subscription[] = []; appConfig = this.appConfigService.getConfig(); - currentUser: User = new User(); + + currentUser: ReturnedUserDto; userGroups: string[] = []; clearColumnSearch = false; @@ -121,7 +125,7 @@ export class DashboardComponent implements OnInit, OnDestroy { } } - onRowClick(dataset: Dataset): void { + onRowClick(dataset: OutputDatasetObsoleteDto): void { const pid = encodeURIComponent(dataset.pid); this.router.navigateByUrl("/datasets/" + pid); } @@ -135,10 +139,10 @@ export class DashboardComponent implements OnInit, OnDestroy { dialogRef.afterClosed().subscribe((res) => { if (res) { const { username, email } = this.currentUser; - const dataset = new DerivedDataset({ + const dataset = { accessGroups: [], contactEmail: email, // Required - creationTime: new Date(), // Required + creationTime: new Date().toString(), // Required datasetName: res.datasetName, description: res.description, isPublished: false, @@ -153,12 +157,17 @@ export class DashboardComponent implements OnInit, OnDestroy { inputDatasets: [], // Required investigator: email, // Required scientificMetadata: {}, + numberOfFilesArchived: 0, // Required usedSoftware: res.usedSoftware .split(",") .map((entry: string) => entry.trim()) .filter((entry: string) => entry !== ""), // Required - }); - this.store.dispatch(addDatasetAction({ dataset })); + }; + this.store.dispatch( + addDatasetAction({ + dataset: dataset, + }), + ); } }); } diff --git a/src/app/datasets/datablocks-table/datablocks-table.component.ts b/src/app/datasets/datablocks-table/datablocks-table.component.ts index 38abc124e..674d7e169 100644 --- a/src/app/datasets/datablocks-table/datablocks-table.component.ts +++ b/src/app/datasets/datablocks-table/datablocks-table.component.ts @@ -1,6 +1,6 @@ import { Component, Input } from "@angular/core"; -import { Datablock } from "shared/sdk/models"; import { MatTableDataSource } from "@angular/material/table"; +import { Datablock } from "@scicatproject/scicat-sdk-ts"; @Component({ selector: "datablocks-table", diff --git a/src/app/datasets/datafiles-actions/datafiles-action.component.spec.ts b/src/app/datasets/datafiles-actions/datafiles-action.component.spec.ts index 2c95b6e4c..46e362e2b 100644 --- a/src/app/datasets/datafiles-actions/datafiles-action.component.spec.ts +++ b/src/app/datasets/datafiles-actions/datafiles-action.component.spec.ts @@ -10,13 +10,14 @@ import { ReactiveFormsModule } from "@angular/forms"; import { MatDialogModule, MatDialogRef } from "@angular/material/dialog"; import { RouterModule } from "@angular/router"; import { StoreModule } from "@ngrx/store"; -import { UserApi } from "shared/sdk"; import { MockHtmlElement, MockMatDialogRef, MockUserApi, } from "shared/MockStubs"; import { ActionDataset } from "./datafiles-action.interfaces"; +import { UsersService } from "@scicatproject/scicat-sdk-ts"; +import { AuthService } from "shared/services/auth/auth.service"; describe("1000: DatafilesActionComponent", () => { let component: DatafilesActionComponent; @@ -121,8 +122,8 @@ describe("1000: DatafilesActionComponent", () => { notebook_selected = 3, } - const jwt = () => ({ - subscribe: (f: any) => ({ + const usersControllerGetUserJWT = () => ({ + subscribe: () => ({ jwt: "9a2322a8-4a7d-11ef-a0f5-d7c40fcf1693", }), }); @@ -165,9 +166,16 @@ describe("1000: DatafilesActionComponent", () => { TestBed.overrideComponent(DatafilesActionComponent, { set: { providers: [ - { provide: UserApi, useClass: MockUserApi }, + { provide: UsersService, useClass: MockUserApi }, { provide: MatDialogRef, useClass: MockMatDialogRef }, - { provide: UserApi, useValue: { jwt, getCurrentToken } }, + { + provide: UsersService, + useValue: { usersControllerGetUserJWT }, + }, + { + provide: AuthService, + useValue: { getToken: getCurrentToken }, + }, ], }, }); diff --git a/src/app/datasets/datafiles-actions/datafiles-action.component.ts b/src/app/datasets/datafiles-actions/datafiles-action.component.ts index 9ede93d88..414e63b6b 100644 --- a/src/app/datasets/datafiles-actions/datafiles-action.component.ts +++ b/src/app/datasets/datafiles-actions/datafiles-action.component.ts @@ -6,9 +6,10 @@ import { SimpleChanges, } from "@angular/core"; -import { UserApi } from "shared/sdk"; +import { UsersService } from "@scicatproject/scicat-sdk-ts"; import { ActionConfig, ActionDataset } from "./datafiles-action.interfaces"; import { DataFiles_File } from "datasets/datafiles/datafiles.interfaces"; +import { AuthService } from "shared/services/auth/auth.service"; @Component({ selector: "datafiles-action", @@ -33,8 +34,11 @@ export class DatafilesActionComponent implements OnInit, OnChanges { form: HTMLFormElement = null; - constructor(private userApi: UserApi) { - this.userApi.jwt().subscribe((jwt) => { + constructor( + private usersService: UsersService, + private authService: AuthService, + ) { + this.usersService.usersControllerGetUserJWT().subscribe((jwt) => { this.jwt = jwt.jwt; }); } @@ -126,7 +130,7 @@ export class DatafilesActionComponent implements OnInit, OnChanges { this.form.style.display = "none"; this.form.appendChild( - this.add_input("auth_token", this.userApi.getCurrentToken().id), + this.add_input("auth_token", `Bearer ${this.authService.getToken().id}`), ); this.form.appendChild(this.add_input("jwt", this.jwt)); diff --git a/src/app/datasets/datafiles-actions/datafiles-actions.component.spec.ts b/src/app/datasets/datafiles-actions/datafiles-actions.component.spec.ts index f8bdc5284..19216153d 100644 --- a/src/app/datasets/datafiles-actions/datafiles-actions.component.spec.ts +++ b/src/app/datasets/datafiles-actions/datafiles-actions.component.spec.ts @@ -10,9 +10,9 @@ import { ReactiveFormsModule } from "@angular/forms"; import { MatDialogModule, MatDialogRef } from "@angular/material/dialog"; import { RouterModule } from "@angular/router"; import { StoreModule } from "@ngrx/store"; -import { UserApi } from "shared/sdk"; import { MockMatDialogRef, MockUserApi } from "shared/MockStubs"; import { AppConfigService } from "app-config.service"; +import { UsersService } from "@scicatproject/scicat-sdk-ts"; describe("DatafilesActionsComponent", () => { let component: DatafilesActionsComponent; @@ -91,10 +91,10 @@ describe("DatafilesActionsComponent", () => { TestBed.overrideComponent(DatafilesActionsComponent, { set: { providers: [ - { provide: UserApi, useClass: MockUserApi }, + { provide: UsersService, useClass: MockUserApi }, { provide: MatDialogRef, useClass: MockMatDialogRef }, { provide: AppConfigService, useValue: mockAppConfigService }, - { provide: UserApi, useClass: MockUserApi }, + { provide: UsersService, useClass: MockUserApi }, ], }, }); diff --git a/src/app/datasets/datafiles/datafiles.component.spec.ts b/src/app/datasets/datafiles/datafiles.component.spec.ts index 589fb0c3e..064bb536d 100644 --- a/src/app/datasets/datafiles/datafiles.component.spec.ts +++ b/src/app/datasets/datafiles/datafiles.component.spec.ts @@ -2,13 +2,13 @@ import { NO_ERRORS_SCHEMA } from "@angular/core"; import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; import { ReactiveFormsModule } from "@angular/forms"; import { DatafilesComponent } from "./datafiles.component"; -import { UserApi } from "shared/sdk"; import { MatTableModule } from "@angular/material/table"; import { PipesModule } from "shared/pipes/pipes.module"; import { RouterModule } from "@angular/router"; import { StoreModule } from "@ngrx/store"; import { CheckboxEvent } from "shared/modules/table/table.component"; import { + MockAuthService, MockDatafilesActionsComponent, MockMatDialogRef, MockUserApi, @@ -19,6 +19,8 @@ import { MatButtonModule } from "@angular/material/button"; import { AppConfigService } from "app-config.service"; import { MatDialogModule, MatDialogRef } from "@angular/material/dialog"; import { DatafilesActionsComponent } from "datasets/datafiles-actions/datafiles-actions.component"; +import { UsersService } from "@scicatproject/scicat-sdk-ts"; +import { AuthService } from "shared/services/auth/auth.service"; import { FileSizePipe } from "shared/pipes/filesize.pipe"; describe("DatafilesComponent", () => { @@ -93,10 +95,10 @@ describe("DatafilesComponent", () => { TestBed.overrideComponent(DatafilesComponent, { set: { providers: [ - { provide: UserApi, useClass: MockUserApi }, + { provide: UsersService, useClass: MockUserApi }, { provide: MatDialogRef, useClass: MockMatDialogRef }, { provide: AppConfigService, useValue: { getConfig } }, - { provide: UserApi, useClass: MockUserApi }, + { provide: AuthService, useValue: MockAuthService }, { provide: DatafilesActionsComponent, useClass: MockDatafilesActionsComponent, @@ -129,6 +131,7 @@ describe("DatafilesComponent", () => { gid: "string", perm: "string", selected: false, + hash: "", }, { path: "test2", @@ -139,6 +142,7 @@ describe("DatafilesComponent", () => { gid: "string", perm: "string", selected: false, + hash: "", }, ]; component.tableData = component.files; diff --git a/src/app/datasets/datafiles/datafiles.component.ts b/src/app/datasets/datafiles/datafiles.component.ts index c643ac84b..d807d0914 100644 --- a/src/app/datasets/datafiles/datafiles.component.ts +++ b/src/app/datasets/datafiles/datafiles.component.ts @@ -22,7 +22,7 @@ import { selectIsLoading, selectIsLoggedIn, } from "state-management/selectors/user.selectors"; -import { Job, UserApi } from "shared/sdk"; +import { CreateUserJWT, UsersService } from "@scicatproject/scicat-sdk-ts"; import { FileSizePipe } from "shared/pipes/filesize.pipe"; import { MatCheckboxChange } from "@angular/material/checkbox"; import { MatDialog } from "@angular/material/dialog"; @@ -32,6 +32,7 @@ import { AppConfigService } from "app-config.service"; import { NgForm } from "@angular/forms"; import { DataFiles_File } from "./datafiles.interfaces"; import { ActionDataset } from "datasets/datafiles-actions/datafiles-action.interfaces"; +import { AuthService } from "shared/services/auth/auth.service"; @Component({ selector: "datafiles", @@ -61,7 +62,7 @@ export class DatafilesComponent subscriptions: Subscription[] = []; - files: Array = []; + files: Array = []; datasetPid = ""; actionDataset: ActionDataset; @@ -81,8 +82,8 @@ export class DatafilesComponent maxFileSizeWarning: string | null = this.appConfig.maxFileSizeWarning || `Some files are above the max size ${this.fileSizePipe.transform(this.maxFileSize)}`; - jwt: any; - auth_token: any; + jwt: CreateUserJWT; + auth_token: string; tableColumns: TableColumn[] = [ { @@ -114,8 +115,9 @@ export class DatafilesComponent private store: Store, private cdRef: ChangeDetectorRef, private dialog: MatDialog, + private usersService: UsersService, + private authService: AuthService, private fileSizePipe: FileSizePipe, - private userApi: UserApi, ) {} onPageChange(event: PageChangeEvent) { @@ -253,7 +255,7 @@ export class DatafilesComponent if (datablocks) { const files: DataFiles_File[] = []; datablocks.forEach((block) => { - block.dataFileList.map((file) => { + block.dataFileList.map((file: DataFiles_File) => { this.totalFileSize += file.size; file.selected = false; files.push(file); @@ -274,12 +276,12 @@ export class DatafilesComponent downloadFiles(form: "downloadAllForm" | "downloadSelectedForm") { if (this.appConfig.multipleDownloadUseAuthToken) { - this.auth_token = this.userApi.getCurrentToken().id; + this.auth_token = `Bearer ${this.authService.getToken().id}`; this[`${form}Element`].nativeElement.auth_token.value = this.auth_token; } if (!this.jwt) { this.subscriptions.push( - this.userApi.jwt().subscribe((jwt) => { + this.usersService.usersControllerGetUserJWT().subscribe((jwt) => { this.jwt = jwt; this[`${form}Element`].nativeElement.jwt.value = jwt.jwt; this[`${form}Element`].nativeElement.submit(); @@ -312,8 +314,7 @@ export class DatafilesComponent }, ], }; - const job = new Job(data); - this.store.dispatch(submitJobAction({ job })); + this.store.dispatch(submitJobAction({ job: data })); } }); } diff --git a/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts b/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts index e31898a84..d40eeeb86 100644 --- a/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts +++ b/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts @@ -12,9 +12,7 @@ import { SharedScicatFrontendModule } from "shared/shared.module"; import { MatTableModule } from "@angular/material/table"; import { MatChipInputEvent, MatChipsModule } from "@angular/material/chips"; import { of } from "rxjs"; -import { Dataset, Sample, User } from "shared/sdk"; import { MatDialogRef } from "@angular/material/dialog"; -import { SampleEditComponent } from "datasets/sample-edit/sample-edit.component"; import { MatCardModule } from "@angular/material/card"; import { MatIconModule } from "@angular/material/icon"; import { MatInputModule } from "@angular/material/input"; @@ -35,10 +33,19 @@ import { MatSlideToggleChange, } from "@angular/material/slide-toggle"; import { ActivatedRoute, Router } from "@angular/router"; -import { MockActivatedRoute } from "shared/MockStubs"; +import { + createMock, + MockActivatedRoute, + mockDataset, + mockSample, +} from "shared/MockStubs"; import { DialogComponent } from "shared/modules/dialog/dialog.component"; import { AppConfigService } from "app-config.service"; import { AttachmentService } from "shared/services/attachment.service"; +import { + OutputDatasetObsoleteDto, + ReturnedUserDto, +} from "@scicatproject/scicat-sdk-ts"; describe("DatasetDetailComponent", () => { let component: DatasetDetailComponent; @@ -98,7 +105,7 @@ describe("DatasetDetailComponent", () => { component.dataset = { pid: "testPid", isPublished: false, - } as unknown as Dataset; + } as unknown as OutputDatasetObsoleteDto; fixture.detectChanges(); })); afterEach(() => { @@ -113,7 +120,7 @@ describe("DatasetDetailComponent", () => { it("should update datasets keyword filter and navigate to datasets table", () => { const dispatchSpy = spyOn(store, "dispatch"); const keyword = "test"; - component.dataset = new Dataset(); + component.dataset = mockDataset; component.onClickKeyword(keyword); expect(dispatchSpy).toHaveBeenCalledTimes(2); @@ -136,7 +143,7 @@ describe("DatasetDetailComponent", () => { value: "test", }; const pid = "testPid"; - component.dataset = new Dataset(); + component.dataset = mockDataset; component.dataset.pid = pid; component.onEditModeEnable(); component.onAddKeyword(event as MatChipInputEvent); @@ -155,7 +162,7 @@ describe("DatasetDetailComponent", () => { }, value: "test", }; - component.dataset = new Dataset(); + component.dataset = mockDataset; component.dataset.keywords = ["test"]; component.onEditModeEnable(); expect(component.keywords.value.length).toBe(1); @@ -176,7 +183,7 @@ describe("DatasetDetailComponent", () => { value: "test", }; const pid = "testPid"; - component.dataset = new Dataset(); + component.dataset = mockDataset; component.dataset.pid = pid; component.dataset.keywords = []; component.onEditModeEnable(); @@ -194,7 +201,7 @@ describe("DatasetDetailComponent", () => { const dispatchSpy = spyOn(store, "dispatch"); const keyword = "test"; - component.dataset = new Dataset(); + component.dataset = mockDataset; component.dataset.keywords = []; component.onRemoveKeyword(keyword); @@ -204,7 +211,7 @@ describe("DatasetDetailComponent", () => { it("should dispatch an updatePropertyAction if the keyword does exist", () => { const keyword = "test"; const pid = "testPid"; - component.dataset = new Dataset(); + component.dataset = mockDataset; component.dataset.pid = pid; component.dataset.keywords = [keyword]; component.onEditModeEnable(); @@ -223,7 +230,7 @@ describe("DatasetDetailComponent", () => { const keyword = "test"; const pid = "testPid"; - component.dataset = new Dataset(); + component.dataset = mockDataset; component.dataset.pid = pid; component.dataset.keywords = [keyword]; component.dataset.datasetName = "Test dataset name"; @@ -250,7 +257,7 @@ describe("DatasetDetailComponent", () => { it("should dispatch a updatePropertyAction", () => { const dispatchSpy = spyOn(store, "dispatch"); const pid = "testPid"; - component.dataset = new Dataset(); + component.dataset = mockDataset; component.dataset.pid = pid; const event = new MatSlideToggleChange({} as MatSlideToggle, true); const property = { isPublished: true }; @@ -277,7 +284,7 @@ describe("DatasetDetailComponent", () => { it("should do nothing if dataset is defined and group does not exist", () => { const dispatchSpy = spyOn(store, "dispatch"); - component.dataset = new Dataset(); + component.dataset = mockDataset; component.dataset.sharedWith = []; const share = "test"; component.onRemoveShare(share); @@ -294,7 +301,7 @@ describe("DatasetDetailComponent", () => { pid, isPublished: false, sharedWith: [share], - } as unknown as Dataset; + } as unknown as OutputDatasetObsoleteDto; const dialogOpenSpy = spyOn(component.dialog, "open").and.returnValue({ afterClosed: () => of("ok"), } as MatDialogRef); @@ -346,7 +353,7 @@ describe("DatasetDetailComponent", () => { const dispatchSpy = spyOn(store, "dispatch"); const pid = "testPid"; - component.dataset = new Dataset(); + component.dataset = mockDataset; component.dataset.pid = pid; const metadata = {}; const property = { scientificMetadata: metadata }; diff --git a/src/app/datasets/dataset-detail/dataset-detail.component.ts b/src/app/datasets/dataset-detail/dataset-detail.component.ts index 668582c22..c13db28b0 100644 --- a/src/app/datasets/dataset-detail/dataset-detail.component.ts +++ b/src/app/datasets/dataset-detail/dataset-detail.component.ts @@ -1,5 +1,4 @@ import { Component, OnInit, OnDestroy, Inject } from "@angular/core"; -import { Dataset, Proposal, Sample } from "shared/sdk/models"; import { ENTER, COMMA, SPACE } from "@angular/cdk/keycodes"; import { MatChipInputEvent } from "@angular/material/chips"; @@ -29,7 +28,6 @@ import { } from "state-management/actions/datasets.actions"; import { Router } from "@angular/router"; import { selectCurrentProposal } from "state-management/selectors/proposals.selectors"; -import { DerivedDataset, Instrument, RawDataset, User } from "shared/sdk"; import { MatSlideToggleChange } from "@angular/material/slide-toggle"; import { EditableComponent } from "app-routing/pending-changes.guard"; import { AppConfigService } from "app-config.service"; @@ -44,6 +42,13 @@ import { } from "@angular/forms"; import { Message, MessageType } from "state-management/models"; import { DOCUMENT } from "@angular/common"; +import { + Instrument, + OutputDatasetObsoleteDto, + ProposalClass, + ReturnedUserDto, + SampleClass, +} from "@scicatproject/scicat-sdk-ts"; import { AttachmentService } from "shared/services/attachment.service"; /** @@ -72,14 +77,14 @@ export class DatasetDetailComponent appConfig = this.appConfigService.getConfig(); - dataset: Dataset | undefined; + dataset: OutputDatasetObsoleteDto | undefined; datasetWithout$ = this.store.select(selectCurrentDatasetWithoutFileInfo); attachments$ = this.store.select(selectCurrentAttachments); loading$ = this.store.select(selectIsLoading); instrument: Instrument | undefined; - proposal: Proposal | undefined; - sample: Sample | undefined; - user: User | undefined; + proposal: ProposalClass | undefined; + sample: SampleClass | undefined; + user: ReturnedUserDto | undefined; editingAllowed = false; editEnabled = false; show = false; diff --git a/src/app/datasets/dataset-details-dashboard/dataset-details-dashboard.component.spec.ts b/src/app/datasets/dataset-details-dashboard/dataset-details-dashboard.component.spec.ts index a717e90c0..78b821412 100644 --- a/src/app/datasets/dataset-details-dashboard/dataset-details-dashboard.component.spec.ts +++ b/src/app/datasets/dataset-details-dashboard/dataset-details-dashboard.component.spec.ts @@ -8,7 +8,6 @@ import { import { DatasetDetailsDashboardComponent } from "./dataset-details-dashboard.component"; import { MockActivatedRoute, MockUserApi } from "shared/MockStubs"; import { Store, StoreModule } from "@ngrx/store"; -import { UserApi } from "shared/sdk"; import { NO_ERRORS_SCHEMA } from "@angular/core"; import { SharedScicatFrontendModule } from "shared/shared.module"; import { Router, ActivatedRoute } from "@angular/router"; @@ -19,6 +18,7 @@ import { MatButtonModule } from "@angular/material/button"; import { MockStore } from "@ngrx/store/testing"; import { AppConfigService } from "app-config.service"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; +import { UsersService } from "@scicatproject/scicat-sdk-ts"; describe("DetailsDashboardComponent", () => { let component: DatasetDetailsDashboardComponent; @@ -59,7 +59,7 @@ describe("DetailsDashboardComponent", () => { }, }, { provide: ActivatedRoute, useClass: MockActivatedRoute }, - { provide: UserApi, useClass: MockUserApi }, + { provide: UsersService, useClass: MockUserApi }, ], }, }); diff --git a/src/app/datasets/dataset-details-dashboard/dataset-details-dashboard.component.ts b/src/app/datasets/dataset-details-dashboard/dataset-details-dashboard.component.ts index e022a675b..52b505b6a 100644 --- a/src/app/datasets/dataset-details-dashboard/dataset-details-dashboard.component.ts +++ b/src/app/datasets/dataset-details-dashboard/dataset-details-dashboard.component.ts @@ -6,8 +6,10 @@ import { AfterViewChecked, } from "@angular/core"; import { Store } from "@ngrx/store"; -import { Dataset } from "shared/sdk/models"; -import { UserApi } from "shared/sdk"; +import { + OutputDatasetObsoleteDto, + UsersService, +} from "@scicatproject/scicat-sdk-ts"; import { selectCurrentDataset } from "state-management/selectors/datasets.selectors"; import { selectIsAdmin, @@ -76,7 +78,7 @@ export class DatasetDetailsDashboardComponent jwt$: Observable = new Observable(); appConfig = this.appConfigService.getConfig(); - dataset: Dataset | undefined; + dataset: OutputDatasetObsoleteDto | undefined; navLinks: { location: string; label: string; @@ -114,7 +116,7 @@ export class DatasetDetailsDashboardComponent private cdRef: ChangeDetectorRef, private route: ActivatedRoute, private store: Store, - private userApi: UserApi, + private userService: UsersService, public dialog: MatDialog, ) {} @@ -221,7 +223,7 @@ export class DatasetDetailsDashboardComponent } }); this.subscriptions.push(datasetSub); - this.jwt$ = this.userApi.jwt(); + this.jwt$ = this.userService.usersControllerGetUserJWT(); } resetTabs() { Object.values(this.fetchDataActions).forEach((tab) => { diff --git a/src/app/datasets/dataset-file-uploader/dataset-file-uploader.component.spec.ts b/src/app/datasets/dataset-file-uploader/dataset-file-uploader.component.spec.ts index cb14374dc..de3f709a2 100644 --- a/src/app/datasets/dataset-file-uploader/dataset-file-uploader.component.spec.ts +++ b/src/app/datasets/dataset-file-uploader/dataset-file-uploader.component.spec.ts @@ -3,7 +3,6 @@ import { Router } from "@angular/router"; import { Store, StoreModule } from "@ngrx/store"; import { MockStore } from "@ngrx/store/testing"; import { SubmitCaptionEvent } from "shared/modules/file-uploader/file-uploader.component"; -import { Dataset, User } from "shared/sdk"; import { addAttachmentAction, removeAttachmentAction, @@ -14,7 +13,7 @@ import { DatasetFileUploaderComponent } from "./dataset-file-uploader.component" import { SharedScicatFrontendModule } from "shared/shared.module"; import { AppConfigService } from "app-config.service"; import { HttpClient } from "@angular/common/http"; -import { MockHttp } from "shared/MockStubs"; +import { mockDataset, MockHttp, mockUser } from "shared/MockStubs"; const router = { navigateByUrl: jasmine.createSpy("navigateByUrl"), @@ -66,8 +65,8 @@ describe("DatasetFileUploaderComponent", () => { it("should dispatch an AddAttchment action", () => { dispatchSpy = spyOn(store, "dispatch"); - component.user = new User(); - component.dataset = new Dataset(); + component.user = mockUser; + component.dataset = mockDataset; const file = { name: "test", size: 100, @@ -87,7 +86,7 @@ describe("DatasetFileUploaderComponent", () => { it("should dispatch an UpdateAttachmentCaptionAction", () => { dispatchSpy = spyOn(store, "dispatch"); - component.dataset = new Dataset(); + component.dataset = mockDataset; const event: SubmitCaptionEvent = { attachmentId: "testAttachmentId", caption: "Test caption", @@ -100,6 +99,7 @@ describe("DatasetFileUploaderComponent", () => { datasetId: component.dataset.pid, attachmentId: event.attachmentId, caption: event.caption, + ownerGroup: component.dataset.ownerGroup, }), ); }); @@ -109,7 +109,7 @@ describe("DatasetFileUploaderComponent", () => { it("should dispatch a DeleteAttachment action", () => { dispatchSpy = spyOn(store, "dispatch"); - component.dataset = new Dataset(); + component.dataset = mockDataset; const attachmentId = "testAttachmentId"; component.deleteAttachment(attachmentId); diff --git a/src/app/datasets/dataset-file-uploader/dataset-file-uploader.component.ts b/src/app/datasets/dataset-file-uploader/dataset-file-uploader.component.ts index 4194c61e3..8c87c9e00 100644 --- a/src/app/datasets/dataset-file-uploader/dataset-file-uploader.component.ts +++ b/src/app/datasets/dataset-file-uploader/dataset-file-uploader.component.ts @@ -6,7 +6,11 @@ import { PickedFile, SubmitCaptionEvent, } from "shared/modules/file-uploader/file-uploader.component"; -import { Attachment, Dataset, User } from "shared/sdk"; +import { + Attachment, + OutputDatasetObsoleteDto, + ReturnedUserDto, +} from "@scicatproject/scicat-sdk-ts"; import { OwnershipService } from "shared/services/ownership.service"; import { addAttachmentAction, @@ -28,8 +32,8 @@ export class DatasetFileUploaderComponent implements OnInit, OnDestroy { attachments: Attachment[] = []; subscriptions: Subscription[] = []; attachment: Partial = {}; - dataset: Dataset | undefined; - user: User | undefined; + dataset: OutputDatasetObsoleteDto | undefined; + user: ReturnedUserDto | undefined; constructor( private store: Store, private ownershipService: OwnershipService, @@ -82,6 +86,7 @@ export class DatasetFileUploaderComponent implements OnInit, OnDestroy { datasetId: this.dataset.pid, attachmentId: event.attachmentId, caption: event.caption, + ownerGroup: this.dataset.ownerGroup, }), ); } diff --git a/src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.spec.ts b/src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.spec.ts index 626b64377..578a5ae71 100644 --- a/src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.spec.ts +++ b/src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.spec.ts @@ -10,7 +10,6 @@ import { DatasetLifecycleComponent } from "./dataset-lifecycle.component"; import { NO_ERRORS_SCHEMA } from "@angular/core"; import { PipesModule } from "shared/pipes/pipes.module"; import { DatePipe } from "@angular/common"; -import { Dataset } from "shared/sdk"; import { MatCardModule } from "@angular/material/card"; import { MatIconModule } from "@angular/material/icon"; import { MatTableModule } from "@angular/material/table"; @@ -20,6 +19,11 @@ import { NgxJsonViewerModule } from "ngx-json-viewer"; import { Store, StoreModule } from "@ngrx/store"; import { MockStore } from "@ngrx/store/testing"; import { AppConfigService } from "app-config.service"; +import { createMock, mockDataset } from "shared/MockStubs"; +import { + HistoryClass, + OutputDatasetObsoleteDto, +} from "@scicatproject/scicat-sdk-ts"; const historyItems = [ { @@ -74,7 +78,12 @@ describe("DatasetLifecycleComponent", () => { beforeEach(() => { fixture = TestBed.createComponent(DatasetLifecycleComponent); component = fixture.componentInstance; - component.dataset = { pid: "testPid", history: [] } as unknown as Dataset; + component.dataset = createMock< + OutputDatasetObsoleteDto & { history: HistoryClass[] } + >({ + pid: "testPid", + history: [], + }); fixture.detectChanges(); }); beforeEach(inject([Store], (mockStore: MockStore) => { @@ -114,7 +123,10 @@ describe("DatasetLifecycleComponent", () => { it("should parse dataset.history into a HistoryItem array if dataset is defined", () => { const keywords = ["test", "parse"]; - const dataset = new Dataset(); + const dataset = createMock< + OutputDatasetObsoleteDto & { history: HistoryClass[] } + >({ ...mockDataset }); + // TODO: Check the types here and see if we need the keywords at all or not as it doesn't exist on the HistoryClass. dataset.history = [ { id: "testId", @@ -122,7 +134,7 @@ describe("DatasetLifecycleComponent", () => { updatedBy: "Test User", updatedAt: new Date().toISOString(), }, - ]; + ] as unknown as HistoryClass[]; component.dataset = dataset; const parsedHistoryItems = component["parseHistoryItems"](); diff --git a/src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.ts b/src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.ts index ac67f1189..c48016849 100644 --- a/src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.ts +++ b/src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.ts @@ -1,5 +1,8 @@ import { Component, OnInit, OnChanges, SimpleChange } from "@angular/core"; -import { Dataset } from "shared/sdk"; +import { + DatasetClass, + OutputDatasetObsoleteDto, +} from "@scicatproject/scicat-sdk-ts"; import { trigger, state, @@ -40,7 +43,7 @@ export interface HistoryItem { export class DatasetLifecycleComponent implements OnInit, OnChanges { appConfig = this.appConfigService.getConfig(); - dataset: Dataset | undefined; + dataset: OutputDatasetObsoleteDto | undefined; historyItems: HistoryItem[] = []; pageSizeOptions = [10, 25, 50, 100, 500, 1000]; @@ -59,24 +62,20 @@ export class DatasetLifecycleComponent implements OnInit, OnChanges { ) {} private parseHistoryItems(): HistoryItem[] { - if (this.dataset && this.dataset.history) { - const history = this.dataset.history.map( + // TODO: This should be checked because something is wrong with the types + const dataset = this.dataset as DatasetClass; + if (dataset && dataset.history) { + const history = dataset.history.map( ({ updatedAt, updatedBy, id, ...properties }) => - Object.keys(properties).map( - (property) => - ({ - property, - value: properties[property], - updatedBy: updatedBy.replace("ldap.", ""), - updatedAt: this.datePipe.transform( - updatedAt, - "yyyy-MM-dd HH:mm", - ), - }) as HistoryItem, - ), + Object.keys(properties).map((property) => ({ + property, + value: properties[property], + updatedBy: updatedBy.replace("ldap.", ""), + updatedAt: this.datePipe.transform(updatedAt, "yyyy-MM-dd HH:mm"), + })), ); // flatten and reverse array before return - return ([] as HistoryItem[]).concat(...history).reverse(); + return [].concat(...history).reverse(); } return []; } diff --git a/src/app/datasets/dataset-table-actions/dataset-table-actions.component.spec.ts b/src/app/datasets/dataset-table-actions/dataset-table-actions.component.spec.ts index de553c72d..aca315309 100644 --- a/src/app/datasets/dataset-table-actions/dataset-table-actions.component.spec.ts +++ b/src/app/datasets/dataset-table-actions/dataset-table-actions.component.spec.ts @@ -8,10 +8,10 @@ import { } from "@angular/core/testing"; import { DatasetTableActionsComponent } from "./dataset-table-actions.component"; -import { MockStore, MockArchivingService } from "shared/MockStubs"; +import { MockStore, MockArchivingService, mockDataset } from "shared/MockStubs"; import { NO_ERRORS_SCHEMA } from "@angular/core"; import { Store, StoreModule } from "@ngrx/store"; -import { ArchViewMode, Dataset } from "state-management/models"; +import { ArchViewMode } from "state-management/models"; import { setArchiveViewModeAction, setPublicViewModeAction, @@ -130,7 +130,7 @@ describe("DatasetTableActionsComponent", () => { }); it("should return false if the length of selectedSets is larger than 0", () => { - component.selectedSets = [new Dataset()]; + component.selectedSets = [mockDataset]; const isEmpty = component.isEmptySelection(); diff --git a/src/app/datasets/dataset-table-actions/dataset-table-actions.component.ts b/src/app/datasets/dataset-table-actions/dataset-table-actions.component.ts index dd33b31b1..5f430fb92 100644 --- a/src/app/datasets/dataset-table-actions/dataset-table-actions.component.ts +++ b/src/app/datasets/dataset-table-actions/dataset-table-actions.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, Input, OnDestroy } from "@angular/core"; -import { ArchViewMode, MessageType, Dataset } from "state-management/models"; +import { ArchViewMode, MessageType } from "state-management/models"; import { Store } from "@ngrx/store"; import { setPublicViewModeAction, @@ -19,6 +19,7 @@ import { DialogComponent } from "shared/modules/dialog/dialog.component"; import { showMessageAction } from "state-management/actions/user.actions"; import { selectSubmitError } from "state-management/selectors/jobs.selectors"; import { AppConfigService } from "app-config.service"; +import { OutputDatasetObsoleteDto } from "@scicatproject/scicat-sdk-ts"; @Component({ selector: "dataset-table-actions", @@ -29,7 +30,7 @@ export class DatasetTableActionsComponent implements OnInit, OnDestroy { appConfig = this.appConfigService.getConfig(); loading$ = this.store.select(selectIsLoading); - @Input() selectedSets: Dataset[] | null = []; + @Input() selectedSets: OutputDatasetObsoleteDto[] | null = []; public currentArchViewMode: ArchViewMode = ArchViewMode.all; public viewModes = ArchViewMode; diff --git a/src/app/datasets/dataset-table/dataset-table.component.spec.ts b/src/app/datasets/dataset-table/dataset-table.component.spec.ts index fbf8d9acc..f23ae2a68 100644 --- a/src/app/datasets/dataset-table/dataset-table.component.spec.ts +++ b/src/app/datasets/dataset-table/dataset-table.component.spec.ts @@ -4,7 +4,12 @@ import { DatasetTableComponent, SortChangeEvent, } from "./dataset-table.component"; -import { MockStore, MockDatasetApi } from "shared/MockStubs"; +import { + MockStore, + MockDatasetApi, + mockDataset, + createMock, +} from "shared/MockStubs"; import { NO_ERRORS_SCHEMA } from "@angular/core"; import { ComponentFixture, @@ -13,7 +18,6 @@ import { waitForAsync, } from "@angular/core/testing"; import { StoreModule, Store } from "@ngrx/store"; -import { Dataset, DatasetApi } from "shared/sdk"; import { SharedScicatFrontendModule } from "shared/shared.module"; import { selectDatasetAction, @@ -34,6 +38,7 @@ import { MatIconModule } from "@angular/material/icon"; import { MatPaginatorModule } from "@angular/material/paginator"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { AppConfigService } from "app-config.service"; +import { DatasetClass, DatasetsService } from "@scicatproject/scicat-sdk-ts"; const getConfig = () => ({}); @@ -71,7 +76,7 @@ describe("DatasetTableComponent", () => { provide: AppConfigService, useValue: { getConfig }, }, - { provide: DatasetApi, useClass: MockDatasetApi }, + { provide: DatasetsService, useClass: MockDatasetApi }, ], }, }); @@ -113,7 +118,7 @@ describe("DatasetTableComponent", () => { it("should emit the dataset clicked", () => { const emitSpy = spyOn(component.rowClick, "emit"); - const dataset = new Dataset(); + const dataset = mockDataset; component.doRowClick(dataset); expect(emitSpy).toHaveBeenCalledTimes(1); @@ -131,7 +136,7 @@ describe("DatasetTableComponent", () => { describe("#userErrorCondition()", () => { it("should return true if dataset has missingFilesError", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archiveStatusMessage: "missingFilesError", }; @@ -142,7 +147,7 @@ describe("DatasetTableComponent", () => { }); it("should return false if dataset has no missingFilesError", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archiveStatusMessage: "", }; @@ -155,7 +160,7 @@ describe("DatasetTableComponent", () => { describe("#archivableCondition()", () => { it("should return false if dataset is not archivable and retrievable and does not have a missingFilesError", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: false, retrievable: true, @@ -168,7 +173,7 @@ describe("DatasetTableComponent", () => { }); it("should return false if dataset is not archivable and retrievable and does have a missingFilesError", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: false, retrievable: true, @@ -181,7 +186,7 @@ describe("DatasetTableComponent", () => { }); it("should return false if dataset is not archivable and not retrievable and does not have a missingFilesError", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: false, retrievable: false, @@ -194,7 +199,7 @@ describe("DatasetTableComponent", () => { }); it("should return false if dataset is not archivable and not retrievable and does have a missingFilesError", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: false, retrievable: false, @@ -207,7 +212,7 @@ describe("DatasetTableComponent", () => { }); it("should return false if dataset is not archivable and retrievable and does not have a missingFilesError", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: false, retrievable: true, @@ -220,7 +225,7 @@ describe("DatasetTableComponent", () => { }); it("should return false if dataset is archivable and retrievable and does not have a missingFilesError", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: true, retrievable: true, @@ -233,7 +238,7 @@ describe("DatasetTableComponent", () => { }); it("should return false if dataset is archivable and retrievable and does have a missingFilesError", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: true, retrievable: true, @@ -246,7 +251,7 @@ describe("DatasetTableComponent", () => { }); it("should return true if dataset is archivable and not retrievable and does not have a missingFilesError", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: true, retrievable: false, @@ -261,7 +266,7 @@ describe("DatasetTableComponent", () => { describe("#retrievableCondition()", () => { it("should return false if dataset is archivable and not retrievable", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: true, retrievable: false, @@ -273,7 +278,7 @@ describe("DatasetTableComponent", () => { }); it("should return false if dataset is not archivable and not retrievable", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: false, retrievable: false, @@ -285,7 +290,7 @@ describe("DatasetTableComponent", () => { }); it("should return false if dataset is archivable and retrievable", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: true, retrievable: true, @@ -297,7 +302,7 @@ describe("DatasetTableComponent", () => { }); it("should return true if dataset is retrievable and not archivable", () => { - const dataset = new Dataset(); + const dataset = createMock({}); dataset.datasetlifecycle = { archivable: false, retrievable: true, @@ -311,7 +316,7 @@ describe("DatasetTableComponent", () => { describe("#isSelected()", () => { it("should return false if dataset is not selected", () => { - const dataset = new Dataset(); + const dataset = createMock({}); const selected = component.isSelected(dataset); expect(selected).toEqual(false); @@ -320,7 +325,7 @@ describe("DatasetTableComponent", () => { describe("#isAllSelected()", () => { it("should return false if length of datasets and length of selectedSets are not equal", () => { - component.datasets = [new Dataset()]; + component.datasets = [mockDataset]; const allSelected = component.isAllSelected(); @@ -336,7 +341,7 @@ describe("DatasetTableComponent", () => { describe("#isInBatch()", () => { it("should return false if dataset is not in batch", () => { - const dataset = new Dataset(); + const dataset = createMock({}); const inBatch = component.isInBatch(dataset); expect(inBatch).toEqual(false); @@ -349,7 +354,7 @@ describe("DatasetTableComponent", () => { const event = new MatCheckboxChange(); event.checked = true; - const dataset = new Dataset(); + const dataset = mockDataset; component.onSelect(event, dataset); expect(dispatchSpy).toHaveBeenCalledTimes(1); @@ -363,7 +368,7 @@ describe("DatasetTableComponent", () => { const event = new MatCheckboxChange(); event.checked = false; - const dataset = new Dataset(); + const dataset = mockDataset; component.onSelect(event, dataset); expect(dispatchSpy).toHaveBeenCalledTimes(1); @@ -417,7 +422,7 @@ describe("DatasetTableComponent", () => { describe("#countDerivedDatasets()", () => { xit("should return the number of derived datasets for a dataset", () => { - // const dataset = new Dataset(); + // const dataset = mockDataset; // const numberOfDerivedDataset = component.countDerivedDatasets(dataset); // expect(numberOfDerivedDataset).toEqual(0); }); diff --git a/src/app/datasets/dataset-table/dataset-table.component.ts b/src/app/datasets/dataset-table/dataset-table.component.ts index c3976abd8..fc7a121c1 100644 --- a/src/app/datasets/dataset-table/dataset-table.component.ts +++ b/src/app/datasets/dataset-table/dataset-table.component.ts @@ -9,7 +9,7 @@ import { SimpleChange, ViewEncapsulation, } from "@angular/core"; -import { Dataset, TableColumn } from "state-management/models"; +import { TableColumn } from "state-management/models"; import { MatCheckboxChange } from "@angular/material/checkbox"; import { Subscription } from "rxjs"; import { Store } from "@ngrx/store"; @@ -28,20 +28,19 @@ import { selectTotalSets, selectDatasetsInBatch, } from "state-management/selectors/datasets.selectors"; -import { get } from "lodash"; +import { get } from "lodash-es"; import { AppConfigService } from "app-config.service"; import { selectCurrentUser } from "state-management/selectors/user.selectors"; +import { + DatasetClass, + OutputDatasetObsoleteDto, +} from "@scicatproject/scicat-sdk-ts"; import { PageEvent } from "@angular/material/paginator"; export interface SortChangeEvent { active: string; direction: "asc" | "desc" | ""; } -// interface DatasetDerivationsMap { -// datasetPid: string; -// derivedDatasetsNum: number; -// } - @Component({ selector: "dataset-table", templateUrl: "dataset-table.component.html", @@ -61,18 +60,16 @@ export class DatasetTableComponent implements OnInit, OnDestroy, OnChanges { @Input() tableColumns: TableColumn[] | null = null; displayedColumns: string[] = []; - @Input() selectedSets: Dataset[] | null = null; + @Input() selectedSets: OutputDatasetObsoleteDto[] | null = null; @Output() pageChange = new EventEmitter<{ pageIndex: number; pageSize: number; }>(); - datasets: Dataset[] = []; - // datasetDerivationsMaps: DatasetDerivationsMap[] = []; - // derivationMapPids: string[] = []; + datasets: OutputDatasetObsoleteDto[] = []; @Output() settingsClick = new EventEmitter(); - @Output() rowClick = new EventEmitter(); + @Output() rowClick = new EventEmitter(); constructor( public appConfigService: AppConfigService, @@ -89,13 +86,13 @@ export class DatasetTableComponent implements OnInit, OnDestroy, OnChanges { this.settingsClick.emit(event); } - doRowClick(dataset: Dataset): void { + doRowClick(dataset: OutputDatasetObsoleteDto): void { this.rowClick.emit(dataset); } // conditional to asses dataset status and assign correct icon ArchViewMode.work_in_progress // TODO: when these concepts stabilise, we should move the definitions to site config - wipCondition(dataset: Dataset): boolean { + wipCondition(dataset: DatasetClass): boolean { if ( !dataset.datasetlifecycle.archivable && !dataset.datasetlifecycle.retrievable && @@ -109,7 +106,7 @@ export class DatasetTableComponent implements OnInit, OnDestroy, OnChanges { return false; } - systemErrorCondition(dataset: Dataset): boolean { + systemErrorCondition(dataset: DatasetClass): boolean { if ( (dataset.datasetlifecycle.retrievable && dataset.datasetlifecycle.archivable) || @@ -123,14 +120,14 @@ export class DatasetTableComponent implements OnInit, OnDestroy, OnChanges { return false; } - userErrorCondition(dataset: Dataset): boolean { + userErrorCondition(dataset: DatasetClass): boolean { if (dataset.datasetlifecycle.archiveStatusMessage === "missingFilesError") { return true; } return false; } - archivableCondition(dataset: Dataset): boolean { + archivableCondition(dataset: DatasetClass): boolean { if ( dataset.datasetlifecycle.archivable && !dataset.datasetlifecycle.retrievable && @@ -141,7 +138,7 @@ export class DatasetTableComponent implements OnInit, OnDestroy, OnChanges { return false; } - retrievableCondition(dataset: Dataset): boolean { + retrievableCondition(dataset: DatasetClass): boolean { if ( !dataset.datasetlifecycle.archivable && dataset.datasetlifecycle.retrievable @@ -151,7 +148,7 @@ export class DatasetTableComponent implements OnInit, OnDestroy, OnChanges { return false; } - isSelected(dataset: Dataset): boolean { + isSelected(dataset: DatasetClass): boolean { if (!this.selectedSets) { return false; } @@ -164,11 +161,11 @@ export class DatasetTableComponent implements OnInit, OnDestroy, OnChanges { return numSelected === numRows; } - isInBatch(dataset: Dataset): boolean { + isInBatch(dataset: DatasetClass): boolean { return this.inBatchPids.indexOf(dataset.pid) !== -1; } - onSelect(event: MatCheckboxChange, dataset: Dataset): void { + onSelect(event: MatCheckboxChange, dataset: OutputDatasetObsoleteDto): void { if (event.checked) { this.store.dispatch(selectDatasetAction({ dataset })); } else { diff --git a/src/app/datasets/publish/publish.component.spec.ts b/src/app/datasets/publish/publish.component.spec.ts index b0418dce9..a60687402 100644 --- a/src/app/datasets/publish/publish.component.spec.ts +++ b/src/app/datasets/publish/publish.component.spec.ts @@ -9,7 +9,6 @@ import { MockActivatedRoute, } from "shared/MockStubs"; import { Store, ActionsSubject } from "@ngrx/store"; -import { PublishedDataApi } from "shared/sdk"; import { FormsModule, ReactiveFormsModule } from "@angular/forms"; import { of } from "rxjs"; import { NO_ERRORS_SCHEMA } from "@angular/core"; @@ -25,6 +24,7 @@ import { MatInputModule } from "@angular/material/input"; import { MatSelectModule } from "@angular/material/select"; import { MatButtonModule } from "@angular/material/button"; import { AppConfigService } from "app-config.service"; +import { PublishedDataService } from "@scicatproject/scicat-sdk-ts"; const getConfig = () => ({ facility: "test", @@ -65,7 +65,7 @@ describe("PublishComponent", () => { { provide: ActivatedRoute, useClass: MockActivatedRoute }, { provide: ActionsSubject, useValue: of({}) }, { provide: AppConfigService, useValue: { getConfig } }, - { provide: PublishedDataApi, useClass: MockPublishedDataApi }, + { provide: PublishedDataService, useClass: MockPublishedDataApi }, { provide: Router, useClass: MockRouter }, { provide: Store, useClass: MockStore }, ], diff --git a/src/app/datasets/publish/publish.component.ts b/src/app/datasets/publish/publish.component.ts index d79cda7cd..3141a3229 100644 --- a/src/app/datasets/publish/publish.component.ts +++ b/src/app/datasets/publish/publish.component.ts @@ -11,8 +11,10 @@ import { fetchPublishedDataCompleteAction, } from "state-management/actions/published-data.actions"; -import { PublishedDataApi } from "shared/sdk/services/custom"; -import { PublishedData } from "shared/sdk/models"; +import { + CreatePublishedDataDto, + PublishedDataService, +} from "@scicatproject/scicat-sdk-ts"; import { formatDate } from "@angular/common"; import { Router } from "@angular/router"; import { selectCurrentPublishedData } from "state-management/selectors/published-data.selectors"; @@ -60,7 +62,7 @@ export class PublishComponent implements OnInit, OnDestroy { constructor( private appConfigService: AppConfigService, private store: Store, - private publishedDataApi: PublishedDataApi, + private publishedDataApi: PublishedDataService, private actionsSubj: ActionsSubject, private router: Router, ) {} @@ -147,7 +149,7 @@ export class PublishComponent implements OnInit, OnDestroy { }); this.publishedDataApi - .formPopulate(this.form.pidArray[0]) + .publishedDataControllerFormPopulate(this.form.pidArray[0]) .subscribe((result) => { this.form.abstract = result.abstract; this.form.title = result.title; @@ -175,25 +177,38 @@ export class PublishComponent implements OnInit, OnDestroy { } public onPublish() { - const publishedData = new PublishedData(); - publishedData.title = this.form.title; - publishedData.abstract = this.form.abstract; - publishedData.dataDescription = this.form.description; - publishedData.resourceType = this.form.resourceType; - - publishedData.creator = this.form.creators; - publishedData.pidArray = this.form.pidArray; - publishedData.publisher = this.form.publisher; - publishedData.publicationYear = parseInt( - formatDate(this.today, "yyyy", "en_GB"), - 10, - ); - publishedData.url = this.form.url; - publishedData.thumbnail = this.form.thumbnail; - publishedData.numberOfFiles = this.form.numberOfFiles; - publishedData.sizeOfArchive = this.form.sizeOfArchive; - publishedData.downloadLink = this.form.downloadLink; - publishedData.relatedPublications = this.form.relatedPublications; + const { + title, + abstract, + description, + creators, + resourceType, + pidArray, + publisher, + url, + thumbnail, + numberOfFiles, + sizeOfArchive, + downloadLink, + relatedPublications, + } = this.form; + + const publishedData: CreatePublishedDataDto = { + title: title, + abstract: abstract, + dataDescription: description, + creator: creators, + resourceType: resourceType, + pidArray: pidArray, + publisher: publisher, + publicationYear: parseInt(formatDate(this.today, "yyyy", "en_GB"), 10), + url: url, + thumbnail: thumbnail, + numberOfFiles: numberOfFiles, + sizeOfArchive: sizeOfArchive, + downloadLink: downloadLink, + relatedPublications: relatedPublications, + }; this.store.dispatch(publishDatasetAction({ data: publishedData })); } diff --git a/src/app/datasets/reduce/reduce.component.spec.ts b/src/app/datasets/reduce/reduce.component.spec.ts index b3b9f31ce..713d9a0c6 100644 --- a/src/app/datasets/reduce/reduce.component.spec.ts +++ b/src/app/datasets/reduce/reduce.component.spec.ts @@ -8,7 +8,7 @@ import { import { Store, StoreModule } from "@ngrx/store"; import { ReduceComponent } from "./reduce.component"; -import { MockStore } from "shared/MockStubs"; +import { MockStore, createMock, mockDataset } from "shared/MockStubs"; import { Router } from "@angular/router"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; @@ -17,7 +17,6 @@ import { selectOpenwhiskResult, selectDatasets, } from "state-management/selectors/datasets.selectors"; -import { Dataset } from "shared/sdk"; import { reduceDatasetAction } from "state-management/actions/datasets.actions"; import { FormBuilder } from "@angular/forms"; import { MatButtonModule } from "@angular/material/button"; @@ -29,6 +28,7 @@ import { MatStepperModule } from "@angular/material/stepper"; import { MatTableModule } from "@angular/material/table"; import { MatFormFieldModule } from "@angular/material/form-field"; import { MatOptionModule } from "@angular/material/core"; +import { DatasetClass } from "@scicatproject/scicat-sdk-ts"; describe("ReduceComponent", () => { let component: ReduceComponent; @@ -97,7 +97,7 @@ describe("ReduceComponent", () => { it("should dispatch a reduceDatasetAction", () => { dispatchSpy = spyOn(store, "dispatch"); - const dataset = new Dataset(); + const dataset = mockDataset; component.reduceDataset(dataset); @@ -110,7 +110,7 @@ describe("ReduceComponent", () => { describe("#onRowClick()", () => { it("should navigate to a dataset", () => { - const dataset = new Dataset(); + const dataset = createMock({}); component.onRowClick(dataset); expect(router.navigateByUrl).toHaveBeenCalledTimes(1); diff --git a/src/app/datasets/reduce/reduce.component.ts b/src/app/datasets/reduce/reduce.component.ts index bfc198f0c..d91884fd5 100644 --- a/src/app/datasets/reduce/reduce.component.ts +++ b/src/app/datasets/reduce/reduce.component.ts @@ -7,7 +7,6 @@ import { } from "@angular/core"; import { Router } from "@angular/router"; import { Store } from "@ngrx/store"; -import { Dataset, DerivedDataset } from "shared/sdk/models"; import { selectOpenwhiskResult, selectDatasets, @@ -22,6 +21,10 @@ import { selectIsLoggedIn, } from "state-management/selectors/user.selectors"; import { OwnershipService } from "shared/services/ownership.service"; +import { + DatasetClass, + OutputDatasetObsoleteDto, +} from "@scicatproject/scicat-sdk-ts"; @Component({ selector: "reduce", @@ -29,20 +32,21 @@ import { OwnershipService } from "shared/services/ownership.service"; styleUrls: ["./reduce.component.scss"], }) export class ReduceComponent implements OnInit, OnChanges, OnDestroy { - dataset: Dataset | undefined; + dataset: OutputDatasetObsoleteDto | undefined; subscriptions: Subscription[] = []; - derivedDatasets$ = this.store.select(selectDatasets).pipe( - map((datasets) => - datasets - .filter((dataset) => dataset.type === "derived") - .map((dataset: unknown) => dataset as DerivedDataset) - .filter((dataset) => - dataset["inputDatasets"].includes(this.dataset?.pid), - ), - ), - ); - - derivedDatasets: DerivedDataset[] = []; + derivedDatasets$ = this.store + .select(selectDatasets) + .pipe( + map((datasets) => + datasets + .filter((dataset) => dataset.type === "derived") + .filter((dataset) => + dataset["inputDatasets"].includes(this.dataset?.pid), + ), + ), + ); + + derivedDatasets = []; loading$ = this.store.select(selectIsLoading); loggedIn$ = this.store.select(selectIsLoggedIn); result$ = this.store.select(selectOpenwhiskResult); @@ -83,11 +87,11 @@ export class ReduceComponent implements OnInit, OnChanges, OnDestroy { private ownershipService: OwnershipService, ) {} - reduceDataset(dataset: Dataset): void { + reduceDataset(dataset: OutputDatasetObsoleteDto): void { this.store.dispatch(reduceDatasetAction({ dataset })); } - onRowClick(dataset: Dataset): void { + onRowClick(dataset: DatasetClass): void { const pid = encodeURIComponent(dataset.pid); this.router.navigateByUrl("/datasets/" + pid); } @@ -130,16 +134,17 @@ export class ReduceComponent implements OnInit, OnChanges, OnDestroy { for (const propName in changes) { if (propName === "dataset") { this.dataset = changes[propName].currentValue; - this.derivedDatasets$ = this.store.select(selectDatasets).pipe( - map((datasets) => - datasets - .filter((dataset) => dataset.type === "derived") - .map((dataset: unknown) => dataset as DerivedDataset) - .filter((dataset) => - dataset["inputDatasets"].includes(this.dataset?.pid), - ), - ), - ); + this.derivedDatasets$ = this.store + .select(selectDatasets) + .pipe( + map((datasets) => + datasets + .filter((dataset) => dataset.type === "derived") + .filter((dataset) => + dataset["inputDatasets"].includes(this.dataset?.pid), + ), + ), + ); } } } diff --git a/src/app/datasets/related-datasets/related-datasets.component.spec.ts b/src/app/datasets/related-datasets/related-datasets.component.spec.ts index d90f547e5..654c70d91 100644 --- a/src/app/datasets/related-datasets/related-datasets.component.spec.ts +++ b/src/app/datasets/related-datasets/related-datasets.component.spec.ts @@ -4,7 +4,6 @@ import { Router } from "@angular/router"; import { Store } from "@ngrx/store"; import { provideMockStore } from "@ngrx/store/testing"; import { PageChangeEvent } from "shared/modules/table/table.component"; -import { Dataset } from "shared/sdk"; import { changeRelatedDatasetsPageAction, fetchRelatedDatasetsAction, @@ -13,6 +12,8 @@ import { selectRelatedDatasetsPageViewModel } from "state-management/selectors/d import { RelatedDatasetsComponent } from "./related-datasets.component"; import { TableModule } from "shared/modules/table/table.module"; +import { createMock } from "shared/MockStubs"; +import { DatasetClass } from "@scicatproject/scicat-sdk-ts"; describe("RelatedDatasetsComponent", () => { let component: RelatedDatasetsComponent; @@ -88,7 +89,7 @@ describe("RelatedDatasetsComponent", () => { describe("#onRowClick()", () => { it("should navigate to a dataset", () => { - const dataset = new Dataset(); + const dataset = createMock({}); component.onRowClick(dataset); diff --git a/src/app/datasets/related-datasets/related-datasets.component.ts b/src/app/datasets/related-datasets/related-datasets.component.ts index 85981282d..2c1007323 100644 --- a/src/app/datasets/related-datasets/related-datasets.component.ts +++ b/src/app/datasets/related-datasets/related-datasets.component.ts @@ -7,7 +7,10 @@ import { PageChangeEvent, TableColumn, } from "shared/modules/table/table.component"; -import { Dataset } from "shared/sdk"; +import { + DatasetClass, + OutputDatasetObsoleteDto, +} from "@scicatproject/scicat-sdk-ts"; import { changeRelatedDatasetsPageAction, fetchRelatedDatasetsAction, @@ -79,7 +82,9 @@ export class RelatedDatasetsComponent { private store: Store, ) {} - formatTableData(datasets: Dataset[]): Record[] { + formatTableData( + datasets: OutputDatasetObsoleteDto[], + ): Record[] { if (!datasets) { return []; } @@ -108,7 +113,7 @@ export class RelatedDatasetsComponent { this.store.dispatch(fetchRelatedDatasetsAction()); } - onRowClick(dataset: Dataset): void { + onRowClick(dataset: DatasetClass): void { const pid = encodeURIComponent(dataset.pid); this.router.navigateByUrl("/datasets/" + pid); } diff --git a/src/app/datasets/sample-edit/sample-edit.component.spec.ts b/src/app/datasets/sample-edit/sample-edit.component.spec.ts index d8222c610..0478b37be 100644 --- a/src/app/datasets/sample-edit/sample-edit.component.spec.ts +++ b/src/app/datasets/sample-edit/sample-edit.component.spec.ts @@ -19,12 +19,11 @@ import { MatPaginatorModule } from "@angular/material/paginator"; import { MatTableModule } from "@angular/material/table"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { Store } from "@ngrx/store"; -import { MockStore } from "shared/MockStubs"; +import { createMock, MockStore } from "shared/MockStubs"; import { PageChangeEvent, SortChangeEvent, } from "shared/modules/table/table.component"; -import { Sample } from "shared/sdk"; import { changePageAction, setTextFilterAction, @@ -32,6 +31,7 @@ import { } from "state-management/actions/samples.actions"; import { SampleEditComponent } from "./sample-edit.component"; +import { SampleClass } from "@scicatproject/scicat-sdk-ts"; describe("SampleEditComponent", () => { let component: SampleEditComponent; @@ -162,22 +162,18 @@ describe("SampleEditComponent", () => { it("should return false if sample in form has same id as current sample", () => { const sampleId = "abc123"; - const sample = new Sample({ + const sample = createMock({ sampleId, owner: "test", description: "test", - createdAt: new Date(), + createdAt: new Date().toString(), sampleCharacteristics: {}, isPublished: false, ownerGroup: "test", accessGroups: [], createdBy: "test", updatedBy: "test", - datasetId: "test", - datasetsId: "test", - rawDatasetId: "test", - derivedDatasetId: "test", - updatedAt: new Date(), + updatedAt: new Date().toString(), }); component.data.sampleId = sampleId; @@ -191,22 +187,18 @@ describe("SampleEditComponent", () => { it("should return true if form is valid", () => { const sampleId = "abc123"; - const sample = new Sample({ + const sample = createMock({ sampleId: "123abc", owner: "test", description: "test", - createdAt: new Date(), + createdAt: new Date().toString(), sampleCharacteristics: {}, isPublished: false, ownerGroup: "test", accessGroups: [], createdBy: "test", updatedBy: "test", - datasetId: "test", - datasetsId: "test", - rawDatasetId: "test", - derivedDatasetId: "test", - updatedAt: new Date(), + updatedAt: new Date().toString(), }); component.data.sampleId = sampleId; @@ -232,22 +224,18 @@ describe("SampleEditComponent", () => { it("should close the dialog and emit data", () => { const dialogCloseSpy = spyOn(component.dialogRef, "close"); - const sample = new Sample({ + const sample = createMock({ sampleId: "123abc", owner: "test", description: "test", - createdAt: new Date(), + createdAt: new Date().toString(), sampleCharacteristics: {}, isPublished: false, ownerGroup: "test", accessGroups: [], createdBy: "test", updatedBy: "test", - datasetId: "test", - datasetsId: "test", - rawDatasetId: "test", - derivedDatasetId: "test", - updatedAt: new Date(), + updatedAt: new Date().toString(), }); component.sample.setValue(sample); diff --git a/src/app/datasets/sample-edit/sample-edit.component.ts b/src/app/datasets/sample-edit/sample-edit.component.ts index da7b6f1c2..3f744e3c6 100644 --- a/src/app/datasets/sample-edit/sample-edit.component.ts +++ b/src/app/datasets/sample-edit/sample-edit.component.ts @@ -21,7 +21,7 @@ import { PageChangeEvent, SortChangeEvent, } from "shared/modules/table/table.component"; -import { Sample } from "shared/sdk"; +import { SampleClass } from "@scicatproject/scicat-sdk-ts"; import { changePageAction, fetchSamplesAction, @@ -57,7 +57,7 @@ export class SampleEditComponent implements OnInit, OnDestroy { ); samplesSubscription: Subscription = new Subscription(); - samples: Sample[] = []; + samples: SampleClass[] = []; selectedSampleId = ""; displayedColumns = [ @@ -69,7 +69,7 @@ export class SampleEditComponent implements OnInit, OnDestroy { ]; form = new FormGroup({ - sample: new FormControl(null, [ + sample: new FormControl(null, [ Validators.required, this.sampleValidator(), ]), @@ -79,7 +79,7 @@ export class SampleEditComponent implements OnInit, OnDestroy { @Inject(MAT_DIALOG_DATA) public data: { ownerGroup: string; sampleId: string }, public dialogRef: MatDialogRef, - private store: Store, + private store: Store, ) { this.store.dispatch(setTextFilterAction({ text: "" })); this.store.dispatch(changePageAction({ page: 0, limit: 10 })); @@ -128,7 +128,7 @@ export class SampleEditComponent implements OnInit, OnDestroy { sortByColumnAction({ column: event.active, direction: event.direction }), ); - onRowClick = (sample: Sample): void => { + onRowClick = (sample: SampleClass): void => { this.selectedSampleId = sample.sampleId; this.sample?.setValue(sample); }; diff --git a/src/app/datasets/share-dialog/share-dialog.component.spec.ts b/src/app/datasets/share-dialog/share-dialog.component.spec.ts index a1144532d..9acc15820 100644 --- a/src/app/datasets/share-dialog/share-dialog.component.spec.ts +++ b/src/app/datasets/share-dialog/share-dialog.component.spec.ts @@ -9,30 +9,16 @@ import { import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { Store, StoreModule } from "@ngrx/store"; -import { of } from "rxjs"; import { MockAppConfigService, + MockAuthService, MockDatasetApi, MockHttp, - MockLoopBackAuth, MockPublishedDataApi, MockStore, MockUserApi, MockUserIdentityApi, } from "shared/MockStubs"; -import { - DatasetApi, - InstrumentApi, - InternalStorage, - JobApi, - LogbookApi, - LoopBackAuth, - ProposalApi, - PublishedDataApi, - SampleApi, - UserApi, - UserIdentityApi, -} from "shared/sdk"; import { showMessageAction } from "state-management/actions/user.actions"; import { Message, MessageType } from "state-management/models"; @@ -41,6 +27,22 @@ import { DatasetsModule } from "datasets/datasets.module"; import { EffectsModule } from "@ngrx/effects"; import { AppConfigService } from "app-config.service"; import { HttpClient } from "@angular/common/http"; +import { + Configuration, + DatasetsService, + InstrumentsService, + JobsService, + LogbooksService, + ProposalsService, + PublishedDataService, + SamplesService, + UserIdentitiesService, + UsersService, +} from "@scicatproject/scicat-sdk-ts"; +import { AuthService } from "shared/services/auth/auth.service"; +import { InternalStorage } from "shared/services/auth/base.storage"; +import { cold } from "jasmine-marbles"; +import { of } from "rxjs"; const data = { infoMessage: "", @@ -51,9 +53,8 @@ const data = { describe("ShareDialogComponent", () => { let component: ShareDialogComponent; let fixture: ComponentFixture; - const appconfig = new MockAppConfigService( - null, - ) as unknown as AppConfigService; + const appconfig = new MockAppConfigService(null); + const authService = new MockAuthService(); beforeEach(async () => { await TestBed.configureTestingModule({ @@ -67,19 +68,27 @@ describe("ShareDialogComponent", () => { providers: [ { provide: MatDialogRef, useValue: { close: () => {} } }, { provide: Store, useClass: MockStore }, - { provide: UserIdentityApi, useClass: MockUserIdentityApi }, - { provide: LogbookApi, useValue: {} }, - { provide: DatasetApi, useClass: MockDatasetApi }, + { provide: UserIdentitiesService, useClass: MockUserIdentityApi }, + { provide: LogbooksService, useValue: {} }, + { provide: DatasetsService, useClass: MockDatasetApi }, { provide: AppConfigService, useValue: appconfig }, { provide: HttpClient, useClass: MockHttp }, - { provide: LoopBackAuth, useClass: MockLoopBackAuth }, - { provide: UserApi, useClass: MockUserApi }, - { provide: InstrumentApi, useValue: {} }, - { provide: JobApi, useValue: {} }, - { provide: ProposalApi, useValue: {} }, - { provide: SampleApi, useValue: {} }, - { provide: PublishedDataApi, useClass: MockPublishedDataApi }, + { provide: AuthService, useValue: authService }, + { provide: UsersService, useClass: MockUserApi }, + { provide: InstrumentsService, useValue: {} }, + { provide: JobsService, useValue: {} }, + { provide: ProposalsService, useValue: {} }, + { provide: SamplesService, useValue: {} }, + { provide: PublishedDataService, useClass: MockPublishedDataApi }, { provide: MAT_DIALOG_DATA, useValue: data }, + { + provide: Configuration, + useClass: Configuration, + }, + { + provide: UserIdentitiesService, + useValue: { userIdentitiesControllerIsValidEmail: () => {} }, + }, InternalStorage, ], }).compileComponents(); @@ -126,9 +135,10 @@ describe("ShareDialogComponent", () => { describe("#add()", () => { it("should dispatch a showMessageAction with type `error` if user does not exist", fakeAsync(() => { - spyOn(component.userIdentityApi, "isValidEmail").and.throwError( - "Not found", - ); + spyOn( + component.userIdentititiesService, + "userIdentitiesControllerIsValidEmail", + ).and.throwError("Not found"); const dispatchSpy = spyOn(component.store, "dispatch"); const email = "test@email.com"; @@ -153,9 +163,11 @@ describe("ShareDialogComponent", () => { email, }, }; - spyOn(component.userIdentityApi, "isValidEmail").and.returnValue( - of(true), - ); + // TODO: Fix this any type casting here + spyOn( + component.userIdentititiesService, + "userIdentitiesControllerIsValidEmail", + ).and.returnValue(of(true) as any); component.emailFormControl.setValue(email); expect(component.emailFormControl.value).toEqual(email); diff --git a/src/app/datasets/share-dialog/share-dialog.component.ts b/src/app/datasets/share-dialog/share-dialog.component.ts index 245faa423..fa4540e70 100644 --- a/src/app/datasets/share-dialog/share-dialog.component.ts +++ b/src/app/datasets/share-dialog/share-dialog.component.ts @@ -2,7 +2,10 @@ import { Component, Inject } from "@angular/core"; import { FormControl, Validators } from "@angular/forms"; import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; import { Store } from "@ngrx/store"; -import { UserIdentityApi } from "shared/sdk"; +import { + UserIdentitiesService, + UsersService, +} from "@scicatproject/scicat-sdk-ts"; import { showMessageAction } from "state-management/actions/user.actions"; import { Message, MessageType } from "state-management/models"; @@ -23,7 +26,7 @@ export class ShareDialogComponent { constructor( public dialogRef: MatDialogRef, public store: Store, - public userIdentityApi: UserIdentityApi, + public userIdentititiesService: UserIdentitiesService, @Inject(MAT_DIALOG_DATA) data: { infoMessage: string; @@ -41,10 +44,12 @@ export class ShareDialogComponent { add = async (email: string): Promise => { try { - const isValidEmail = await this.userIdentityApi - .isValidEmail({ - where: { "profile.email": email.trim() }, - }) + const isValidEmail = await this.userIdentititiesService + .userIdentitiesControllerIsValidEmail( + JSON.stringify({ + where: { "profile.email": email.trim() }, + }), + ) .toPromise(); if (!isValidEmail) { diff --git a/src/app/instruments/instruments-dashboard/instruments-dashboard.component.spec.ts b/src/app/instruments/instruments-dashboard/instruments-dashboard.component.spec.ts index 880e9d244..251df08d1 100644 --- a/src/app/instruments/instruments-dashboard/instruments-dashboard.component.spec.ts +++ b/src/app/instruments/instruments-dashboard/instruments-dashboard.component.spec.ts @@ -6,7 +6,7 @@ import { } from "@angular/core/testing"; import { InstrumentsDashboardComponent } from "./instruments-dashboard.component"; -import { MockStore } from "shared/MockStubs"; +import { MockStore, mockInstrument } from "shared/MockStubs"; import { NO_ERRORS_SCHEMA } from "@angular/core"; import { provideMockStore } from "@ngrx/store/testing"; import { selectInstrumentsDashboardPageViewModel } from "state-management/selectors/instruments.selectors"; @@ -22,7 +22,6 @@ import { sortByColumnAction, } from "state-management/actions/instruments.actions"; import { Router } from "@angular/router"; -import { Instrument } from "shared/sdk"; import { FlexLayoutModule } from "@ngbracket/ngx-layout"; describe("InstrumentsDashboardComponent", () => { @@ -126,7 +125,7 @@ describe("InstrumentsDashboardComponent", () => { describe("#onRowClick()", () => { it("should navigate to an instrument", () => { - const instrument = new Instrument(); + const instrument = mockInstrument; const pid = encodeURIComponent(instrument.pid); component.onRowClick(instrument); diff --git a/src/app/instruments/instruments-dashboard/instruments-dashboard.component.ts b/src/app/instruments/instruments-dashboard/instruments-dashboard.component.ts index 85e1df1b1..29dd67d7b 100644 --- a/src/app/instruments/instruments-dashboard/instruments-dashboard.component.ts +++ b/src/app/instruments/instruments-dashboard/instruments-dashboard.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from "@angular/core"; import { Store } from "@ngrx/store"; -import { Instrument } from "shared/sdk"; +import { Instrument } from "@scicatproject/scicat-sdk-ts"; import { fetchInstrumentsAction, changePageAction, diff --git a/src/app/jobs/jobs-dashboard-new/jobs-dashboard-new.component.spec.ts b/src/app/jobs/jobs-dashboard-new/jobs-dashboard-new.component.spec.ts index ab4c4b82b..897502c7a 100644 --- a/src/app/jobs/jobs-dashboard-new/jobs-dashboard-new.component.spec.ts +++ b/src/app/jobs/jobs-dashboard-new/jobs-dashboard-new.component.spec.ts @@ -4,8 +4,9 @@ import { ActivatedRoute, Router } from "@angular/router"; import { AppConfigService } from "app-config.service"; import { MockActivatedRoute, + MockAppConfigService, + MockAuthService, MockHttp, - MockLoopBackAuth, MockRouter, } from "shared/MockStubs"; import { ExportExcelService } from "shared/services/export-excel.service"; @@ -13,16 +14,18 @@ import { JobsDashboardNewComponent } from "./jobs-dashboard-new.component"; import { SharedTableModule } from "shared/modules/shared-table/shared-table.module"; import { SharedScicatFrontendModule } from "shared/shared.module"; import { HttpClient } from "@angular/common/http"; -import { InternalStorage, LoopBackAuth } from "shared/sdk"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; +import { InternalStorage } from "shared/services/auth/base.storage"; +import { AuthService } from "shared/services/auth/auth.service"; describe("JobsDashboardNewComponent", () => { let component: JobsDashboardNewComponent; let fixture: ComponentFixture; - const getConfig = () => ({}); - beforeEach(waitForAsync(() => { + const appconfig = new MockAppConfigService(null); + const authService = new MockAuthService(); + TestBed.configureTestingModule({ schemas: [NO_ERRORS_SCHEMA], declarations: [JobsDashboardNewComponent], @@ -33,11 +36,11 @@ describe("JobsDashboardNewComponent", () => { ], providers: [ { provide: ActivatedRoute, useClass: MockActivatedRoute }, - { provide: AppConfigService, useValue: { getConfig } }, { provide: ExportExcelService, useValue: {} }, { provide: Router, useClass: MockRouter }, { provide: HttpClient, useClass: MockHttp }, - { provide: LoopBackAuth, useClass: MockLoopBackAuth }, + { provide: AppConfigService, useValue: appconfig }, + { provide: AuthService, useValue: authService }, { provide: InternalStorage }, ], }).compileComponents(); diff --git a/src/app/jobs/jobs-dashboard-new/jobs-dashboard-new.component.ts b/src/app/jobs/jobs-dashboard-new/jobs-dashboard-new.component.ts index 753b181cb..611ee66ce 100644 --- a/src/app/jobs/jobs-dashboard-new/jobs-dashboard-new.component.ts +++ b/src/app/jobs/jobs-dashboard-new/jobs-dashboard-new.component.ts @@ -7,9 +7,9 @@ import { import { SciCatDataSource } from "../../shared/services/scicat.datasource"; import { ScicatDataService } from "../../shared/services/scicat-data-service"; import { ExportExcelService } from "../../shared/services/export-excel.service"; -import { Job } from "shared/sdk"; import { Column } from "shared/modules/shared-table/shared-table.module"; import { AppConfigService } from "app-config.service"; +import { JobsTableData } from "jobs/jobs-dashboard/jobs-dashboard.component"; @Component({ selector: "app-jobs-new-dashboard", @@ -119,7 +119,7 @@ export class JobsDashboardNewComponent implements OnDestroy, AfterViewChecked { this.dataSource.disconnectExportData(); } - onRowClick(job: Job) { + onRowClick(job: JobsTableData) { // currently deactivated, no extra data available /* console.log("Row clicked:", job); const id = encodeURIComponent(job.id); diff --git a/src/app/jobs/jobs-dashboard/jobs-dashboard.component.spec.ts b/src/app/jobs/jobs-dashboard/jobs-dashboard.component.spec.ts index f2e118367..0084ef2f6 100644 --- a/src/app/jobs/jobs-dashboard/jobs-dashboard.component.spec.ts +++ b/src/app/jobs/jobs-dashboard/jobs-dashboard.component.spec.ts @@ -6,10 +6,9 @@ import { } from "@angular/core/testing"; import { JobsDashboardComponent } from "./jobs-dashboard.component"; -import { MockStore } from "shared/MockStubs"; +import { MockStore, createMock, mockJob } from "shared/MockStubs"; import { Router } from "@angular/router"; import { Store, StoreModule } from "@ngrx/store"; -import { Job } from "shared/sdk"; import { NO_ERRORS_SCHEMA } from "@angular/core"; import { SharedScicatFrontendModule } from "shared/shared.module"; import { DatePipe } from "@angular/common"; @@ -24,6 +23,7 @@ import { FlexLayoutModule } from "@ngbracket/ngx-layout"; import { MatCardModule } from "@angular/material/card"; import { MatIconModule } from "@angular/material/icon"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; +import { JobClass } from "@scicatproject/scicat-sdk-ts"; describe("JobsDashboardComponent", () => { let component: JobsDashboardComponent; @@ -84,7 +84,7 @@ describe("JobsDashboardComponent", () => { }); it("should return an array of data object jobs are defined", () => { - const jobs = [new Job()]; + const jobs = [mockJob]; const data = component.formatTableData(jobs); @@ -144,9 +144,13 @@ describe("JobsDashboardComponent", () => { describe("#onRowClick()", () => { it("should navigate to a job", () => { - const job = new Job(); - job.id = "test"; - component.onRowClick(job); + const job = createMock({ id: "test" }); + component.onRowClick({ + ...job, + initiator: "", + statusMessage: "", + createdAt: "", + }); expect(router.navigateByUrl).toHaveBeenCalledTimes(1); expect(router.navigateByUrl).toHaveBeenCalledWith( diff --git a/src/app/jobs/jobs-dashboard/jobs-dashboard.component.ts b/src/app/jobs/jobs-dashboard/jobs-dashboard.component.ts index 04b7ce599..2033ad245 100644 --- a/src/app/jobs/jobs-dashboard/jobs-dashboard.component.ts +++ b/src/app/jobs/jobs-dashboard/jobs-dashboard.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, OnDestroy } from "@angular/core"; import { Router } from "@angular/router"; import { Store } from "@ngrx/store"; -import { Job } from "shared/sdk"; +import { JobClass } from "@scicatproject/scicat-sdk-ts"; import { Subscription } from "rxjs"; import { selectJobs, @@ -91,11 +91,11 @@ export class JobsDashboardComponent implements OnInit, OnDestroy { ); } - formatTableData(jobs: Job[]): JobsTableData[] { + formatTableData(jobs: JobClass[]): JobsTableData[] { let tableData: JobsTableData[] = []; if (jobs) { tableData = jobs.map((job) => ({ - id: job.id, + id: job._id, initiator: job.emailJobInitiator, type: job.type, createdAt: this.datePipe.transform( @@ -145,7 +145,7 @@ export class JobsDashboardComponent implements OnInit, OnDestroy { ); } - onRowClick(job: Job) { + onRowClick(job: JobsTableData) { const id = encodeURIComponent(job.id); this.router.navigateByUrl("/user/jobs/" + id); } diff --git a/src/app/jobs/jobs-detail/jobs-detail.component.ts b/src/app/jobs/jobs-detail/jobs-detail.component.ts index 5ff6a899f..910febb14 100644 --- a/src/app/jobs/jobs-detail/jobs-detail.component.ts +++ b/src/app/jobs/jobs-detail/jobs-detail.component.ts @@ -3,7 +3,8 @@ import { fetchJobAction } from "state-management/actions/jobs.actions"; import { Store } from "@ngrx/store"; import { ActivatedRoute } from "@angular/router"; import { selectCurrentJob } from "state-management/selectors/jobs.selectors"; -import { Subscription } from "rxjs"; +import { Observable, Subscription } from "rxjs"; +import { JobClass } from "@scicatproject/scicat-sdk-ts"; @Component({ selector: "app-jobs-detail", @@ -11,7 +12,10 @@ import { Subscription } from "rxjs"; styleUrls: ["./jobs-detail.component.scss"], }) export class JobsDetailComponent implements OnInit, OnDestroy { - job$ = this.store.select(selectCurrentJob); + // TODO: We should extract the response dto with the right properties instead of using the schema for ApiResponse in the backend + job$ = this.store.select(selectCurrentJob) as Observable< + JobClass & { createdAt: string; updatedAt: string } + >; routeSubscription: Subscription = new Subscription(); constructor( diff --git a/src/app/logbooks/logbooks-dashboard/logbooks-dashboard.component.spec.ts b/src/app/logbooks/logbooks-dashboard/logbooks-dashboard.component.spec.ts index d061266a6..58eb7fa4e 100644 --- a/src/app/logbooks/logbooks-dashboard/logbooks-dashboard.component.spec.ts +++ b/src/app/logbooks/logbooks-dashboard/logbooks-dashboard.component.spec.ts @@ -8,7 +8,7 @@ import { import { LogbooksDashboardComponent } from "./logbooks-dashboard.component"; import { Store, StoreModule } from "@ngrx/store"; -import { MockStore, MockActivatedRoute } from "shared/MockStubs"; +import { MockStore, MockActivatedRoute, createMock } from "shared/MockStubs"; import { ActivatedRoute, Router } from "@angular/router"; import { setTextFilterAction, @@ -17,12 +17,6 @@ import { changePageAction, sortByColumnAction, } from "state-management/actions/logbooks.actions"; -import { - RawDataset, - RawDatasetInterface, - Logbook, - LogbookInterface, -} from "shared/sdk"; import { LogbookFilters } from "state-management/models"; import { RouterTestingModule } from "@angular/router/testing"; @@ -48,14 +42,7 @@ describe("DashboardComponent", () => { let store: MockStore; let dispatchSpy; - const logbookData: LogbookInterface = { - name: "testLogbook", - roomId: "testId", - messages: [{ message: "test1" }, { message: "test2" }], - }; - const logbook = new Logbook(logbookData); - - const rawDatasetData: RawDatasetInterface = { + const rawDatasetData = { pid: "67ac46e4-5e87-11ed-9634-fba3f42127ef", ownerGroup: "testLogbook", proposalId: "testLogbook", @@ -66,8 +53,16 @@ describe("DashboardComponent", () => { sourceFolder: "some/folders/on/some/server", creationTime: undefined, type: "raw", + createdAt: "", + createdBy: "", + inputDatasets: [], + investigator: "", + numberOfFilesArchived: 0, + updatedAt: "", + updatedBy: "", + usedSoftware: [], }; - const dataset = new RawDataset(rawDatasetData); + const dataset = createMock(rawDatasetData); beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ diff --git a/src/app/logbooks/logbooks-dashboard/logbooks-dashboard.component.ts b/src/app/logbooks/logbooks-dashboard/logbooks-dashboard.component.ts index 821838901..0afd3148a 100644 --- a/src/app/logbooks/logbooks-dashboard/logbooks-dashboard.component.ts +++ b/src/app/logbooks/logbooks-dashboard/logbooks-dashboard.component.ts @@ -6,7 +6,10 @@ import { AfterViewChecked, } from "@angular/core"; import { Store } from "@ngrx/store"; -import { Dataset, Logbook } from "shared/sdk"; +import { + Logbook, + OutputDatasetObsoleteDto, +} from "@scicatproject/scicat-sdk-ts"; import { combineLatest, Subscription } from "rxjs"; import { selectLogbooksDashboardPageViewModel } from "state-management/selectors/logbooks.selectors"; import { @@ -48,7 +51,7 @@ export class LogbooksDashboardComponent { vm$ = this.store.select(selectLogbooksDashboardPageViewModel); - dataset: Dataset | undefined = undefined; + dataset: OutputDatasetObsoleteDto | undefined = undefined; appConfig = this.appConfigService.getConfig(); subscriptions: Subscription[] = []; diff --git a/src/app/logbooks/logbooks-detail/logbooks-detail.component.ts b/src/app/logbooks/logbooks-detail/logbooks-detail.component.ts index b7d7ce4e3..7a81635d8 100644 --- a/src/app/logbooks/logbooks-detail/logbooks-detail.component.ts +++ b/src/app/logbooks/logbooks-detail/logbooks-detail.component.ts @@ -5,7 +5,6 @@ import { EventEmitter, ViewEncapsulation, } from "@angular/core"; -import { Logbook } from "state-management/models"; import { PageChangeEvent, SortChangeEvent, @@ -18,7 +17,7 @@ import { encapsulation: ViewEncapsulation.None, }) export class LogbooksDetailComponent { - @Input() logbook: Logbook = new Logbook(); + @Input() logbook: any; @Input() entriesCount: number | null = 0; @Input() entriesPerPage: number | null = 0; @Input() currentPage: number | null = 0; diff --git a/src/app/logbooks/logbooks-table/logbooks-table.component.spec.ts b/src/app/logbooks/logbooks-table/logbooks-table.component.spec.ts index 5d43ca1b4..c1c22ed1a 100644 --- a/src/app/logbooks/logbooks-table/logbooks-table.component.spec.ts +++ b/src/app/logbooks/logbooks-table/logbooks-table.component.spec.ts @@ -4,8 +4,7 @@ import { Store } from "@ngrx/store"; import { Router } from "@angular/router"; import { LogbooksTableComponent } from "./logbooks-table.component"; -import { MockStore } from "shared/MockStubs"; -import { Logbook } from "shared/sdk"; +import { MockStore, mockLogbook } from "shared/MockStubs"; import { MatTableModule } from "@angular/material/table"; import { MatIconModule } from "@angular/material/icon"; import { MatCardModule } from "@angular/material/card"; @@ -52,7 +51,7 @@ describe("LogbooksTableComponent", () => { describe("#onClick()", () => { it("should navigate to a logbook", () => { const name = "testName"; - const logbook = new Logbook(); + const logbook = mockLogbook; logbook.name = name; component.onClick(logbook); diff --git a/src/app/logbooks/logbooks-table/logbooks-table.component.ts b/src/app/logbooks/logbooks-table/logbooks-table.component.ts index a583b3d27..e90e1f21e 100644 --- a/src/app/logbooks/logbooks-table/logbooks-table.component.ts +++ b/src/app/logbooks/logbooks-table/logbooks-table.component.ts @@ -1,10 +1,10 @@ import { Component, OnInit } from "@angular/core"; import { Router } from "@angular/router"; import { Store } from "@ngrx/store"; +import { Logbook } from "@scicatproject/scicat-sdk-ts"; import { fetchLogbooksAction } from "state-management/actions/logbooks.actions"; import { selectLogbooks } from "state-management/selectors/logbooks.selectors"; -import { Logbook } from "state-management/models"; @Component({ selector: "app-logbooks-table", diff --git a/src/app/policies/edit-dialog/edit-dialog.component.ts b/src/app/policies/edit-dialog/edit-dialog.component.ts index cd85bcad8..4d2827868 100644 --- a/src/app/policies/edit-dialog/edit-dialog.component.ts +++ b/src/app/policies/edit-dialog/edit-dialog.component.ts @@ -3,7 +3,7 @@ import { MatChipInputEvent } from "@angular/material/chips"; import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; import { FormControl, FormGroup } from "@angular/forms"; import { COMMA, ENTER } from "@angular/cdk/keycodes"; -import { Policy } from "shared/sdk"; +import { Policy } from "@scicatproject/scicat-sdk-ts"; @Component({ selector: "edit-dialog", diff --git a/src/app/policies/policies-dashboard/policies-dashboard.component.spec.ts b/src/app/policies/policies-dashboard/policies-dashboard.component.spec.ts index dd8a93e55..9ac79e493 100644 --- a/src/app/policies/policies-dashboard/policies-dashboard.component.spec.ts +++ b/src/app/policies/policies-dashboard/policies-dashboard.component.spec.ts @@ -8,8 +8,7 @@ import { import { PoliciesDashboardComponent } from "./policies-dashboard.component"; import { NO_ERRORS_SCHEMA } from "@angular/core"; import { SharedScicatFrontendModule } from "shared/shared.module"; -import { DatasetApi, Policy } from "shared/sdk"; -import { MockDatasetApi, MockStore } from "shared/MockStubs"; +import { MockDatasetApi, MockStore, mockPolicy } from "shared/MockStubs"; import { StoreModule, Store } from "@ngrx/store"; import { PageChangeEvent, @@ -44,6 +43,7 @@ import { MatButtonModule } from "@angular/material/button"; import { MatIconModule } from "@angular/material/icon"; import { FlexLayoutModule } from "@ngbracket/ngx-layout"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; +import { DatasetsService } from "@scicatproject/scicat-sdk-ts"; describe("PoliciesDashboardComponent", () => { let component: PoliciesDashboardComponent; @@ -95,7 +95,7 @@ describe("PoliciesDashboardComponent", () => { TestBed.overrideComponent(PoliciesDashboardComponent, { set: { providers: [ - { provide: DatasetApi, useClass: MockDatasetApi }, + { provide: DatasetsService, useClass: MockDatasetApi }, { provide: Router, useValue: router }, ], }, @@ -292,7 +292,7 @@ describe("PoliciesDashboardComponent", () => { const checkboxEvent: CheckboxEvent = { event: new MatCheckboxChange(), - row: new Policy(), + row: mockPolicy, }; checkboxEvent.event.checked = true; component.onSelectOne(checkboxEvent); @@ -308,7 +308,7 @@ describe("PoliciesDashboardComponent", () => { const checkboxEvent: CheckboxEvent = { event: new MatCheckboxChange(), - row: new Policy(), + row: mockPolicy, }; checkboxEvent.event.checked = false; component.onSelectOne(checkboxEvent); @@ -336,7 +336,7 @@ describe("PoliciesDashboardComponent", () => { it("should dispatch a submitPolicyAction and a clearSelectionAction if there is a result", () => { dispatchSpy = spyOn(store, "dispatch"); - const result = new Policy(); + const result = mockPolicy; component.selectedGroups = ["test"]; component.onDialogClose(result); diff --git a/src/app/policies/policies-dashboard/policies-dashboard.component.ts b/src/app/policies/policies-dashboard/policies-dashboard.component.ts index 2574d4e20..b6319513c 100644 --- a/src/app/policies/policies-dashboard/policies-dashboard.component.ts +++ b/src/app/policies/policies-dashboard/policies-dashboard.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from "@angular/core"; import { Store } from "@ngrx/store"; -import { Policy, DatasetApi } from "shared/sdk"; +import { DatasetsService, Policy } from "@scicatproject/scicat-sdk-ts"; import { TableColumn, PageChangeEvent, @@ -75,7 +75,7 @@ export class PoliciesDashboardComponent implements OnInit { ]; constructor( - private datasetApi: DatasetApi, + private datasetService: DatasetsService, public dialog: MatDialog, private router: Router, private store: Store, @@ -195,8 +195,8 @@ export class PoliciesDashboardComponent implements OnInit { ); // if datasets already exist this.selectedGroups.forEach((group) => { - this.datasetApi - .count({ ownerGroup: group }) + this.datasetService + .datasetsControllerCount(`{ "ownerGroup": "${group}" }`) .pipe( map((count) => { if (count) { diff --git a/src/app/proposals/proposal-dashboard/proposal-dashboard.component.spec.ts b/src/app/proposals/proposal-dashboard/proposal-dashboard.component.spec.ts index e2c468ec3..e79288a81 100644 --- a/src/app/proposals/proposal-dashboard/proposal-dashboard.component.spec.ts +++ b/src/app/proposals/proposal-dashboard/proposal-dashboard.component.spec.ts @@ -16,10 +16,10 @@ import { Store, StoreModule } from "@ngrx/store"; import { ProposalDashboardComponent } from "./proposal-dashboard.component"; import { ProposalsModule } from "proposals/proposals.module"; import { EffectsModule } from "@ngrx/effects"; -import { DatasetApi, LogbookApi, ProposalApi } from "shared/sdk"; import { HttpClient } from "@angular/common/http"; import { ScicatDataService } from "shared/services/scicat-data-service"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; +import { DatasetsService } from "@scicatproject/scicat-sdk-ts"; describe("ProposalDashboardComponent", () => { let component: ProposalDashboardComponent; @@ -49,15 +49,7 @@ describe("ProposalDashboardComponent", () => { { provide: ExportExcelService, useValue: {} }, { provide: Router, useClass: MockRouter }, { provide: Store, useClass: MockStore }, - { provide: DatasetApi, useClass: MockDatasetApi }, - { - provide: LogbookApi, - useValue: jasmine.createSpyObj("logbookApi", ["find", "findByName"]), - }, - { - provide: ProposalApi, - useValue: jasmine.createSpyObj("proposalApi", ["find", "findByName"]), - }, + { provide: DatasetsService, useClass: MockDatasetApi }, { provide: ScicatDataService, useValue: {} }, ], }).compileComponents(); diff --git a/src/app/proposals/proposal-dashboard/proposal-dashboard.component.ts b/src/app/proposals/proposal-dashboard/proposal-dashboard.component.ts index 59c2c6d59..741540750 100644 --- a/src/app/proposals/proposal-dashboard/proposal-dashboard.component.ts +++ b/src/app/proposals/proposal-dashboard/proposal-dashboard.component.ts @@ -7,7 +7,7 @@ import { import { Router } from "@angular/router"; import { AppConfigService } from "app-config.service"; import { Column } from "shared/modules/shared-table/shared-table.module"; -import { Proposal } from "shared/sdk"; +import { ProposalClass } from "@scicatproject/scicat-sdk-ts"; import { ExportExcelService } from "shared/services/export-excel.service"; import { ScicatDataService } from "shared/services/scicat-data-service"; import { SciCatDataSource } from "shared/services/scicat.datasource"; @@ -97,7 +97,7 @@ export class ProposalDashboardComponent implements OnDestroy, AfterViewChecked { ngOnDestroy() { this.dataSource.disconnectExportData(); } - onRowClick(proposal: Proposal) { + onRowClick(proposal: ProposalClass) { const id = encodeURIComponent(proposal.proposalId); this.router.navigateByUrl("/proposals/" + id); } diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.ts b/src/app/proposals/proposal-detail/proposal-detail.component.ts index 97e4befb9..d1b46df23 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.ts +++ b/src/app/proposals/proposal-detail/proposal-detail.component.ts @@ -1,5 +1,5 @@ import { Component, Input, OnDestroy, OnInit } from "@angular/core"; -import { Proposal } from "state-management/models"; +import { ProposalClass } from "@scicatproject/scicat-sdk-ts"; import { AppConfigService } from "app-config.service"; import { Store } from "@ngrx/store"; import { @@ -30,8 +30,8 @@ import { clearProposalsStateAction } from "state-management/actions/proposals.ac export class ProposalDetailComponent implements OnInit, OnDestroy { private subscriptions: Subscription[] = []; private _hasUnsavedChanges = false; - @Input() proposal: Proposal; - parentProposal: Proposal | undefined; + @Input() proposal: ProposalClass; + parentProposal: ProposalClass | undefined; parentProposal$ = this.store.select(selectParentProposal); editingAllowed = false; userProfile$ = this.store.select(selectProfile); diff --git a/src/app/proposals/proposal-logbook/proposal-logbook.component.spec.ts b/src/app/proposals/proposal-logbook/proposal-logbook.component.spec.ts index f221861c5..dda4ac492 100644 --- a/src/app/proposals/proposal-logbook/proposal-logbook.component.spec.ts +++ b/src/app/proposals/proposal-logbook/proposal-logbook.component.spec.ts @@ -8,7 +8,7 @@ import { import { ProposalLogbookComponent } from "./proposal-logbook.component"; import { Store, StoreModule } from "@ngrx/store"; -import { MockStore, MockActivatedRoute } from "shared/MockStubs"; +import { MockStore, MockActivatedRoute, createMock } from "shared/MockStubs"; import { ActivatedRoute } from "@angular/router"; import { setTextFilterAction, @@ -17,7 +17,6 @@ import { sortByColumnAction, fetchLogbookAction, } from "state-management/actions/logbooks.actions"; -import { Logbook, LogbookInterface } from "shared/sdk"; import { LogbookFilters } from "state-management/models"; import { RouterTestingModule } from "@angular/router/testing"; @@ -30,6 +29,7 @@ import { MatIconModule } from "@angular/material/icon"; import { MatExpansionModule } from "@angular/material/expansion"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { AppConfigService } from "app-config.service"; +import { Logbook } from "@scicatproject/scicat-sdk-ts"; const getConfig = () => ({ riotBaseUrl: "https://riot.base.com", @@ -42,12 +42,11 @@ describe("DashboardComponent", () => { let store: MockStore; let dispatchSpy; - const logbookData: LogbookInterface = { + const logbook = createMock({ name: "testLogbook", roomId: "testId", messages: [{ message: "test1" }, { message: "test2" }], - }; - const logbook = new Logbook(logbookData); + }); beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ diff --git a/src/app/proposals/proposal-logbook/proposal-logbook.component.ts b/src/app/proposals/proposal-logbook/proposal-logbook.component.ts index 9133cb58b..3242ba76e 100644 --- a/src/app/proposals/proposal-logbook/proposal-logbook.component.ts +++ b/src/app/proposals/proposal-logbook/proposal-logbook.component.ts @@ -7,7 +7,6 @@ import { AfterViewChecked, } from "@angular/core"; import { Store } from "@ngrx/store"; -import { Logbook } from "shared/sdk"; import { Observable, Subscription, take } from "rxjs"; import { selectCurrentLogbook } from "state-management/selectors/logbooks.selectors"; import { @@ -25,6 +24,7 @@ import { SortChangeEvent, } from "shared/modules/table/table.component"; import { AppConfigService } from "app-config.service"; +import { Logbook } from "@scicatproject/scicat-sdk-ts"; export interface LogbookData { logbook: Logbook; @@ -41,8 +41,7 @@ export interface LogbookData { export class ProposalLogbookComponent implements OnInit, OnDestroy, AfterViewChecked { - logbook$: Observable = - this.store.select(selectCurrentLogbook); + logbook$: Observable = this.store.select(selectCurrentLogbook); appConfig = this.appConfigService.getConfig(); subscriptions: Subscription[] = []; diff --git a/src/app/proposals/view-proposal-page/view-proposal-page.component.spec.ts b/src/app/proposals/view-proposal-page/view-proposal-page.component.spec.ts index c1d092427..3bab22327 100644 --- a/src/app/proposals/view-proposal-page/view-proposal-page.component.spec.ts +++ b/src/app/proposals/view-proposal-page/view-proposal-page.component.spec.ts @@ -6,12 +6,17 @@ import { waitForAsync, } from "@angular/core/testing"; import { NO_ERRORS_SCHEMA } from "@angular/core"; -import { MockStore, MockActivatedRoute } from "shared/MockStubs"; +import { + MockStore, + MockActivatedRoute, + createMock, + mockDataset, + mockProposal, +} from "shared/MockStubs"; import { Router, ActivatedRoute } from "@angular/router"; import { StoreModule, Store } from "@ngrx/store"; import { DatePipe, SlicePipe } from "@angular/common"; import { FileSizePipe } from "shared/pipes/filesize.pipe"; -import { Dataset, Proposal } from "shared/sdk"; import { changeDatasetsPageAction, fetchProposalDatasetsAction, @@ -21,6 +26,7 @@ import { MatTabsModule } from "@angular/material/tabs"; import { MatIconModule } from "@angular/material/icon"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { AppConfigService } from "app-config.service"; +import { DatasetClass } from "@scicatproject/scicat-sdk-ts"; const getConfig = () => ({ logbookEnabled: true, @@ -86,7 +92,7 @@ describe("ViewProposalPageComponent", () => { }); it("should return an array of data objects if there are datasets", () => { - const datasets = [new Dataset()]; + const datasets = [mockDataset]; const data = component.formatTableData(datasets); expect(data.length).toEqual(1); @@ -97,7 +103,7 @@ describe("ViewProposalPageComponent", () => { it("should dispatch a changeDatasetsPageAction and a fetchProposalDatasetsAction", () => { dispatchSpy = spyOn(store, "dispatch"); - const proposal = new Proposal(); + const proposal = mockProposal; proposal.proposalId = "testId"; component.proposal = proposal; const event: PageChangeEvent = { @@ -122,7 +128,7 @@ describe("ViewProposalPageComponent", () => { describe("#onRowClick()", () => { it("should navigate to a dataset", () => { - const dataset = new Dataset(); + const dataset = createMock({}); const pid = encodeURIComponent(dataset.pid); component.onRowClick(dataset); diff --git a/src/app/proposals/view-proposal-page/view-proposal-page.component.ts b/src/app/proposals/view-proposal-page/view-proposal-page.component.ts index d7e0c0341..5ea64cae1 100644 --- a/src/app/proposals/view-proposal-page/view-proposal-page.component.ts +++ b/src/app/proposals/view-proposal-page/view-proposal-page.component.ts @@ -10,7 +10,6 @@ import { clearProposalsStateAction, } from "state-management/actions/proposals.actions"; import { selectViewProposalPageViewModel } from "state-management/selectors/proposals.selectors"; -import { Dataset, Proposal } from "state-management/models"; import { TableColumn, PageChangeEvent, @@ -20,6 +19,11 @@ import { FileSizePipe } from "shared/pipes/filesize.pipe"; import { fetchLogbookAction } from "state-management/actions/logbooks.actions"; import { AppConfigService } from "app-config.service"; import { selectLogbooksDashboardPageViewModel } from "state-management/selectors/logbooks.selectors"; +import { + DatasetClass, + OutputDatasetObsoleteDto, + ProposalClass, +} from "@scicatproject/scicat-sdk-ts"; export interface TableData { pid: string; @@ -41,7 +45,7 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy { logbook$ = this.store.select(selectLogbooksDashboardPageViewModel); appConfig = this.appConfigService.getConfig(); - proposal: Proposal; + proposal: ProposalClass; subscriptions: Subscription[] = []; @@ -66,7 +70,7 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy { private store: Store, ) {} - formatTableData(datasets: Dataset[]): TableData[] { + formatTableData(datasets: OutputDatasetObsoleteDto[]): TableData[] { let tableData: TableData[] = []; if (datasets) { tableData = datasets.map((dataset: any) => ({ @@ -98,7 +102,7 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy { ); } - onRowClick(dataset: Dataset) { + onRowClick(dataset: DatasetClass) { const pid = encodeURIComponent(dataset.pid); this.router.navigateByUrl("/datasets/" + pid); } diff --git a/src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.spec.ts b/src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.spec.ts index c088d2a66..49307cab0 100644 --- a/src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.spec.ts +++ b/src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.spec.ts @@ -6,12 +6,11 @@ import { } from "@angular/core/testing"; import { PublisheddataDashboardComponent } from "./publisheddata-dashboard.component"; -import { MockStore } from "shared/MockStubs"; +import { MockStore, createMock, mockPublishedData } from "shared/MockStubs"; import { NO_ERRORS_SCHEMA } from "@angular/core"; import { StoreModule, Store } from "@ngrx/store"; import { Router } from "@angular/router"; import { CheckboxEvent } from "shared/modules/table/table.component"; -import { PublishedData } from "shared/sdk"; import { MatCheckboxChange } from "@angular/material/checkbox"; import { of } from "rxjs"; import { Message, MessageType } from "state-management/models"; @@ -22,6 +21,7 @@ import { MatIconModule } from "@angular/material/icon"; import { AppConfigService } from "app-config.service"; import { ScicatDataService } from "shared/services/scicat-data-service"; import { ExportExcelService } from "shared/services/export-excel.service"; +import { PublishedData } from "@scicatproject/scicat-sdk-ts"; const getConfig = () => ({}); @@ -105,7 +105,7 @@ describe("PublisheddataDashboardComponent", () => { describe("#onRowClick", () => { it("should navigate to a Published Dataset", () => { - const published = new PublishedData(); + const published = mockPublishedData; const id = encodeURIComponent(published.doi); component.onRowClick(published); @@ -118,7 +118,7 @@ describe("PublisheddataDashboardComponent", () => { describe("#onSelectAll()", () => { it("should add all DOI's to selectedDOIs if checked is true", () => { - const published = new PublishedData({ + const published = createMock({ doi: "test", creator: ["test"], publisher: "test", @@ -128,6 +128,10 @@ describe("PublisheddataDashboardComponent", () => { dataDescription: "test", resourceType: "test", pidArray: [], + createdAt: "", + registeredTime: "", + status: "", + updatedAt: "", }); spyOn(component.vm$, "pipe").and.returnValue( diff --git a/src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.ts b/src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.ts index 9f01cfef8..f0b205b95 100644 --- a/src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.ts +++ b/src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, OnDestroy, Inject } from "@angular/core"; import { Store } from "@ngrx/store"; -import { PublishedData } from "shared/sdk"; +import { PublishedData } from "@scicatproject/scicat-sdk-ts"; import { Router } from "@angular/router"; import { selectPublishedDataDashboardPageViewModel } from "state-management/selectors/published-data.selectors"; import { CheckboxEvent } from "shared/modules/table/table.component"; diff --git a/src/app/publisheddata/publisheddata-details/publisheddata-details.component.spec.ts b/src/app/publisheddata/publisheddata-details/publisheddata-details.component.spec.ts index 4a2a52f1a..079e0b0fc 100644 --- a/src/app/publisheddata/publisheddata-details/publisheddata-details.component.spec.ts +++ b/src/app/publisheddata/publisheddata-details/publisheddata-details.component.spec.ts @@ -7,7 +7,6 @@ import { MockActivatedRoute, } from "shared/MockStubs"; import { Store } from "@ngrx/store"; -import { PublishedDataApi } from "shared/sdk"; import { NgxJsonViewerModule } from "ngx-json-viewer"; import { Router, ActivatedRoute } from "@angular/router"; import { LinkyModule } from "ngx-linky"; @@ -16,6 +15,7 @@ import { MatCardModule } from "@angular/material/card"; import { MatIconModule } from "@angular/material/icon"; import { MatButtonModule } from "@angular/material/button"; import { AppConfigService } from "app-config.service"; +import { PublishedDataService } from "@scicatproject/scicat-sdk-ts"; const getConfig = () => ({ editMetadataEnabled: true, @@ -45,7 +45,7 @@ describe("PublisheddataDetailsComponent", () => { { provide: Store, useClass: MockStore }, { provide: Router, useClass: MockRouter }, { provide: ActivatedRoute, useClass: MockActivatedRoute }, - { provide: PublishedDataApi, useClass: MockPublishedDataApi }, + { provide: PublishedDataService, useClass: MockPublishedDataApi }, { provide: AppConfigService, useValue: { getConfig }, diff --git a/src/app/publisheddata/publisheddata-details/publisheddata-details.component.ts b/src/app/publisheddata/publisheddata-details/publisheddata-details.component.ts index e4527a267..bbfd06043 100644 --- a/src/app/publisheddata/publisheddata-details/publisheddata-details.component.ts +++ b/src/app/publisheddata/publisheddata-details/publisheddata-details.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, OnDestroy } from "@angular/core"; -import { PublishedData } from "shared/sdk"; +import { PublishedData } from "@scicatproject/scicat-sdk-ts"; import { Store } from "@ngrx/store"; import { ActivatedRoute, Router } from "@angular/router"; import { @@ -18,7 +18,7 @@ import { AppConfigService } from "app-config.service"; }) export class PublisheddataDetailsComponent implements OnInit, OnDestroy { currentData$ = this.store.select(selectCurrentPublishedData); - publishedData: PublishedData = new PublishedData(); + publishedData: PublishedData; subscriptions: Subscription[] = []; appConfig = this.appConfigService.getConfig(); show = false; diff --git a/src/app/publisheddata/publisheddata-edit/publisheddata-edit.component.spec.ts b/src/app/publisheddata/publisheddata-edit/publisheddata-edit.component.spec.ts index 472b77d97..692d6c5fb 100644 --- a/src/app/publisheddata/publisheddata-edit/publisheddata-edit.component.spec.ts +++ b/src/app/publisheddata/publisheddata-edit/publisheddata-edit.component.spec.ts @@ -9,7 +9,6 @@ import { MockActivatedRoute, } from "shared/MockStubs"; import { Store, ActionsSubject } from "@ngrx/store"; -import { PublishedDataApi } from "shared/sdk"; import { FormsModule, ReactiveFormsModule } from "@angular/forms"; import { of } from "rxjs"; import { NO_ERRORS_SCHEMA } from "@angular/core"; @@ -25,6 +24,7 @@ import { MatSelectModule } from "@angular/material/select"; import { MatOptionModule } from "@angular/material/core"; import { MatButtonModule } from "@angular/material/button"; import { FlexLayoutModule } from "@ngbracket/ngx-layout"; +import { PublishedDataService } from "@scicatproject/scicat-sdk-ts"; describe("PublisheddataEditComponent", () => { let component: PublisheddataEditComponent; @@ -59,7 +59,7 @@ describe("PublisheddataEditComponent", () => { providers: [ { provide: ActivatedRoute, useClass: MockActivatedRoute }, { provide: ActionsSubject, useValue: of({}) }, - { provide: PublishedDataApi, useClass: MockPublishedDataApi }, + { provide: PublishedDataService, useClass: MockPublishedDataApi }, { provide: Router, useClass: MockRouter }, { provide: Store, useClass: MockStore }, ], diff --git a/src/app/publisheddata/publisheddata-edit/publisheddata-edit.component.ts b/src/app/publisheddata/publisheddata-edit/publisheddata-edit.component.ts index 6618d555b..d7c3ca73c 100644 --- a/src/app/publisheddata/publisheddata-edit/publisheddata-edit.component.ts +++ b/src/app/publisheddata/publisheddata-edit/publisheddata-edit.component.ts @@ -8,7 +8,7 @@ import { import { ActivatedRoute, Router } from "@angular/router"; import { selectCurrentPublishedData } from "state-management/selectors/published-data.selectors"; import { MatChipInputEvent } from "@angular/material/chips"; -import { Attachment, PublishedData } from "shared/sdk"; +import { Attachment, PublishedData } from "@scicatproject/scicat-sdk-ts"; import { PickedFile } from "shared/modules/file-uploader/file-uploader.component"; import { tap } from "rxjs/operators"; import { FormBuilder, FormGroup, Validators } from "@angular/forms"; diff --git a/src/app/samples/sample-dashboard/sample-dashboard.component.spec.ts b/src/app/samples/sample-dashboard/sample-dashboard.component.spec.ts index 350453726..629f5e554 100644 --- a/src/app/samples/sample-dashboard/sample-dashboard.component.spec.ts +++ b/src/app/samples/sample-dashboard/sample-dashboard.component.spec.ts @@ -1,4 +1,4 @@ -import { MockStore, MockActivatedRoute } from "shared/MockStubs"; +import { MockStore, MockActivatedRoute, mockSample } from "shared/MockStubs"; import { NO_ERRORS_SCHEMA } from "@angular/core"; import { Router, ActivatedRoute } from "@angular/router"; import { SampleDashboardComponent } from "./sample-dashboard.component"; @@ -14,7 +14,6 @@ import { changePageAction, sortByColumnAction, } from "state-management/actions/samples.actions"; -import { Sample } from "shared/sdk"; import { PageChangeEvent, SortChangeEvent, @@ -92,7 +91,7 @@ describe("SampleDashboardComponent", () => { describe("#formatTableData", () => { it("should return an array of sample objects formatted for the table", () => { - const samples = [new Sample()]; + const samples = [mockSample]; const data = component.formatTableData(samples); @@ -174,7 +173,7 @@ describe("SampleDashboardComponent", () => { describe("#onRowClick()", () => { it("should navigate to a sample", () => { - const sample = new Sample(); + const sample = mockSample; component.onRowClick(sample); diff --git a/src/app/samples/sample-dashboard/sample-dashboard.component.ts b/src/app/samples/sample-dashboard/sample-dashboard.component.ts index 495a8dc12..9fdb827aa 100644 --- a/src/app/samples/sample-dashboard/sample-dashboard.component.ts +++ b/src/app/samples/sample-dashboard/sample-dashboard.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, OnDestroy } from "@angular/core"; import { Store } from "@ngrx/store"; -import { Sample } from "shared/sdk"; +import { SampleClass } from "@scicatproject/scicat-sdk-ts"; import { changePageAction, fetchSamplesAction, @@ -65,7 +65,7 @@ export class SampleDashboardComponent implements OnInit, OnDestroy { private store: Store, ) {} - formatTableData(samples: Sample[]): any { + formatTableData(samples: SampleClass[]): any { if (samples) { return samples.map((sample) => ({ sampleId: sample.sampleId, @@ -127,7 +127,7 @@ export class SampleDashboardComponent implements OnInit, OnDestroy { ); } - onRowClick(sample: Sample) { + onRowClick(sample: SampleClass) { const id = encodeURIComponent(sample.sampleId); this.router.navigateByUrl("/samples/" + id); } diff --git a/src/app/samples/sample-detail/sample-detail.component.spec.ts b/src/app/samples/sample-detail/sample-detail.component.spec.ts index 3128c8288..8c5064e7b 100644 --- a/src/app/samples/sample-detail/sample-detail.component.spec.ts +++ b/src/app/samples/sample-detail/sample-detail.component.spec.ts @@ -1,6 +1,12 @@ import { ActivatedRoute, Router } from "@angular/router"; -import { MockActivatedRoute, MockStore } from "shared/MockStubs"; +import { + MockActivatedRoute, + MockStore, + createMock, + mockDataset, + mockSample, +} from "shared/MockStubs"; import { SampleDetailComponent } from "./sample-detail.component"; import { Store, StoreModule } from "@ngrx/store"; import { @@ -19,7 +25,6 @@ import { removeAttachmentAction, addAttachmentAction, } from "state-management/actions/samples.actions"; -import { Dataset, Sample, User } from "shared/sdk"; import { SharedScicatFrontendModule } from "shared/shared.module"; import { DatePipe, SlicePipe } from "@angular/common"; import { FileSizePipe } from "shared/pipes/filesize.pipe"; @@ -31,6 +36,7 @@ import { MatIconModule } from "@angular/material/icon"; import { MatTabsModule } from "@angular/material/tabs"; import { FlexLayoutModule } from "@ngbracket/ngx-layout"; import { AppConfigService } from "app-config.service"; +import { DatasetClass, ReturnedUserDto } from "@scicatproject/scicat-sdk-ts"; const getConfig = () => ({ editMetadataEnabled: true, @@ -105,7 +111,7 @@ describe("SampleDetailComponent", () => { }); it("should return an array of data objects if there are datasets", () => { - const datasets = [new Dataset()]; + const datasets = [mockDataset]; const data = component.formatTableData(datasets); expect(data.length).toEqual(1); @@ -116,7 +122,7 @@ describe("SampleDetailComponent", () => { it("should dispatch a saveCharacteristicsAction", () => { dispatchSpy = spyOn(store, "dispatch"); - const sample = new Sample(); + const sample = mockSample; sample.sampleId = "testId"; component.sample = sample; const characteristics = {}; @@ -137,8 +143,8 @@ describe("SampleDetailComponent", () => { it("should dispatch an addAttachmentAction", () => { dispatchSpy = spyOn(store, "dispatch"); - component.user = new User(); - component.sample = new Sample(); + component.user = createMock({}); + component.sample = mockSample; const file = { name: "test", size: 100, @@ -158,7 +164,7 @@ describe("SampleDetailComponent", () => { it("should dispatch an updateAttachmentCaptionAction", () => { dispatchSpy = spyOn(store, "dispatch"); - component.sample = new Sample(); + component.sample = mockSample; const sampleId = "testId"; component.sample.sampleId = sampleId; const event: SubmitCaptionEvent = { @@ -182,7 +188,7 @@ describe("SampleDetailComponent", () => { it("should dispatch a removeAttachmentAction", () => { dispatchSpy = spyOn(store, "dispatch"); - component.sample = new Sample(); + component.sample = mockSample; const sampleId = "testId"; component.sample.sampleId = sampleId; const attachmentId = "testId"; @@ -199,7 +205,7 @@ describe("SampleDetailComponent", () => { it("should dispatch a changeDatasetsPageAction and a fetchSampleDatasetsAction", () => { dispatchSpy = spyOn(store, "dispatch"); - const sample = new Sample(); + const sample = mockSample; sample.sampleId = "testId"; component.sample = sample; const event: PageChangeEvent = { @@ -225,10 +231,10 @@ describe("SampleDetailComponent", () => { describe("#onRowClick()", () => { it("should navigate to a dataset", () => { - const dataset = new Dataset(); + const dataset = mockDataset; dataset.pid = "testId"; - component.onRowClick(dataset); + component.onRowClick(dataset as DatasetClass); expect(router.navigateByUrl).toHaveBeenCalledTimes(1); expect(router.navigateByUrl).toHaveBeenCalledWith( diff --git a/src/app/samples/sample-detail/sample-detail.component.ts b/src/app/samples/sample-detail/sample-detail.component.ts index 657da590c..a807baabb 100644 --- a/src/app/samples/sample-detail/sample-detail.component.ts +++ b/src/app/samples/sample-detail/sample-detail.component.ts @@ -1,7 +1,6 @@ import { ActivatedRoute, Router } from "@angular/router"; import { Component, OnDestroy, OnInit } from "@angular/core"; import { fromEvent, Subscription } from "rxjs"; -import { Sample, Attachment, User, Dataset } from "shared/sdk/models"; import { selectSampleDetailPageViewModel } from "../../state-management/selectors/samples.selectors"; import { Store } from "@ngrx/store"; import { @@ -26,6 +25,14 @@ import { } from "shared/modules/file-uploader/file-uploader.component"; import { EditableComponent } from "app-routing/pending-changes.guard"; import { AppConfigService } from "app-config.service"; +import { + Attachment, + CreateAttachmentDto, + DatasetClass, + OutputDatasetObsoleteDto, + ReturnedUserDto, + SampleClass, +} from "@scicatproject/scicat-sdk-ts"; export interface TableData { pid: string; @@ -50,10 +57,10 @@ export class SampleDetailComponent appConfig = this.appConfigService.getConfig(); - sample: Sample = new Sample(); - user: User = new User(); - attachment: Partial = new Attachment(); - attachments: Attachment[] = [new Attachment()]; + sample: SampleClass; + user: ReturnedUserDto; + attachment: CreateAttachmentDto; + attachments: Attachment[] = []; show = false; subscriptions: Subscription[] = []; @@ -78,7 +85,7 @@ export class SampleDetailComponent private store: Store, ) {} - formatTableData(datasets: Dataset[]): TableData[] { + formatTableData(datasets: OutputDatasetObsoleteDto[]): TableData[] { let tableData: TableData[] = []; if (datasets) { tableData = datasets.map((dataset: any) => ({ @@ -114,12 +121,6 @@ export class SampleDetailComponent ownerGroup: this.sample.ownerGroup, accessGroups: this.sample.accessGroups, sampleId: this.sample.sampleId, - dataset: undefined, - datasetId: undefined, - rawDatasetId: undefined, - derivedDatasetId: undefined, - proposal: undefined, - proposalId: undefined, }; this.store.dispatch(addAttachmentAction({ attachment: this.attachment })); } @@ -153,7 +154,7 @@ export class SampleDetailComponent ); } - onRowClick(dataset: Dataset) { + onRowClick(dataset: DatasetClass) { const id = encodeURIComponent(dataset.pid); this.router.navigateByUrl("/datasets/" + id); } diff --git a/src/app/samples/sample-dialog/sample-dialog.component.ts b/src/app/samples/sample-dialog/sample-dialog.component.ts index 9fa54cbf9..b52d90cd5 100644 --- a/src/app/samples/sample-dialog/sample-dialog.component.ts +++ b/src/app/samples/sample-dialog/sample-dialog.component.ts @@ -2,7 +2,7 @@ import { Component, Inject, OnInit, OnDestroy } from "@angular/core"; import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; import { FormBuilder, FormGroup, Validators } from "@angular/forms"; -import { Sample } from "shared/sdk"; +import { SampleClass } from "@scicatproject/scicat-sdk-ts"; import { Store } from "@ngrx/store"; import { addSampleAction, @@ -22,7 +22,7 @@ export class SampleDialogComponent implements OnInit, OnDestroy { private vm$ = this.store.select(selectSampleDialogPageViewModel); public form: FormGroup; description: string; - sample: Sample = new Sample(); + sample: SampleClass; username = ""; userGroups: string[] | undefined; @@ -33,7 +33,7 @@ export class SampleDialogComponent implements OnInit, OnDestroy { private fb: FormBuilder, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) - { description, sampleCharacteristics, ownerGroup }: Sample, + { description, sampleCharacteristics, ownerGroup }: SampleClass, ) { this.description = description; @@ -47,7 +47,6 @@ export class SampleDialogComponent implements OnInit, OnDestroy { save() { this.dialogRef.close(this.form.value); console.log("gmnov", this.form.value); - this.sample = new Sample(); this.sample.sampleCharacteristics = { characteristics: this.form.value.sampleCharacteristics, }; diff --git a/src/app/shared/MockStubs.ts b/src/app/shared/MockStubs.ts index cfd964f0a..3060e7ce8 100644 --- a/src/app/shared/MockStubs.ts +++ b/src/app/shared/MockStubs.ts @@ -4,13 +4,24 @@ import { Observable, of } from "rxjs"; import { convertToParamMap, UrlTree } from "@angular/router"; import { AppConfig } from "app-config.module"; import { SciCatDataSource } from "./services/scicat.datasource"; -import { LoopBackAuth } from "./sdk"; -import { Injectable } from "@angular/core"; import { ActionConfig, ActionDataset, } from "datasets/datafiles-actions/datafiles-action.interfaces"; import { DataFiles_File } from "datasets/datafiles/datafiles.interfaces"; +import { + Attachment, + Instrument, + JobClass, + OutputDatasetObsoleteDto, + ProposalClass, + PublishedData, + SampleClass, + Logbook, + Policy, + ReturnedUserDto, +} from "@scicatproject/scicat-sdk-ts"; +import { SDKToken } from "./services/auth/auth.service"; export class MockUserApi { getCurrentId() { @@ -29,11 +40,67 @@ export class MockUserApi { return { username: "admin" }; } - jwt() { + usersControllerGetUserJWT() { return of(""); } } +export class MockAuthService { + private token = new SDKToken(); + + protected load(prop: string) { + return ""; + } + + protected persist( + prop: string, + value: string | number | Date | boolean, + expires?: Date, + ): void {} + + public clear(): void {} + + public setRememberMe(value: boolean): void {} + + public setUser(user: ReturnedUserDto) { + this.save(); + } + + public setToken(token: SDKToken): void { + this.save(); + } + + public getToken(): SDKToken { + return this.token; + } + + public getAccessTokenId(): string { + return this.token.id; + } + + public getCurrentUserId() { + return this.token.userId; + } + + public getCurrentUserData() { + return typeof this.token.user === "string" + ? JSON.parse(this.token.user) + : this.token.user; + } + + public isAuthenticated() { + return !( + this.getCurrentUserId() === "" || + this.getCurrentUserId() == null || + this.getCurrentUserId() == "null" + ); + } + + public save(): boolean { + return true; + } +} + export class MockUserIdentityApi { isValidEmail(): Observable { return of(true); @@ -49,15 +116,15 @@ export class MockDatasetApi { return of([]); } - find() { + datasetsControllerFindAll() { return of([]); } - findById() { + datasetsControllerFindById() { return of([]); } - count(data?: any) { + datasetsControllerCount(data?: any) { return of(0); } } @@ -143,7 +210,7 @@ export class MockArchivingService { } export class MockPublishedDataApi { - findbyId() { + publishedDataControllerFindOne() { return of({ creator: "string", publicationYear: "string", @@ -154,7 +221,7 @@ export class MockPublishedDataApi { }); } - find() { + publishedDataControllerFindAll() { return of([ { creator: "string", @@ -167,7 +234,7 @@ export class MockPublishedDataApi { ]); } - formPopulate() { + publishedDataControllerFormPopulate() { return of({}); } } @@ -191,21 +258,6 @@ export class MockScicatDataSource extends SciCatDataSource { } } -@Injectable() -export class MockLoopBackAuth extends LoopBackAuth { - getToken = () => ({ - id: "test", - ttl: null, - scopes: null, - created: null, - user: null, - userId: null, - rememberMe: false, - }); - getAccessToken = () => ({ id: "test" }); - getAccessTokenId = () => "test"; -} - export class MockDatafilesActionsComponent { actionsConfig: ActionConfig[]; dataset: ActionDataset; @@ -263,3 +315,18 @@ export class MockHtmlElement { } submit() {} } + +export function createMock(data?: Partial): T { + return data as T; +} + +export const mockDataset = createMock({}); +export const mockAttachment = createMock({}); +export const mockSample = createMock({}); +export const mockProposal = createMock({}); +export const mockInstrument = createMock({}); +export const mockJob = createMock({}); +export const mockLogbook = createMock({}); +export const mockPolicy = createMock({}); +export const mockPublishedData = createMock({}); +export const mockUser = createMock({}); diff --git a/src/app/shared/modules/file-uploader/file-uploader.component.ts b/src/app/shared/modules/file-uploader/file-uploader.component.ts index af18cfb49..e611a3f3d 100644 --- a/src/app/shared/modules/file-uploader/file-uploader.component.ts +++ b/src/app/shared/modules/file-uploader/file-uploader.component.ts @@ -2,7 +2,7 @@ import { Component, Output, EventEmitter, Input } from "@angular/core"; import { Store } from "@ngrx/store"; import { AppConfigService } from "app-config.service"; import saveAs from "file-saver"; -import { Attachment } from "shared/sdk"; +import { Attachment } from "@scicatproject/scicat-sdk-ts"; import { AttachmentService } from "shared/services/attachment.service"; import { showMessageAction } from "state-management/actions/user.actions"; import { Message, MessageType } from "state-management/models"; diff --git a/src/app/shared/modules/scientific-metadata/metadata-view/metadata-view.component.ts b/src/app/shared/modules/scientific-metadata/metadata-view/metadata-view.component.ts index 125b7220a..92f072a86 100644 --- a/src/app/shared/modules/scientific-metadata/metadata-view/metadata-view.component.ts +++ b/src/app/shared/modules/scientific-metadata/metadata-view/metadata-view.component.ts @@ -18,7 +18,7 @@ import { UnitsService } from "shared/services/units.service"; styleUrls: ["./metadata-view.component.scss"], }) export class MetadataViewComponent implements OnInit, OnChanges { - @Input() metadata: Record = {}; + @Input() metadata: object = {}; tableData: ScientificMetadataTableData[] = []; columnsToDisplay: string[] = ["name", "value", "unit"]; diff --git a/src/app/shared/sdk/index.ts b/src/app/shared/sdk/index.ts deleted file mode 100644 index c49b274a9..000000000 --- a/src/app/shared/sdk/index.ts +++ /dev/null @@ -1,134 +0,0 @@ -/* eslint-disable */ -/** - * @module SDKModule - * @author Jonathan Casarrubias - * @license MIT 2016 Jonathan Casarrubias - * @version 2.1.0 - * @description - * The SDKModule is a generated Software Development Kit automatically built by - * the LoopBack SDK Builder open source module. - * - * The SDKModule provides Angular 2 >= RC.5 support, which means that NgModules - * can import this Software Development Kit as follows: - * - * - * APP Route Module Context - * ============================================================================ - * import { NgModule } from '@angular/core'; - * import { BrowserModule } from '@angular/platform-browser'; - * // App Root - * import { AppComponent } from './app.component'; - * // Feature Modules - * import { SDK[Browser|Node|Native]Module } from './shared/sdk/sdk.module'; - * // Import Routing - * import { routing } from './app.routing'; - * @NgModule({ - * imports: [ - * BrowserModule, - * routing, - * SDK[Browser|Node|Native]Module.forRoot() - * ], - * declarations: [ AppComponent ], - * bootstrap: [ AppComponent ] - * }) - * export class AppModule { } - * - **/ -import { ErrorHandler } from "./services/core/error.service"; -import { LoopBackAuth } from "./services/core/auth.service"; -import { LoggerService } from "./services/custom/logger.service"; -import { SDKModels } from "./services/custom/SDKModels"; -import { InternalStorage, SDKStorage } from "./storage/storage.swaps"; -import { HttpClientModule } from "@angular/common/http"; -import { CommonModule } from "@angular/common"; -import { NgModule, ModuleWithProviders } from "@angular/core"; -import { CookieBrowser } from "./storage/cookie.browser"; -import { StorageBrowser } from "./storage/storage.browser"; -import { SocketBrowser } from "./sockets/socket.browser"; -import { SocketDriver } from "./sockets/socket.driver"; -import { SocketConnection } from "./sockets/socket.connections"; -import { RealTime } from "./services/core/real.time"; -import { UserApi } from "./services/custom/User"; -import { UserCredentialApi } from "./services/custom/UserCredential"; -import { UserIdentityApi } from "./services/custom/UserIdentity"; -import { ApplicationCredentialApi } from "./services/custom/ApplicationCredential"; -import { LogbookApi } from "./services/custom/Logbook"; -import { PublishedDataApi } from "./services/custom/PublishedData"; -import { DatasetApi } from "./services/custom/Dataset"; -import { RawDatasetApi } from "./services/custom/RawDataset"; -import { DerivedDatasetApi } from "./services/custom/DerivedDataset"; -import { SampleApi } from "./services/custom/Sample"; -import { ProposalApi } from "./services/custom/Proposal"; -import { DatablockApi } from "./services/custom/Datablock"; -import { PolicyApi } from "./services/custom/Policy"; -import { OrigDatablockApi } from "./services/custom/OrigDatablock"; -import { AttachmentApi } from "./services/custom/Attachment"; -import { JobApi } from "./services/custom/Job"; -import { ShareGroupApi } from "./services/custom/ShareGroup"; -import { UserSettingApi } from "./services/custom/UserSetting"; -import { InstrumentApi } from "./services/custom/Instrument"; -/** - * @module SDKBrowserModule - * @description - * This module should be imported when building a Web Application in the following scenarios: - * - * 1.- Regular web application - * 2.- Angular universal application (Browser Portion) - * 3.- Progressive applications (Angular Mobile, Ionic, WebViews, etc) - **/ -@NgModule({ - imports: [CommonModule, HttpClientModule], - declarations: [], - exports: [], - providers: [ErrorHandler, SocketConnection], -}) -export class SDKBrowserModule { - static forRoot( - internalStorageProvider: any = { - provide: InternalStorage, - useClass: CookieBrowser, - }, - ): ModuleWithProviders { - return { - ngModule: SDKBrowserModule, - providers: [ - LoopBackAuth, - LoggerService, - SDKModels, - RealTime, - UserApi, - UserCredentialApi, - UserIdentityApi, - ApplicationCredentialApi, - LogbookApi, - PublishedDataApi, - DatasetApi, - RawDatasetApi, - DerivedDatasetApi, - SampleApi, - ProposalApi, - DatablockApi, - PolicyApi, - OrigDatablockApi, - AttachmentApi, - JobApi, - ShareGroupApi, - UserSettingApi, - InstrumentApi, - internalStorageProvider, - { provide: SDKStorage, useClass: StorageBrowser }, - { provide: SocketDriver, useClass: SocketBrowser }, - ], - }; - } -} -/** - * Have Fun!!! - * - Jon - **/ -export * from "./models/index"; -export * from "./services/index"; -export * from "./lb.config"; -export * from "./storage/storage.swaps"; -export { CookieBrowser } from "./storage/cookie.browser"; -export { StorageBrowser } from "./storage/storage.browser"; diff --git a/src/app/shared/sdk/lb.config.ts b/src/app/shared/sdk/lb.config.ts deleted file mode 100644 index 9f8cf2b64..000000000 --- a/src/app/shared/sdk/lb.config.ts +++ /dev/null @@ -1,109 +0,0 @@ -/* eslint-disable */ -/** - * @module LoopBackConfig - * @description - * - * The LoopBackConfig module help developers to externally - * configure the base url and api version for loopback.io - * - * Example - * - * import { LoopBackConfig } from './sdk'; - * - * @Component() // No metadata needed for this module - * - * export class MyApp { - * constructor() { - * LoopBackConfig.setBaseURL('http://localhost:3000'); - * LoopBackConfig.setApiVersion('api'); - * } - * } - **/ -export class LoopBackConfig { - private static path: string = "//0.0.0.0:3000"; - private static version: string | number = "api/v3"; - private static authPrefix: string = ""; - private static debug: boolean = true; - private static filterOn: string = "headers"; - private static whereOn: string = "headers"; - private static secure: boolean = false; - private static withCredentials: boolean = false; - - public static setApiVersion(version: string = "api"): void { - LoopBackConfig.version = version; - } - - public static getApiVersion(): string | number { - return LoopBackConfig.version; - } - - public static setBaseURL(url: string = "/"): void { - LoopBackConfig.path = url; - } - - public static getPath(): string { - return LoopBackConfig.path; - } - - public static setAuthPrefix(authPrefix: string = ""): void { - LoopBackConfig.authPrefix = authPrefix; - } - - public static getAuthPrefix(): string { - return LoopBackConfig.authPrefix; - } - - public static setDebugMode(isEnabled: boolean): void { - LoopBackConfig.debug = isEnabled; - } - - public static debuggable(): boolean { - return LoopBackConfig.debug; - } - - public static filterOnUrl(): void { - LoopBackConfig.filterOn = "url"; - } - - public static filterOnHeaders(): void { - LoopBackConfig.filterOn = "headers"; - } - - public static whereOnUrl(): void { - LoopBackConfig.whereOn = "url"; - } - - public static whereOnHeaders(): void { - LoopBackConfig.whereOn = "headers"; - } - - public static isHeadersFilteringSet(): boolean { - return LoopBackConfig.filterOn === "headers"; - } - - public static isHeadersWhereSet(): boolean { - return LoopBackConfig.whereOn === "headers"; - } - - public static setSecureWebSockets(): void { - LoopBackConfig.secure = true; - } - - public static unsetSecureWebSockets(): void { - LoopBackConfig.secure = false; - } - - public static isSecureWebSocketsSet(): boolean { - return LoopBackConfig.secure; - } - - public static setRequestOptionsCredentials( - withCredentials: boolean = false, - ): void { - LoopBackConfig.withCredentials = withCredentials; - } - - public static getRequestOptionsCredentials(): boolean { - return LoopBackConfig.withCredentials; - } -} diff --git a/src/app/shared/sdk/models/ApplicationCredential.ts b/src/app/shared/sdk/models/ApplicationCredential.ts deleted file mode 100644 index 100154ff3..000000000 --- a/src/app/shared/sdk/models/ApplicationCredential.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* eslint-disable */ - -declare var Object: any; -export interface ApplicationCredentialInterface { - provider: string; - authScheme?: string; - credentials?: any; - created?: Date; - modified?: Date; - id?: any; -} - -export class ApplicationCredential implements ApplicationCredentialInterface { - "provider": string; - "authScheme": string; - "credentials": any; - "created": Date; - "modified": Date; - "id": any; - constructor(data?: ApplicationCredentialInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `ApplicationCredential`. - */ - public static getModelName() { - return "ApplicationCredential"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of ApplicationCredential for dynamic purposes. - **/ - public static factory( - data: ApplicationCredentialInterface, - ): ApplicationCredential { - return new ApplicationCredential(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "ApplicationCredential", - plural: "ApplicationCredentials", - path: "ApplicationCredentials", - idName: "id", - properties: { - provider: { - name: "provider", - type: "string", - }, - authScheme: { - name: "authScheme", - type: "string", - }, - credentials: { - name: "credentials", - type: "any", - }, - created: { - name: "created", - type: "Date", - }, - modified: { - name: "modified", - type: "Date", - }, - id: { - name: "id", - type: "any", - }, - }, - relations: {}, - }; - } -} diff --git a/src/app/shared/sdk/models/Attachment.ts b/src/app/shared/sdk/models/Attachment.ts deleted file mode 100644 index 15b3f8d6b..000000000 --- a/src/app/shared/sdk/models/Attachment.ts +++ /dev/null @@ -1,163 +0,0 @@ -/* eslint-disable */ -import { Dataset, Sample, Proposal } from "../index"; - -declare var Object: any; -export interface AttachmentInterface { - id?: string; - thumbnail: string; - caption?: string; - ownerGroup: string; - accessGroups?: Array; - createdBy?: string; - updatedBy?: string; - datasetId?: string; - sampleId?: string; - proposalId?: string; - rawDatasetId?: string; - derivedDatasetId?: string; - createdAt?: Date; - updatedAt?: Date; - dataset?: Dataset; - sample?: Sample; - proposal?: Proposal; -} - -export class Attachment implements AttachmentInterface { - "id": string; - "thumbnail": string; - "caption": string; - "ownerGroup": string; - "accessGroups": Array; - "createdBy": string; - "updatedBy": string; - "datasetId": string; - "sampleId": string; - "proposalId": string; - "rawDatasetId": string; - "derivedDatasetId": string; - "createdAt": Date; - "updatedAt": Date; - dataset: Dataset; - sample: Sample; - proposal: Proposal; - constructor(data?: AttachmentInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `Attachment`. - */ - public static getModelName() { - return "Attachment"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of Attachment for dynamic purposes. - **/ - public static factory(data: AttachmentInterface): Attachment { - return new Attachment(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "Attachment", - plural: "Attachments", - path: "Attachments", - idName: "id", - properties: { - id: { - name: "id", - type: "string", - }, - thumbnail: { - name: "thumbnail", - type: "string", - default: "retrieve", - }, - caption: { - name: "caption", - type: "string", - default: "", - }, - ownerGroup: { - name: "ownerGroup", - type: "string", - }, - accessGroups: { - name: "accessGroups", - type: "Array<any>", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - datasetId: { - name: "datasetId", - type: "string", - }, - sampleId: { - name: "sampleId", - type: "string", - }, - proposalId: { - name: "proposalId", - type: "string", - }, - rawDatasetId: { - name: "rawDatasetId", - type: "string", - }, - derivedDatasetId: { - name: "derivedDatasetId", - type: "string", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - }, - relations: { - dataset: { - name: "dataset", - type: "Dataset", - model: "Dataset", - relationType: "belongsTo", - keyFrom: "datasetId", - keyTo: "pid", - }, - sample: { - name: "sample", - type: "Sample", - model: "Sample", - relationType: "belongsTo", - keyFrom: "sampleId", - keyTo: "sampleId", - }, - proposal: { - name: "proposal", - type: "Proposal", - model: "Proposal", - relationType: "belongsTo", - keyFrom: "proposalId", - keyTo: "proposalId", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/BaseModels.ts b/src/app/shared/sdk/models/BaseModels.ts deleted file mode 100644 index 9db3d4679..000000000 --- a/src/app/shared/sdk/models/BaseModels.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* eslint-disable */ - -import { FilterLimits } from "shared/services/scicat-data-service"; - -declare var Object: any; -export interface LoopBackFilter { - fields?: any; - include?: any; - limit?: any; - limits?: FilterLimits; - order?: any; - skip?: any; - offset?: any; - where?: any; -} - -export interface AccessTokenInterface { - id?: string; - ttl?: number; - scopes?: ["string"]; - created?: Date; - userId?: string; - user?: any; -} - -export class AccessToken implements AccessTokenInterface { - "id": string; - "ttl": number; - "scopes": ["string"]; - "created": Date; - "userId": string; - "user": any; - constructor(data?: AccessTokenInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `AccessToken`. - */ - public static getModelName() { - return "AccessToken"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of AccessToken for dynamic purposes. - **/ - public static factory(data: AccessTokenInterface): AccessToken { - return new AccessToken(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "AccessToken", - plural: "AccessTokens", - properties: { - id: { - name: "id", - type: "string", - }, - ttl: { - name: "ttl", - type: "number", - default: 1209600, - }, - scopes: { - name: "scopes", - type: '["string"]', - }, - created: { - name: "created", - type: "Date", - }, - userId: { - name: "userId", - type: "string", - }, - }, - relations: { - user: { - name: "user", - type: "User", - model: "User", - }, - }, - }; - } -} - -export class SDKToken implements AccessTokenInterface { - id: any = null; - ttl: number = null; - scopes: any = null; - created: any = null; - userId: any = null; - user: any = null; - rememberMe: boolean = null; - constructor(data?: AccessTokenInterface) { - Object.assign(this, data); - } -} -/** - * This GeoPoint represents both, LoopBack and MongoDB GeoPoint - **/ -export interface GeoPoint { - lat?: number; - lng?: number; - type?: string; - coordinates?: number[]; -} - -export interface StatFilter { - range: string; - custom?: { - start: string; - end: string; - }; - where?: {}; - groupBy?: string; -} diff --git a/src/app/shared/sdk/models/Datablock.ts b/src/app/shared/sdk/models/Datablock.ts deleted file mode 100644 index f5cbae169..000000000 --- a/src/app/shared/sdk/models/Datablock.ts +++ /dev/null @@ -1,153 +0,0 @@ -/* eslint-disable */ -import { Dataset } from "../index"; - -declare var Object: any; -export interface DatablockInterface { - id?: string; - archiveId: string; - size: number; - packedSize?: number; - chkAlg?: string; - version: string; - dataFileList: Array; - ownerGroup: string; - accessGroups?: Array; - createdBy?: string; - updatedBy?: string; - datasetId?: string; - rawDatasetId?: string; - derivedDatasetId?: string; - createdAt?: Date; - updatedAt?: Date; - dataset?: Dataset; -} - -export class Datablock implements DatablockInterface { - "id": string; - "archiveId": string; - "size": number; - "packedSize": number; - "chkAlg": string; - "version": string; - "dataFileList": Array; - "ownerGroup": string; - "accessGroups": Array; - "createdBy": string; - "updatedBy": string; - "datasetId": string; - "rawDatasetId": string; - "derivedDatasetId": string; - "createdAt": Date; - "updatedAt": Date; - dataset: Dataset; - constructor(data?: DatablockInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `Datablock`. - */ - public static getModelName() { - return "Datablock"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of Datablock for dynamic purposes. - **/ - public static factory(data: DatablockInterface): Datablock { - return new Datablock(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "Datablock", - plural: "Datablocks", - path: "Datablocks", - idName: "id", - properties: { - id: { - name: "id", - type: "string", - }, - archiveId: { - name: "archiveId", - type: "string", - }, - size: { - name: "size", - type: "number", - }, - packedSize: { - name: "packedSize", - type: "number", - }, - chkAlg: { - name: "chkAlg", - type: "string", - }, - version: { - name: "version", - type: "string", - }, - dataFileList: { - name: "dataFileList", - type: "Array<any>", - }, - ownerGroup: { - name: "ownerGroup", - type: "string", - }, - accessGroups: { - name: "accessGroups", - type: "Array<any>", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - datasetId: { - name: "datasetId", - type: "string", - }, - rawDatasetId: { - name: "rawDatasetId", - type: "string", - }, - derivedDatasetId: { - name: "derivedDatasetId", - type: "string", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - }, - relations: { - dataset: { - name: "dataset", - type: "Dataset", - model: "Dataset", - relationType: "belongsTo", - keyFrom: "datasetId", - keyTo: "pid", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/Dataset.ts b/src/app/shared/sdk/models/Dataset.ts deleted file mode 100644 index cc2578b4f..000000000 --- a/src/app/shared/sdk/models/Dataset.ts +++ /dev/null @@ -1,354 +0,0 @@ -/* eslint-disable */ -import { - PublishedData, - Sample, - Datablock, - OrigDatablock, - Attachment, - Instrument, -} from "../index"; - -declare var Object: any; -export interface DatasetInterface { - pid?: string; - owner: string; - ownerEmail?: string; - orcidOfOwner?: string; - contactEmail: string; - sourceFolder: string; - sourceFolderHost?: string; - size?: number; - packedSize?: number; - numberOfFiles?: number; - numberOfFilesArchived?: number; - creationTime: Date; - type: string; - validationStatus?: string; - keywords?: Array; - description?: string; - datasetName?: string; - classification?: string; - license?: string; - version?: string; - isPublished?: boolean; - sharedWith?: Array; - ownerGroup: string; - accessGroups?: Array; - createdBy?: string; - updatedBy?: string; - history?: Array; - datasetlifecycle?: any; - publisheddataId?: string; - techniques?: Array; - publishedDataId?: string; - createdAt?: Date; - updatedAt?: Date; - instrumentId?: string; - proposalId?: string | string[]; - sampleId?: string | string[]; - historyList?: any[]; - datasetLifecycle?: any[]; - publisheddata?: PublishedData; - techniquesList?: any[]; - samples?: Sample[]; - datablocks?: Datablock[]; - origdatablocks?: OrigDatablock[]; - attachments?: Attachment[]; - instrument?: Instrument; - scientificMetadata?: any; -} - -export class Dataset implements DatasetInterface { - "pid": string; - "owner": string; - "ownerEmail": string; - "orcidOfOwner": string; - "contactEmail": string; - "sourceFolder": string; - "sourceFolderHost": string; - "size": number; - "packedSize": number; - "numberOfFiles": number; - "numberOfFilesArchived": number; - "creationTime": Date; - "type": string; - "validationStatus": string; - "keywords": Array; - "description": string; - "datasetName": string; - "classification": string; - "license": string; - "version": string; - "isPublished": boolean; - "sharedWith": Array; - "ownerGroup": string; - "accessGroups": Array; - "createdBy": string; - "updatedBy": string; - "history": Array; - "datasetlifecycle": any; - "publisheddataId": string; - "techniques": Array; - "publishedDataId": string; - "createdAt": Date; - "updatedAt": Date; - "instrumentId": string; - historyList: any[]; - datasetLifecycle: any[]; - publisheddata: PublishedData; - techniquesList: any[]; - samples: Sample[]; - datablocks: Datablock[]; - origdatablocks: OrigDatablock[]; - attachments: Attachment[]; - instrument: Instrument; - scientificMetadata?: any; - constructor(data?: DatasetInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `Dataset`. - */ - public static getModelName() { - return "Dataset"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of Dataset for dynamic purposes. - **/ - public static factory(data: DatasetInterface): Dataset { - return new Dataset(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "Dataset", - plural: "Datasets", - path: "Datasets", - idName: "pid", - properties: { - pid: { - name: "pid", - type: "string", - }, - owner: { - name: "owner", - type: "string", - }, - ownerEmail: { - name: "ownerEmail", - type: "string", - }, - orcidOfOwner: { - name: "orcidOfOwner", - type: "string", - }, - contactEmail: { - name: "contactEmail", - type: "string", - }, - sourceFolder: { - name: "sourceFolder", - type: "string", - }, - sourceFolderHost: { - name: "sourceFolderHost", - type: "string", - }, - size: { - name: "size", - type: "number", - }, - packedSize: { - name: "packedSize", - type: "number", - }, - numberOfFiles: { - name: "numberOfFiles", - type: "number", - }, - numberOfFilesArchived: { - name: "numberOfFilesArchived", - type: "number", - }, - creationTime: { - name: "creationTime", - type: "Date", - }, - type: { - name: "type", - type: "string", - }, - validationStatus: { - name: "validationStatus", - type: "string", - }, - keywords: { - name: "keywords", - type: "Array<any>", - }, - description: { - name: "description", - type: "string", - }, - datasetName: { - name: "datasetName", - type: "string", - }, - classification: { - name: "classification", - type: "string", - }, - license: { - name: "license", - type: "string", - }, - version: { - name: "version", - type: "string", - }, - isPublished: { - name: "isPublished", - type: "boolean", - }, - sharedWith: { - name: "sharedWith", - type: "Array<any>", - }, - ownerGroup: { - name: "ownerGroup", - type: "string", - }, - accessGroups: { - name: "accessGroups", - type: "Array<any>", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - history: { - name: "history", - type: "Array<any>", - default: [], - }, - datasetlifecycle: { - name: "datasetlifecycle", - type: "any", - }, - publisheddataId: { - name: "publisheddataId", - type: "string", - }, - techniques: { - name: "techniques", - type: "Array<any>", - default: [], - }, - publishedDataId: { - name: "publishedDataId", - type: "string", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - instrumentId: { - name: "instrumentId", - type: "string", - }, - }, - relations: { - historyList: { - name: "historyList", - type: "any[]", - model: "", - relationType: "embedsMany", - keyFrom: "history", - keyTo: "id", - }, - datasetLifecycle: { - name: "datasetLifecycle", - type: "any[]", - model: "", - relationType: "embedsOne", - keyFrom: "datasetlifecycle", - keyTo: "id", - }, - publisheddata: { - name: "publisheddata", - type: "PublishedData", - model: "PublishedData", - relationType: "belongsTo", - keyFrom: "publisheddataId", - keyTo: "doi", - }, - techniquesList: { - name: "techniquesList", - type: "any[]", - model: "", - relationType: "embedsMany", - keyFrom: "techniques", - keyTo: "pid", - }, - samples: { - name: "samples", - type: "Sample[]", - model: "Sample", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "datasetId", - }, - datablocks: { - name: "datablocks", - type: "Datablock[]", - model: "Datablock", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "datasetId", - }, - origdatablocks: { - name: "origdatablocks", - type: "OrigDatablock[]", - model: "OrigDatablock", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "datasetId", - }, - attachments: { - name: "attachments", - type: "Attachment[]", - model: "Attachment", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "datasetId", - }, - instrument: { - name: "instrument", - type: "Instrument", - model: "Instrument", - relationType: "belongsTo", - keyFrom: "instrumentId", - keyTo: "pid", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/DerivedDataset.ts b/src/app/shared/sdk/models/DerivedDataset.ts deleted file mode 100644 index aacf6f6ed..000000000 --- a/src/app/shared/sdk/models/DerivedDataset.ts +++ /dev/null @@ -1,380 +0,0 @@ -/* eslint-disable */ -import { - PublishedData, - Sample, - Datablock, - OrigDatablock, - Attachment, - Instrument, -} from "../index"; - -declare var Object: any; -export interface DerivedDatasetInterface { - investigator: string; - inputDatasets: Array; - usedSoftware: Array; - jobParameters?: any; - jobLogData?: string; - scientificMetadata?: any; - pid?: string; - owner: string; - ownerEmail?: string; - orcidOfOwner?: string; - contactEmail: string; - sourceFolder: string; - sourceFolderHost?: string; - size?: number; - packedSize?: number; - numberOfFiles?: number; - numberOfFilesArchived?: number; - creationTime: Date; - type: string; - validationStatus?: string; - keywords?: Array; - description?: string; - datasetName?: string; - classification?: string; - license?: string; - version?: string; - isPublished?: boolean; - sharedWith?: Array; - ownerGroup: string; - accessGroups?: Array; - createdBy?: string; - updatedBy?: string; - history?: Array; - datasetlifecycle?: any; - publisheddataId?: string; - techniques?: Array; - createdAt?: Date; - updatedAt?: Date; - instrumentId?: string; - historyList?: any[]; - datasetLifecycle?: any[]; - publisheddata?: PublishedData; - techniquesList?: any[]; - samples?: Sample[]; - datablocks?: Datablock[]; - origdatablocks?: OrigDatablock[]; - attachments?: Attachment[]; - instrument?: Instrument; -} - -export class DerivedDataset implements DerivedDatasetInterface { - "investigator": string; - "inputDatasets": Array; - "usedSoftware": Array; - "jobParameters": any; - "jobLogData": string; - "scientificMetadata": any; - "pid": string; - "owner": string; - "ownerEmail": string; - "orcidOfOwner": string; - "contactEmail": string; - "sourceFolder": string; - "sourceFolderHost": string; - "size": number; - "packedSize": number; - "numberOfFiles": number; - "numberOfFilesArchived": number; - "creationTime": Date; - "type": string; - "validationStatus": string; - "keywords": Array; - "description": string; - "datasetName": string; - "classification": string; - "license": string; - "version": string; - "isPublished": boolean; - "sharedWith": Array; - "ownerGroup": string; - "accessGroups": Array; - "createdBy": string; - "updatedBy": string; - "history": Array; - "datasetlifecycle": any; - "publisheddataId": string; - "techniques": Array; - "createdAt": Date; - "updatedAt": Date; - "instrumentId": string; - historyList: any[]; - datasetLifecycle: any[]; - publisheddata: PublishedData; - techniquesList: any[]; - samples: Sample[]; - datablocks: Datablock[]; - origdatablocks: OrigDatablock[]; - attachments: Attachment[]; - instrument: Instrument; - constructor(data?: DerivedDatasetInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `DerivedDataset`. - */ - public static getModelName() { - return "DerivedDataset"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of DerivedDataset for dynamic purposes. - **/ - public static factory(data: DerivedDatasetInterface): DerivedDataset { - return new DerivedDataset(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "DerivedDataset", - plural: "DerivedDatasets", - path: "DerivedDatasets", - idName: "pid", - properties: { - investigator: { - name: "investigator", - type: "string", - }, - inputDatasets: { - name: "inputDatasets", - type: "Array<any>", - }, - usedSoftware: { - name: "usedSoftware", - type: "Array<any>", - }, - jobParameters: { - name: "jobParameters", - type: "any", - }, - jobLogData: { - name: "jobLogData", - type: "string", - }, - scientificMetadata: { - name: "scientificMetadata", - type: "any", - }, - pid: { - name: "pid", - type: "string", - }, - owner: { - name: "owner", - type: "string", - }, - ownerEmail: { - name: "ownerEmail", - type: "string", - }, - orcidOfOwner: { - name: "orcidOfOwner", - type: "string", - }, - contactEmail: { - name: "contactEmail", - type: "string", - }, - sourceFolder: { - name: "sourceFolder", - type: "string", - }, - sourceFolderHost: { - name: "sourceFolderHost", - type: "string", - }, - size: { - name: "size", - type: "number", - }, - packedSize: { - name: "packedSize", - type: "number", - }, - numberOfFiles: { - name: "numberOfFiles", - type: "number", - }, - numberOfFilesArchived: { - name: "numberOfFilesArchived", - type: "number", - }, - creationTime: { - name: "creationTime", - type: "Date", - }, - type: { - name: "type", - type: "string", - }, - validationStatus: { - name: "validationStatus", - type: "string", - }, - keywords: { - name: "keywords", - type: "Array<any>", - }, - description: { - name: "description", - type: "string", - }, - datasetName: { - name: "datasetName", - type: "string", - }, - classification: { - name: "classification", - type: "string", - }, - license: { - name: "license", - type: "string", - }, - version: { - name: "version", - type: "string", - }, - isPublished: { - name: "isPublished", - type: "boolean", - }, - sharedWith: { - name: "sharedWith", - type: "Array<any>", - }, - ownerGroup: { - name: "ownerGroup", - type: "string", - }, - accessGroups: { - name: "accessGroups", - type: "Array<any>", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - history: { - name: "history", - type: "Array<any>", - default: [], - }, - datasetlifecycle: { - name: "datasetlifecycle", - type: "any", - }, - publisheddataId: { - name: "publisheddataId", - type: "string", - }, - techniques: { - name: "techniques", - type: "Array<any>", - default: [], - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - instrumentId: { - name: "instrumentId", - type: "string", - }, - }, - relations: { - historyList: { - name: "historyList", - type: "any[]", - model: "", - relationType: "embedsMany", - keyFrom: "history", - keyTo: "id", - }, - datasetLifecycle: { - name: "datasetLifecycle", - type: "any[]", - model: "", - relationType: "embedsOne", - keyFrom: "datasetlifecycle", - keyTo: "id", - }, - publisheddata: { - name: "publisheddata", - type: "PublishedData", - model: "PublishedData", - relationType: "belongsTo", - keyFrom: "publisheddataId", - keyTo: "doi", - }, - techniquesList: { - name: "techniquesList", - type: "any[]", - model: "", - relationType: "embedsMany", - keyFrom: "techniques", - keyTo: "pid", - }, - samples: { - name: "samples", - type: "Sample[]", - model: "Sample", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "derivedDatasetId", - }, - datablocks: { - name: "datablocks", - type: "Datablock[]", - model: "Datablock", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "derivedDatasetId", - }, - origdatablocks: { - name: "origdatablocks", - type: "OrigDatablock[]", - model: "OrigDatablock", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "derivedDatasetId", - }, - attachments: { - name: "attachments", - type: "Attachment[]", - model: "Attachment", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "derivedDatasetId", - }, - instrument: { - name: "instrument", - type: "Instrument", - model: "Instrument", - relationType: "belongsTo", - keyFrom: "instrumentId", - keyTo: "pid", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/FireLoop.ts b/src/app/shared/sdk/models/FireLoop.ts deleted file mode 100644 index 4ffdd88d8..000000000 --- a/src/app/shared/sdk/models/FireLoop.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable */ -import { FireLoopRef } from "./index"; - -export class FireLoop { - private references: any = {}; - - constructor( - private socket: any, - private models: { get: Function }, - ) {} - - public ref(model: any): FireLoopRef { - let name: string = model.getModelName(); - model.models = this.models; - this.references[name] = new FireLoopRef(model, this.socket); - return this.references[name]; - } -} diff --git a/src/app/shared/sdk/models/FireLoopRef.ts b/src/app/shared/sdk/models/FireLoopRef.ts deleted file mode 100644 index ad93b6b96..000000000 --- a/src/app/shared/sdk/models/FireLoopRef.ts +++ /dev/null @@ -1,359 +0,0 @@ -/* eslint-disable */ -import { merge, Observable, Subject, throwError } from "rxjs"; -import { catchError } from "rxjs/operators"; -import { LoopBackFilter, StatFilter } from "./index"; -import { SocketConnection } from "../sockets/socket.connections"; -/** - * @class FireLoopRef - * @author Jonathan Casarrubias - * @license MIT - * @description - * This class allows to create FireLoop References which will be in sync with - * Server. It also allows to create FireLoop Reference Childs, that allows to - * persist data according the generic model relationships. - **/ -export class FireLoopRef { - // Reference ID - private id: number = this.buildId(); - // Model Instance (For child references, empty on root references) - private instance: any; - // Model Childs - private childs: any = {}; - // Disposable Events - private disposable: { [key: string]: any } = {}; - /** - * @method constructor - * @param {any} model The model we want to create a reference - * @param {SocketConnection} socket Socket connection to handle events - * @param {FireLoopRef} parent Parent FireLoop model reference - * @param {string} relationship The defined model relationship - * @description - * The constructor will receive the required parameters and then will register this reference - * into the server, needed to allow multiple references for the same model. - * This ids are referenced into this specific client connection and won't have issues - * with other client ids. - **/ - constructor( - private model: any, - private socket: SocketConnection, - private parent: FireLoopRef = null, - private relationship: string = null, - ) { - this.socket.emit( - `Subscribe.${ - !parent ? model.getModelName() : parent.model.getModelName() - }`, - { id: this.id, scope: model.getModelName(), relationship: relationship }, - ); - return this; - } - /** - * @method dispose - * @return {void} - * @description - * This method is super important to avoid memory leaks in the server. - * This method requires to be called on components destroy - * - * ngOnDestroy() { - * this.someRef.dispose() - * } - **/ - public dispose(): void { - const subscription = this.operation("dispose", {}).subscribe(() => { - Object.keys(this.disposable).forEach((channel: string) => { - this.socket.removeListener(channel, this.disposable[channel]); - this.socket.removeAllListeners(channel); - }); - subscription.unsubscribe(); - }); - } - /** - * @method upsert - * @param {T} data Persisted model instance - * @return {Observable} - * @description - * Operation wrapper for upsert function. - **/ - public upsert(data: T): Observable { - return this.operation("upsert", data); - } - /** - * @method create - * @param {T} data Persisted model instance - * @return {Observable} - * @description - * Operation wrapper for create function. - **/ - public create(data: T): Observable { - return this.operation("create", data); - } - /** - * @method remove - * @param {T} data Persisted model instance - * @return {Observable} - * @description - * Operation wrapper for remove function. - **/ - public remove(data: T): Observable { - return this.operation("remove", data); - } - /** - * @method remote - * @param {string} method Remote method name - * @param {any[]=} params Parameters to be applied into the remote method - * @param {boolean} broadcast Flag to define if the method results should be broadcasted - * @return {Observable} - * @description - * This method calls for any remote method. It is flexible enough to - * allow you call either built-in or custom remote methods. - * - * FireLoop provides this interface to enable calling remote methods - * but also to optionally send any defined accept params that will be - * applied within the server. - **/ - public remote( - method: string, - params?: any[], - broadcast: boolean = false, - ): Observable { - return this.operation("remote", { method, params, broadcast }); - } - /** - * @method onRemote - * @param {string} method Remote method name - * @return {Observable} - * @description - * This method listen for public broadcasted remote method results. If the remote method - * execution is not public only the owner will receive the result data. - **/ - public onRemote(method: string): Observable { - let event: string = "remote"; - if (!this.relationship) { - event = `${this.model.getModelName()}.${event}`; - } else { - event = `${this.parent.model.getModelName()}.${ - this.relationship - }.${event}`; - } - return this.broadcasts(event, {}); - } - /** - * @method on - * @param {string} event Event name - * @param {LoopBackFilter} filter LoopBack query filter - * @return {Observable} - * @description - * Listener for different type of events. Valid events are: - * - change (Triggers on any model change -create, update, remove-) - * - value (Triggers on new entries) - * - child_added (Triggers when a child is added) - * - child_updated (Triggers when a child is updated) - * - child_removed (Triggers when a child is removed) - **/ - public on( - event: string, - filter: LoopBackFilter = { limit: 100, order: "id DESC" }, - ): Observable { - if (event === "remote") { - throw new Error( - 'The "remote" event is not allowed using "on()" method, use "onRemote()" instead', - ); - } - let request: any; - if (!this.relationship) { - event = `${this.model.getModelName()}.${event}`; - request = { filter }; - } else { - event = `${this.parent.model.getModelName()}.${ - this.relationship - }.${event}`; - request = { filter, parent: this.parent.instance }; - } - if (event.match(/(value|change|stats)/)) { - return merge(this.pull(event, request), this.broadcasts(event, request)); - } else { - return this.broadcasts(event, request); - } - } - /** - * @method stats - * @param {LoopBackFilter=} filter LoopBack query filter - * @return {Observable} - * @description - * Listener for real-time statistics, will trigger on every - * statistic modification. - * TIP: You can improve performance by adding memcached to LoopBack models. - **/ - public stats(filter?: StatFilter): Observable { - return this.on("stats", filter); - } - /** - * @method make - * @param {any} instance Persisted model instance reference - * @return {Observable} - * @description - * This method will set a model instance into this a new FireLoop Reference. - * This allows to persiste parentship when creating related instances. - * - * It also allows to have multiple different persisted instance references to same model. - * otherwise if using singleton will replace a previous instance for a new instance, when - * we actually want to have more than 1 instance of same model. - **/ - public make(instance: any): FireLoopRef { - let reference: FireLoopRef = new FireLoopRef(this.model, this.socket); - reference.instance = instance; - return reference; - } - /** - * @method child - * @param {string} relationship A defined model relationship - * @return {FireLoopRef} - * @description - * This method creates child references, which will persist related model - * instances. e.g. Room.messages, where messages belongs to a specific Room. - **/ - public child(relationship: string): FireLoopRef { - // Return singleton instance - if (this.childs[relationship]) { - return this.childs[relationship]; - } - // Try to get relation settings from current model - let settings: any = this.model.getModelDefinition().relations[relationship]; - // Verify the relationship actually exists - if (!settings) { - throw new Error( - `Invalid model relationship ${this.model.getModelName()} <-> ${relationship}, verify your model settings.`, - ); - } - // Verify if the relationship model is public - if (settings.model === "") { - throw new Error( - `Relationship model is private, cam't use ${relationship} unless you set your model as public.`, - ); - } - // Lets get a model reference and add a reference for all of the models - let model: any = this.model.models.get(settings.model); - model.models = this.model.models; - // If everything goes well, we will store a child reference and return it. - this.childs[relationship] = new FireLoopRef( - model, - this.socket, - this, - relationship, - ); - return this.childs[relationship]; - } - /** - * @method pull - * @param {string} event Event name - * @param {any} request Type of request, can be LB-only filter or FL+LB filter - * @return {Observable} - * @description - * This method will pull initial data from server - **/ - private pull(event: string, request: any): Observable { - let sbj: Subject = new Subject(); - let that: FireLoopRef = this; - let nowEvent: any = `${event}.pull.requested.${this.id}`; - this.socket.emit(`${event}.pull.request.${this.id}`, request); - function pullNow(data: any) { - if (that.socket.removeListener) { - that.socket.removeListener(nowEvent, pullNow); - } - sbj.next(data); - } - this.socket.on(nowEvent, pullNow); - return sbj.asObservable(); - } - /** - * @method broadcasts - * @param {string} event Event name - * @param {any} request Type of request, can be LB-only filter or FL+LB filter - * @return {Observable} - * @description - * This will listen for public broadcasts announces and then request - * for data according a specific client request, not shared with other clients. - **/ - private broadcasts(event: string, request: any): Observable { - let sbj: Subject = new Subject(); - let channels: { announce: string; broadcast: string } = { - announce: `${event}.broadcast.announce.${this.id}`, - broadcast: `${event}.broadcast.${this.id}`, - }; - let that = this; - // Announces Handler - this.disposable[channels.announce] = function (res: T) { - that.socket.emit(`${event}.broadcast.request.${that.id}`, request); - }; - // Broadcasts Handler - this.disposable[channels.broadcast] = function (data: any) { - sbj.next(data); - }; - this.socket.on(channels.announce, this.disposable[channels.announce]); - this.socket.on(channels.broadcast, this.disposable[channels.broadcast]); - return sbj.asObservable(); - } - /** - * @method operation - * @param {string} event Event name - * @param {any} data Any type of data sent to the server - * @return {Observable} - * @description - * This internal method will run operations depending on current context - **/ - private operation(event: string, data: any): Observable { - if (!this.relationship) { - event = `${this.model.getModelName()}.${event}.${this.id}`; - } else { - event = `${this.parent.model.getModelName()}.${ - this.relationship - }.${event}.${this.id}`; - } - let subject: Subject = new Subject(); - let config: { data: any; parent: any } = { - data, - parent: this.parent && this.parent.instance ? this.parent.instance : null, - }; - this.socket.emit(event, config); - let resultEvent: string = ""; - if (!this.relationship) { - resultEvent = `${this.model.getModelName()}.value.result.${this.id}`; - } else { - resultEvent = `${this.parent.model.getModelName()}.${ - this.relationship - }.value.result.${this.id}`; - } - this.socket.on(resultEvent, (res: any) => { - if (res.error) { - subject.error(res); - } else { - subject.next(res); - } - }); - if (event.match("dispose")) { - setTimeout(() => subject.next(null)); - } - // This event listener will be wiped within socket.connections - this.socket.sharedObservables.sharedOnDisconnect.subscribe(() => - subject.complete(), - ); - return subject - .asObservable() - .pipe(catchError((error: any) => throwError(() => new Error(error)))); - } - /** - * @method buildId - * @return {number} - * @description - * This internal method build an ID for this reference, this allows to have - * multiple references for the same model or relationships. - **/ - private buildId(): number { - return ( - Date.now() + - Math.floor(Math.random() * 100800) * - Math.floor(Math.random() * 100700) * - Math.floor(Math.random() * 198500) - ); - } -} diff --git a/src/app/shared/sdk/models/Instrument.ts b/src/app/shared/sdk/models/Instrument.ts deleted file mode 100644 index 241ca5871..000000000 --- a/src/app/shared/sdk/models/Instrument.ts +++ /dev/null @@ -1,101 +0,0 @@ -/* eslint-disable */ -import { Dataset } from "../index"; - -declare var Object: any; -export interface InstrumentInterface { - pid?: string; - uniqueName: string; - name: string; - customMetadata?: any; - createdBy?: string; - updatedBy?: string; - createdAt?: Date; - updatedAt?: Date; - datasets?: Dataset[]; -} - -export class Instrument implements InstrumentInterface { - "pid": string; - "uniqueName": string; - "name": string; - "customMetadata": any; - "createdBy": string; - "updatedBy": string; - "createdAt": Date; - "updatedAt": Date; - datasets: Dataset[]; - constructor(data?: InstrumentInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `Instrument`. - */ - public static getModelName() { - return "Instrument"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of Instrument for dynamic purposes. - **/ - public static factory(data: InstrumentInterface): Instrument { - return new Instrument(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "Instrument", - plural: "Instruments", - path: "Instruments", - idName: "pid", - properties: { - pid: { - name: "pid", - type: "string", - }, - name: { - name: "name", - type: "string", - }, - customMetadata: { - name: "customMetadata", - type: "any", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - }, - relations: { - datasets: { - name: "datasets", - type: "Dataset[]", - model: "Dataset", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "instrumentId", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/Job.ts b/src/app/shared/sdk/models/Job.ts deleted file mode 100644 index 52e0e77a8..000000000 --- a/src/app/shared/sdk/models/Job.ts +++ /dev/null @@ -1,124 +0,0 @@ -/* eslint-disable */ - -declare var Object: any; -export interface JobInterface { - id?: string; - emailJobInitiator: string; - type: string; - creationTime?: Date; - executionTime?: Date; - jobParams?: any; - jobStatusMessage?: string; - datasetList?: any; - jobResultObject?: any; - createdBy?: string; - updatedBy?: string; - createdAt?: Date; - updatedAt?: Date; -} - -export class Job implements JobInterface { - "id": string; - "emailJobInitiator": string; - "type": string; - "creationTime": Date; - "executionTime": Date; - "jobParams": any; - "jobStatusMessage": string; - "datasetList": any; - "jobResultObject": any; - "createdBy": string; - "updatedBy": string; - "createdAt": Date; - "updatedAt": Date; - constructor(data?: JobInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `Job`. - */ - public static getModelName() { - return "Job"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of Job for dynamic purposes. - **/ - public static factory(data: JobInterface): Job { - return new Job(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "Job", - plural: "Jobs", - path: "Jobs", - idName: "id", - properties: { - id: { - name: "id", - type: "string", - }, - emailJobInitiator: { - name: "emailJobInitiator", - type: "string", - }, - type: { - name: "type", - type: "string", - default: "retrieve", - }, - creationTime: { - name: "creationTime", - type: "Date", - }, - executionTime: { - name: "executionTime", - type: "Date", - }, - jobParams: { - name: "jobParams", - type: "any", - }, - jobStatusMessage: { - name: "jobStatusMessage", - type: "string", - }, - datasetList: { - name: "datasetList", - type: "any", - }, - jobResultObject: { - name: "jobResultObject", - type: "any", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - }, - relations: {}, - }; - } -} diff --git a/src/app/shared/sdk/models/Logbook.ts b/src/app/shared/sdk/models/Logbook.ts deleted file mode 100644 index a7b09685d..000000000 --- a/src/app/shared/sdk/models/Logbook.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* eslint-disable */ - -declare var Object: any; -export interface LogbookInterface { - name?: string; - roomId?: string; - messages?: Array; -} - -export class Logbook implements LogbookInterface { - "name": string; - "roomId": string; - "messages": Array; - constructor(data?: LogbookInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `Logbook`. - */ - public static getModelName() { - return "Logbook"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of Logbook for dynamic purposes. - **/ - public static factory(data: LogbookInterface): Logbook { - return new Logbook(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "Logbook", - plural: "Logbooks", - path: "Logbooks", - idName: "id", - properties: { - name: { - name: "name", - type: "string", - }, - roomId: { - name: "roomId", - type: "string", - }, - messages: { - name: "messages", - type: "Array<any>", - }, - }, - relations: {}, - }; - } -} diff --git a/src/app/shared/sdk/models/OrigDatablock.ts b/src/app/shared/sdk/models/OrigDatablock.ts deleted file mode 100644 index 55b71f2cc..000000000 --- a/src/app/shared/sdk/models/OrigDatablock.ts +++ /dev/null @@ -1,140 +0,0 @@ -/* eslint-disable */ -import { Dataset } from "../index"; - -declare var Object: any; -export interface OrigDatablockInterface { - id?: string; - size: number; - ownerGroup: string; - accessGroups?: Array; - createdBy?: string; - updatedBy?: string; - datasetId?: string; - dataFileList?: Array; - rawDatasetId?: string; - derivedDatasetId?: string; - createdAt?: Date; - updatedAt?: Date; - dataset?: Dataset; - files?: any[]; -} - -export class OrigDatablock implements OrigDatablockInterface { - "id": string; - "size": number; - "ownerGroup": string; - "accessGroups": Array; - "createdBy": string; - "updatedBy": string; - "datasetId": string; - "dataFileList": Array; - "rawDatasetId": string; - "derivedDatasetId": string; - "createdAt": Date; - "updatedAt": Date; - dataset: Dataset; - files: any[]; - constructor(data?: OrigDatablockInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `OrigDatablock`. - */ - public static getModelName() { - return "OrigDatablock"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of OrigDatablock for dynamic purposes. - **/ - public static factory(data: OrigDatablockInterface): OrigDatablock { - return new OrigDatablock(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "OrigDatablock", - plural: "OrigDatablocks", - path: "OrigDatablocks", - idName: "id", - properties: { - id: { - name: "id", - type: "string", - }, - size: { - name: "size", - type: "number", - }, - ownerGroup: { - name: "ownerGroup", - type: "string", - }, - accessGroups: { - name: "accessGroups", - type: "Array<any>", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - datasetId: { - name: "datasetId", - type: "string", - }, - dataFileList: { - name: "dataFileList", - type: "Array<any>", - default: [], - }, - rawDatasetId: { - name: "rawDatasetId", - type: "string", - }, - derivedDatasetId: { - name: "derivedDatasetId", - type: "string", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - }, - relations: { - dataset: { - name: "dataset", - type: "Dataset", - model: "Dataset", - relationType: "belongsTo", - keyFrom: "datasetId", - keyTo: "pid", - }, - files: { - name: "files", - type: "any[]", - model: "", - relationType: "embedsMany", - keyFrom: "dataFileList", - keyTo: "path", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/Policy.ts b/src/app/shared/sdk/models/Policy.ts deleted file mode 100644 index eb0b3a154..000000000 --- a/src/app/shared/sdk/models/Policy.ts +++ /dev/null @@ -1,147 +0,0 @@ -/* eslint-disable */ - -declare var Object: any; -export interface PolicyInterface { - id?: string; - manager?: Array; - tapeRedundancy?: string; - autoArchive?: boolean; - autoArchiveDelay?: number; - archiveEmailNotification?: boolean; - archiveEmailsToBeNotified?: Array; - retrieveEmailNotification?: boolean; - retrieveEmailsToBeNotified?: Array; - embargoPeriod?: number; - ownerGroup: string; - accessGroups?: Array; - createdBy?: string; - updatedBy?: string; - createdAt?: Date; - updatedAt?: Date; -} - -export class Policy implements PolicyInterface { - "id": string; - "manager": Array; - "tapeRedundancy": string; - "autoArchive": boolean; - "autoArchiveDelay": number; - "archiveEmailNotification": boolean; - "archiveEmailsToBeNotified": Array; - "retrieveEmailNotification": boolean; - "retrieveEmailsToBeNotified": Array; - "embargoPeriod": number; - "ownerGroup": string; - "accessGroups": Array; - "createdBy": string; - "updatedBy": string; - "createdAt": Date; - "updatedAt": Date; - constructor(data?: PolicyInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `Policy`. - */ - public static getModelName() { - return "Policy"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of Policy for dynamic purposes. - **/ - public static factory(data: PolicyInterface): Policy { - return new Policy(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "Policy", - plural: "Policies", - path: "Policies", - idName: "id", - properties: { - id: { - name: "id", - type: "string", - }, - manager: { - name: "manager", - type: "Array<any>", - }, - tapeRedundancy: { - name: "tapeRedundancy", - type: "string", - default: "low", - }, - autoArchive: { - name: "autoArchive", - type: "boolean", - default: true, - }, - autoArchiveDelay: { - name: "autoArchiveDelay", - type: "number", - default: 7, - }, - archiveEmailNotification: { - name: "archiveEmailNotification", - type: "boolean", - default: false, - }, - archiveEmailsToBeNotified: { - name: "archiveEmailsToBeNotified", - type: "Array<any>", - }, - retrieveEmailNotification: { - name: "retrieveEmailNotification", - type: "boolean", - default: false, - }, - retrieveEmailsToBeNotified: { - name: "retrieveEmailsToBeNotified", - type: "Array<any>", - }, - embargoPeriod: { - name: "embargoPeriod", - type: "number", - default: 3, - }, - ownerGroup: { - name: "ownerGroup", - type: "string", - }, - accessGroups: { - name: "accessGroups", - type: "Array<any>", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - }, - relations: {}, - }; - } -} diff --git a/src/app/shared/sdk/models/Proposal.ts b/src/app/shared/sdk/models/Proposal.ts deleted file mode 100644 index cbff6ac9c..000000000 --- a/src/app/shared/sdk/models/Proposal.ts +++ /dev/null @@ -1,176 +0,0 @@ -/* eslint-disable */ -import { Attachment } from "../index"; - -declare var Object: any; -export interface ProposalInterface { - proposalId: string; - pi_email?: string; - pi_firstname?: string; - pi_lastname?: string; - email: string; - firstname?: string; - lastname?: string; - title?: string; - abstract?: string; - startTime?: Date; - endTime?: Date; - ownerGroup: string; - accessGroups?: Array; - createdBy?: string; - updatedBy?: string; - MeasurementPeriodList?: Array; - createdAt?: Date; - updatedAt?: Date; - measurementPeriods?: any[]; - attachments?: Attachment[]; -} - -export class Proposal implements ProposalInterface { - "proposalId": string; - "pi_email": string; - "pi_firstname": string; - "pi_lastname": string; - "email": string; - "firstname": string; - "lastname": string; - "title": string; - "abstract": string; - "startTime": Date; - "endTime": Date; - "ownerGroup": string; - "accessGroups": Array; - "createdBy": string; - "updatedBy": string; - "MeasurementPeriodList": Array; - "createdAt": Date; - "updatedAt": Date; - measurementPeriods: any[]; - attachments: Attachment[]; - constructor(data?: ProposalInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `Proposal`. - */ - public static getModelName() { - return "Proposal"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of Proposal for dynamic purposes. - **/ - public static factory(data: ProposalInterface): Proposal { - return new Proposal(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "Proposal", - plural: "Proposals", - path: "Proposals", - idName: "proposalId", - properties: { - proposalId: { - name: "proposalId", - type: "string", - }, - pi_email: { - name: "pi_email", - type: "string", - }, - pi_firstname: { - name: "pi_firstname", - type: "string", - }, - pi_lastname: { - name: "pi_lastname", - type: "string", - }, - email: { - name: "email", - type: "string", - }, - firstname: { - name: "firstname", - type: "string", - }, - lastname: { - name: "lastname", - type: "string", - }, - title: { - name: "title", - type: "string", - }, - abstract: { - name: "abstract", - type: "string", - }, - startTime: { - name: "startTime", - type: "Date", - }, - endTime: { - name: "endTime", - type: "Date", - }, - ownerGroup: { - name: "ownerGroup", - type: "string", - }, - accessGroups: { - name: "accessGroups", - type: "Array<any>", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - MeasurementPeriodList: { - name: "MeasurementPeriodList", - type: "Array<any>", - default: [], - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - }, - relations: { - measurementPeriods: { - name: "measurementPeriods", - type: "any[]", - model: "", - relationType: "embedsMany", - keyFrom: "MeasurementPeriodList", - keyTo: "id", - }, - attachments: { - name: "attachments", - type: "Attachment[]", - model: "Attachment", - relationType: "hasMany", - keyFrom: "proposalId", - keyTo: "proposalId", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/PublishedData.ts b/src/app/shared/sdk/models/PublishedData.ts deleted file mode 100644 index 82790febb..000000000 --- a/src/app/shared/sdk/models/PublishedData.ts +++ /dev/null @@ -1,201 +0,0 @@ -/* eslint-disable */ -import { Dataset } from "../index"; - -declare var Object: any; -export interface PublishedDataInterface { - doi?: string; - affiliation?: string; - creator: Array; - publisher: string; - publicationYear: number; - title: string; - url?: string; - abstract: string; - dataDescription: string; - resourceType: string; - numberOfFiles?: number; - sizeOfArchive?: number; - pidArray: Array; - authors?: Array; - registeredTime?: Date; - status?: string; - scicatUser?: string; - thumbnail?: string; - relatedPublications?: Array; - downloadLink?: string; - createdBy?: string; - updatedBy?: string; - createdAt?: Date; - updatedAt?: Date; - datasets?: Dataset[]; -} - -export class PublishedData implements PublishedDataInterface { - "doi": string; - "affiliation": string; - "creator": Array; - "publisher": string; - "publicationYear": number; - "title": string; - "url": string; - "abstract": string; - "dataDescription": string; - "resourceType": string; - "numberOfFiles": number; - "sizeOfArchive": number; - "pidArray": Array; - "authors": Array; - "registeredTime": Date; - "status": string; - "scicatUser": string; - "thumbnail": string; - "relatedPublications": Array; - "downloadLink": string; - "createdBy": string; - "updatedBy": string; - "createdAt": Date; - "updatedAt": Date; - datasets: Dataset[]; - constructor(data?: PublishedDataInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `PublishedData`. - */ - public static getModelName() { - return "PublishedData"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of PublishedData for dynamic purposes. - **/ - public static factory(data: PublishedDataInterface): PublishedData { - return new PublishedData(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "PublishedData", - plural: "PublishedData", - path: "PublishedData", - idName: "doi", - properties: { - doi: { - name: "doi", - type: "string", - }, - affiliation: { - name: "affiliation", - type: "string", - }, - creator: { - name: "creator", - type: "Array<any>", - }, - publisher: { - name: "publisher", - type: "string", - }, - publicationYear: { - name: "publicationYear", - type: "number", - }, - title: { - name: "title", - type: "string", - }, - url: { - name: "url", - type: "string", - }, - abstract: { - name: "abstract", - type: "string", - }, - dataDescription: { - name: "dataDescription", - type: "string", - }, - resourceType: { - name: "resourceType", - type: "string", - }, - numberOfFiles: { - name: "numberOfFiles", - type: "number", - }, - sizeOfArchive: { - name: "sizeOfArchive", - type: "number", - }, - pidArray: { - name: "pidArray", - type: "Array<any>", - }, - authors: { - name: "authors", - type: "Array<any>", - }, - registeredTime: { - name: "registeredTime", - type: "Date", - }, - status: { - name: "status", - type: "string", - }, - scicatUser: { - name: "scicatUser", - type: "string", - }, - thumbnail: { - name: "thumbnail", - type: "string", - }, - relatedPublications: { - name: "relatedPublications", - type: "Array<any>", - }, - downloadLink: { - name: "downloadLink", - type: "string", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - }, - relations: { - datasets: { - name: "datasets", - type: "Dataset[]", - model: "Dataset", - relationType: "hasMany", - keyFrom: "doi", - keyTo: "publishedDataId", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/RawDataset.ts b/src/app/shared/sdk/models/RawDataset.ts deleted file mode 100644 index 53b66ceaf..000000000 --- a/src/app/shared/sdk/models/RawDataset.ts +++ /dev/null @@ -1,407 +0,0 @@ -/* eslint-disable */ -import { - PublishedData, - Sample, - Proposal, - Datablock, - OrigDatablock, - Attachment, - Instrument, -} from "../index"; - -declare var Object: any; -export interface RawDatasetInterface { - principalInvestigator: string; - endTime?: Date; - creationLocation: string; - dataFormat?: string; - scientificMetadata?: any; - pid?: string; - owner: string; - ownerEmail?: string; - orcidOfOwner?: string; - contactEmail: string; - sourceFolder: string; - sourceFolderHost?: string; - size?: number; - packedSize?: number; - numberOfFiles?: number; - numberOfFilesArchived?: number; - creationTime: Date; - type: string; - validationStatus?: string; - keywords?: Array; - description?: string; - datasetName?: string; - classification?: string; - license?: string; - version?: string; - isPublished?: boolean; - sharedWith?: Array; - ownerGroup: string; - accessGroups?: Array; - createdBy?: string; - updatedBy?: string; - history?: Array; - datasetlifecycle?: any; - publisheddataId?: string; - techniques?: Array; - createdAt?: Date; - updatedAt?: Date; - sampleId?: string; - proposalId?: string; - instrumentId?: string; - historyList?: any[]; - datasetLifecycle?: any[]; - publisheddata?: PublishedData; - techniquesList?: any[]; - samples?: Sample[]; - sample?: Sample; - proposal?: Proposal; - datablocks?: Datablock[]; - origdatablocks?: OrigDatablock[]; - attachments?: Attachment[]; - instrument?: Instrument; -} - -export class RawDataset implements RawDatasetInterface { - "principalInvestigator": string; - "endTime": Date; - "creationLocation": string; - "dataFormat": string; - "scientificMetadata": any; - "pid": string; - "owner": string; - "ownerEmail": string; - "orcidOfOwner": string; - "contactEmail": string; - "sourceFolder": string; - "sourceFolderHost": string; - "size": number; - "packedSize": number; - "numberOfFiles": number; - "numberOfFilesArchived": number; - "creationTime": Date; - "type": string; - "validationStatus": string; - "keywords": Array; - "description": string; - "datasetName": string; - "classification": string; - "license": string; - "version": string; - "isPublished": boolean; - "sharedWith": Array; - "ownerGroup": string; - "accessGroups": Array; - "createdBy": string; - "updatedBy": string; - "history": Array; - "datasetlifecycle": any; - "publisheddataId": string; - "techniques": Array; - "createdAt": Date; - "updatedAt": Date; - "sampleId": string; - "proposalId": string; - "instrumentId": string; - historyList: any[]; - datasetLifecycle: any[]; - publisheddata: PublishedData; - techniquesList: any[]; - samples: Sample[]; - sample: Sample; - proposal: Proposal; - datablocks: Datablock[]; - origdatablocks: OrigDatablock[]; - attachments: Attachment[]; - instrument: Instrument; - constructor(data?: RawDatasetInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `RawDataset`. - */ - public static getModelName() { - return "RawDataset"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of RawDataset for dynamic purposes. - **/ - public static factory(data: RawDatasetInterface): RawDataset { - return new RawDataset(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "RawDataset", - plural: "RawDatasets", - path: "RawDatasets", - idName: "pid", - properties: { - principalInvestigator: { - name: "principalInvestigator", - type: "string", - }, - endTime: { - name: "endTime", - type: "Date", - }, - creationLocation: { - name: "creationLocation", - type: "string", - }, - dataFormat: { - name: "dataFormat", - type: "string", - }, - scientificMetadata: { - name: "scientificMetadata", - type: "any", - }, - pid: { - name: "pid", - type: "string", - }, - owner: { - name: "owner", - type: "string", - }, - ownerEmail: { - name: "ownerEmail", - type: "string", - }, - orcidOfOwner: { - name: "orcidOfOwner", - type: "string", - }, - contactEmail: { - name: "contactEmail", - type: "string", - }, - sourceFolder: { - name: "sourceFolder", - type: "string", - }, - sourceFolderHost: { - name: "sourceFolderHost", - type: "string", - }, - size: { - name: "size", - type: "number", - }, - packedSize: { - name: "packedSize", - type: "number", - }, - numberOfFiles: { - name: "numberOfFiles", - type: "number", - }, - numberOfFilesArchived: { - name: "numberOfFilesArchived", - type: "number", - }, - creationTime: { - name: "creationTime", - type: "Date", - }, - type: { - name: "type", - type: "string", - }, - validationStatus: { - name: "validationStatus", - type: "string", - }, - keywords: { - name: "keywords", - type: "Array<any>", - }, - description: { - name: "description", - type: "string", - }, - datasetName: { - name: "datasetName", - type: "string", - }, - classification: { - name: "classification", - type: "string", - }, - license: { - name: "license", - type: "string", - }, - version: { - name: "version", - type: "string", - }, - isPublished: { - name: "isPublished", - type: "boolean", - }, - sharedWith: { - name: "sharedWith", - type: "Array<any>", - }, - ownerGroup: { - name: "ownerGroup", - type: "string", - }, - accessGroups: { - name: "accessGroups", - type: "Array<any>", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - history: { - name: "history", - type: "Array<any>", - default: [], - }, - datasetlifecycle: { - name: "datasetlifecycle", - type: "any", - }, - publisheddataId: { - name: "publisheddataId", - type: "string", - }, - techniques: { - name: "techniques", - type: "Array<any>", - default: [], - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - sampleId: { - name: "sampleId", - type: "string", - }, - proposalId: { - name: "proposalId", - type: "string", - }, - instrumentId: { - name: "instrumentId", - type: "string", - }, - }, - relations: { - historyList: { - name: "historyList", - type: "any[]", - model: "", - relationType: "embedsMany", - keyFrom: "history", - keyTo: "id", - }, - datasetLifecycle: { - name: "datasetLifecycle", - type: "any[]", - model: "", - relationType: "embedsOne", - keyFrom: "datasetlifecycle", - keyTo: "id", - }, - publisheddata: { - name: "publisheddata", - type: "PublishedData", - model: "PublishedData", - relationType: "belongsTo", - keyFrom: "publisheddataId", - keyTo: "doi", - }, - techniquesList: { - name: "techniquesList", - type: "any[]", - model: "", - relationType: "embedsMany", - keyFrom: "techniques", - keyTo: "pid", - }, - samples: { - name: "samples", - type: "Sample[]", - model: "Sample", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "rawDatasetId", - }, - sample: { - name: "sample", - type: "Sample", - model: "Sample", - relationType: "belongsTo", - keyFrom: "sampleId", - keyTo: "sampleId", - }, - proposal: { - name: "proposal", - type: "Proposal", - model: "Proposal", - relationType: "belongsTo", - keyFrom: "proposalId", - keyTo: "proposalId", - }, - datablocks: { - name: "datablocks", - type: "Datablock[]", - model: "Datablock", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "rawDatasetId", - }, - origdatablocks: { - name: "origdatablocks", - type: "OrigDatablock[]", - model: "OrigDatablock", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "rawDatasetId", - }, - attachments: { - name: "attachments", - type: "Attachment[]", - model: "Attachment", - relationType: "hasMany", - keyFrom: "pid", - keyTo: "rawDatasetId", - }, - instrument: { - name: "instrument", - type: "Instrument", - model: "Instrument", - relationType: "belongsTo", - keyFrom: "instrumentId", - keyTo: "pid", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/Sample.ts b/src/app/shared/sdk/models/Sample.ts deleted file mode 100644 index 6a6c74d28..000000000 --- a/src/app/shared/sdk/models/Sample.ts +++ /dev/null @@ -1,157 +0,0 @@ -/* eslint-disable */ -import { Dataset, Attachment } from "../index"; - -declare var Object: any; -export interface SampleInterface { - sampleId?: string; - owner?: string; - description?: string; - createdAt?: Date; - sampleCharacteristics?: any; - isPublished?: boolean; - ownerGroup: string; - accessGroups?: Array; - createdBy?: string; - updatedBy?: string; - datasetsId?: string; - datasetId?: string; - rawDatasetId?: string; - derivedDatasetId?: string; - updatedAt?: Date; - datasets?: Dataset; - attachments?: Attachment[]; -} - -export class Sample implements SampleInterface { - "sampleId": string; - "owner": string; - "description": string; - "createdAt": Date; - "sampleCharacteristics": any; - "isPublished": boolean; - "ownerGroup": string; - "accessGroups": Array; - "createdBy": string; - "updatedBy": string; - "datasetsId": string; - "datasetId": string; - "rawDatasetId": string; - "derivedDatasetId": string; - "updatedAt": Date; - datasets: Dataset; - attachments: Attachment[]; - constructor(data?: SampleInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `Sample`. - */ - public static getModelName() { - return "Sample"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of Sample for dynamic purposes. - **/ - public static factory(data: SampleInterface): Sample { - return new Sample(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "Sample", - plural: "Samples", - path: "Samples", - idName: "sampleId", - properties: { - sampleId: { - name: "sampleId", - type: "string", - }, - owner: { - name: "owner", - type: "string", - }, - description: { - name: "description", - type: "string", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - sampleCharacteristics: { - name: "sampleCharacteristics", - type: "any", - }, - isPublished: { - name: "isPublished", - type: "boolean", - }, - ownerGroup: { - name: "ownerGroup", - type: "string", - }, - accessGroups: { - name: "accessGroups", - type: "Array<any>", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - datasetsId: { - name: "datasetsId", - type: "string", - }, - datasetId: { - name: "datasetId", - type: "string", - }, - rawDatasetId: { - name: "rawDatasetId", - type: "string", - }, - derivedDatasetId: { - name: "derivedDatasetId", - type: "string", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - }, - relations: { - datasets: { - name: "datasets", - type: "Dataset", - model: "Dataset", - relationType: "belongsTo", - keyFrom: "datasetsId", - keyTo: "pid", - }, - attachments: { - name: "attachments", - type: "Attachment[]", - model: "Attachment", - relationType: "hasMany", - keyFrom: "sampleId", - keyTo: "sampleId", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/ShareGroup.ts b/src/app/shared/sdk/models/ShareGroup.ts deleted file mode 100644 index 8d65471ed..000000000 --- a/src/app/shared/sdk/models/ShareGroup.ts +++ /dev/null @@ -1,93 +0,0 @@ -/* eslint-disable */ - -declare var Object: any; -export interface ShareGroupInterface { - groupID?: string; - members?: Array; - datasets?: Array; - createdBy?: string; - updatedBy?: string; - id?: any; - createdAt?: Date; - updatedAt?: Date; -} - -export class ShareGroup implements ShareGroupInterface { - "groupID": string; - "members": Array; - "datasets": Array; - "createdBy": string; - "updatedBy": string; - "id": any; - "createdAt": Date; - "updatedAt": Date; - constructor(data?: ShareGroupInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `ShareGroup`. - */ - public static getModelName() { - return "ShareGroup"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of ShareGroup for dynamic purposes. - **/ - public static factory(data: ShareGroupInterface): ShareGroup { - return new ShareGroup(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "ShareGroup", - plural: "ShareGroups", - path: "ShareGroups", - idName: "id", - properties: { - groupID: { - name: "groupID", - type: "string", - }, - members: { - name: "members", - type: "Array<any>", - }, - datasets: { - name: "datasets", - type: "Array<any>", - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - id: { - name: "id", - type: "any", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - }, - relations: {}, - }; - } -} diff --git a/src/app/shared/sdk/models/User.ts b/src/app/shared/sdk/models/User.ts deleted file mode 100644 index 4ab543376..000000000 --- a/src/app/shared/sdk/models/User.ts +++ /dev/null @@ -1,124 +0,0 @@ -/* eslint-disable */ -import { UserSetting, UserIdentity, UserCredential } from "../index"; - -declare var Object: any; -export interface UserInterface { - realm?: string; - username?: string; - email: string; - emailVerified?: boolean; - id?: any; - password?: string; - accessTokens?: any[]; - settings?: UserSetting; - identities?: UserIdentity[]; - credentials?: UserCredential[]; -} - -export class User implements UserInterface { - "realm": string; - "username": string; - "email": string; - "emailVerified": boolean; - "id": any; - "password": string; - "authStrategy"?: string; - accessTokens: any[]; - settings: UserSetting; - identities: UserIdentity[]; - credentials: UserCredential[]; - constructor(data?: UserInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `User`. - */ - public static getModelName() { - return "User"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of User for dynamic purposes. - **/ - public static factory(data: UserInterface): User { - return new User(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "User", - plural: "Users", - path: "Users", - idName: "id", - properties: { - realm: { - name: "realm", - type: "string", - }, - username: { - name: "username", - type: "string", - }, - email: { - name: "email", - type: "string", - }, - emailVerified: { - name: "emailVerified", - type: "boolean", - }, - id: { - name: "id", - type: "any", - }, - password: { - name: "password", - type: "string", - }, - }, - relations: { - accessTokens: { - name: "accessTokens", - type: "any[]", - model: "", - relationType: "hasMany", - keyFrom: "id", - keyTo: "userId", - }, - settings: { - name: "settings", - type: "UserSetting", - model: "UserSetting", - relationType: "hasOne", - keyFrom: "id", - keyTo: "userId", - }, - identities: { - name: "identities", - type: "UserIdentity[]", - model: "UserIdentity", - relationType: "hasMany", - keyFrom: "id", - keyTo: "userId", - }, - credentials: { - name: "credentials", - type: "UserCredential[]", - model: "UserCredential", - relationType: "hasMany", - keyFrom: "id", - keyTo: "userId", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/UserCredential.ts b/src/app/shared/sdk/models/UserCredential.ts deleted file mode 100644 index 6ee853ef3..000000000 --- a/src/app/shared/sdk/models/UserCredential.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* eslint-disable */ -import { User } from "../index"; - -declare var Object: any; -export interface UserCredentialInterface { - provider?: string; - authScheme?: string; - externalId?: string; - profile?: any; - credentials?: any; - created?: Date; - modified?: Date; - id?: any; - userId?: any; - user?: User; -} - -export class UserCredential implements UserCredentialInterface { - "provider": string; - "authScheme": string; - "externalId": string; - "profile": any; - "credentials": any; - "created": Date; - "modified": Date; - "id": any; - "userId": any; - user: User; - constructor(data?: UserCredentialInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `UserCredential`. - */ - public static getModelName() { - return "UserCredential"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of UserCredential for dynamic purposes. - **/ - public static factory(data: UserCredentialInterface): UserCredential { - return new UserCredential(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "UserCredential", - plural: "UserCredentials", - path: "UserCredentials", - idName: "id", - properties: { - provider: { - name: "provider", - type: "string", - }, - authScheme: { - name: "authScheme", - type: "string", - }, - externalId: { - name: "externalId", - type: "string", - }, - profile: { - name: "profile", - type: "any", - }, - credentials: { - name: "credentials", - type: "any", - }, - created: { - name: "created", - type: "Date", - }, - modified: { - name: "modified", - type: "Date", - }, - id: { - name: "id", - type: "any", - }, - userId: { - name: "userId", - type: "any", - }, - }, - relations: { - user: { - name: "user", - type: "User", - model: "User", - relationType: "belongsTo", - keyFrom: "userId", - keyTo: "id", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/UserIdentity.ts b/src/app/shared/sdk/models/UserIdentity.ts deleted file mode 100644 index 037dcec4d..000000000 --- a/src/app/shared/sdk/models/UserIdentity.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* eslint-disable */ -import { User } from "../index"; - -declare var Object: any; -export interface UserIdentityInterface { - provider?: string; - authScheme?: string; - externalId?: string; - profile?: any; - credentials?: any; - created?: Date; - modified?: Date; - id?: any; - userId?: any; - user?: User; -} - -export class UserIdentity implements UserIdentityInterface { - "provider": string; - "authScheme": string; - "externalId": string; - "profile": any; - "credentials": any; - "created": Date; - "modified": Date; - "id": any; - "userId": any; - user: User; - constructor(data?: UserIdentityInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `UserIdentity`. - */ - public static getModelName() { - return "UserIdentity"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of UserIdentity for dynamic purposes. - **/ - public static factory(data: UserIdentityInterface): UserIdentity { - return new UserIdentity(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "UserIdentity", - plural: "UserIdentities", - path: "UserIdentities", - idName: "id", - properties: { - provider: { - name: "provider", - type: "string", - }, - authScheme: { - name: "authScheme", - type: "string", - }, - externalId: { - name: "externalId", - type: "string", - }, - profile: { - name: "profile", - type: "any", - }, - credentials: { - name: "credentials", - type: "any", - }, - created: { - name: "created", - type: "Date", - }, - modified: { - name: "modified", - type: "Date", - }, - id: { - name: "id", - type: "any", - }, - userId: { - name: "userId", - type: "any", - }, - }, - relations: { - user: { - name: "user", - type: "User", - model: "User", - relationType: "belongsTo", - keyFrom: "userId", - keyTo: "id", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/UserSetting.ts b/src/app/shared/sdk/models/UserSetting.ts deleted file mode 100644 index 3f516e82a..000000000 --- a/src/app/shared/sdk/models/UserSetting.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* eslint-disable */ -import { User } from "../index"; -import { - ConditionConfig, - FilterConfig, -} from "../../modules/filters/filters.module"; - -declare var Object: any; -export interface UserSettingInterface { - id?: string; - columns?: Array; - datasetCount?: number; - jobCount?: number; - createdBy?: string; - updatedBy?: string; - userId?: any; - createdAt?: Date; - updatedAt?: Date; - user?: User; - conditions?: Array; - filters?: Array; -} - -export class UserSetting implements UserSettingInterface { - "id": string; - "columns": Array; - "datasetCount": number; - "jobCount": number; - "createdBy": string; - "updatedBy": string; - "userId": any; - "createdAt": Date; - "updatedAt": Date; - "conditions": Array; - "filters": Array; - user: User; - constructor(data?: UserSettingInterface) { - Object.assign(this, data); - } - /** - * The name of the model represented by this $resource, - * i.e. `UserSetting`. - */ - public static getModelName() { - return "UserSetting"; - } - /** - * @method factory - * @author Jonathan Casarrubias - * @license MIT - * This method creates an instance of UserSetting for dynamic purposes. - **/ - public static factory(data: UserSettingInterface): UserSetting { - return new UserSetting(data); - } - /** - * @method getModelDefinition - * @author Julien Ledun - * @license MIT - * This method returns an object that represents some of the model - * definitions. - **/ - public static getModelDefinition() { - return { - name: "UserSetting", - plural: "UserSettings", - path: "UserSettings", - idName: "id", - properties: { - id: { - name: "id", - type: "string", - }, - columns: { - name: "columns", - type: "Array<any>", - }, - datasetCount: { - name: "datasetCount", - type: "number", - default: 25, - }, - jobCount: { - name: "jobCount", - type: "number", - default: 25, - }, - createdBy: { - name: "createdBy", - type: "string", - }, - updatedBy: { - name: "updatedBy", - type: "string", - }, - userId: { - name: "userId", - type: "any", - }, - createdAt: { - name: "createdAt", - type: "Date", - }, - updatedAt: { - name: "updatedAt", - type: "Date", - }, - conditions: { - name: "conditions", - type: "Array<ConditionConfig>", - }, - filters: { - name: "filters", - type: "Array<FilterConfig>", - }, - }, - relations: { - user: { - name: "user", - type: "User", - model: "User", - relationType: "belongsTo", - keyFrom: "userId", - keyTo: "id", - }, - }, - }; - } -} diff --git a/src/app/shared/sdk/models/index.ts b/src/app/shared/sdk/models/index.ts deleted file mode 100644 index 99ae94433..000000000 --- a/src/app/shared/sdk/models/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable */ -export * from "./User"; -export * from "./UserCredential"; -export * from "./UserIdentity"; -export * from "./ApplicationCredential"; -export * from "./Logbook"; -export * from "./PublishedData"; -export * from "./Dataset"; -export * from "./RawDataset"; -export * from "./DerivedDataset"; -export * from "./Sample"; -export * from "./Proposal"; -export * from "./Datablock"; -export * from "./Policy"; -export * from "./OrigDatablock"; -export * from "./Attachment"; -export * from "./Job"; -export * from "./ShareGroup"; -export * from "./UserSetting"; -export * from "./Instrument"; -export * from "./BaseModels"; -export * from "./FireLoopRef"; diff --git a/src/app/shared/sdk/services/core/auth.service.ts b/src/app/shared/sdk/services/core/auth.service.ts deleted file mode 100644 index d09b832fa..000000000 --- a/src/app/shared/sdk/services/core/auth.service.ts +++ /dev/null @@ -1,167 +0,0 @@ -/* eslint-disable */ -declare var Object: any; -import { Injectable, Inject } from "@angular/core"; -import { InternalStorage } from "../../storage/storage.swaps"; -import { SDKToken } from "../../models/BaseModels"; -/** - * @author Jonathan Casarrubias - * @module SocketConnection - * @license MIT - * @description - * This module handle socket connections and return singleton instances for each - * connection, it will use the SDK Socket Driver Available currently supporting - * Angular 2 for web, NativeScript 2 and Angular Universal. - **/ -@Injectable() -export class LoopBackAuth { - /** - * @type {SDKToken} - **/ - private token: SDKToken = new SDKToken(); - /** - * @type {string} - **/ - protected prefix: string = "$LoopBackSDK$"; - /** - * @method constructor - * @param {InternalStorage} storage Internal Storage Driver - * @description - * The constructor will initialize the token loading data from storage - **/ - constructor(@Inject(InternalStorage) protected storage: InternalStorage) { - this.token.id = this.load("id"); - this.token.user = this.load("user"); - this.token.userId = this.load("userId"); - this.token.created = this.load("created"); - this.token.ttl = this.load("ttl"); - this.token.rememberMe = this.load("rememberMe"); - } - /** - * @method setRememberMe - * @param {boolean} value Flag to remember credentials - * @return {void} - * @description - * This method will set a flag in order to remember the current credentials - **/ - public setRememberMe(value: boolean): void { - this.token.rememberMe = value; - } - /** - * @method setUser - * @param {any} user Any type of user model - * @return {void} - * @description - * This method will update the user information and persist it if the - * rememberMe flag is set. - **/ - public setUser(user: any) { - this.token.user = user; - this.save(); - } - /** - * @method setToken - * @param {SDKToken} token SDKToken or casted AccessToken instance - * @return {void} - * @description - * This method will set a flag in order to remember the current credentials - **/ - public setToken(token: SDKToken): void { - this.token = Object.assign({}, this.token, token); - this.save(); - } - /** - * @method getToken - * @return {void} - * @description - * This method will set a flag in order to remember the current credentials. - **/ - public getToken(): SDKToken { - return this.token; - } - /** - * @method getAccessTokenId - * @return {string} - * @description - * This method will return the actual token string, not the object instance. - **/ - public getAccessTokenId(): string { - return this.token.id; - } - /** - * @method getCurrentUserId - * @return {any} - * @description - * This method will return the current user id, it can be number or string. - **/ - public getCurrentUserId(): any { - return this.token.userId; - } - /** - * @method getCurrentUserData - * @return {any} - * @description - * This method will return the current user instance. - **/ - public getCurrentUserData(): any { - return typeof this.token.user === "string" - ? JSON.parse(this.token.user) - : this.token.user; - } - /** - * @method save - * @return {boolean} Whether or not the information was saved - * @description - * This method will save in either local storage or cookies the current credentials. - * But only if rememberMe is enabled. - **/ - public save(): boolean { - let today = new Date(); - let expires = new Date(today.getTime() + this.token.ttl * 1000); - this.persist("id", this.token.id, expires); - this.persist("user", this.token.user, expires); - this.persist("userId", this.token.userId, expires); - this.persist("created", this.token.created, expires); - this.persist("ttl", this.token.ttl, expires); - this.persist("rememberMe", this.token.rememberMe, expires); - return true; - } - /** - * @method load - * @param {string} prop Property name - * @return {any} Any information persisted in storage - * @description - * This method will load either from local storage or cookies the provided property. - **/ - protected load(prop: string): any { - return decodeURIComponent(this.storage.get(`${this.prefix}${prop}`)); - } - /** - * @method clear - * @return {void} - * @description - * This method will clear cookies or the local storage. - **/ - public clear(): void { - Object.keys(this.token).forEach((prop: string) => - this.storage.remove(`${this.prefix}${prop}`), - ); - this.token = new SDKToken(); - } - /** - * @method persist - * @return {void} - * @description - * This method saves values to storage - **/ - protected persist(prop: string, value: any, expires?: Date): void { - try { - this.storage.set( - `${this.prefix}${prop}`, - typeof value === "object" ? JSON.stringify(value) : value, - this.token.rememberMe ? expires : null, - ); - } catch (err) { - console.error("Cannot access local/session storage:", err); - } - } -} diff --git a/src/app/shared/sdk/services/core/base.service.ts b/src/app/shared/sdk/services/core/base.service.ts deleted file mode 100644 index 5011a6ccc..000000000 --- a/src/app/shared/sdk/services/core/base.service.ts +++ /dev/null @@ -1,892 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { - HttpClient, - HttpHeaders, - HttpRequest, - HttpParams, - HttpResponse, - HttpParameterCodec, -} from "@angular/common/http"; -import { NgModule, ModuleWithProviders } from "@angular/core"; -import { ErrorHandler } from "./error.service"; -import { LoopBackAuth } from "./auth.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackFilter, AccessToken } from "../../models/BaseModels"; -import { SDKModels } from "../custom/SDKModels"; -import { Observable, Subject } from "rxjs"; -import { catchError, map, filter } from "rxjs/operators"; -import { SocketConnection } from "../../sockets/socket.connections"; -// Making Sure EventSource Type is available to avoid compilation issues. -declare var EventSource: any; -class CustomQueryEncoderHelper implements HttpParameterCodec { - encodeKey(k: string): string { - return encodeURIComponent(k); - } - - encodeValue(v: string): string { - return encodeURIComponent(v); - } - - decodeKey(k: string): string { - return decodeURIComponent(k); - } - - decodeValue(v: string): string { - return decodeURIComponent(v); - } -} -/** - * @module BaseLoopBackApi - * @author Jonathan Casarrubias <@johncasarrubias> - * @author Nikolay Matiushenkov - * @license MIT - * @description - * Abstract class that will be implemented in every custom service automatically built - * by the sdk builder. - * It provides the core functionallity for every API call, either by HTTP Calls or by - * WebSockets. - **/ -@Injectable() -export abstract class BaseLoopBackApi { - protected path: string; - protected model: any; - - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - this.model = this.models.get(this.getModelName()); - } - /** - * @method request - * @param {string} method Request method (GET, POST, PUT) - * @param {string} url Request url (my-host/my-url/:id) - * @param {any} routeParams Values of url parameters - * @param {any} urlParams Parameters for building url (filter and other) - * @param {any} postBody Request postBody - * @return {Observable} - * @description - * This is a core method, every HTTP Call will be done from here, every API Service will - * extend this class and use this method to get RESTful communication. - **/ - public request( - method: string, - url: string, - routeParams: any = {}, - urlParams: any = {}, - postBody: any = {}, - pubsub: boolean = false, - customHeaders?: Function, - ): Observable { - // Transpile route variables to the actual request Values - Object.keys(routeParams).forEach((key: string) => { - url = url.replace( - new RegExp(":" + key + "(/|$)", "g"), - routeParams[key] + "$1", - ); - }); - if (pubsub) { - if (url.match(/fk/)) { - let arr = url.split("/"); - arr.pop(); - url = arr.join("/"); - } - let event: string = `[${method}]${url}`.replace(/\?/, ""); - let subject: Subject = new Subject(); - this.connection.on(event, (res: any) => subject.next(res)); - return subject.asObservable(); - } else { - let httpParams = new HttpParams({ - encoder: new CustomQueryEncoderHelper(), - }); - // Headers to be sent - let headers: HttpHeaders = new HttpHeaders(); - headers = headers.append("Content-Type", "application/json"); - // Authenticate request - headers = this.authenticate(url, headers); - // Body fix for built in remote methods using "data", "options" or "credentials - // that are the actual body, Custom remote method properties are different and need - // to be wrapped into a body object - let body: any; - let postBodyKeys = - typeof postBody === "object" ? Object.keys(postBody) : []; - if (postBodyKeys.length === 1) { - body = postBody[postBodyKeys.shift()]; - } else { - body = postBody; - } - - let queryString: string = ""; - - // Separate filter object from url params and add to search query - if (urlParams.filter) { - if (LoopBackConfig.isHeadersFilteringSet()) { - headers = headers.append("filter", JSON.stringify(urlParams.filter)); - } else { - queryString = `?filter=${encodeURIComponent( - JSON.stringify(urlParams.filter), - )}`; - } - delete urlParams.filter; - } - - // Separate where object from url params and add to search query - if (urlParams.where) { - if (LoopBackConfig.isHeadersWhereSet()) { - /** - CODE BELOW WILL GENERATE THE FOLLOWING ISSUES: - - https://github.com/mean-expert-official/loopback-sdk-builder/issues/356 - - https://github.com/mean-expert-official/loopback-sdk-builder/issues/328 - **/ - headers = headers.append("where", JSON.stringify(urlParams.where)); - } else { - queryString = `?where=${encodeURIComponent( - JSON.stringify(urlParams.where), - )}`; - } - delete urlParams.where; - } - - if (typeof customHeaders === "function") { - headers = customHeaders(headers); - } - /* enhancement/configure-where-headers - this.searchParams.setJSON(urlParams); - let request: Request = new Request( - new RequestOptions({ - headers : headers, - method : method, - url : `${url}${queryString}`, - search : Object.keys(urlParams).length > 0 ? this.searchParams.getURLSearchParams() : null, - body : body ? JSON.stringify(body) : undefined, - withCredentials: LoopBackConfig.getRequestOptionsCredentials() - }) - ); -TODO Fix Merge Conflict */ - Object.keys(urlParams).forEach((paramKey) => { - let paramValue = urlParams[paramKey]; - paramValue = - typeof paramValue === "object" - ? JSON.stringify(paramValue) - : paramValue; - httpParams = httpParams.append(paramKey, paramValue); - }); - let request = new HttpRequest(method, `${url}${queryString}`, body, { - headers: headers, - params: httpParams, - withCredentials: LoopBackConfig.getRequestOptionsCredentials(), - }); - return this.http.request(request).pipe( - filter((event) => event instanceof HttpResponse), - map((res: HttpResponse) => res.body), - catchError((e) => this.errorHandler.handleError(e)), - ); - } - } - /** - * @method authenticate - * @author Jonathan Casarrubias - * @license MIT - * @param {string} url Server URL - * @param {Headers} headers HTTP Headers - * @return {void} - * @description - * This method will try to authenticate using either an access_token or basic http auth - */ - public authenticate(url: string, headers: HttpHeaders): HttpHeaders { - if (this.auth.getAccessTokenId()) { - headers = headers.append( - "Authorization", - LoopBackConfig.getAuthPrefix() + this.auth.getAccessTokenId(), - ); - } - - return headers; - } - /** - * @method create - * @author Jonathan Casarrubias - * @license MIT - * @param {T} data Generic data type - * @return {Observable} - * @description - * Generic create method - */ - public create(data: T, customHeaders?: Function): Observable { - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ].join("/"), - undefined, - undefined, - { data }, - null, - customHeaders, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method onCreate - * @author Jonathan Casarrubias - * @license MIT - * @param {T[]} data Generic data type array - * @return {Observable} - * @description - * Generic pubsub oncreate many method - */ - public onCreate(data: T[]): Observable { - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ].join("/"), - undefined, - undefined, - { data }, - true, - ).pipe( - map((datum: T[]) => datum.map((data: T) => this.model.factory(data))), - ); - } - /** - * @method createMany - * @author Jonathan Casarrubias - * @license MIT - * @param {T[]} data Generic data type array - * @return {Observable} - * @description - * Generic create many method - */ - public createMany(data: T[], customHeaders?: Function): Observable { - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ].join("/"), - undefined, - undefined, - { data }, - null, - customHeaders, - ).pipe( - map((datum: T[]) => datum.map((data: T) => this.model.factory(data))), - ); - } - /** - * @method onCreateMany - * @author Jonathan Casarrubias - * @license MIT - * @param {T[]} data Generic data type array - * @return {Observable} - * @description - * Generic create many method - */ - public onCreateMany(data: T[]): Observable { - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ].join("/"), - undefined, - undefined, - { data }, - true, - ).pipe( - map((datum: T[]) => datum.map((data: T) => this.model.factory(data))), - ); - } - /** - * @method findById - * @author Jonathan Casarrubias - * @license MIT - * @param {any} data Generic data type - * @return {Observable} - * @description - * Generic findById method - */ - public findById( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _urlParams: any = {}; - if (filter) _urlParams.filter = filter; - return this.request( - "GET", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ":id", - ].join("/"), - { id }, - _urlParams, - undefined, - null, - customHeaders, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method find - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic find method - */ - public find( - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - return this.request( - "GET", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ].join("/"), - undefined, - { filter }, - undefined, - null, - customHeaders, - ).pipe( - map((datum: T[]) => datum.map((data: T) => this.model.factory(data))), - ); - } - /** - * @method exists - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic exists method - */ - public exists(id: any, customHeaders?: Function): Observable { - return this.request( - "GET", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ":id/exists", - ].join("/"), - { id }, - undefined, - undefined, - null, - customHeaders, - ); - } - /** - * @method findOne - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic findOne method - */ - public findOne( - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - return this.request( - "GET", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - "findOne", - ].join("/"), - undefined, - { filter }, - undefined, - null, - customHeaders, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method updateAll - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic updateAll method - */ - public updateAll( - where: any = {}, - data: T, - customHeaders?: Function, - ): Observable<{ count: "number" }> { - let _urlParams: any = {}; - if (where) _urlParams.where = where; - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - "update", - ].join("/"), - undefined, - _urlParams, - { data }, - null, - customHeaders, - ); - } - /** - * @method onUpdateAll - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic pubsub onUpdateAll method - */ - public onUpdateAll( - where: any = {}, - data: T, - ): Observable<{ count: "number" }> { - let _urlParams: any = {}; - if (where) _urlParams.where = where; - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - "update", - ].join("/"), - undefined, - _urlParams, - { data }, - true, - ); - } - /** - * @method deleteById - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic deleteById method - */ - public deleteById(id: any, customHeaders?: Function): Observable { - return this.request( - "DELETE", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ":id", - ].join("/"), - { id }, - undefined, - undefined, - null, - customHeaders, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method onDeleteById - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic pubsub onDeleteById method - */ - public onDeleteById(id: any): Observable { - return this.request( - "DELETE", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ":id", - ].join("/"), - { id }, - undefined, - undefined, - true, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method count - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable<{ count: number }>} - * @description - * Generic count method - */ - public count( - where: any = {}, - customHeaders?: Function, - ): Observable<{ count: number }> { - let _urlParams: any = {}; - if (where) _urlParams.where = where; - return this.request( - "GET", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - "count", - ].join("/"), - undefined, - _urlParams, - undefined, - null, - customHeaders, - ); - } - /** - * @method updateAttributes - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic updateAttributes method - */ - public updateAttributes( - id: any, - data: T, - customHeaders?: Function, - ): Observable { - return this.request( - "PUT", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ":id", - ].join("/"), - { id }, - undefined, - { data }, - null, - customHeaders, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method onUpdateAttributes - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic onUpdateAttributes method - */ - public onUpdateAttributes(id: any, data: T): Observable { - return this.request( - "PUT", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ":id", - ].join("/"), - { id }, - undefined, - { data }, - true, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method upsert - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic upsert method - */ - public upsert(data: any = {}, customHeaders?: Function): Observable { - return this.request( - "PUT", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ].join("/"), - undefined, - undefined, - { data }, - null, - customHeaders, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method onUpsert - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic pubsub onUpsert method - */ - public onUpsert(data: any = {}): Observable { - return this.request( - "PUT", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ].join("/"), - undefined, - undefined, - { data }, - true, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method upsertPatch - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic upsert method using patch http method - */ - public upsertPatch( - data: any = {}, - customHeaders?: Function, - ): Observable { - return this.request( - "PATCH", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ].join("/"), - undefined, - undefined, - { data }, - null, - customHeaders, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method onUpsertPatch - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic pubsub onUpsertPatch method using patch http method - */ - public onUpsertPatch(data: any = {}): Observable { - return this.request( - "PATCH", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ].join("/"), - undefined, - undefined, - { data }, - true, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method upsertWithWhere - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic upsertWithWhere method - */ - public upsertWithWhere( - where: any = {}, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _urlParams: any = {}; - if (where) _urlParams.where = where; - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - "upsertWithWhere", - ].join("/"), - undefined, - _urlParams, - { data }, - null, - customHeaders, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method onUpsertWithWhere - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic pubsub onUpsertWithWhere method - */ - public onUpsertWithWhere(where: any = {}, data: any = {}): Observable { - let _urlParams: any = {}; - if (where) _urlParams.where = where; - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - "upsertWithWhere", - ].join("/"), - undefined, - _urlParams, - { data }, - true, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method replaceOrCreate - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic replaceOrCreate method - */ - public replaceOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - "replaceOrCreate", - ].join("/"), - undefined, - undefined, - { data }, - null, - customHeaders, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method onReplaceOrCreate - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic onReplaceOrCreate method - */ - public onReplaceOrCreate(data: any = {}): Observable { - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - "replaceOrCreate", - ].join("/"), - undefined, - undefined, - { data }, - true, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method replaceById - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic replaceById method - */ - public replaceById( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ":id", - "replace", - ].join("/"), - { id }, - undefined, - { data }, - null, - customHeaders, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method onReplaceById - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic onReplaceById method - */ - public onReplaceById(id: any, data: any = {}): Observable { - return this.request( - "POST", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - ":id", - "replace", - ].join("/"), - { id }, - undefined, - { data }, - true, - ).pipe(map((data: T) => this.model.factory(data))); - } - /** - * @method createChangeStream - * @author Jonathan Casarrubias - * @license MIT - * @return {Observable} - * @description - * Generic createChangeStream method - */ - public createChangeStream(): Observable { - let subject = new Subject(); - if (typeof EventSource !== "undefined") { - let emit = (msg: any) => subject.next(JSON.parse(msg.data)); - var source = new EventSource( - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - "change-stream", - ].join("/"), - ); - source.addEventListener("data", emit); - source.onerror = emit; - } else { - console.warn("SDK Builder: EventSource is not supported"); - } - return subject.asObservable(); - } - /** - * @method getModelName - * @author Jonathan Casarrubias - * @license MIT - * @return {string} - * @description - * Abstract getModelName method - */ - abstract getModelName(): string; -} diff --git a/src/app/shared/sdk/services/core/error.service.ts b/src/app/shared/sdk/services/core/error.service.ts deleted file mode 100644 index eacd763d3..000000000 --- a/src/app/shared/sdk/services/core/error.service.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable */ -import { Injectable } from "@angular/core"; -import { HttpErrorResponse } from "@angular/common/http"; -import { Observable, throwError } from "rxjs"; -/** - * Default error handler - */ -@Injectable() -export class ErrorHandler { - public handleError(errorResponse: HttpErrorResponse): Observable { - return throwError(errorResponse.error.error || "Server error"); - } -} diff --git a/src/app/shared/sdk/services/core/index.ts b/src/app/shared/sdk/services/core/index.ts deleted file mode 100644 index 0b455c18d..000000000 --- a/src/app/shared/sdk/services/core/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable */ -export * from "./auth.service"; -export * from "./error.service"; -export * from "./base.service"; -export * from "./real.time"; diff --git a/src/app/shared/sdk/services/core/io.service.ts b/src/app/shared/sdk/services/core/io.service.ts deleted file mode 100644 index b4860d8e3..000000000 --- a/src/app/shared/sdk/services/core/io.service.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* eslint-disable */ -import { Observable, Subject } from "rxjs"; - -export class IO { - private socket: any; - private observables: any = {}; - - constructor(socket: any) { - this.socket = socket; - } - - emit(event: string, data: any): void { - this.socket.emit("ME:RT:1://event", { - event: event, - data: data, - }); - } - - on(event: string): Observable { - if (this.observables[event]) { - return this.observables[event]; - } - let subject: Subject = new Subject(); - this.socket.on(event, (res: any) => subject.next(res)); - this.observables[event] = subject.asObservable(); - return this.observables[event]; - } -} diff --git a/src/app/shared/sdk/services/core/real.time.ts b/src/app/shared/sdk/services/core/real.time.ts deleted file mode 100644 index 40260dbeb..000000000 --- a/src/app/shared/sdk/services/core/real.time.ts +++ /dev/null @@ -1,120 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject } from "@angular/core"; -import { IO } from "./io.service"; -import { LoopBackAuth } from "./auth.service"; -import { FireLoop } from "../../models/FireLoop"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { SDKModels } from "../custom/SDKModels"; -import { Observable, Subject, Subscription } from "rxjs"; -import { share } from "rxjs/operators"; -/** - * @author Jonathan Casarrubias - * @module RealTime - * @license MIT - * @description - * This module is a real-time interface for using socket connections, its main purpose - * is to make sure that when there is a valid connection, it will create instances - * of the different real-time functionalities like FireLoop, PubSub and IO. - **/ -@Injectable() -export class RealTime { - public IO: IO; - public FireLoop: FireLoop; - private connecting: boolean = false; - private onReadySubject: Subject = new Subject(); - private sharedOnReady: Observable = this.onReadySubject - .asObservable() - .pipe(share()); - /** - * @method constructor - * @param {SocketConnection} connection WebSocket connection service - * @param {SDKModels} models Model provider service - * @param {LoopBackAuth} auth LoopBack authentication service - * @description - * It will intialize the shared on ready communication channel. - **/ - constructor( - @Inject(SocketConnection) public connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - ) { - this.sharedOnReady.subscribe(); - } - /** - * @method onDisconnect - * @return {Observable} - * @description - * Will trigger when Real-Time Service is disconnected from server. - **/ - onDisconnect(): Observable { - return this.connection.sharedObservables.sharedOnDisconnect; - } - /** - * @method onAuthenticated - * @return {Observable} - * @description - * Will trigger when Real-Time Service is authenticated with the server. - **/ - onAuthenticated(): Observable { - return this.connection.sharedObservables.sharedOnAuthenticated; - } - /** - * @method onUnAuthorized - * @return {Observable} - * @description - * Will trigger when Real-Time Service is not authorized to connect with the server. - **/ - onUnAuthorized(): Observable { - return this.connection.sharedObservables.sharedOnUnAuthorized; - } - /** - * @method onReady - * @return {Observable} - * @description - * Will trigger when Real-Time Service is Ready for broadcasting. - * and will register connection flow events to notify subscribers. - **/ - public onReady(): Observable { - // If there is a valid connection, then we just send back to the EventLoop - // Or next will be executed before the actual subscription. - if (this.connection.isConnected()) { - let to = setTimeout(() => { - this.onReadySubject.next("shared-connection"); - clearTimeout(to); - }); - // Else if there is a current attempt of connection we wait for the prior - // process that started the connection flow. - } else if (this.connecting) { - let ti = setInterval(() => { - if (this.connection.isConnected()) { - this.onReadySubject.next("shared-connection"); - clearInterval(ti); - } - }, 500); - // If there is not valid connection or attempt, then we start the connection flow - // and make sure we notify all the onReady subscribers when done. - // Also it will listen for desconnections so we unsubscribe and avoid both: - // Memory leaks and duplicated triggered events. - } else { - this.connecting = true; - this.connection.connect(this.auth.getToken()); - this.IO = new IO(this.connection); - this.FireLoop = new FireLoop(this.connection, this.models); - // Fire event for those subscribed - let s1: Subscription = - this.connection.sharedObservables.sharedOnConnect.subscribe(() => { - console.log("Real-Time connection has been established"); - this.connecting = false; - this.onReadySubject.next("connected"); - let s2: Subscription = - this.connection.sharedObservables.sharedOnDisconnect.subscribe( - () => { - s1.unsubscribe(); - s2.unsubscribe(); - }, - ); - }); - } - return this.sharedOnReady; - } -} diff --git a/src/app/shared/sdk/services/custom/ApplicationCredential.ts b/src/app/shared/sdk/services/custom/ApplicationCredential.ts deleted file mode 100644 index a455aca45..000000000 --- a/src/app/shared/sdk/services/custom/ApplicationCredential.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { ApplicationCredential } from "../../models/ApplicationCredential"; -import { SocketConnection } from "../../sockets/socket.connections"; - -/** - * Api services for the `ApplicationCredential` model. - */ -@Injectable() -export class ApplicationCredentialApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `ApplicationCredential` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/ApplicationCredentials"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id ApplicationCredential id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `ApplicationCredential` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/ApplicationCredentials/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `ApplicationCredential`. - */ - public getModelName() { - return "ApplicationCredential"; - } -} diff --git a/src/app/shared/sdk/services/custom/Attachment.ts b/src/app/shared/sdk/services/custom/Attachment.ts deleted file mode 100644 index dc8ef74dc..000000000 --- a/src/app/shared/sdk/services/custom/Attachment.ts +++ /dev/null @@ -1,406 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { ErrorHandler } from "../core/error.service"; -import { Observable } from "rxjs"; -import { SocketConnection } from "../../sockets/socket.connections"; - -/** - * Api services for the `Attachment` model. - * - * **Details** - * - * Small less than 16 MB attachments, envisaged for png/jpeg previews - */ -@Injectable() -export class AttachmentApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Fetches belongsTo relation dataset. - * - * @param {any} id Attachment id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Attachment` object.) - * - */ - public getDataset( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Attachments/:id/dataset"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches belongsTo relation sample. - * - * @param {any} id Attachment id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Attachment` object.) - * - */ - public getSample( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Attachments/:id/sample"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches belongsTo relation proposal. - * - * @param {any} id Attachment id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Attachment` object.) - * - */ - public getProposal( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Attachments/:id/proposal"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Attachment` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Attachments"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id Attachment id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Attachment` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Attachments/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Attachment` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Attachments/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Attachment` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Attachments/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Check if data is valid according to a schema - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Attachment` object.) - * - */ - public isValid( - ownableItem: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Attachments/isValid"; - let _routeParams: any = {}; - let _postBody: any = { - ownableItem: ownableItem, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `Attachment`. - */ - public getModelName() { - return "Attachment"; - } -} diff --git a/src/app/shared/sdk/services/custom/Datablock.ts b/src/app/shared/sdk/services/custom/Datablock.ts deleted file mode 100644 index 13d711e73..000000000 --- a/src/app/shared/sdk/services/custom/Datablock.ts +++ /dev/null @@ -1,318 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { Datablock } from "../../models/Datablock"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { Dataset } from "../../models/Dataset"; - -/** - * Api services for the `Datablock` model. - * - * **Details** - * - * When archiving a dataset all files contained in the dataset are listed here together with their checksum information. Several datablocks can be created if the file listing is too long for a single datablock. This partitioning decision is done by the archiving system to allow for chunks of datablocks with managable sizes. E.g a dataset consisting of 10 TB of data could be split into 10 datablocks of about 1 TB each. The upper limit set by the data catalog system itself is given by the fact that documents must be smaller than 16 MB, which typically allows for datasets of about 100000 files. - */ -@Injectable() -export class DatablockApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Fetches belongsTo relation dataset. - * - * @param {any} id Datablock id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Datablock` object.) - * - */ - public getDataset( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datablocks/:id/dataset"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Datablock` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datablocks"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id Datablock id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Datablock` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datablocks/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Datablock` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datablocks/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Datablock` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datablocks/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Check if data is valid according to a schema - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Datablock` object.) - * - */ - public isValid( - ownableItem: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datablocks/isValid"; - let _routeParams: any = {}; - let _postBody: any = { - ownableItem: ownableItem, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `Datablock`. - */ - public getModelName() { - return "Datablock"; - } -} diff --git a/src/app/shared/sdk/services/custom/Dataset.ts b/src/app/shared/sdk/services/custom/Dataset.ts deleted file mode 100644 index d26e78d1e..000000000 --- a/src/app/shared/sdk/services/custom/Dataset.ts +++ /dev/null @@ -1,2989 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { Dataset } from "../../models/Dataset"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { PublishedData } from "../../models/PublishedData"; -import { Sample } from "../../models/Sample"; -import { Datablock } from "../../models/Datablock"; -import { OrigDatablock } from "../../models/OrigDatablock"; -import { Attachment } from "../../models/Attachment"; -import { Instrument } from "../../models/Instrument"; - -/** - * Api services for the `Dataset` model. - * - * **Details** - * - * Stores the meta data information for a given collection of files. It defines a list of mandatory and optional metadata fields to be defined. Datasets have a PID field for unique identification. This is the base 'class' for derived documents like raw datasets or derived datasets. The type field is used to distinguish between the different types of datasets. For each dataset in addition an embedded DatasetLifecycle is created. However the definition of which files belong to a given dataset is defined in an extra OrigDatablock collection. - */ -@Injectable() -export class DatasetApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Find a related item by id for historyList. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for historyList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public findByIdHistoryList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/historyList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for historyList. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for historyList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdHistoryList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/historyList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for historyList. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for historyList - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public updateByIdHistoryList( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/historyList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches hasOne relation datasetLifecycle. - * - * @param {any} id Dataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public getDatasetLifecycle( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datasetLifecycle of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createDatasetLifecycle( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update datasetLifecycle of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public updateDatasetLifecycle( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes datasetLifecycle of this model. - * - * @param {any} id Dataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyDatasetLifecycle( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches belongsTo relation publisheddata. - * - * @param {any} id Dataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public getPublisheddata( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/publisheddata"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for techniquesList. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for techniquesList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public findByIdTechniquesList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/techniquesList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for techniquesList. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for techniquesList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdTechniquesList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/techniquesList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for techniquesList. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for techniquesList - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public updateByIdTechniquesList( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/techniquesList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for samples. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for samples - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public findByIdSamples( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/samples/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for samples. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for samples - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdSamples( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/samples/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for samples. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for samples - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public updateByIdSamples( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/samples/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for datablocks. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for datablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public findByIdDatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for datablocks. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for datablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdDatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for datablocks. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for datablocks - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public updateByIdDatablocks( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for origdatablocks. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for origdatablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public findByIdOrigdatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/origdatablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for origdatablocks. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for origdatablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdOrigdatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/origdatablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for origdatablocks. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for origdatablocks - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public updateByIdOrigdatablocks( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/origdatablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for attachments. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for attachments - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public findByIdAttachments( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for attachments. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for attachments - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdAttachments( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for attachments. - * - * @param {any} id Dataset id - * - * @param {any} fk Foreign key for attachments - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public updateByIdAttachments( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches belongsTo relation instrument. - * - * @param {any} id Dataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public getInstrument( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/instrument"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries historyList of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public getHistoryList( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in historyList of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createHistoryList( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all historyList of this model. - * - * @param {any} id Dataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteHistoryList(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts historyList of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countHistoryList( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/historyList/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries techniquesList of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public getTechniquesList( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in techniquesList of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createTechniquesList( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all techniquesList of this model. - * - * @param {any} id Dataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteTechniquesList( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts techniquesList of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countTechniquesList( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/techniquesList/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries samples of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public getSamples( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in samples of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createSamples( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all samples of this model. - * - * @param {any} id Dataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteSamples(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts samples of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countSamples( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/samples/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries datablocks of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public getDatablocks( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datablocks of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createDatablocks( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all datablocks of this model. - * - * @param {any} id Dataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteDatablocks(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts datablocks of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countDatablocks( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datablocks/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries origdatablocks of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public getOrigdatablocks( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in origdatablocks of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createOrigdatablocks( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all origdatablocks of this model. - * - * @param {any} id Dataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteOrigdatablocks( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts origdatablocks of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countOrigdatablocks( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/origdatablocks/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries attachments of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public getAttachments( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in attachments of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createAttachments( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all attachments of this model. - * - * @param {any} id Dataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteAttachments(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts attachments of Dataset. - * - * @param {any} id Dataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countAttachments( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/attachments/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Check if data is valid according to a schema - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public isValid( - ownableItem: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/isValid"; - let _routeParams: any = {}; - let _postBody: any = { - ownableItem: ownableItem, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Reset archive status by deleting created datablocks of dataset and resetting archiveStatusMessage and archivable flag. - * - * @param {object} data Request data. - * - * - `datasetId` – `{string}` - - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public reset(datasetId: any = {}, customHeaders?: Function): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/resetArchiveStatus"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof datasetId !== "undefined" && datasetId !== null) - _urlParams.datasetId = datasetId; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Sends a post request for Dataset reduction to OpenWhisk - * - * @param {object} data Request data. - * - * - `dataset` – `{Dataset}` - The Dataset to send for reduction - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * The response from the OpenWhisk reduce action - */ - public reduceDataset( - dataset: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/reduce"; - let _routeParams: any = {}; - let _postBody: any = { - dataset: dataset, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * updates a single record by appending data to the specified field - * - * @param {object} data Request data. - * - * - `id` – `{string}` - - * - * - `fieldName` – `{string}` - Name of field to append data to - * - * - `data` – `{any}` - An array of values to append - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public appendToArrayField( - id: any, - fieldName: any, - data: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/appendToArrayField"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fieldName !== "undefined" && fieldName !== null) - _urlParams.fieldName = fieldName; - if (typeof data !== "undefined" && data !== null) _urlParams.data = data; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return array of metadata keys from datasets corresponding to the current filters. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There is also support for a `text` search to look for strings anywhere in the dataset. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public metadataKeys( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/metadataKeys"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * - * (The remote method definition does not provide any description.) - * - * - * @param {string} id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public thumbnail(id: any, customHeaders?: Function): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/thumbnail"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datasetLifecycle of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createManyDatasetLifecycle( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in historyList of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createManyHistoryList( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in techniquesList of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createManyTechniquesList( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in samples of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createManySamples( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datablocks of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createManyDatablocks( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in origdatablocks of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createManyOrigdatablocks( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in attachments of this model. - * - * @param {any} id Dataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Dataset` object.) - * - */ - public createManyAttachments( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `Dataset`. - */ - public getModelName() { - return "Dataset"; - } -} diff --git a/src/app/shared/sdk/services/custom/DerivedDataset.ts b/src/app/shared/sdk/services/custom/DerivedDataset.ts deleted file mode 100644 index d303b2fe6..000000000 --- a/src/app/shared/sdk/services/custom/DerivedDataset.ts +++ /dev/null @@ -1,2989 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { DerivedDataset } from "../../models/DerivedDataset"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { PublishedData } from "../../models/PublishedData"; -import { Sample } from "../../models/Sample"; -import { Datablock } from "../../models/Datablock"; -import { OrigDatablock } from "../../models/OrigDatablock"; -import { Attachment } from "../../models/Attachment"; -import { Instrument } from "../../models/Instrument"; - -/** - * Api services for the `DerivedDataset` model. - * - * **Details** - * - * Contains the information for datasets which are the result of an analysis step, typically based on raw datasets or other derived datasets as input. Derived datasets are typically added by the researcher pursuing the specific analysis. This schema inherits the fields from the generic Dataset collection and adds specific fields as defined below. - */ -@Injectable() -export class DerivedDatasetApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Find a related item by id for historyList. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for historyList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public findByIdHistoryList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/historyList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for historyList. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for historyList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdHistoryList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/historyList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for historyList. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for historyList - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public updateByIdHistoryList( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/historyList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches hasOne relation datasetLifecycle. - * - * @param {any} id DerivedDataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public getDatasetLifecycle( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datasetLifecycle of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createDatasetLifecycle( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update datasetLifecycle of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public updateDatasetLifecycle( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes datasetLifecycle of this model. - * - * @param {any} id DerivedDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyDatasetLifecycle( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches belongsTo relation publisheddata. - * - * @param {any} id DerivedDataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public getPublisheddata( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/publisheddata"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for techniquesList. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for techniquesList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public findByIdTechniquesList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/techniquesList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for techniquesList. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for techniquesList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdTechniquesList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/techniquesList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for techniquesList. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for techniquesList - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public updateByIdTechniquesList( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/techniquesList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for samples. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for samples - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public findByIdSamples( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/samples/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for samples. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for samples - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdSamples( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/samples/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for samples. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for samples - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public updateByIdSamples( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/samples/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for datablocks. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for datablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public findByIdDatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for datablocks. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for datablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdDatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for datablocks. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for datablocks - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public updateByIdDatablocks( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for origdatablocks. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for origdatablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public findByIdOrigdatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/origdatablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for origdatablocks. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for origdatablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdOrigdatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/origdatablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for origdatablocks. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for origdatablocks - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public updateByIdOrigdatablocks( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/origdatablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for attachments. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for attachments - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public findByIdAttachments( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for attachments. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for attachments - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdAttachments( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for attachments. - * - * @param {any} id DerivedDataset id - * - * @param {any} fk Foreign key for attachments - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public updateByIdAttachments( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches belongsTo relation instrument. - * - * @param {any} id DerivedDataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public getInstrument( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/instrument"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries historyList of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public getHistoryList( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in historyList of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createHistoryList( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all historyList of this model. - * - * @param {any} id DerivedDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteHistoryList(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts historyList of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countHistoryList( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/historyList/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries techniquesList of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public getTechniquesList( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in techniquesList of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createTechniquesList( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all techniquesList of this model. - * - * @param {any} id DerivedDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteTechniquesList( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts techniquesList of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countTechniquesList( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/techniquesList/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries samples of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public getSamples( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in samples of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createSamples( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all samples of this model. - * - * @param {any} id DerivedDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteSamples(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts samples of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countSamples( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/samples/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries datablocks of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public getDatablocks( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datablocks of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createDatablocks( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all datablocks of this model. - * - * @param {any} id DerivedDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteDatablocks(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts datablocks of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countDatablocks( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datablocks/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries origdatablocks of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public getOrigdatablocks( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in origdatablocks of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createOrigdatablocks( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all origdatablocks of this model. - * - * @param {any} id DerivedDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteOrigdatablocks( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts origdatablocks of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countOrigdatablocks( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/origdatablocks/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries attachments of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public getAttachments( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in attachments of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createAttachments( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all attachments of this model. - * - * @param {any} id DerivedDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteAttachments(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts attachments of DerivedDataset. - * - * @param {any} id DerivedDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countAttachments( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/attachments/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Check if data is valid according to a schema - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public isValid( - ownableItem: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/isValid"; - let _routeParams: any = {}; - let _postBody: any = { - ownableItem: ownableItem, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Reset archive status by deleting created datablocks of dataset and resetting archiveStatusMessage and archivable flag. - * - * @param {object} data Request data. - * - * - `datasetId` – `{string}` - - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public reset(datasetId: any = {}, customHeaders?: Function): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/resetArchiveStatus"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof datasetId !== "undefined" && datasetId !== null) - _urlParams.datasetId = datasetId; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Sends a post request for Dataset reduction to OpenWhisk - * - * @param {object} data Request data. - * - * - `dataset` – `{Dataset}` - The Dataset to send for reduction - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * The response from the OpenWhisk reduce action - */ - public reduceDataset( - dataset: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/reduce"; - let _routeParams: any = {}; - let _postBody: any = { - dataset: dataset, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * updates a single record by appending data to the specified field - * - * @param {object} data Request data. - * - * - `id` – `{string}` - - * - * - `fieldName` – `{string}` - Name of field to append data to - * - * - `data` – `{any}` - An array of values to append - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public appendToArrayField( - id: any, - fieldName: any, - data: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/appendToArrayField"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fieldName !== "undefined" && fieldName !== null) - _urlParams.fieldName = fieldName; - if (typeof data !== "undefined" && data !== null) _urlParams.data = data; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return array of metadata keys from datasets corresponding to the current filters. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There is also support for a `text` search to look for strings anywhere in the dataset. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public metadataKeys( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/metadataKeys"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * - * (The remote method definition does not provide any description.) - * - * - * @param {string} id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public thumbnail(id: any, customHeaders?: Function): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/thumbnail"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datasetLifecycle of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createManyDatasetLifecycle( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in historyList of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createManyHistoryList( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in techniquesList of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createManyTechniquesList( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in samples of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createManySamples( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datablocks of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createManyDatablocks( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in origdatablocks of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createManyOrigdatablocks( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in attachments of this model. - * - * @param {any} id DerivedDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `DerivedDataset` object.) - * - */ - public createManyAttachments( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/DerivedDatasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `DerivedDataset`. - */ - public getModelName() { - return "DerivedDataset"; - } -} diff --git a/src/app/shared/sdk/services/custom/Instrument.ts b/src/app/shared/sdk/services/custom/Instrument.ts deleted file mode 100644 index 70eedb99e..000000000 --- a/src/app/shared/sdk/services/custom/Instrument.ts +++ /dev/null @@ -1,590 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { Instrument } from "../../models/Instrument"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { Dataset } from "../../models/Dataset"; - -/** - * Api services for the `Instrument` model. - * - * **Details** - * - * Stores metadata information for an instrument - */ -@Injectable() -export class InstrumentApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Find a related item by id for datasets. - * - * @param {any} id Instrument id - * - * @param {any} fk Foreign key for datasets - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Instrument` object.) - * - */ - public findByIdDatasets( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/:id/datasets/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for datasets. - * - * @param {any} id Instrument id - * - * @param {any} fk Foreign key for datasets - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdDatasets( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/:id/datasets/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for datasets. - * - * @param {any} id Instrument id - * - * @param {any} fk Foreign key for datasets - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Instrument` object.) - * - */ - public updateByIdDatasets( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/:id/datasets/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries datasets of Instrument. - * - * @param {any} id Instrument id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Instrument` object.) - * - */ - public getDatasets( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/:id/datasets"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datasets of this model. - * - * @param {any} id Instrument id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Instrument` object.) - * - */ - public createDatasets( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/:id/datasets"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all datasets of this model. - * - * @param {any} id Instrument id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteDatasets(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/:id/datasets"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts datasets of Instrument. - * - * @param {any} id Instrument id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countDatasets( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/:id/datasets/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Instrument` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id Instrument id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Instrument` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Instrument` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Instrument` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datasets of this model. - * - * @param {any} id Instrument id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Instrument` object.) - * - */ - public createManyDatasets( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Instruments/:id/datasets"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `Instrument`. - */ - public getModelName() { - return "Instrument"; - } -} diff --git a/src/app/shared/sdk/services/custom/Job.ts b/src/app/shared/sdk/services/custom/Job.ts deleted file mode 100644 index f621ea746..000000000 --- a/src/app/shared/sdk/services/custom/Job.ts +++ /dev/null @@ -1,283 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { Job } from "../../models/Job"; -import { SocketConnection } from "../../sockets/socket.connections"; - -/** - * Api services for the `Job` model. - * - * **Details** - * - * This collection keeps information about jobs to be excuted in external systems. In particular it keeps information about the jobs submitted for archiving or retrieving datasets stored inside an archive system. It can also be used to keep track of analysis jobs e.g. for automated analysis workflows. - */ -@Injectable() -export class JobApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Job` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() + "/Jobs"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id Job id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Job` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Jobs/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Job` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Jobs/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Job` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Jobs/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Returns for all linked datasets the details as defined in the fields array. Useful to avoid URL size limititations for large dataset queries - * - * @param {string} jobId - * - * @param {object} datasetFields - * - * @param {object} include - * - * @param {object} includeFields - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Job` object.) - * - */ - public datasetDetails( - jobId: any = {}, - datasetFields: any = {}, - include: any = {}, - includeFields: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Jobs/datasetDetails"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof jobId !== "undefined" && jobId !== null) - _urlParams.jobId = jobId; - if (typeof datasetFields !== "undefined" && datasetFields !== null) - _urlParams.datasetFields = datasetFields; - if (typeof include !== "undefined" && include !== null) - _urlParams.include = include; - if (typeof includeFields !== "undefined" && includeFields !== null) - _urlParams.includeFields = includeFields; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `Job`. - */ - public getModelName() { - return "Job"; - } -} diff --git a/src/app/shared/sdk/services/custom/Logbook.ts b/src/app/shared/sdk/services/custom/Logbook.ts deleted file mode 100644 index 942b7b598..000000000 --- a/src/app/shared/sdk/services/custom/Logbook.ts +++ /dev/null @@ -1,168 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { Logbook } from "../../models/Logbook"; -import { SocketConnection } from "../../sockets/socket.connections"; - -/** - * Api services for the `Logbook` model. - */ -@Injectable() -export class LogbookApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Find Logbook model instance by name - * - * @param {string} name Name of the Logbook - * - * @param {string} filters Filter json object, keys: textSearch, showBotMessages, showUserMessages, showImages, skip, limit, sortField - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Logbook model instance - */ - public findByName( - name: any, - filters: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Logbooks/:name"; - let _routeParams: any = { - name: name, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filters !== "undefined" && filters !== null) - _urlParams.filters = filters; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result.pipe(map((instance: Logbook) => new Logbook(instance))); - } - - /** - * Find Logbook model instance associated to the dataset passed - * - * @param {string} pid Dataset pid - * - * @param {string} filters Filter json object, keys: textSearch, showBotMessages, showUserMessages, showImages, skip, limit, sortField - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Logbook model instance - */ - public findDatasetLogbook( - pid: any, - filters: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Datasets/:pid/Logbook"; - let _routeParams: any = { - pid: pid, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filters !== "undefined" && filters !== null) - _urlParams.filters = filters; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result.pipe(map((instance: Logbook) => new Logbook(instance))); - } - - /** - * Send message to a Logbook - * - * @param {string} name Name of the Logbook - * - * @param {object} data Request data. - * - * - `data` – `{object}` - JSON object with the key `message` - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Object containing the event id of the message - */ - public sendMessage( - name: any, - data: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Logbooks/:name/message"; - let _routeParams: any = { - name: name, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `Logbook`. - */ - public getModelName() { - return "Logbook"; - } -} diff --git a/src/app/shared/sdk/services/custom/OrigDatablock.ts b/src/app/shared/sdk/services/custom/OrigDatablock.ts deleted file mode 100644 index a34c5ac35..000000000 --- a/src/app/shared/sdk/services/custom/OrigDatablock.ts +++ /dev/null @@ -1,731 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { OrigDatablock } from "../../models/OrigDatablock"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { Dataset } from "../../models/Dataset"; - -/** - * Api services for the `OrigDatablock` model. - * - * **Details** - * - * Container list all files and their attributes which make up a dataset. Usually Filled at the time the datasets metadata is created in the data catalog. Can be used by subsequent archiving processes to create the archived datasets. - */ -@Injectable() -export class OrigDatablockApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Fetches belongsTo relation dataset. - * - * @param {any} id OrigDatablock id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public getDataset( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/:id/dataset"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for files. - * - * @param {any} id OrigDatablock id - * - * @param {any} fk Foreign key for files - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public findByIdFiles( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/:id/files/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for files. - * - * @param {any} id OrigDatablock id - * - * @param {any} fk Foreign key for files - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdFiles( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/:id/files/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for files. - * - * @param {any} id OrigDatablock id - * - * @param {any} fk Foreign key for files - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public updateByIdFiles( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/:id/files/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries files of OrigDatablock. - * - * @param {any} id OrigDatablock id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public getFiles( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/:id/files"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in files of this model. - * - * @param {any} id OrigDatablock id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public createFiles( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/:id/files"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all files of this model. - * - * @param {any} id OrigDatablock id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteFiles(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/:id/files"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts files of OrigDatablock. - * - * @param {any} id OrigDatablock id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countFiles( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/:id/files/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id OrigDatablock id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Check if data is valid according to a schema - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public isValid( - ownableItem: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/isValid"; - let _routeParams: any = {}; - let _postBody: any = { - ownableItem: ownableItem, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Returns matching file objects in dataFileList grouped by dataset pid - * - * @param {object} fields Define datasetId field to select a dataset and/or the filenameExp field to define a search regexp for file names. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public findFilesByName( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/findFilesByName"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result.pipe( - map((instances: Array) => - instances.map((instance: OrigDatablock) => new OrigDatablock(instance)), - ), - ); - } - - /** - * Creates a new instance in files of this model. - * - * @param {any} id OrigDatablock id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `OrigDatablock` object.) - * - */ - public createManyFiles( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/OrigDatablocks/:id/files"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `OrigDatablock`. - */ - public getModelName() { - return "OrigDatablock"; - } -} diff --git a/src/app/shared/sdk/services/custom/Policy.ts b/src/app/shared/sdk/services/custom/Policy.ts deleted file mode 100644 index 24da55d92..000000000 --- a/src/app/shared/sdk/services/custom/Policy.ts +++ /dev/null @@ -1,318 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { Policy } from "../../models/Policy"; -import { SocketConnection } from "../../sockets/socket.connections"; - -/** - * Api services for the `Policy` model. - * - * **Details** - * - * Definition of policy parameters relevant for the storgae lifecycle management of the datasets - */ -@Injectable() -export class PolicyApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Policy` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Policies"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id Policy id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Policy` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Policies/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Policy` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Policies/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Policy` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Policies/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Check if data is valid according to a schema - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Policy` object.) - * - */ - public isValid( - ownableItem: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Policies/isValid"; - let _routeParams: any = {}; - let _postBody: any = { - ownableItem: ownableItem, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * updates multiple records on the Policy model and uses ownerGroup to identify those records - * - * @param {object} data Request data. - * - * - `ownerGroupList` – `{string}` - Comma-separated string of owner groups to update e.g. "p14159, p24959" - * - * - `data` – `{object}` - - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Policy` object.) - * - */ - public updatewhere( - ownerGroupList: any, - data: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Policies/updatewhere"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof ownerGroupList !== "undefined" && ownerGroupList !== null) - _postBody.ownerGroupList = ownerGroupList; - if (typeof data !== "undefined" && data !== null) _postBody.data = data; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `Policy`. - */ - public getModelName() { - return "Policy"; - } -} diff --git a/src/app/shared/sdk/services/custom/Proposal.ts b/src/app/shared/sdk/services/custom/Proposal.ts deleted file mode 100644 index d95256b94..000000000 --- a/src/app/shared/sdk/services/custom/Proposal.ts +++ /dev/null @@ -1,1109 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { Proposal } from "../../models/Proposal"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { Attachment } from "../../models/Attachment"; - -/** - * Api services for the `Proposal` model. - * - * **Details** - * - * Defines the purpose of an experiment and links an experiment to principal investigator and main proposer - */ -@Injectable() -export class ProposalApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Find a related item by id for measurementPeriods. - * - * @param {any} id Proposal id - * - * @param {any} fk Foreign key for measurementPeriods - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public findByIdMeasurementPeriods( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/measurementPeriods/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for measurementPeriods. - * - * @param {any} id Proposal id - * - * @param {any} fk Foreign key for measurementPeriods - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdMeasurementPeriods( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/measurementPeriods/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for measurementPeriods. - * - * @param {any} id Proposal id - * - * @param {any} fk Foreign key for measurementPeriods - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public updateByIdMeasurementPeriods( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/measurementPeriods/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for attachments. - * - * @param {any} id Proposal id - * - * @param {any} fk Foreign key for attachments - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public findByIdAttachments( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for attachments. - * - * @param {any} id Proposal id - * - * @param {any} fk Foreign key for attachments - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdAttachments( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for attachments. - * - * @param {any} id Proposal id - * - * @param {any} fk Foreign key for attachments - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public updateByIdAttachments( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries measurementPeriods of Proposal. - * - * @param {any} id Proposal id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public getMeasurementPeriods( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/measurementPeriods"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in measurementPeriods of this model. - * - * @param {any} id Proposal id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public createMeasurementPeriods( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/measurementPeriods"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all measurementPeriods of this model. - * - * @param {any} id Proposal id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteMeasurementPeriods( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/measurementPeriods"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts measurementPeriods of Proposal. - * - * @param {any} id Proposal id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countMeasurementPeriods( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/measurementPeriods/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries attachments of Proposal. - * - * @param {any} id Proposal id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public getAttachments( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in attachments of this model. - * - * @param {any} id Proposal id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public createAttachments( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all attachments of this model. - * - * @param {any} id Proposal id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteAttachments(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts attachments of Proposal. - * - * @param {any} id Proposal id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countAttachments( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/attachments/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id Proposal id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Check if data is valid according to a schema - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public isValid( - ownableItem: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/isValid"; - let _routeParams: any = {}; - let _postBody: any = { - ownableItem: ownableItem, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * @method findByIdAccess - * @param {string} id ID of the resource - * @param {Function} [customHeaders] Optional custom headers function - * @return {Observable<{ canAccess: boolean }>} - */ - public findByIdAccess( - id: string, - customHeaders?: Function, - ): Observable<{ canAccess: boolean }> { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/authorization"; - let _routeParams: any = { id }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - /** - * Find proposal that took data at specified instrument and time - * - * @param {string} instrument - * - * @param {date} measureTime - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `findByInstrumentAndDate` – `{Object}` - - */ - public findByInstrumentAndDate( - instrument: any = {}, - measureTime: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/findByInstrumentAndDate"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof instrument !== "undefined" && instrument !== null) - _urlParams.instrument = instrument; - if (typeof measureTime !== "undefined" && measureTime !== null) - _urlParams.measureTime = measureTime; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result.pipe(map((instance: Proposal) => new Proposal(instance))); - } - - /** - * Search text inside proposal - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `searchText` – `{Object}` - - */ - public searchText(customHeaders?: Function): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/searchText"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in measurementPeriods of this model. - * - * @param {any} id Proposal id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public createManyMeasurementPeriods( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/measurementPeriods"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in attachments of this model. - * - * @param {any} id Proposal id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Proposal` object.) - * - */ - public createManyAttachments( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Proposals/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `Proposal`. - */ - public getModelName() { - return "Proposal"; - } -} diff --git a/src/app/shared/sdk/services/custom/PublishedData.ts b/src/app/shared/sdk/services/custom/PublishedData.ts deleted file mode 100644 index b5ebbea84..000000000 --- a/src/app/shared/sdk/services/custom/PublishedData.ts +++ /dev/null @@ -1,712 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable } from "rxjs"; -import { SocketConnection } from "../../sockets/socket.connections"; - -/** - * Api services for the `PublishedData` model. - * - * **Details** - * - * Stores the meta data information for an accessible, published and DOI-identified collection of datasets. It defines a list of mandatory and optional metadata fields to be included. DataCite mandatory fields, a full URL to the landing page and modification times are included. - */ -@Injectable() -export class PublishedDataApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Find a related item by id for datasets. - * - * @param {any} id PublishedData id - * - * @param {any} fk Foreign key for datasets - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `PublishedData` object.) - * - */ - public findByIdDatasets( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id/datasets/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for datasets. - * - * @param {any} id PublishedData id - * - * @param {any} fk Foreign key for datasets - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdDatasets( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id/datasets/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for datasets. - * - * @param {any} id PublishedData id - * - * @param {any} fk Foreign key for datasets - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `PublishedData` object.) - * - */ - public updateByIdDatasets( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id/datasets/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries datasets of PublishedData. - * - * @param {any} id PublishedData id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `PublishedData` object.) - * - */ - public getDatasets( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id/datasets"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datasets of this model. - * - * @param {any} id PublishedData id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `PublishedData` object.) - * - */ - public createDatasets( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id/datasets"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all datasets of this model. - * - * @param {any} id PublishedData id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteDatasets(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id/datasets"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts datasets of PublishedData. - * - * @param {any} id PublishedData id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countDatasets( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id/datasets/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `PublishedData` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id PublishedData id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `PublishedData` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `PublishedData` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `PublishedData` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * - * (The remote method definition does not provide any description.) - * - * - * @param {string} pid - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `PublishedData` object.) - * - */ - public formPopulate(pid: any, customHeaders?: Function): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/formPopulate"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof pid !== "undefined" && pid !== null) _urlParams.pid = pid; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * - * (The remote method definition does not provide any description.) - * - * - * @param {object} data Request data. - * - * - `id` – `{string}` - - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `doi` – `{string}` - - */ - public register(id: any, customHeaders?: Function): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id/register"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * - * (The remote method definition does not provide any description.) - * - * - * @param {object} data Request data. - * - * - `id` – `{string}` - - * - * - `data` – `{object}` - - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `doi` – `{string}` - - */ - public resync(id: any, data: any, customHeaders?: Function): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id/resync"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datasets of this model. - * - * @param {any} id PublishedData id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `PublishedData` object.) - * - */ - public createManyDatasets( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/PublishedData/:id/datasets"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `PublishedData`. - */ - public getModelName() { - return "PublishedData"; - } -} diff --git a/src/app/shared/sdk/services/custom/RawDataset.ts b/src/app/shared/sdk/services/custom/RawDataset.ts deleted file mode 100644 index 1999d852b..000000000 --- a/src/app/shared/sdk/services/custom/RawDataset.ts +++ /dev/null @@ -1,3082 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { RawDataset } from "../../models/RawDataset"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { PublishedData } from "../../models/PublishedData"; -import { Sample } from "../../models/Sample"; -import { Proposal } from "../../models/Proposal"; -import { Datablock } from "../../models/Datablock"; -import { OrigDatablock } from "../../models/OrigDatablock"; -import { Attachment } from "../../models/Attachment"; -import { Instrument } from "../../models/Instrument"; - -/** - * Api services for the `RawDataset` model. - * - * **Details** - * - * Contains the information for datasets which are the result of measurements or of simulations. Often raw datasets are automatically added as part of an automated ingest step as part of the data acquisition chain at an instrument. This schema inherits the fields from the generic Dataset collection and adds specific fields as defined below. - */ -@Injectable() -export class RawDatasetApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Find a related item by id for historyList. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for historyList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public findByIdHistoryList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/historyList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for historyList. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for historyList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdHistoryList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/historyList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for historyList. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for historyList - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public updateByIdHistoryList( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/historyList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches hasOne relation datasetLifecycle. - * - * @param {any} id RawDataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getDatasetLifecycle( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datasetLifecycle of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createDatasetLifecycle( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update datasetLifecycle of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public updateDatasetLifecycle( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes datasetLifecycle of this model. - * - * @param {any} id RawDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyDatasetLifecycle( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches belongsTo relation publisheddata. - * - * @param {any} id RawDataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getPublisheddata( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/publisheddata"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for techniquesList. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for techniquesList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public findByIdTechniquesList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/techniquesList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for techniquesList. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for techniquesList - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdTechniquesList( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/techniquesList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for techniquesList. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for techniquesList - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public updateByIdTechniquesList( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/techniquesList/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for samples. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for samples - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public findByIdSamples( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/samples/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for samples. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for samples - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdSamples( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/samples/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for samples. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for samples - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public updateByIdSamples( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/samples/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches belongsTo relation sample. - * - * @param {any} id RawDataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getSample( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/sample"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches belongsTo relation proposal. - * - * @param {any} id RawDataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getProposal( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/proposal"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for datablocks. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for datablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public findByIdDatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for datablocks. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for datablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdDatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for datablocks. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for datablocks - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public updateByIdDatablocks( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for origdatablocks. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for origdatablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public findByIdOrigdatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/origdatablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for origdatablocks. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for origdatablocks - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdOrigdatablocks( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/origdatablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for origdatablocks. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for origdatablocks - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public updateByIdOrigdatablocks( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/origdatablocks/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for attachments. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for attachments - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public findByIdAttachments( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for attachments. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for attachments - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdAttachments( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for attachments. - * - * @param {any} id RawDataset id - * - * @param {any} fk Foreign key for attachments - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public updateByIdAttachments( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches belongsTo relation instrument. - * - * @param {any} id RawDataset id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getInstrument( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/instrument"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries historyList of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getHistoryList( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in historyList of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createHistoryList( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all historyList of this model. - * - * @param {any} id RawDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteHistoryList(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts historyList of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countHistoryList( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/historyList/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries techniquesList of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getTechniquesList( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in techniquesList of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createTechniquesList( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all techniquesList of this model. - * - * @param {any} id RawDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteTechniquesList( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts techniquesList of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countTechniquesList( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/techniquesList/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries samples of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getSamples( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in samples of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createSamples( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all samples of this model. - * - * @param {any} id RawDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteSamples(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts samples of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countSamples( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/samples/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries datablocks of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getDatablocks( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datablocks of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createDatablocks( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all datablocks of this model. - * - * @param {any} id RawDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteDatablocks(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts datablocks of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countDatablocks( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datablocks/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries origdatablocks of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getOrigdatablocks( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in origdatablocks of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createOrigdatablocks( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all origdatablocks of this model. - * - * @param {any} id RawDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteOrigdatablocks( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts origdatablocks of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countOrigdatablocks( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/origdatablocks/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries attachments of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public getAttachments( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in attachments of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createAttachments( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all attachments of this model. - * - * @param {any} id RawDataset id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteAttachments(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts attachments of RawDataset. - * - * @param {any} id RawDataset id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countAttachments( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/attachments/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Check if data is valid according to a schema - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public isValid( - ownableItem: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/isValid"; - let _routeParams: any = {}; - let _postBody: any = { - ownableItem: ownableItem, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Reset archive status by deleting created datablocks of dataset and resetting archiveStatusMessage and archivable flag. - * - * @param {object} data Request data. - * - * - `datasetId` – `{string}` - - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public reset(datasetId: any = {}, customHeaders?: Function): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/resetArchiveStatus"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof datasetId !== "undefined" && datasetId !== null) - _urlParams.datasetId = datasetId; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Sends a post request for Dataset reduction to OpenWhisk - * - * @param {object} data Request data. - * - * - `dataset` – `{Dataset}` - The Dataset to send for reduction - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * The response from the OpenWhisk reduce action - */ - public reduceDataset( - dataset: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/reduce"; - let _routeParams: any = {}; - let _postBody: any = { - dataset: dataset, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * updates a single record by appending data to the specified field - * - * @param {object} data Request data. - * - * - `id` – `{string}` - - * - * - `fieldName` – `{string}` - Name of field to append data to - * - * - `data` – `{any}` - An array of values to append - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public appendToArrayField( - id: any, - fieldName: any, - data: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/appendToArrayField"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fieldName !== "undefined" && fieldName !== null) - _urlParams.fieldName = fieldName; - if (typeof data !== "undefined" && data !== null) _urlParams.data = data; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return array of metadata keys from datasets corresponding to the current filters. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There is also support for a `text` search to look for strings anywhere in the dataset. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public metadataKeys( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/metadataKeys"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * - * (The remote method definition does not provide any description.) - * - * - * @param {string} id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public thumbnail(id: any, customHeaders?: Function): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/thumbnail"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datasetLifecycle of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createManyDatasetLifecycle( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datasetLifecycle"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in historyList of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createManyHistoryList( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/historyList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in techniquesList of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createManyTechniquesList( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/techniquesList"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in samples of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createManySamples( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/samples"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in datablocks of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createManyDatablocks( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/datablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in origdatablocks of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createManyOrigdatablocks( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/origdatablocks"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in attachments of this model. - * - * @param {any} id RawDataset id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `RawDataset` object.) - * - */ - public createManyAttachments( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/RawDatasets/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `RawDataset`. - */ - public getModelName() { - return "RawDataset"; - } -} diff --git a/src/app/shared/sdk/services/custom/SDKModels.ts b/src/app/shared/sdk/services/custom/SDKModels.ts deleted file mode 100644 index aec8f8250..000000000 --- a/src/app/shared/sdk/services/custom/SDKModels.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* eslint-disable */ -import { Injectable } from "@angular/core"; -import { User } from "../../models/User"; -import { UserCredential } from "../../models/UserCredential"; -import { UserIdentity } from "../../models/UserIdentity"; -import { ApplicationCredential } from "../../models/ApplicationCredential"; -import { Logbook } from "../../models/Logbook"; -import { PublishedData } from "../../models/PublishedData"; -import { Dataset } from "../../models/Dataset"; -import { RawDataset } from "../../models/RawDataset"; -import { DerivedDataset } from "../../models/DerivedDataset"; -import { Sample } from "../../models/Sample"; -import { Proposal } from "../../models/Proposal"; -import { Datablock } from "../../models/Datablock"; -import { Policy } from "../../models/Policy"; -import { OrigDatablock } from "../../models/OrigDatablock"; -import { Attachment } from "../../models/Attachment"; -import { Job } from "../../models/Job"; -import { ShareGroup } from "../../models/ShareGroup"; -import { UserSetting } from "../../models/UserSetting"; -import { Instrument } from "../../models/Instrument"; - -export interface Models { - [name: string]: any; -} - -@Injectable() -export class SDKModels { - private models: Models = { - User: User, - UserCredential: UserCredential, - UserIdentity: UserIdentity, - ApplicationCredential: ApplicationCredential, - Logbook: Logbook, - PublishedData: PublishedData, - Dataset: Dataset, - RawDataset: RawDataset, - DerivedDataset: DerivedDataset, - Sample: Sample, - Proposal: Proposal, - Datablock: Datablock, - Policy: Policy, - OrigDatablock: OrigDatablock, - Attachment: Attachment, - Job: Job, - ShareGroup: ShareGroup, - UserSetting: UserSetting, - Instrument: Instrument, - }; - - public get(modelName: string): any { - return this.models[modelName]; - } - - public getAll(): Models { - return this.models; - } - - public getModelNames(): string[] { - return Object.keys(this.models); - } -} diff --git a/src/app/shared/sdk/services/custom/Sample.ts b/src/app/shared/sdk/services/custom/Sample.ts deleted file mode 100644 index ba77b7d5a..000000000 --- a/src/app/shared/sdk/services/custom/Sample.ts +++ /dev/null @@ -1,756 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { Sample } from "../../models/Sample"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { Dataset } from "../../models/Dataset"; -import { Attachment } from "../../models/Attachment"; - -/** - * Api services for the `Sample` model. - * - * **Details** - * - * Models describing the characteristics of the samples to be investigated. Raw datasets should be linked to such sample definitions. - */ -@Injectable() -export class SampleApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Fetches belongsTo relation datasets. - * - * @param {any} id Sample id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public getDatasets( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id/datasets"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for attachments. - * - * @param {any} id Sample id - * - * @param {any} fk Foreign key for attachments - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public findByIdAttachments( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for attachments. - * - * @param {any} id Sample id - * - * @param {any} fk Foreign key for attachments - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdAttachments( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for attachments. - * - * @param {any} id Sample id - * - * @param {any} fk Foreign key for attachments - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public updateByIdAttachments( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id/attachments/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries attachments of Sample. - * - * @param {any} id Sample id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public getAttachments( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in attachments of this model. - * - * @param {any} id Sample id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public createAttachments( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all attachments of this model. - * - * @param {any} id Sample id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteAttachments(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts attachments of Sample. - * - * @param {any} id Sample id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countAttachments( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id/attachments/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id Sample id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Check if data is valid according to a schema - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public isValid( - ownableItem: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/isValid"; - let _routeParams: any = {}; - let _postBody: any = { - ownableItem: ownableItem, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * @method findByIdAccess - * @param {string} id ID of the resource - * @param {Function} [customHeaders] Optional custom headers function - * @return {Observable<{ canAccess: boolean }>} - */ - public findByIdAccess( - id: string, - customHeaders?: Function, - ): Observable<{ canAccess: boolean }> { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id/authorization"; - let _routeParams: any = { id }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Get a list of sample characteristic keys - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There is also support for a `text` search to look for strings anywhere in the sample. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Array of sample characteristic keys - */ - public metadataKeys( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/metadataKeys"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in attachments of this model. - * - * @param {any} id Sample id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `Sample` object.) - * - */ - public createManyAttachments( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Samples/:id/attachments"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `Sample`. - */ - public getModelName() { - return "Sample"; - } -} diff --git a/src/app/shared/sdk/services/custom/ShareGroup.ts b/src/app/shared/sdk/services/custom/ShareGroup.ts deleted file mode 100644 index ac5510f76..000000000 --- a/src/app/shared/sdk/services/custom/ShareGroup.ts +++ /dev/null @@ -1,269 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { ShareGroup } from "../../models/ShareGroup"; -import { SocketConnection } from "../../sockets/socket.connections"; - -/** - * Api services for the `ShareGroup` model. - * - * **Details** - * - * Definition of groups to share datasets between scicat users - */ -@Injectable() -export class ShareGroupApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `ShareGroup` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/ShareGroups"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id ShareGroup id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `ShareGroup` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/ShareGroups/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `ShareGroup` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/ShareGroups/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `ShareGroup` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/ShareGroups/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * - * (The remote method definition does not provide any description.) - * - * - * @param {object} data Request data. - * - * - `id` – `{string}` - - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `groups` – `{Object}` - - */ - public getGroups(id: any, customHeaders?: Function): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/ShareGroups/:id/register"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `ShareGroup`. - */ - public getModelName() { - return "ShareGroup"; - } -} diff --git a/src/app/shared/sdk/services/custom/User.ts b/src/app/shared/sdk/services/custom/User.ts deleted file mode 100644 index 6778d4983..000000000 --- a/src/app/shared/sdk/services/custom/User.ts +++ /dev/null @@ -1,2018 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter, SDKToken, AccessToken } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { User } from "../../models/User"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { UserSetting, UserSettingInterface } from "../../models/UserSetting"; -import { UserIdentity } from "../../models/UserIdentity"; -import { UserCredential } from "../../models/UserCredential"; -import { AppConfigService } from "app-config.service"; - -/** - * Api services for the `User` model. - */ -@Injectable() -export class UserApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - private configService: AppConfigService, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Find a related item by id for accessTokens. - * - * @param {any} id User id - * - * @param {any} fk Foreign key for accessTokens - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public findByIdAccessTokens( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/accessTokens/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for accessTokens. - * - * @param {any} id User id - * - * @param {any} fk Foreign key for accessTokens - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdAccessTokens( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/accessTokens/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for accessTokens. - * - * @param {any} id User id - * - * @param {any} fk Foreign key for accessTokens - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public updateByIdAccessTokens( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/accessTokens/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Fetches hasOne relation settings. - * - * @param {any} id User id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public getSettings( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/settings"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in settings of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public createSettings( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/settings"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update settings of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public updateSettings( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/settings"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update settings of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public partialUpdateSettings( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/settings"; - let _routeParams: any = { - id: id, - }; - - let _postBody: any = { - data: data, - }; - - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update settings of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public partialUpdateExternalSettings( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/settings/external"; - let _routeParams: any = { - id: id, - }; - - let _postBody: any = { - data: data, - }; - - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes settings of this model. - * - * @param {any} id User id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroySettings(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/settings"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for identities. - * - * @param {any} id User id - * - * @param {any} fk Foreign key for identities - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public findByIdIdentities( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/identities/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for identities. - * - * @param {any} id User id - * - * @param {any} fk Foreign key for identities - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdIdentities( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/identities/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for identities. - * - * @param {any} id User id - * - * @param {any} fk Foreign key for identities - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public updateByIdIdentities( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/identities/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Find a related item by id for credentials. - * - * @param {any} id User id - * - * @param {any} fk Foreign key for credentials - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public findByIdCredentials( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/credentials/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Delete a related item by id for credentials. - * - * @param {any} id User id - * - * @param {any} fk Foreign key for credentials - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public destroyByIdCredentials( - id: any, - fk: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/credentials/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Update a related item by id for credentials. - * - * @param {any} id User id - * - * @param {any} fk Foreign key for credentials - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public updateByIdCredentials( - id: any, - fk: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PUT"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/credentials/:fk"; - let _routeParams: any = { - id: id, - fk: fk, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries accessTokens of User. - * - * @param {any} id User id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public getAccessTokens( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/accessTokens"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in accessTokens of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public createAccessTokens( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/accessTokens"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all accessTokens of this model. - * - * @param {any} id User id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteAccessTokens( - id: any, - customHeaders?: Function, - ): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/accessTokens"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts accessTokens of User. - * - * @param {any} id User id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countAccessTokens( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/accessTokens/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries identities of User. - * - * @param {any} id User id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public getIdentities( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/identities"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in identities of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public createIdentities( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/identities"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all identities of this model. - * - * @param {any} id User id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteIdentities(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/identities"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts identities of User. - * - * @param {any} id User id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countIdentities( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/identities/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Queries credentials of User. - * - * @param {any} id User id - * - * @param {object} filter - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public getCredentials( - id: any, - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/credentials"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof filter !== "undefined" && filter !== null) - _urlParams.filter = filter; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in credentials of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public createCredentials( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/credentials"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Deletes all credentials of this model. - * - * @param {any} id User id - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public deleteCredentials(id: any, customHeaders?: Function): Observable { - let _method: string = "DELETE"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/credentials"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Counts credentials of User. - * - * @param {any} id User id - * - * @param {object} where Criteria to match model instances - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `count` – `{number}` - - */ - public countCredentials( - id: any, - where: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/credentials/count"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof where !== "undefined" && where !== null) - _urlParams.where = where; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Login a user with username/email and password. - * - * @param {string} include Related objects to include in the response. See the description of return value for more details. - * Default value: `user`. - * - * - `rememberMe` - `boolean` - Whether the authentication credentials - * should be remembered in localStorage across app/browser restarts. - * Default: `true`. - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * The response body contains properties of the AccessToken created on login. - * Depending on the value of `include` parameter, the body may contain additional properties: - * - * - `user` - `U+007BUserU+007D` - Data of the currently logged in user. (`include=user`) - * - * - */ - public login( - credentials: any, - include: any = "user", - rememberMe: boolean = true, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/auth/login"; - let _routeParams: any = {}; - let _postBody: any = { - credentials: credentials, - }; - let _urlParams: any = {}; - if (typeof include !== "undefined" && include !== null) - _urlParams.include = include; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ).pipe( - map((response: any) => { - const accessTokenPrefix = - this.configService.getConfig().accessTokenPrefix; - response.id = accessTokenPrefix + response.id; - response.ttl = parseInt(response.ttl); - response.rememberMe = rememberMe; - this.auth.setToken(response); - return response; - }), - ); - return result; - } - - /** - * Logout a user with access token. - * - * @param {object} data Request data. - * - * This method does not accept any data. Supply an empty object. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public logout(customHeaders?: Function): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/logout"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - _urlParams.access_token = this.auth.getAccessTokenId(); - this.auth.clear(); - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Trigger user's identity verification with configured verifyOptions - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method does not accept any data. Supply an empty object. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public verify(id: any, customHeaders?: Function): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/verify"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Confirm a user registration with identity verification token. - * - * @param {string} uid - * - * @param {string} token - * - * @param {string} redirect - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public confirm( - uid: any, - token: any, - redirect: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/confirm"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof uid !== "undefined" && uid !== null) _urlParams.uid = uid; - if (typeof token !== "undefined" && token !== null) - _urlParams.token = token; - if (typeof redirect !== "undefined" && redirect !== null) - _urlParams.redirect = redirect; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Reset password for a user with email. - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public resetPassword( - options: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/reset"; - let _routeParams: any = {}; - let _postBody: any = { - options: options, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Change a user's password. - * - * @param {object} data Request data. - * - * - `oldPassword` – `{string}` - - * - * - `newPassword` – `{string}` - - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public changePassword( - oldPassword: any, - newPassword: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/change-password"; - let _routeParams: any = {}; - let _postBody: any = { - data: { - oldPassword: oldPassword, - newPassword: newPassword, - }, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Reset user's password via a password-reset token. - * - * @param {object} data Request data. - * - * - `newPassword` – `{string}` - - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * This method returns no data. - */ - public setPassword( - newPassword: any, - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/reset-password"; - let _routeParams: any = {}; - let _postBody: any = { - data: { - newPassword: newPassword, - }, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Returns username, email , group membership etc for the user linked with the provided accessToken. - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public userInfos(customHeaders?: Function): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/userInfos"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * - * (The remote method definition does not provide any description.) - * - * - * @param {object} data Request data. - * - * This method does not accept any data. Supply an empty object. - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * Data properties: - * - * - `jwt` – `{string}` - - */ - public jwt(customHeaders?: Function): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/jwt"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in settings of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public createManySettings( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/settings"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in accessTokens of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public createManyAccessTokens( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/accessTokens"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in identities of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public createManyIdentities( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/identities"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Creates a new instance in credentials of this model. - * - * @param {any} id User id - * - * @param {object} data Request data. - * - * This method expects a subset of model properties as request parameters. - * - * @returns {object[]} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `User` object.) - * - */ - public createManyCredentials( - id: any, - data: any[] = [], - customHeaders?: Function, - ): Observable { - let _method: string = "POST"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/:id/credentials"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - /** - * @ngdoc method - * @name sdk.User#getCurrent - * @methodOf sdk.User - * - * @description - * - * Get data of the currently logged user. Fail with HTTP result 401 - * when there is no user logged in. - * - * @returns object An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - */ - public getCurrent(filter: LoopBackFilter = {}): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users" + - "/:id"; - let id: any = this.auth.getCurrentUserId(); - if (id == null) id = "__anonymous__"; - let _routeParams: any = { id: id }; - let _urlParams: any = {}; - let _postBody: any = {}; - if (filter) _urlParams.filter = filter; - return this.request(_method, _url, _routeParams, _urlParams, _postBody); - } - /** - * Get data of the currently logged user that was returned by the last - * call to {@link sdk.User#login} or - * {@link sdk.User#getCurrent}. Return null when there - * is no user logged in or the data of the current user were not fetched - * yet. - * - * @returns object An Account instance. - */ - public getCachedCurrent() { - return this.auth.getCurrentUserData(); - } - /** - * Get data of the currently logged access tokern that was returned by the last - * call to {@link sdk.User#login} - * - * @returns object An AccessToken instance. - */ - public getCurrentToken(): AccessToken { - return this.auth.getToken(); - } - /** - * @name sdk.User#isAuthenticated - * - * @returns {boolean} True if the current user is authenticated (logged in). - */ - public isAuthenticated() { - return !( - this.getCurrentId() === "" || - this.getCurrentId() == null || - this.getCurrentId() == "null" - ); - } - - /** - * @name sdk.User#getCurrentId - * - * @returns object Id of the currently logged-in user or null. - */ - public getCurrentId() { - return this.auth.getCurrentUserId(); - } - - /** - * The name of the model represented by this $resource, - * i.e. `User`. - */ - public getModelName() { - return "User"; - } - - private defaultSettingsUrl = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/Users/settings/default"; - - getDefaultSettings(): Observable { - return this.http.get(this.defaultSettingsUrl); - } -} diff --git a/src/app/shared/sdk/services/custom/UserCredential.ts b/src/app/shared/sdk/services/custom/UserCredential.ts deleted file mode 100644 index 02a1710cf..000000000 --- a/src/app/shared/sdk/services/custom/UserCredential.ts +++ /dev/null @@ -1,175 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { UserCredential } from "../../models/UserCredential"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { User } from "../../models/User"; - -/** - * Api services for the `UserCredential` model. - */ -@Injectable() -export class UserCredentialApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Fetches belongsTo relation user. - * - * @param {any} id UserCredential id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserCredential` object.) - * - */ - public getUser( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserCredentials/:id/user"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserCredential` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserCredentials"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id UserCredential id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserCredential` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserCredentials/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `UserCredential`. - */ - public getModelName() { - return "UserCredential"; - } -} diff --git a/src/app/shared/sdk/services/custom/UserIdentity.ts b/src/app/shared/sdk/services/custom/UserIdentity.ts deleted file mode 100644 index 4e9533454..000000000 --- a/src/app/shared/sdk/services/custom/UserIdentity.ts +++ /dev/null @@ -1,203 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { UserIdentity } from "../../models/UserIdentity"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { User } from "../../models/User"; - -/** - * Api services for the `UserIdentity` model. - */ -@Injectable() -export class UserIdentityApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Fetches belongsTo relation user. - * - * @param {any} id UserIdentity id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserIdentity` object.) - * - */ - public getUser( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserIdentities/:id/user"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserIdentity` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserIdentities"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id UserIdentity id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserIdentity` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserIdentities/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `UserIdentity`. - */ - public getModelName() { - return "UserIdentity"; - } - - // NOTE: Checks if an email is connected with valid scicat user. - /** - * @method isValidEmail - * @license MIT - * @return {boolean} - * @description - * Created isValidEmail method - */ - public isValidEmail( - filter: LoopBackFilter = {}, - customHeaders?: Function, - ): Observable { - return this.request( - "GET", - [ - LoopBackConfig.getPath(), - LoopBackConfig.getApiVersion(), - this.model.getModelDefinition().path, - "isValidEmail", - ].join("/"), - undefined, - { filter }, - undefined, - null, - customHeaders, - ).pipe(map((data: boolean) => data)); - } -} diff --git a/src/app/shared/sdk/services/custom/UserSetting.ts b/src/app/shared/sdk/services/custom/UserSetting.ts deleted file mode 100644 index 0a3deeb4d..000000000 --- a/src/app/shared/sdk/services/custom/UserSetting.ts +++ /dev/null @@ -1,275 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, Optional } from "@angular/core"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { SDKModels } from "./SDKModels"; -import { BaseLoopBackApi } from "../core/base.service"; -import { LoopBackConfig } from "../../lb.config"; -import { LoopBackAuth } from "../core/auth.service"; -import { LoopBackFilter } from "../../models/BaseModels"; -import { ErrorHandler } from "../core/error.service"; -import { Observable, Subject } from "rxjs"; -import { map } from "rxjs/operators"; -import { UserSetting } from "../../models/UserSetting"; -import { SocketConnection } from "../../sockets/socket.connections"; -import { User } from "../../models/User"; - -/** - * Api services for the `UserSetting` model. - * - * **Details** - * - * User settings such as job count and dataset count - */ -@Injectable() -export class UserSettingApi extends BaseLoopBackApi { - constructor( - @Inject(HttpClient) protected http: HttpClient, - @Inject(SocketConnection) protected connection: SocketConnection, - @Inject(SDKModels) protected models: SDKModels, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler, - ) { - super(http, connection, models, auth, errorHandler); - } - - /** - * Fetches belongsTo relation user. - * - * @param {any} id UserSetting id - * - * @param {boolean} refresh - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserSetting` object.) - * - */ - public getUser( - id: any, - refresh: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserSettings/:id/user"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof refresh !== "undefined" && refresh !== null) - _urlParams.refresh = refresh; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch an existing model instance or insert a new one into the data source. - * - * @param {object} data Request data. - * - * - `data` – `{object}` - Model instance data - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserSetting` object.) - * - */ - public patchOrCreate( - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserSettings"; - let _routeParams: any = {}; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Patch attributes for a model instance and persist it into the data source. - * - * @param {any} id UserSetting id - * - * @param {object} data Request data. - * - * - `data` – `{object}` - An object of model property name/value pairs - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserSetting` object.) - * - */ - public patchAttributes( - id: any, - data: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "PATCH"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserSettings/:id"; - let _routeParams: any = { - id: id, - }; - let _postBody: any = { - data: data, - }; - let _urlParams: any = {}; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return facet counts relevant for the given selected subset of datasets. - * - * @param {object} fields Define the filter conditions by specifying the name and values of fields. There ia also support for a `text` search to look for strngs anywhere in the dataset. - * - * @param {any} facets Defines list of field names, for which facet counts should be calculated - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserSetting` object.) - * - */ - public fullfacet( - fields: any = {}, - facets: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserSettings/fullfacet"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof facets !== "undefined" && facets !== null) - _urlParams.facets = facets; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * Return datasets fulfilling complex filter conditions, including from fields of joined models. - * - * @param {object} fields Define the filter conditions by specifying the name of values of fields requested. There ia also support for a `text` search to look for strings anywhere in the dataset. Skip and limit parameters allow for paging. - * - * @param {object} limits Define further query parameters like skip, limit, order - * - * @param {object} options - * - * @returns {object} An empty reference that will be - * populated with the actual data once the response is returned - * from the server. - * - * - * (The remote method definition does not provide any description. - * This usually means the response is a `UserSetting` object.) - * - */ - public fullquery( - fields: any = {}, - limits: any = {}, - customHeaders?: Function, - ): Observable { - let _method: string = "GET"; - let _url: string = - LoopBackConfig.getPath() + - "/" + - LoopBackConfig.getApiVersion() + - "/UserSettings/fullquery"; - let _routeParams: any = {}; - let _postBody: any = {}; - let _urlParams: any = {}; - if (typeof fields !== "undefined" && fields !== null) - _urlParams.fields = fields; - if (typeof limits !== "undefined" && limits !== null) - _urlParams.limits = limits; - let result = this.request( - _method, - _url, - _routeParams, - _urlParams, - _postBody, - null, - customHeaders, - ); - return result; - } - - /** - * The name of the model represented by this $resource, - * i.e. `UserSetting`. - */ - public getModelName() { - return "UserSetting"; - } -} diff --git a/src/app/shared/sdk/services/custom/index.ts b/src/app/shared/sdk/services/custom/index.ts deleted file mode 100644 index cb2c10eac..000000000 --- a/src/app/shared/sdk/services/custom/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable */ -export * from "./User"; -export * from "./UserCredential"; -export * from "./UserIdentity"; -export * from "./ApplicationCredential"; -export * from "./Logbook"; -export * from "./PublishedData"; -export * from "./Dataset"; -export * from "./RawDataset"; -export * from "./DerivedDataset"; -export * from "./Sample"; -export * from "./Proposal"; -export * from "./Datablock"; -export * from "./Policy"; -export * from "./OrigDatablock"; -export * from "./Attachment"; -export * from "./Job"; -export * from "./ShareGroup"; -export * from "./UserSetting"; -export * from "./Instrument"; -export * from "./SDKModels"; -export * from "./logger.service"; diff --git a/src/app/shared/sdk/services/custom/logger.service.ts b/src/app/shared/sdk/services/custom/logger.service.ts deleted file mode 100644 index ecb180067..000000000 --- a/src/app/shared/sdk/services/custom/logger.service.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* eslint-disable */ -import { Injectable } from "@angular/core"; -import { LoopBackConfig } from "../../lb.config"; -/** - * @author Jonathan Casarrubias - * @module LoggerService - * @license MIT - * @description - * Console Log wrapper that can be disabled in production mode - **/ -@Injectable() -export class LoggerService { - log(...args: any[]) { - if (LoopBackConfig.debuggable()) console.log.apply(console, args); - } - - info(...args: any[]) { - if (LoopBackConfig.debuggable()) console.info.apply(console, args); - } - - error(...args: any[]) { - if (LoopBackConfig.debuggable()) console.error.apply(console, args); - } - - count(arg: string) { - if (LoopBackConfig.debuggable()) console.count(arg); - } - - group(arg: string) { - if (LoopBackConfig.debuggable()) console.count(arg); - } - - groupEnd() { - if (LoopBackConfig.debuggable()) console.groupEnd(); - } - - profile(arg: string) { - if (LoopBackConfig.debuggable()) console.count(arg); - } - - // profileEnd() { - // if (LoopBackConfig.debuggable()) - // console.profileEnd(); - // } - - time(arg: string) { - if (LoopBackConfig.debuggable()) console.time(arg); - } - - timeEnd(arg: string) { - if (LoopBackConfig.debuggable()) console.timeEnd(arg); - } -} diff --git a/src/app/shared/sdk/services/index.ts b/src/app/shared/sdk/services/index.ts deleted file mode 100644 index 41d25f3f7..000000000 --- a/src/app/shared/sdk/services/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* eslint-disable */ -export * from "./core/index"; -export * from "./custom/index"; diff --git a/src/app/shared/sdk/sockets/socket.browser.ts b/src/app/shared/sdk/sockets/socket.browser.ts deleted file mode 100644 index c307c8464..000000000 --- a/src/app/shared/sdk/sockets/socket.browser.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable */ -import { io } from "socket.io-client"; -/** - * @author Jonathan Casarrubias - * @module SocketBrowser - * @license MIT - * @description - * This module handle socket connections for web browsers, it will be DI Swapped - * depending on the platform environment. - * This module will be generated when the -d ng2web flag is set - **/ -export class SocketBrowser { - /** - * @method connect - * @param {string} url URL path to connect with the server. - * @param {any} options Any socket.io v1 =< valid options - * @return {any} Not currently a socket.io-client for web Typings implemented. - * @description - * This method will return a valid socket connection. - **/ - connect(url: string, options: any): any { - return io(url, options); - } -} diff --git a/src/app/shared/sdk/sockets/socket.connections.ts b/src/app/shared/sdk/sockets/socket.connections.ts deleted file mode 100644 index e0644a3cc..000000000 --- a/src/app/shared/sdk/sockets/socket.connections.ts +++ /dev/null @@ -1,218 +0,0 @@ -/* eslint-disable */ -import { Injectable, Inject, NgZone } from "@angular/core"; -import { SocketDriver } from "./socket.driver"; -import { AccessToken } from "../models"; -import { Observable, Subject } from "rxjs"; -import { share } from "rxjs/operators"; -import { LoopBackConfig } from "../lb.config"; -/** - * @author Jonathan Casarrubias - * @module SocketConnection - * @license MIT - * @description - * This module handle socket connections and return singleton instances for each - * connection, it will use the SDK Socket Driver Available currently supporting - * Angular 2 for web, NativeScript 2 and Angular Universal. - **/ -@Injectable() -export class SocketConnection { - private socket: any; - private subjects: { - onConnect: Subject; - onDisconnect: Subject; - onAuthenticated: Subject; - onUnAuthorized: Subject; - } = { - onConnect: new Subject(), - onDisconnect: new Subject(), - onAuthenticated: new Subject(), - onUnAuthorized: new Subject(), - }; - public sharedObservables: { - sharedOnConnect?: Observable; - sharedOnDisconnect?: Observable; - sharedOnAuthenticated?: Observable; - sharedOnUnAuthorized?: Observable; - } = {}; - public authenticated: boolean = false; - /** - * @method constructor - * @param {SocketDriver} driver Socket IO Driver - * @param {NgZone} zone Angular 2 Zone - * @description - * The constructor will set references for the shared hot observables from - * the class subjects. Then it will subscribe each of these observables - * that will create a channel that later will be shared between subscribers. - **/ - constructor( - @Inject(SocketDriver) private driver: SocketDriver, - @Inject(NgZone) private zone: NgZone, - ) { - this.sharedObservables = { - sharedOnConnect: this.subjects.onConnect.asObservable().pipe(share()), - sharedOnDisconnect: this.subjects.onDisconnect - .asObservable() - .pipe(share()), - sharedOnAuthenticated: this.subjects.onAuthenticated - .asObservable() - .pipe(share()), - sharedOnUnAuthorized: this.subjects.onUnAuthorized - .asObservable() - .pipe(share()), - }; - // This is needed to create the first channel, subsequents will share the connection - // We are using Hot Observables to avoid duplicating connection status events. - this.sharedObservables.sharedOnConnect.subscribe(); - this.sharedObservables.sharedOnDisconnect.subscribe(); - this.sharedObservables.sharedOnAuthenticated.subscribe(); - this.sharedObservables.sharedOnUnAuthorized.subscribe(); - } - /** - * @method connect - * @param {AccessToken} token AccesToken instance - * @return {void} - * @description - * This method will create a new socket connection when not previously established. - * If there is a broken connection it will re-connect. - **/ - public connect(token: AccessToken = null): void { - if (!this.socket) { - console.info( - "Creating a new connection with: ", - LoopBackConfig.getPath(), - ); - // Create new socket connection - this.socket = this.driver.connect(LoopBackConfig.getPath(), { - log: false, - secure: LoopBackConfig.isSecureWebSocketsSet(), - forceNew: true, - forceWebsockets: true, - transports: ["websocket"], - }); - // Listen for connection - this.on("connect", () => { - this.subjects.onConnect.next("connected"); - // Authenticate or start heartbeat now - this.emit("authentication", token); - }); - // Listen for authentication - this.on("authenticated", () => { - this.authenticated = true; - this.subjects.onAuthenticated.next("authenticated"); - this.heartbeater(); - }); - // Listen for authentication - this.on("unauthorized", (err: any) => { - this.authenticated = false; - this.subjects.onUnAuthorized.next(err); - }); - // Listen for disconnections - this.on("disconnect", (status: any) => - this.subjects.onDisconnect.next(status), - ); - } else if (this.socket && !this.socket.connected) { - if (typeof this.socket.off === "function") { - this.socket.off(); - } - if (typeof this.socket.destroy === "function") { - this.socket.destroy(); - } - delete this.socket; - this.connect(token); - } - } - /** - * @method isConnected - * @return {boolean} - * @description - * This method will return true or false depending on established connections - **/ - public isConnected(): boolean { - return this.socket && this.socket.connected; - } - /** - * @method on - * @param {string} event Event name - * @param {Function} handler Event listener handler - * @return {void} - * @description - * This method listen for server events from the current WebSocket connection. - * This method is a facade that will wrap the original "on" method and run it - * within the Angular Zone to avoid update issues. - **/ - public on(event: string, handler: Function): void { - this.socket.on(event, (data: any) => this.zone.run(() => handler(data))); - } - /** - * @method emit - * @param {string} event Event name - * @param {any=} data Any type of data - * @return {void} - * @description - * This method will send any type of data to the server according the event set. - **/ - public emit(event: string, data?: any): void { - if (data) { - this.socket.emit(event, data); - } else { - this.socket.emit(event); - } - } - /** - * @method removeListener - * @param {string} event Event name - * @param {Function} handler Event listener handler - * @return {void} - * @description - * This method will wrap the original "on" method and run it within the Angular Zone - * Note: off is being used since the nativescript socket io client does not provide - * removeListener method, but only provides with off which is provided in any platform. - **/ - public removeListener(event: string, handler: Function): void { - if (typeof this.socket.off === "function") { - this.socket.off(event, handler); - } - } - /** - * @method removeAllListeners - * @param {string} event Event name - * @param {Function} handler Event listener handler - * @return {void} - * @description - * This method will wrap the original "on" method and run it within the Angular Zone - * Note: off is being used since the nativescript socket io client does not provide - * removeListener method, but only provides with off which is provided in any platform. - **/ - public removeAllListeners(event: string): void { - if (typeof this.socket.removeAllListeners === "function") { - this.socket.removeAllListeners(event); - } - } - /** - * @method disconnect - * @return {void} - * @description - * This will disconnect the client from the server - **/ - public disconnect(): void { - this.socket.disconnect(); - } - /** - * @method heartbeater - * @return {void} - * @description - * This will keep the connection as active, even when users are not sending - * data, this avoids disconnection because of a connection not being used. - **/ - private heartbeater(): void { - let heartbeater: any = setInterval(() => { - if (this.isConnected()) { - this.socket.emit("lb-ping"); - } else { - this.socket.removeAllListeners("lb-pong"); - clearInterval(heartbeater); - } - }, 15000); - this.socket.on("lb-pong", (data: any) => console.info("Heartbeat: ", data)); - } -} diff --git a/src/app/shared/sdk/sockets/socket.driver.ts b/src/app/shared/sdk/sockets/socket.driver.ts deleted file mode 100644 index fbf241203..000000000 --- a/src/app/shared/sdk/sockets/socket.driver.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable */ -/** - * @module SocketDriver - * @author Jonathan Casarrubias - * @license MIT - * @description - * The SocketDriver class is used for dependency injection swapping. - * It will be provided using factory method from different sources. - **/ -export class SocketDriver { - connect(url: any, options: any) {} -} diff --git a/src/app/shared/sdk/storage/cookie.browser.ts b/src/app/shared/sdk/storage/cookie.browser.ts deleted file mode 100644 index 9df79e7fc..000000000 --- a/src/app/shared/sdk/storage/cookie.browser.ts +++ /dev/null @@ -1,84 +0,0 @@ -/* eslint-disable */ -import { Injectable } from "@angular/core"; -export interface CookieInterface { - [key: string]: any; -} -/** - * @author Jonathan Casarrubias - * @module CookieBrowser - * @license MIT - * @description - * This module handle cookies, it will be provided using DI Swapping according the - * SDK Socket Driver Available currently supporting Angular 2 for web and NativeScript 2. - **/ -@Injectable() -export class CookieBrowser { - /** - * @type {CookieInterface} - **/ - private cookies: CookieInterface = {}; - /** - * @method get - * @param {string} key Cookie key name - * @return {any} - * @description - * The getter will return any type of data persisted in cookies. - **/ - get(key: string): any { - if (!this.cookies[key]) { - let cookie = window.document.cookie - .split("; ") - .filter((item: any) => item.split("=")[0] === key) - .pop(); - if (!cookie) { - return null; - } - - this.cookies[key] = this.parse(cookie.split("=").slice(1).join("=")); - } - - return this.cookies[key]; - } - /** - * @method set - * @param {string} key Cookie key name - * @param {any} value Any value - * @param {Date=} expires The date of expiration (Optional) - * @return {void} - * @description - * The setter will return any type of data persisted in cookies. - **/ - set(key: string, value: any, expires?: Date): void { - this.cookies[key] = value; - let cookie = `${key}=${encodeURI(value)}; path=/${ - expires ? `; expires=${expires.toUTCString()}` : "" - }`; - window.document.cookie = cookie; - } - /** - * @method remove - * @param {string} key Cookie key name - * @return {void} - * @description - * This method will remove a cookie from the client. - **/ - remove(key: string) { - document.cookie = key + "=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;"; - delete this.cookies[key]; - } - /** - * @method parse - * @param {any} value Input data expected to be JSON - * @return {void} - * @description - * This method will parse the string as JSON if possible, otherwise will - * return the value itself. - **/ - private parse(value: any) { - try { - return JSON.parse(decodeURI(value)); - } catch (e) { - return value; - } - } -} diff --git a/src/app/shared/sdk/storage/storage.browser.ts b/src/app/shared/sdk/storage/storage.browser.ts deleted file mode 100644 index e891d22d6..000000000 --- a/src/app/shared/sdk/storage/storage.browser.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* eslint-disable */ -import { Injectable } from "@angular/core"; -/** - * @author Jonathan Casarrubias - * @module StorageBrowser - * @license MIT - * @description - * This module handle localStorage, it will be provided using DI Swapping according the - * SDK Socket Driver Available currently supporting Angular 2 for web and NativeScript 2. - **/ -@Injectable() -export class StorageBrowser { - /** - * @method get - * @param {string} key Storage key name - * @return {any} - * @description - * The getter will return any type of data persisted in localStorage. - **/ - get(key: string): any { - let data: string = localStorage.getItem(key); - return this.parse(data); - } - /** - * @method set - * @param {string} key Storage key name - * @param {any} value Any value - * @return {void} - * @description - * The setter will return any type of data persisted in localStorage. - **/ - set(key: string, value: any, expires?: Date): void { - localStorage.setItem( - key, - typeof value === "object" ? JSON.stringify(value) : value, - ); - } - /** - * @method remove - * @param {string} key Storage key name - * @return {void} - * @description - * This method will remove a localStorage item from the client. - **/ - remove(key: string): void { - if (localStorage[key]) { - localStorage.removeItem(key); - } else { - console.log("Trying to remove unexisting key: ", key); - } - } - /** - * @method parse - * @param {any} value Input data expected to be JSON - * @return {void} - * @description - * This method will parse the string as JSON if possible, otherwise will - * return the value itself. - **/ - private parse(value: any) { - try { - return JSON.parse(value); - } catch (e) { - return value; - } - } -} diff --git a/src/app/shared/sdk/storage/storage.swaps.ts b/src/app/shared/sdk/storage/storage.swaps.ts deleted file mode 100644 index fdd9491ac..000000000 --- a/src/app/shared/sdk/storage/storage.swaps.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* eslint-disable */ -/** - * @module Storage - * @author Jonathan Casarrubias - * @license MIT - * @description - * The InternalStorage class is used for dependency injection swapping. - * It will be provided using factory method from different sources. - **/ -export class BaseStorage { - /** - * @method get - * @param {string} key Storage key name - * @return {any} - * @description - * The getter will return any type of data persisted in storage. - **/ - get(key: string): any {} - /** - * @method set - * @param {string} key Storage key name - * @param {any} value Any value - * @return {void} - * @description - * The setter will return any type of data persisted in localStorage. - **/ - set(key: string, value: any, expires?: Date): void {} - /** - * @method remove - * @param {string} key Storage key name - * @return {void} - * @description - * This method will remove a localStorage item from the client. - **/ - remove(key: string): void {} -} -/** - * @module InternalStorage - * @author Jonathan Casarrubias - * @license MIT - * @description - * The InternalStorage class is used for dependency injection swapping. - * It will be provided using factory method from different sources. - * This is mainly required because Angular Universal integration. - * It does inject a CookieStorage instead of LocalStorage. - **/ -export class InternalStorage extends BaseStorage {} -/** - * @module SDKStorage - * @author Jonathan Casarrubias - * @license MIT - * @description - * The SDKStorage class is used for dependency injection swapping. - * It will be provided using factory method according the right environment. - * This is created for public usage, to allow persisting custom data - * Into the local storage API. - **/ -export class SDKStorage extends BaseStorage {} diff --git a/src/app/shared/services/auth/auth.service.ts b/src/app/shared/services/auth/auth.service.ts new file mode 100644 index 000000000..ea8115782 --- /dev/null +++ b/src/app/shared/services/auth/auth.service.ts @@ -0,0 +1,128 @@ +import { Injectable, Inject } from "@angular/core"; +import { InternalStorage } from "./base.storage"; +import { ReturnedUserDto } from "@scicatproject/scicat-sdk-ts"; + +export interface AccessTokenInterface { + id?: string; + ttl?: number; + scopes?: [string]; + created?: Date; + userId?: string; + user?: ReturnedUserDto; +} + +export class SDKToken implements AccessTokenInterface { + id: string = null; + ttl: number = null; + scopes: [string] = null; + created: Date = null; + userId: string = null; + user: ReturnedUserDto = null; + rememberMe: boolean = null; + constructor(data?: AccessTokenInterface) { + Object.assign(this, data); + } +} + +@Injectable() +export class AuthService { + private token = new SDKToken(); + + protected prefix = ""; + + /** + * NOTE: This was the suggestion from the ai-bot review to simplify the storage and logic here + * (might be worth checking in the future if we want to make some changes in the cookies storage structure and keep them in one encoded object): + * https://github.com/SciCatProject/frontend/pull/1632#discussion_r1824033871 + */ + constructor(@Inject(InternalStorage) protected storage: InternalStorage) { + this.token.id = this.load("id"); + this.token.user = JSON.parse(this.load("user") || null); + this.token.userId = this.load("userId"); + this.token.created = new Date(this.load("created")); + this.token.ttl = parseInt(this.load("ttl")); + this.token.rememberMe = this.load("rememberMe") === "true"; + } + + protected load(prop: string) { + return decodeURIComponent(this.storage.get(`${this.prefix}${prop}`)); + } + + protected persist( + prop: string, + value: string | number | Date | boolean, + expires?: Date, + ): void { + try { + this.storage.set( + `${this.prefix}${prop}`, + typeof value === "object" ? JSON.stringify(value) : value, + this.token.rememberMe ? expires : null, + ); + } catch (err) { + throw new Error( + `Cannot access local/session storage: ${JSON.stringify(err)}`, + ); + } + } + + public clear(): void { + Object.keys(this.token).forEach((prop: string) => + this.storage.delete(`${this.prefix}${prop}`), + ); + this.token = new SDKToken(); + } + + public setRememberMe(value: boolean): void { + this.token.rememberMe = value; + } + + public setUser(user: ReturnedUserDto) { + this.token.user = user; + this.save(); + } + + public setToken(token: SDKToken): void { + this.token = Object.assign({}, this.token, token); + this.save(); + } + + public getToken(): SDKToken { + return this.token; + } + + public getAccessTokenId(): string { + return this.token.id; + } + + public getCurrentUserId() { + return this.token.userId; + } + + public getCurrentUserData() { + return typeof this.token.user === "string" + ? JSON.parse(this.token.user) + : this.token.user; + } + + public isAuthenticated() { + return !( + this.getCurrentUserId() === "" || + this.getCurrentUserId() == null || + this.getCurrentUserId() == "null" + ); + } + + public save(): boolean { + const today = new Date(); + const expires = new Date(today.getTime() + this.token.ttl * 1000); + this.persist("id", this.token.id, expires); + this.persist("user", JSON.stringify(this.token.user), expires); + this.persist("userId", this.token.userId, expires); + this.persist("created", this.token.created, expires); + this.persist("ttl", this.token.ttl, expires); + this.persist("rememberMe", this.token.rememberMe, expires); + + return true; + } +} diff --git a/src/app/shared/services/auth/base.storage.ts b/src/app/shared/services/auth/base.storage.ts new file mode 100644 index 000000000..14d57968f --- /dev/null +++ b/src/app/shared/services/auth/base.storage.ts @@ -0,0 +1,15 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ + +export class BaseStorage { + get(key: string): string | undefined { + return undefined; + } + + set(key: string, value: string | number | boolean, expires?: Date): void {} + + delete(key: string): void {} +} + +export class InternalStorage extends BaseStorage {} + +export class SDKStorage extends BaseStorage {} diff --git a/src/app/shared/services/auth/storage.browser.ts b/src/app/shared/services/auth/storage.browser.ts new file mode 100644 index 000000000..fe003592e --- /dev/null +++ b/src/app/shared/services/auth/storage.browser.ts @@ -0,0 +1,32 @@ +import { Injectable } from "@angular/core"; + +@Injectable() +export class LocalStorageBrowser { + private parse(value: string) { + try { + return JSON.parse(value); + } catch (e) { + return value; + } + } + + get(key: string) { + const data: string = localStorage.getItem(key); + return this.parse(data); + } + + set(key: string, value: string): void { + localStorage.setItem( + key, + typeof value === "object" ? JSON.stringify(value) : value, + ); + } + + delete(key: string): void { + if (localStorage[key]) { + localStorage.removeItem(key); + } else { + throw new Error(`Cannot remove non-existent key: ${key}`); + } + } +} diff --git a/src/app/shared/services/ownership.service.ts b/src/app/shared/services/ownership.service.ts index 421749da1..0f9e447ec 100644 --- a/src/app/shared/services/ownership.service.ts +++ b/src/app/shared/services/ownership.service.ts @@ -3,7 +3,7 @@ import { Router } from "@angular/router"; import { Store } from "@ngrx/store"; import { combineLatest, Observable } from "rxjs"; import { map } from "rxjs/operators"; -import { Dataset } from "shared/sdk"; +import { OutputDatasetObsoleteDto } from "@scicatproject/scicat-sdk-ts"; import { selectIsAdmin, selectProfile, @@ -14,7 +14,7 @@ import { }) export class OwnershipService { checkDatasetAccess( - dataset: Dataset | undefined, + dataset: OutputDatasetObsoleteDto | undefined, store: Store, router: Router, ) { diff --git a/src/app/shared/services/scicat-data-service.spec.ts b/src/app/shared/services/scicat-data-service.spec.ts index 806c95b30..70463a9d4 100644 --- a/src/app/shared/services/scicat-data-service.spec.ts +++ b/src/app/shared/services/scicat-data-service.spec.ts @@ -1,8 +1,8 @@ import { HttpClient, HttpClientModule } from "@angular/common/http"; import { TestBed } from "@angular/core/testing"; -import { LoopBackAuth } from "shared/sdk"; import { ScicatDataService } from "./scicat-data-service"; +import { AuthService } from "./auth/auth.service"; describe("ScicatDataServiceService", () => { let service: ScicatDataService; @@ -17,7 +17,7 @@ describe("ScicatDataServiceService", () => { ScicatDataService, { provide: HttpClient, useClass: HttpClientModule }, { - provide: LoopBackAuth, + provide: AuthService, useValue: loopBackAuth, }, ], diff --git a/src/app/shared/services/scicat-data-service.ts b/src/app/shared/services/scicat-data-service.ts index f7df10c93..40c52beee 100644 --- a/src/app/shared/services/scicat-data-service.ts +++ b/src/app/shared/services/scicat-data-service.ts @@ -1,9 +1,9 @@ import { Injectable } from "@angular/core"; import { HttpClient, HttpParams } from "@angular/common/http"; import { Observable } from "rxjs"; -import { LoopBackAuth } from "shared/sdk"; import { DateTime } from "luxon"; import { Column } from "shared/modules/shared-table/shared-table.module"; +import { AuthService } from "./auth/auth.service"; export interface FilterLimits { limit: number; @@ -17,7 +17,7 @@ export interface FilterLimits { export class ScicatDataService { constructor( private http: HttpClient, - private auth: LoopBackAuth, + private authService: AuthService, ) {} findDataById(url: string, dataId: number): Observable { @@ -153,13 +153,15 @@ export class ScicatDataService { const params = new HttpParams() .set("fields", JSON.stringify(filterFields)) .set("limits", JSON.stringify(limits)) - .append("access_token", this.auth.getToken().id); + .append("access_token", `Bearer ${this.authService.getToken().id}`); // NOTE: For published data endpoint we don't have fullquery and fullfacet and that's why it is a bit special case. if (url.includes("publishedData")) { return this.http.get(url, { params, - headers: { Authorization: this.auth.getAccessTokenId() }, + headers: { + Authorization: `Bearer ${this.authService.getAccessTokenId()}`, + }, }); } @@ -168,7 +170,9 @@ export class ScicatDataService { return this.http.get(`${url}/fullquery${origDatablocksFiles}`, { params, - headers: { Authorization: this.auth.getAccessTokenId() }, + headers: { + Authorization: `Bearer ${this.authService.getAccessTokenId()}`, + }, }); } @@ -188,13 +192,15 @@ export class ScicatDataService { const params = new HttpParams() .set("fields", JSON.stringify(filterFields)) .set("facets", JSON.stringify([])) - .append("access_token", this.auth.getToken().id); + .append("access_token", `Bearer ${this.authService.getToken().id}`); // NOTE: For published data endpoint we don't have fullquery and fullfacet and that's why it is a bit special case. if (url.includes("publishedData")) { return this.http.get(`${url}/count`, { params, - headers: { Authorization: this.auth.getAccessTokenId() }, + headers: { + Authorization: `Bearer ${this.authService.getAccessTokenId()}`, + }, }); } @@ -203,7 +209,9 @@ export class ScicatDataService { return this.http.get(`${url}/fullfacet${origDatablocksFiles}`, { params, - headers: { Authorization: this.auth.getAccessTokenId() }, + headers: { + Authorization: `Bearer ${this.authService.getAccessTokenId()}`, + }, }); } } diff --git a/src/app/shared/services/scicat.datasource.ts b/src/app/shared/services/scicat.datasource.ts index cd33197b3..17584c6e7 100644 --- a/src/app/shared/services/scicat.datasource.ts +++ b/src/app/shared/services/scicat.datasource.ts @@ -3,7 +3,6 @@ import { Observable, BehaviorSubject, of, Subscription } from "rxjs"; import { ScicatDataService } from "./scicat-data-service"; import { catchError, finalize } from "rxjs/operators"; import { ExportExcelService } from "./export-excel.service"; -import { LoopBackConfig } from "shared/sdk"; import { Column } from "shared/modules/shared-table/shared-table.module"; import { AppConfig, AppConfigService } from "app-config.service"; @@ -33,12 +32,9 @@ export class SciCatDataSource implements DataSource { private tableDefinition: any, ) { this.appConfig = this.appConfigService.getConfig(); + // TODO: Check if we can get the api version somehow or add it in the configuration instеad. this.url = - this.appConfig.lbBaseURL + - "/" + - LoopBackConfig.getApiVersion() + - "/" + - this.tableDefinition.collection; + this.appConfig.lbBaseURL + "/api/v3/" + this.tableDefinition.collection; this.collection = this.tableDefinition.collection; this.columnsdef = this.tableDefinition.columns; @@ -46,7 +42,7 @@ export class SciCatDataSource implements DataSource { // convert array of objects into array of arrays this.dataForExcel = []; if (data.length > 0) { - data.forEach((row: any) => { + data.forEach((row) => { const rowSorted = this.columnsdef.map((col) => resolvePath(row, col.id, null), ); diff --git a/src/app/shared/services/thumbnail.service.spec.ts b/src/app/shared/services/thumbnail.service.spec.ts index fb187528d..062aa2d73 100644 --- a/src/app/shared/services/thumbnail.service.spec.ts +++ b/src/app/shared/services/thumbnail.service.spec.ts @@ -1,15 +1,15 @@ import { TestBed } from "@angular/core/testing"; -import { DatasetApi } from "shared/sdk"; import { AppConfigService } from "app-config.service"; import { ThumbnailService } from "./thumbnail.service"; import { selectDatasetsPerPage } from "state-management/selectors/datasets.selectors"; import { MockStore, provideMockStore } from "@ngrx/store/testing"; import { of, throwError } from "rxjs"; +import { DatasetsService } from "@scicatproject/scicat-sdk-ts"; import { AttachmentService } from "./attachment.service"; describe("ThumbnailService", () => { let service: ThumbnailService; - let datasetApi: jasmine.SpyObj; + let datasetApi: jasmine.SpyObj; let store: MockStore; const cacheTimeout = 5 * 60 * 1000; // 5 minutes in milliseconds @@ -18,12 +18,14 @@ describe("ThumbnailService", () => { }); beforeEach(() => { - const datasetApiSpy = jasmine.createSpyObj("DatasetApi", ["thumbnail"]); + const datasetApiSpy = jasmine.createSpyObj("DatasetApi", [ + "datasetsControllerThumbnail", + ]); TestBed.configureTestingModule({ providers: [ ThumbnailService, - { provide: DatasetApi, useValue: datasetApiSpy }, + { provide: DatasetsService, useValue: datasetApiSpy }, { provide: AppConfigService, useValue: { getConfig }, @@ -43,7 +45,9 @@ describe("ThumbnailService", () => { }); service = TestBed.inject(ThumbnailService); - datasetApi = TestBed.inject(DatasetApi) as jasmine.SpyObj; + datasetApi = TestBed.inject( + DatasetsService, + ) as jasmine.SpyObj; store = TestBed.inject(MockStore); }); @@ -82,10 +86,15 @@ describe("ThumbnailService", () => { isError: false, }; - datasetApi.thumbnail.and.returnValue(of({ thumbnail })); + // TODO: Try to fix any type casting here + datasetApi.datasetsControllerThumbnail.and.returnValue( + of({ thumbnail } as any), + ); const result = await service.getThumbnail(pid); - expect(datasetApi.thumbnail).toHaveBeenCalledWith(encodeURIComponent(pid)); + expect(datasetApi.datasetsControllerThumbnail).toHaveBeenCalledWith( + encodeURIComponent(pid), + ); expect(result).toBe(thumbnail); }); @@ -96,17 +105,21 @@ describe("ThumbnailService", () => { const result = await service.getThumbnail(pid); expect(result).toBeNull(); // Should return null when over limit - expect(datasetApi.thumbnail).not.toHaveBeenCalled(); + expect(datasetApi.datasetsControllerThumbnail).not.toHaveBeenCalled(); }); it("should fetch thumbnail and cache it if not already cached", async () => { const pid = "test-pid"; const thumbnail = "http://thumbnail-url.com/image.jpg"; - datasetApi.thumbnail.and.returnValue(of({ thumbnail })); + datasetApi.datasetsControllerThumbnail.and.returnValue( + of({ thumbnail } as any), + ); const result = await service.getThumbnail(pid); - expect(datasetApi.thumbnail).toHaveBeenCalledWith(encodeURIComponent(pid)); + expect(datasetApi.datasetsControllerThumbnail).toHaveBeenCalledWith( + encodeURIComponent(pid), + ); expect(result).toBe(thumbnail); expect(service["thumbnailCache"][pid].value).toBe(thumbnail); }); @@ -114,7 +127,9 @@ describe("ThumbnailService", () => { it("should cache failed requests as null with isError=true", async () => { const pid = "test-pid"; const err = new Error("Failed to fetch thumbnail"); - datasetApi.thumbnail.and.returnValue(throwError(() => err)); + datasetApi.datasetsControllerThumbnail.and.returnValue( + throwError(() => err), + ); const result = await service.getThumbnail(pid); expect(result).toBeNull(); diff --git a/src/app/shared/services/thumbnail.service.ts b/src/app/shared/services/thumbnail.service.ts index 7990139de..a9f61a909 100644 --- a/src/app/shared/services/thumbnail.service.ts +++ b/src/app/shared/services/thumbnail.service.ts @@ -1,9 +1,9 @@ import { Injectable } from "@angular/core"; import { Store } from "@ngrx/store"; import { distinctUntilChanged, firstValueFrom } from "rxjs"; -import { DatasetApi } from "shared/sdk"; import { selectDatasetsPerPage } from "state-management/selectors/datasets.selectors"; import { AppConfigService } from "app-config.service"; +import { DatasetsService } from "@scicatproject/scicat-sdk-ts"; import { AttachmentService } from "./attachment.service"; interface ThumbnailCache { @@ -24,7 +24,7 @@ export class ThumbnailService { private cacheTimeout = 5 * 60 * 1000; // 5 minutes in milliseconds constructor( - private datasetApi: DatasetApi, + private datasetApi: DatasetsService, private store: Store, private attachmentService: AttachmentService, private appConfigService: AppConfigService, @@ -60,8 +60,9 @@ export class ThumbnailService { } try { - const encodedPid = encodeURIComponent(pid); - const res = await firstValueFrom(this.datasetApi.thumbnail(encodedPid)); + const res = await firstValueFrom( + this.datasetApi.datasetsControllerThumbnail(pid), + ); const thumbnail = this.attachmentService.getImageUrl(res?.thumbnail); this.thumbnailCache[pid] = { diff --git a/src/app/state-management/actions/datasets.actions.spec.ts b/src/app/state-management/actions/datasets.actions.spec.ts index 9cb46268d..a9b6e2067 100644 --- a/src/app/state-management/actions/datasets.actions.spec.ts +++ b/src/app/state-management/actions/datasets.actions.spec.ts @@ -1,13 +1,39 @@ import * as fromActions from "./datasets.actions"; -import { Dataset, Attachment, DerivedDataset } from "shared/sdk"; import { FacetCounts } from "state-management/state/datasets.store"; import { ArchViewMode, DatasetFilters, ScientificCondition, } from "state-management/models"; +import { + mockDataset as dataset, + createMock, + mockAttachment as attachment, +} from "shared/MockStubs"; +import { OutputDatasetObsoleteDto } from "@scicatproject/scicat-sdk-ts"; describe("Dataset Actions", () => { + const datasets = [dataset]; + const derivedDataset = createMock({ + investigator: "", + inputDatasets: [], + usedSoftware: [], + owner: "", + contactEmail: "", + sourceFolder: "", + creationTime: "", + ownerGroup: "", + datasetName: "", + type: "derived", + numberOfFilesArchived: 0, + createdAt: "", + createdBy: "", + creationLocation: "", + principalInvestigator: "", + updatedAt: "", + updatedBy: "", + }); + describe("fetchDatasetsAction", () => { it("should create an action", () => { const action = fromActions.fetchDatasetsAction(); @@ -17,7 +43,6 @@ describe("Dataset Actions", () => { describe("fetchDatasetsCompleteAction", () => { it("should create an action", () => { - const datasets = [new Dataset()]; const action = fromActions.fetchDatasetsCompleteAction({ datasets }); expect({ ...action }).toEqual({ type: "[Dataset] Fetch Datasets Complete", @@ -108,7 +133,6 @@ describe("Dataset Actions", () => { describe("fetchDatasetCompleteAction", () => { it("should create an action", () => { - const dataset = new Dataset(); const action = fromActions.fetchDatasetCompleteAction({ dataset }); expect({ ...action }).toEqual({ type: "[Dataset] Fetch Dataset Complete", @@ -137,7 +161,7 @@ describe("Dataset Actions", () => { describe("fetchRelatedDatasetsCompleteAction", () => { it("should create an action", () => { - const relatedDatasets = [new Dataset()]; + const relatedDatasets = [dataset]; const action = fromActions.fetchRelatedDatasetsCompleteAction({ relatedDatasets, }); @@ -204,7 +228,7 @@ describe("Dataset Actions", () => { describe("prefillBatchCompleteAction", () => { it("should create an action", () => { - const batch = [new Dataset()]; + const batch = [dataset]; const action = fromActions.prefillBatchCompleteAction({ batch }); expect({ ...action }).toEqual({ type: "[Dataset] Prefill Batch Complete", @@ -222,7 +246,6 @@ describe("Dataset Actions", () => { describe("removeFromBatchAction", () => { it("should create an action", () => { - const dataset = new Dataset(); const action = fromActions.removeFromBatchAction({ dataset }); expect({ ...action }).toEqual({ type: "[Dataset] Remove From Batch", @@ -240,7 +263,6 @@ describe("Dataset Actions", () => { describe("addDatasetAction", () => { it("should create an action", () => { - const dataset = new DerivedDataset(); const action = fromActions.addDatasetAction({ dataset }); expect({ ...action }).toEqual({ type: "[Dataset] Add Dataset", dataset }); }); @@ -248,7 +270,7 @@ describe("Dataset Actions", () => { describe("addDatasetCompleteAction", () => { it("should create an action", () => { - const dataset = new DerivedDataset(); + const dataset = derivedDataset; const action = fromActions.addDatasetCompleteAction({ dataset }); expect({ ...action }).toEqual({ type: "[Dataset] Add Dataset Complete", @@ -297,7 +319,6 @@ describe("Dataset Actions", () => { describe("addAttachmentAction", () => { it("should create an action", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentAction({ attachment }); expect({ ...action }).toEqual({ type: "[Dataset] Add Attachment", @@ -308,7 +329,6 @@ describe("Dataset Actions", () => { describe("addAttachmentCompleteAction", () => { it("should create an action", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentCompleteAction({ attachment }); expect({ ...action }).toEqual({ type: "[Dataset] Add Attachment Complete", @@ -331,23 +351,25 @@ describe("Dataset Actions", () => { const datasetId = "testId"; const attachmentId = "testId"; const caption = "test"; + const ownerGroup = "test"; const action = fromActions.updateAttachmentCaptionAction({ datasetId, attachmentId, caption, + ownerGroup, }); expect({ ...action }).toEqual({ type: "[Dataset] Update Attachment Caption", datasetId, attachmentId, caption, + ownerGroup, }); }); }); describe("updateAttachmentCaptionCompleteAction", () => { it("should create an action", () => { - const attachment = new Attachment(); const action = fromActions.updateAttachmentCaptionCompleteAction({ attachment, }); @@ -407,7 +429,6 @@ describe("Dataset Actions", () => { describe("reduceDatasetAction", () => { it("should create an action", () => { - const dataset = new Dataset(); const action = fromActions.reduceDatasetAction({ dataset }); expect({ ...action }).toEqual({ type: "[Dataset] Reduce Dataset", @@ -473,7 +494,6 @@ describe("Dataset Actions", () => { describe("selectDatasetAction", () => { it("should create an action", () => { - const dataset = new Dataset(); const action = fromActions.selectDatasetAction({ dataset }); expect({ ...action }).toEqual({ type: "[Dataset] Select Dataset", @@ -484,7 +504,6 @@ describe("Dataset Actions", () => { describe("deselectDatasetAction", () => { it("should create an action", () => { - const dataset = new Dataset(); const action = fromActions.deselectDatasetAction({ dataset }); expect({ ...action }).toEqual({ type: "[Dataset] Deselect Dataset", diff --git a/src/app/state-management/actions/datasets.actions.ts b/src/app/state-management/actions/datasets.actions.ts index 5c6ce0d93..6573018cb 100644 --- a/src/app/state-management/actions/datasets.actions.ts +++ b/src/app/state-management/actions/datasets.actions.ts @@ -1,11 +1,12 @@ import { createAction, props } from "@ngrx/store"; import { - Dataset, + DatasetClass, Attachment, - DerivedDataset, OrigDatablock, Datablock, -} from "shared/sdk"; + CreateDerivedDatasetObsoleteDto, + OutputDatasetObsoleteDto, +} from "@scicatproject/scicat-sdk-ts"; import { FacetCounts } from "state-management/state/datasets.store"; import { ArchViewMode, @@ -18,7 +19,7 @@ import { export const fetchDatasetsAction = createAction("[Dataset] Fetch Datasets"); export const fetchDatasetsCompleteAction = createAction( "[Dataset] Fetch Datasets Complete", - props<{ datasets: Dataset[] }>(), + props<{ datasets: OutputDatasetObsoleteDto[] }>(), ); export const fetchDatasetsFailedAction = createAction( "[Dataset] Fetch Datasets Failed", @@ -52,7 +53,7 @@ export const fetchDatasetAction = createAction( ); export const fetchDatasetCompleteAction = createAction( "[Dataset] Fetch Dataset Complete", - props<{ dataset: Dataset }>(), + props<{ dataset: OutputDatasetObsoleteDto }>(), ); export const fetchDatasetFailedAction = createAction( "[Dataset] Fetch Dataset Failed", @@ -97,7 +98,7 @@ export const fetchRelatedDatasetsAction = createAction( ); export const fetchRelatedDatasetsCompleteAction = createAction( "[Dataset] Fetch Related Datasets Complete", - props<{ relatedDatasets: Dataset[] }>(), + props<{ relatedDatasets: OutputDatasetObsoleteDto[] }>(), ); export const fetchRelatedDatasetsFailedAction = createAction( "[Datasets] Fetch Related Datasets Failed", @@ -119,26 +120,26 @@ export const changeRelatedDatasetsPageAction = createAction( export const prefillBatchAction = createAction("[Dataset] Prefill Batch"); export const prefillBatchCompleteAction = createAction( "[Dataset] Prefill Batch Complete", - props<{ batch: Dataset[] }>(), + props<{ batch: OutputDatasetObsoleteDto[] }>(), ); export const addToBatchAction = createAction("[Dataset] Add To Batch"); export const storeBatchAction = createAction( "[Dataset] Store To Batch", - props<{ batch: Dataset[] }>(), + props<{ batch: OutputDatasetObsoleteDto[] }>(), ); export const removeFromBatchAction = createAction( "[Dataset] Remove From Batch", - props<{ dataset: Dataset }>(), + props<{ dataset: OutputDatasetObsoleteDto }>(), ); export const clearBatchAction = createAction("[Dataset] Clear Batch"); export const addDatasetAction = createAction( "[Dataset] Add Dataset", - props<{ dataset: DerivedDataset }>(), + props<{ dataset: CreateDerivedDatasetObsoleteDto }>(), ); export const addDatasetCompleteAction = createAction( "[Dataset] Add Dataset Complete", - props<{ dataset: DerivedDataset }>(), + props<{ dataset: OutputDatasetObsoleteDto }>(), ); export const addDatasetFailedAction = createAction( "[Dataset] Add Dataset Failed", @@ -169,7 +170,12 @@ export const addAttachmentFailedAction = createAction( export const updateAttachmentCaptionAction = createAction( "[Dataset] Update Attachment Caption", - props<{ datasetId: string; attachmentId: string; caption: string }>(), + props<{ + datasetId: string; + attachmentId: string; + caption: string; + ownerGroup: string; + }>(), ); export const updateAttachmentCaptionCompleteAction = createAction( "[Dataset] Update Attachment Caption Complete", @@ -193,7 +199,7 @@ export const removeAttachmentFailedAction = createAction( export const reduceDatasetAction = createAction( "[Dataset] Reduce Dataset", - props<{ dataset: Dataset }>(), + props<{ dataset: OutputDatasetObsoleteDto }>(), ); export const reduceDatasetCompleteAction = createAction( "[Dataset] Reduce Dataset Complete", @@ -218,11 +224,11 @@ export const appendToDatasetArrayFieldFailedAction = createAction( export const selectDatasetAction = createAction( "[Dataset] Select Dataset", - props<{ dataset: Dataset }>(), + props<{ dataset: OutputDatasetObsoleteDto }>(), ); export const deselectDatasetAction = createAction( "[Dataset] Deselect Dataset", - props<{ dataset: Dataset }>(), + props<{ dataset: OutputDatasetObsoleteDto }>(), ); export const selectAllDatasetsAction = createAction( diff --git a/src/app/state-management/actions/instruments.actions.spec.ts b/src/app/state-management/actions/instruments.actions.spec.ts index 8a9a4726d..ee65a919f 100644 --- a/src/app/state-management/actions/instruments.actions.spec.ts +++ b/src/app/state-management/actions/instruments.actions.spec.ts @@ -1,7 +1,9 @@ +import { mockInstrument as instrument } from "shared/MockStubs"; import * as fromActions from "./instruments.actions"; -import { Instrument } from "shared/sdk"; describe("Instrument Actions", () => { + const instruments = [instrument]; + describe("fetchInstrumentsAction", () => { it("should create an action", () => { const action = fromActions.fetchInstrumentsAction(); @@ -12,7 +14,6 @@ describe("Instrument Actions", () => { describe("fetchInstrumentsCompleteAction", () => { it("should create an action", () => { - const instruments = [new Instrument()]; const action = fromActions.fetchInstrumentsCompleteAction({ instruments, }); @@ -80,7 +81,6 @@ describe("Instrument Actions", () => { describe("fetchInstrumentCompleteAction", () => { it("should create an action", () => { - const instrument = new Instrument(); const action = fromActions.fetchInstrumentCompleteAction({ instrument, }); @@ -120,7 +120,6 @@ describe("Instrument Actions", () => { describe("saveCustomMetadataCompleteAction", () => { it("should create an action", () => { - const instrument = new Instrument(); const action = fromActions.saveCustomMetadataCompleteAction({ instrument, }); diff --git a/src/app/state-management/actions/instruments.actions.ts b/src/app/state-management/actions/instruments.actions.ts index 3e9ae2455..ea6c15f80 100644 --- a/src/app/state-management/actions/instruments.actions.ts +++ b/src/app/state-management/actions/instruments.actions.ts @@ -1,5 +1,5 @@ import { createAction, props } from "@ngrx/store"; -import { Instrument } from "shared/sdk"; +import { Instrument } from "@scicatproject/scicat-sdk-ts"; export const fetchInstrumentsAction = createAction( "[Instrument] Fetch Instruments", diff --git a/src/app/state-management/actions/jobs.actions.spec.ts b/src/app/state-management/actions/jobs.actions.spec.ts index 22c75efdb..216a5f85d 100644 --- a/src/app/state-management/actions/jobs.actions.spec.ts +++ b/src/app/state-management/actions/jobs.actions.spec.ts @@ -1,7 +1,10 @@ -import { Job } from "shared/sdk/models"; +import { CreateJobDto } from "@scicatproject/scicat-sdk-ts"; import * as fromActions from "./jobs.actions"; +import { mockJob as job } from "shared/MockStubs"; describe("Job Actions", () => { + const jobs = [job]; + describe("fetchJobsAction", () => { it("should create an action", () => { const action = fromActions.fetchJobsAction(); @@ -11,7 +14,6 @@ describe("Job Actions", () => { describe("fetchJobsCompleteAction", () => { it("should create an action", () => { - const jobs = [new Job()]; const action = fromActions.fetchJobsCompleteAction({ jobs }); expect({ ...action }).toEqual({ type: "[Job] Fetch Jobs Complete", @@ -62,7 +64,6 @@ describe("Job Actions", () => { describe("fetchJobCompleteAction", () => { it("should create an action", () => { - const job = new Job(); const action = fromActions.fetchJobCompleteAction({ job }); expect({ ...action }).toEqual({ type: "[Job] Fetch Job Complete", job }); }); @@ -77,15 +78,14 @@ describe("Job Actions", () => { describe("submitJobAction", () => { it("should create an action", () => { - const job = new Job(); - const action = fromActions.submitJobAction({ job }); - expect({ ...action }).toEqual({ type: "[Job] Submit Job", job }); + const newJob = { ...job } as CreateJobDto; + const action = fromActions.submitJobAction({ job: newJob }); + expect({ ...action }).toEqual({ type: "[Job] Submit Job", job: newJob }); }); }); describe("submitJobCompleteAction", () => { it("should create an action", () => { - const job = new Job(); const action = fromActions.submitJobCompleteAction({ job }); expect({ ...action }).toEqual({ type: "[Job] Submit Job Complete", job }); }); diff --git a/src/app/state-management/actions/jobs.actions.ts b/src/app/state-management/actions/jobs.actions.ts index 10c3bf025..993a05777 100644 --- a/src/app/state-management/actions/jobs.actions.ts +++ b/src/app/state-management/actions/jobs.actions.ts @@ -1,10 +1,10 @@ import { createAction, props } from "@ngrx/store"; -import { Job } from "shared/sdk"; +import { CreateJobDto, JobClass } from "@scicatproject/scicat-sdk-ts"; export const fetchJobsAction = createAction("[Job] Fetch Jobs"); export const fetchJobsCompleteAction = createAction( "[Job] Fetch Jobs Complete", - props<{ jobs: Job[] }>(), + props<{ jobs: JobClass[] }>(), ); export const fetchJobsFailedAction = createAction("[Job] Fetch Jobs Failed"); @@ -21,17 +21,17 @@ export const fetchJobAction = createAction( ); export const fetchJobCompleteAction = createAction( "[Job] Fetch Job Complete", - props<{ job: Job }>(), + props<{ job: JobClass }>(), ); export const fetchJobFailedAction = createAction("[Job] Fetch Job Failed"); export const submitJobAction = createAction( "[Job] Submit Job", - props<{ job: Job }>(), + props<{ job: CreateJobDto }>(), ); export const submitJobCompleteAction = createAction( "[Job] Submit Job Complete", - props<{ job: Job }>(), + props<{ job: JobClass }>(), ); export const submitJobFailedAction = createAction( "[Job] Submit Job Failed", diff --git a/src/app/state-management/actions/logbooks.actions.spec.ts b/src/app/state-management/actions/logbooks.actions.spec.ts index 123626b8e..38540264d 100644 --- a/src/app/state-management/actions/logbooks.actions.spec.ts +++ b/src/app/state-management/actions/logbooks.actions.spec.ts @@ -1,5 +1,6 @@ -import { Logbook, LogbookFilters } from "../models"; +import { LogbookFilters } from "../models"; import * as fromActions from "./logbooks.actions"; +import { mockLogbook as logbook } from "shared/MockStubs"; describe("Logbook Actions", () => { describe("fetchLogbooksAction", () => { @@ -11,7 +12,7 @@ describe("Logbook Actions", () => { describe("fetchLogbooksCompleteAction", () => { it("should create an action", () => { - const logbooks = [new Logbook()]; + const logbooks = [logbook]; const action = fromActions.fetchLogbooksCompleteAction({ logbooks }); expect({ ...action }).toEqual({ type: "[Logbook] Fetch Logbooks Complete", @@ -39,7 +40,6 @@ describe("Logbook Actions", () => { describe("fetchLogbookCompleteAction", () => { it("should create an action", () => { - const logbook = new Logbook(); const action = fromActions.fetchLogbookCompleteAction({ logbook }); expect({ ...action }).toEqual({ type: "[Logbook] Fetch Logbook Complete", diff --git a/src/app/state-management/actions/logbooks.actions.ts b/src/app/state-management/actions/logbooks.actions.ts index b8a897b82..6c87a5f6f 100644 --- a/src/app/state-management/actions/logbooks.actions.ts +++ b/src/app/state-management/actions/logbooks.actions.ts @@ -1,5 +1,5 @@ import { createAction, props } from "@ngrx/store"; -import { Logbook } from "shared/sdk"; +import { Logbook } from "@scicatproject/scicat-sdk-ts"; import { LogbookFilters } from "state-management/models"; export const fetchLogbooksAction = createAction("[Logbook] Fetch Logbooks"); diff --git a/src/app/state-management/actions/policies.actions.spec.ts b/src/app/state-management/actions/policies.actions.spec.ts index 6e7cb0d44..b876912fa 100644 --- a/src/app/state-management/actions/policies.actions.spec.ts +++ b/src/app/state-management/actions/policies.actions.spec.ts @@ -1,5 +1,5 @@ +import { mockPolicy as policy } from "shared/MockStubs"; import * as fromActions from "./policies.actions"; -import { Policy } from "shared/sdk"; describe("Policies Actions", () => { describe("fetchPoliciesAction", () => { @@ -11,7 +11,7 @@ describe("Policies Actions", () => { describe("fetchPoliciesCompleteAction", () => { it("should create an action", () => { - const policies = [new Policy()]; + const policies = [policy]; const action = fromActions.fetchPoliciesCompleteAction({ policies }); expect({ ...action }).toEqual({ type: "[Policy] Fetch Policies Complete", @@ -63,7 +63,7 @@ describe("Policies Actions", () => { describe("fetchEditablePoliciesCompleteAction", () => { it("should create an action", () => { - const policies = [new Policy()]; + const policies = [policy]; const action = fromActions.fetchEditablePoliciesCompleteAction({ policies, }); @@ -115,7 +115,6 @@ describe("Policies Actions", () => { describe("submitPolicyAction", () => { it("should create an action", () => { const ownerList = ["test"]; - const policy = new Policy(); const action = fromActions.submitPolicyAction({ ownerList, policy }); expect({ ...action }).toEqual({ type: "[Policy] Submit Policy", @@ -127,7 +126,6 @@ describe("Policies Actions", () => { describe("submitPolicyCompleteAction", () => { it("should create an action", () => { - const policy = new Policy(); const action = fromActions.submitPolicyCompleteAction({ policy }); expect({ ...action }).toEqual({ type: "[Policy] Submit Policy Complete", @@ -145,7 +143,6 @@ describe("Policies Actions", () => { describe("selectPolicyAction", () => { it("should create an action", () => { - const policy = new Policy(); const action = fromActions.selectPolicyAction({ policy }); expect({ ...action }).toEqual({ type: "[Policy] Select Policy", @@ -156,7 +153,6 @@ describe("Policies Actions", () => { describe("deselectPolicyAction", () => { it("should create an action", () => { - const policy = new Policy(); const action = fromActions.deselectPolicyAction({ policy }); expect({ ...action }).toEqual({ type: "[Policy] Deselect Policy", diff --git a/src/app/state-management/actions/policies.actions.ts b/src/app/state-management/actions/policies.actions.ts index e9389fb32..dc88c0138 100644 --- a/src/app/state-management/actions/policies.actions.ts +++ b/src/app/state-management/actions/policies.actions.ts @@ -1,5 +1,5 @@ import { createAction, props } from "@ngrx/store"; -import { Policy } from "state-management/models"; +import { Policy } from "@scicatproject/scicat-sdk-ts"; export const fetchPoliciesAction = createAction("[Policy] Fetch Policies"); export const fetchPoliciesCompleteAction = createAction( diff --git a/src/app/state-management/actions/proposals.actions.spec.ts b/src/app/state-management/actions/proposals.actions.spec.ts index 23b996528..8194afedc 100644 --- a/src/app/state-management/actions/proposals.actions.spec.ts +++ b/src/app/state-management/actions/proposals.actions.spec.ts @@ -1,6 +1,10 @@ -import { Attachment, Dataset, Proposal } from "../models"; import * as fromActions from "./proposals.actions"; import { ProposalFilters } from "state-management/state/proposals.store"; +import { + mockAttachment as attachment, + mockProposal as proposal, + mockDataset, +} from "shared/MockStubs"; describe("Proposal Actions", () => { describe("fetchProposalsAction", () => { @@ -12,7 +16,7 @@ describe("Proposal Actions", () => { describe("fetchProposalsCompleteAction", () => { it("should create an action", () => { - const proposals = [new Proposal()]; + const proposals = [proposal]; const action = fromActions.fetchProposalsCompleteAction({ proposals }); expect({ ...action }).toEqual({ type: "[Proposal] Fetch Proposals Complete", @@ -68,7 +72,6 @@ describe("Proposal Actions", () => { describe("fetchProposalCompleteAction", () => { it("should create an action", () => { - const proposal = new Proposal(); const action = fromActions.fetchProposalCompleteAction({ proposal }); expect({ ...action }).toEqual({ type: "[Proposal] Fetch Proposal Complete", @@ -99,7 +102,7 @@ describe("Proposal Actions", () => { describe("fetchProposalDatasetsCompleteAction", () => { it("should create an action", () => { - const datasets = [new Dataset()]; + const datasets = [mockDataset]; const action = fromActions.fetchProposalDatasetsCompleteAction({ datasets, }); @@ -156,7 +159,6 @@ describe("Proposal Actions", () => { describe("addAttachmentAction", () => { it("should create an action", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentAction({ attachment }); expect({ ...action }).toEqual({ type: "[Proposal] Add Attachment", @@ -167,7 +169,6 @@ describe("Proposal Actions", () => { describe("addAttachmentCompleteAction", () => { it("should create an action", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentCompleteAction({ attachment }); expect({ ...action }).toEqual({ type: "[Proposal] Add Attachment Complete", @@ -206,7 +207,6 @@ describe("Proposal Actions", () => { describe("updateAttachmentCompleteCaption", () => { it("should create an action", () => { - const attachment = new Attachment(); const action = fromActions.updateAttachmentCaptionCompleteAction({ attachment, }); diff --git a/src/app/state-management/actions/proposals.actions.ts b/src/app/state-management/actions/proposals.actions.ts index f03ae0f07..c09f4cbcf 100644 --- a/src/app/state-management/actions/proposals.actions.ts +++ b/src/app/state-management/actions/proposals.actions.ts @@ -1,5 +1,9 @@ import { createAction, props } from "@ngrx/store"; -import { Proposal, Dataset, Attachment } from "shared/sdk/models"; +import { + Attachment, + OutputDatasetObsoleteDto, + ProposalClass, +} from "@scicatproject/scicat-sdk-ts"; import { ProposalFilters } from "state-management/state/proposals.store"; export const fetchProposalsAction = createAction("[Proposal] Fetch Proposals"); @@ -8,7 +12,7 @@ export const clearCurrentProposalAction = createAction( ); export const fetchProposalsCompleteAction = createAction( "[Proposal] Fetch Proposals Complete", - props<{ proposals: Proposal[] }>(), + props<{ proposals: ProposalClass[] }>(), ); export const fetchProposalsFailedAction = createAction( "[Proposal] Fetch Proposals Failed", @@ -29,7 +33,7 @@ export const fetchProposalAction = createAction( ); export const fetchProposalCompleteAction = createAction( "[Proposal] Fetch Proposal Complete", - props<{ proposal: Proposal }>(), + props<{ proposal: ProposalClass }>(), ); export const fetchProposalFailedAction = createAction( "[Proposal] Fetch Proposal Failed", @@ -44,7 +48,7 @@ export const fetchParentProposalAction = createAction( ); export const fetchParentProposalCompleteAction = createAction( "[Proposal] Fetch Parent Proposal Complete", - props<{ proposal: Proposal }>(), + props<{ proposal: ProposalClass }>(), ); export const fetchParentProposalFailedAction = createAction( "[Proposal] Fetch Parent Proposal Failed", @@ -59,7 +63,7 @@ export const fetchProposalDatasetsAction = createAction( ); export const fetchProposalDatasetsCompleteAction = createAction( "[Proposal] Fetch Datasets Complete", - props<{ datasets: Dataset[] }>(), + props<{ datasets: OutputDatasetObsoleteDto[] }>(), ); export const fetchProposalDatasetsFailedAction = createAction( "[Proposal] Fetch Datasets Failed", diff --git a/src/app/state-management/actions/published-data.actions.spec.ts b/src/app/state-management/actions/published-data.actions.spec.ts index 99f5bc57b..7c2bc4227 100644 --- a/src/app/state-management/actions/published-data.actions.spec.ts +++ b/src/app/state-management/actions/published-data.actions.spec.ts @@ -1,7 +1,9 @@ +import { mockPublishedData } from "shared/MockStubs"; import * as fromActions from "./published-data.actions"; -import { PublishedData } from "shared/sdk"; describe("Published Data Actions", () => { + const publishedData = mockPublishedData; + describe("fetchAllPublishedDataAction", () => { it("should create an action", () => { const action = fromActions.fetchAllPublishedDataAction(); @@ -13,13 +15,12 @@ describe("Published Data Actions", () => { describe("fetchAllPublishedDataCompleteAction", () => { it("should create an action", () => { - const publishedData = [new PublishedData()]; const action = fromActions.fetchAllPublishedDataCompleteAction({ - publishedData, + publishedData: [publishedData], }); expect({ ...action }).toEqual({ type: "[PublishedData] Fetch All Published Data Complete", - publishedData, + publishedData: [publishedData], }); }); }); @@ -73,7 +74,6 @@ describe("Published Data Actions", () => { describe("fetchPublishedDataCompleteAction", () => { it("should create an action", () => { - const publishedData = new PublishedData(); const action = fromActions.fetchPublishedDataCompleteAction({ publishedData, }); @@ -95,18 +95,16 @@ describe("Published Data Actions", () => { describe("publishDatasetAction", () => { it("should create an action", () => { - const data = new PublishedData(); - const action = fromActions.publishDatasetAction({ data }); + const action = fromActions.publishDatasetAction({ data: publishedData }); expect({ ...action }).toEqual({ type: "[PublishedData] Publish Dataset", - data, + data: publishedData, }); }); }); describe("publishDatasetCompleteAction", () => { it("should create an action", () => { - const publishedData = new PublishedData(); const action = fromActions.publishDatasetCompleteAction({ publishedData, }); @@ -139,7 +137,6 @@ describe("Published Data Actions", () => { describe("registerPublishedDataCompleteAction", () => { it("should create an action", () => { - const publishedData = new PublishedData(); const action = fromActions.registerPublishedDataCompleteAction({ publishedData, }); diff --git a/src/app/state-management/actions/published-data.actions.ts b/src/app/state-management/actions/published-data.actions.ts index 10aee0470..1294be052 100644 --- a/src/app/state-management/actions/published-data.actions.ts +++ b/src/app/state-management/actions/published-data.actions.ts @@ -1,5 +1,9 @@ import { createAction, props } from "@ngrx/store"; -import { PublishedData } from "shared/sdk"; +import { + CreatePublishedDataDto, + PublishedData, + UpdatePublishedDataDto, +} from "@scicatproject/scicat-sdk-ts"; export const fetchAllPublishedDataAction = createAction( "[PublishedData] Fetch All Published Data", @@ -35,7 +39,7 @@ export const fetchPublishedDataFailedAction = createAction( export const publishDatasetAction = createAction( "[PublishedData] Publish Dataset", - props<{ data: PublishedData }>(), + props<{ data: CreatePublishedDataDto }>(), ); export const publishDatasetCompleteAction = createAction( "[PublishedData] Publish Dataset Complete", @@ -59,7 +63,7 @@ export const registerPublishedDataFailedAction = createAction( export const resyncPublishedDataAction = createAction( "[PublishedData] Resync Published Data", - props<{ doi: string; data: Partial }>(), + props<{ doi: string; data: UpdatePublishedDataDto }>(), ); export const resyncPublishedDataCompleteAction = createAction( "[PublishedData] Resync Published Data Complete", diff --git a/src/app/state-management/actions/samples.actions.spec.ts b/src/app/state-management/actions/samples.actions.spec.ts index ab0f4e9a3..a8287abd3 100644 --- a/src/app/state-management/actions/samples.actions.spec.ts +++ b/src/app/state-management/actions/samples.actions.spec.ts @@ -1,6 +1,10 @@ import * as fromActions from "./samples.actions"; -import { Attachment, Sample, Dataset } from "shared/sdk/models"; import { SampleFilters, ScientificCondition } from "state-management/models"; +import { + mockAttachment as attachment, + mockDataset as dataset, + mockSample as sample, +} from "shared/MockStubs"; describe("Sample Actions", () => { describe("fetchSamplesAction", () => { @@ -12,7 +16,7 @@ describe("Sample Actions", () => { describe("fetchSamplesCompleteAction", () => { it("should create an action", () => { - const samples = [new Sample()]; + const samples = [sample]; const action = fromActions.fetchSamplesCompleteAction({ samples }); expect({ ...action }).toEqual({ type: "[Sample] Fetch Samples Complete", @@ -97,7 +101,7 @@ describe("Sample Actions", () => { describe("fetchSampleCompleteAction", () => { it("should create an action", () => { - const sample = new Sample(); + // const sample = new Sample(); const action = fromActions.fetchSampleCompleteAction({ sample }); expect({ ...action }).toEqual({ type: "[Sample] Fetch Sample Complete", @@ -126,7 +130,7 @@ describe("Sample Actions", () => { describe("fetchSampleDatasetsCompleteAction", () => { it("should create an action", () => { - const datasets = [new Dataset()]; + const datasets = [dataset]; const action = fromActions.fetchSampleDatasetsCompleteAction({ datasets, }); @@ -181,7 +185,6 @@ describe("Sample Actions", () => { describe("addSampleAction", () => { it("should create an action", () => { - const sample = new Sample(); const action = fromActions.addSampleAction({ sample }); expect({ ...action }).toEqual({ type: "[Sample] Add Sample", @@ -192,7 +195,6 @@ describe("Sample Actions", () => { describe("addSampleCompleteAction", () => { it("should create an action", () => { - const sample = new Sample(); const action = fromActions.addSampleCompleteAction({ sample }); expect({ ...action }).toEqual({ type: "[Sample] Add Sample Complete", @@ -226,7 +228,6 @@ describe("Sample Actions", () => { describe("saveCharacteristicsCompleteAction", () => { it("should create an action", () => { - const sample = new Sample(); const action = fromActions.saveCharacteristicsCompleteAction({ sample }); expect({ ...action }).toEqual({ type: "[Sample] Save Characteristics Complete", @@ -246,7 +247,6 @@ describe("Sample Actions", () => { describe("addAttachmentAction", () => { it("should create an action", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentAction({ attachment }); expect({ ...action }).toEqual({ type: "[Sample] Add Attachment", @@ -257,7 +257,6 @@ describe("Sample Actions", () => { describe("addAttachmentCompleteAction", () => { it("should create an action", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentCompleteAction({ attachment }); expect({ ...action }).toEqual({ type: "[Sample] Add Attachment Complete", @@ -296,7 +295,6 @@ describe("Sample Actions", () => { describe("updateAttachmentCompleteCaption", () => { it("should create an action", () => { - const attachment = new Attachment(); const action = fromActions.updateAttachmentCaptionCompleteAction({ attachment, }); diff --git a/src/app/state-management/actions/samples.actions.ts b/src/app/state-management/actions/samples.actions.ts index a5f492ac1..669ab569f 100644 --- a/src/app/state-management/actions/samples.actions.ts +++ b/src/app/state-management/actions/samples.actions.ts @@ -1,11 +1,16 @@ import { createAction, props } from "@ngrx/store"; -import { Sample, Dataset, Attachment } from "shared/sdk/models"; +import { + Attachment, + CreateAttachmentDto, + OutputDatasetObsoleteDto, + SampleClass, +} from "@scicatproject/scicat-sdk-ts"; import { SampleFilters, ScientificCondition } from "state-management/models"; export const fetchSamplesAction = createAction("[Sample] Fetch Samples"); export const fetchSamplesCompleteAction = createAction( "[Sample] Fetch Samples Complete", - props<{ samples: Sample[] }>(), + props<{ samples: SampleClass[] }>(), ); export const fetchSamplesFailedAction = createAction( "[Sample] Fetch Samples Failed", @@ -39,7 +44,7 @@ export const fetchSampleAction = createAction( ); export const fetchSampleCompleteAction = createAction( "[Sample] Fetch Sample Complete", - props<{ sample: Sample }>(), + props<{ sample: SampleClass }>(), ); export const fetchSampleFailedAction = createAction( "[Sample] Fetch Sample Failed", @@ -65,7 +70,7 @@ export const fetchSampleDatasetsAction = createAction( ); export const fetchSampleDatasetsCompleteAction = createAction( "[Sample] Fetch Datasets Complete", - props<{ datasets: Dataset[] }>(), + props<{ datasets: OutputDatasetObsoleteDto[] }>(), ); export const fetchSampleDatasetsFailedAction = createAction( "[Sample] Fetch Datasets Failed", @@ -85,11 +90,11 @@ export const fetchSampleDatasetsCountFailedAction = createAction( export const addSampleAction = createAction( "[Sample] Add Sample", - props<{ sample: Sample }>(), + props<{ sample: SampleClass }>(), ); export const addSampleCompleteAction = createAction( "[Sample] Add Sample Complete", - props<{ sample: Sample }>(), + props<{ sample: SampleClass }>(), ); export const addSampleFailedAction = createAction("[Sample] Add Sample Failed"); @@ -99,7 +104,7 @@ export const saveCharacteristicsAction = createAction( ); export const saveCharacteristicsCompleteAction = createAction( "[Sample] Save Characteristics Complete", - props<{ sample: Sample }>(), + props<{ sample: SampleClass }>(), ); export const saveCharacteristicsFailedAction = createAction( "[Sample] Save Characteristics Failed", @@ -107,7 +112,7 @@ export const saveCharacteristicsFailedAction = createAction( export const addAttachmentAction = createAction( "[Sample] Add Attachment", - props<{ attachment: Partial }>(), + props<{ attachment: CreateAttachmentDto }>(), ); export const addAttachmentCompleteAction = createAction( "[Sample] Add Attachment Complete", diff --git a/src/app/state-management/actions/user.actions.spec.ts b/src/app/state-management/actions/user.actions.spec.ts index 68fac0e3e..d9e15c311 100644 --- a/src/app/state-management/actions/user.actions.spec.ts +++ b/src/app/state-management/actions/user.actions.spec.ts @@ -1,9 +1,15 @@ -import { Message, User, Settings, UserIdentity, MessageType } from "../models"; +import { + ReturnedUserDto, + UserIdentity, + UserSettings, +} from "@scicatproject/scicat-sdk-ts"; +import { Message, Settings, MessageType } from "../models"; import * as fromActions from "./user.actions"; -import { AccessToken, UserSetting } from "shared/sdk"; import { HttpErrorResponse } from "@angular/common/http"; +import { SDKToken } from "shared/services/auth/auth.service"; describe("User Actions", () => { + let user: ReturnedUserDto; const error = new HttpErrorResponse({}); describe("loginAction", () => { it("should create an action", () => { @@ -18,7 +24,6 @@ describe("User Actions", () => { describe("loginCompleteAction", () => { it("should create an action", () => { - const user = new User(); const accountType = "test"; const action = fromActions.loginCompleteAction({ user, accountType }); expect({ ...action }).toEqual({ @@ -69,9 +74,6 @@ describe("User Actions", () => { describe("activeDirLoginFailedAction", () => { it("should create an action", () => { - const username = "test"; - const password = "test"; - const rememberMe = true; const action = fromActions.activeDirLoginFailedAction({ error, }); @@ -165,7 +167,6 @@ describe("User Actions", () => { describe("fetchCurrentUserCompleteAction", () => { it("should create an action", () => { - const user = new User(); const action = fromActions.fetchCurrentUserCompleteAction({ user }); expect({ ...action }).toEqual({ type: "[User] Fetch Current User Complete", @@ -193,7 +194,7 @@ describe("User Actions", () => { describe("fetchUserIdentityCompleteAction", () => { it("should create an action", () => { - const userIdentity = new UserIdentity(); + let userIdentity: UserIdentity; const action = fromActions.fetchUserIdentityCompleteAction({ userIdentity, }); @@ -223,13 +224,15 @@ describe("User Actions", () => { describe("fetchUserSettingsCompleteAction", () => { it("should create an action", () => { - const userSettings = new UserSetting({ - columns: [], + const userSettings: UserSettings = { + externalSettings: { + columns: [], + }, datasetCount: 25, jobCount: 25, userId: "testId", id: "testId", - }); + }; const action = fromActions.fetchUserSettingsCompleteAction({ userSettings, }); @@ -262,13 +265,15 @@ describe("User Actions", () => { describe("updateUserSettingsCompleteAction", () => { it("should create an action", () => { - const userSettings = new UserSetting({ - columns: [], + const userSettings: UserSettings = { + externalSettings: { + columns: [], + }, datasetCount: 25, jobCount: 25, userId: "testId", id: "testId", - }); + }; const action = fromActions.updateUserSettingsCompleteAction({ userSettings, }); @@ -297,7 +302,7 @@ describe("User Actions", () => { describe("fetchScicatTokenCompleteAction", () => { it("should create an action", () => { - const token = new AccessToken(); + const token = new SDKToken(); const action = fromActions.fetchScicatTokenCompleteAction({ token }); expect({ ...action }).toEqual({ type: "[User] Fetch Scicat Token Complete", diff --git a/src/app/state-management/actions/user.actions.ts b/src/app/state-management/actions/user.actions.ts index d2afe4814..31ef00a10 100644 --- a/src/app/state-management/actions/user.actions.ts +++ b/src/app/state-management/actions/user.actions.ts @@ -1,12 +1,17 @@ import { HttpErrorResponse } from "@angular/common/http"; import { createAction, props } from "@ngrx/store"; -import { User, AccessToken, UserIdentity, UserSetting } from "shared/sdk"; +import { + ReturnedUserDto, + UserIdentity, + UserSettings, +} from "@scicatproject/scicat-sdk-ts"; import { Message, Settings, TableColumn } from "state-management/models"; import { ConditionConfig, FilterConfig, } from "../../shared/modules/filters/filters.module"; import { AppConfig } from "app-config.service"; +import { AccessTokenInterface } from "shared/services/auth/auth.service"; export const setDatasetTableColumnsAction = createAction( "[User] Set Dataset Table Columns", @@ -26,7 +31,7 @@ export const loginAction = createAction( ); export const loginCompleteAction = createAction( "[User] Login Complete", - props<{ user: User; accountType: string }>(), + props<{ user: ReturnedUserDto; accountType: string }>(), ); export const loginFailedAction = createAction( "[User] Login Failed", @@ -74,7 +79,7 @@ export const fetchUserFailedAction = createAction( export const fetchCurrentUserAction = createAction("[User] Fetch Current User"); export const fetchCurrentUserCompleteAction = createAction( "[User] Fetch Current User Complete", - props<{ user: User }>(), + props<{ user: ReturnedUserDto }>(), ); export const fetchCurrentUserFailedAction = createAction( "[User] Fetch Current User Failed", @@ -98,7 +103,7 @@ export const fetchUserSettingsAction = createAction( ); export const fetchUserSettingsCompleteAction = createAction( "[User] Fetch User Settings Complete", - props<{ userSettings: UserSetting }>(), + props<{ userSettings: UserSettings }>(), ); export const fetchUserSettingsFailedAction = createAction( "[User] Fetch User Settings Failed", @@ -110,7 +115,7 @@ export const updateUserSettingsAction = createAction( ); export const updateUserSettingsCompleteAction = createAction( "[User] Update User Settings Complete", - props<{ userSettings: UserSetting }>(), + props<{ userSettings: UserSettings }>(), ); export const updateUserSettingsFailedAction = createAction( "[User] Update User Settings Failed", @@ -119,7 +124,7 @@ export const updateUserSettingsFailedAction = createAction( export const fetchScicatTokenAction = createAction("[User] Fetch Scicat Token"); export const fetchScicatTokenCompleteAction = createAction( "[User] Fetch Scicat Token Complete", - props<{ token: AccessToken }>(), + props<{ token: AccessTokenInterface }>(), ); export const fetchScicatTokenFailedAction = createAction( "[User] Fetch Scicat Token Failed", diff --git a/src/app/state-management/effects/datasets.effects.spec.ts b/src/app/state-management/effects/datasets.effects.spec.ts index bf9563fbc..a8af2a876 100644 --- a/src/app/state-management/effects/datasets.effects.spec.ts +++ b/src/app/state-management/effects/datasets.effects.spec.ts @@ -2,16 +2,7 @@ import { TestBed } from "@angular/core/testing"; import { provideMockActions } from "@ngrx/effects/testing"; import { provideMockStore } from "@ngrx/store/testing"; import { cold, hot } from "jasmine-marbles"; -import { - DatasetInterface, - Dataset, - DatasetApi, - Attachment, - DerivedDataset, - DerivedDatasetInterface, -} from "shared/sdk"; import * as fromActions from "../actions/datasets.actions"; -import { Observable } from "rxjs"; import { DatasetEffects } from "./datasets.effects"; import { FacetCounts } from "state-management/state/datasets.store"; import { @@ -27,35 +18,43 @@ import { } from "state-management/actions/user.actions"; import { ScientificCondition } from "state-management/models"; import { Type } from "@angular/core"; +import { + DatasetsService, + OutputDatasetObsoleteDto, +} from "@scicatproject/scicat-sdk-ts"; +import { TestObservable } from "jasmine-marbles/src/test-observables"; +import { + createMock, + mockAttachment as attachment, + mockDataset, +} from "shared/MockStubs"; -const derivedData: DerivedDatasetInterface = { +const derivedData = createMock({ investigator: "", inputDatasets: [], usedSoftware: [], owner: "", contactEmail: "", sourceFolder: "", - creationTime: new Date(), + creationTime: new Date().toString(), type: "derived", ownerGroup: "", -}; -const derivedDataset = new DerivedDataset({ pid: "testPid", ...derivedData }); + createdAt: "", + createdBy: "", + creationLocation: "", + numberOfFilesArchived: 0, + principalInvestigator: "", + updatedAt: "", + updatedBy: "", +}); +const derivedDataset = { pid: "testPid", ...derivedData }; -const data: DatasetInterface = { - owner: "", - contactEmail: "", - sourceFolder: "", - creationTime: new Date(), - type: "", - ownerGroup: "", - attachments: [], -}; -const dataset = new Dataset({ pid: "testPid", ...data }); +const dataset = { pid: "testPid", ...mockDataset }; describe("DatasetEffects", () => { - let actions: Observable; + let actions: TestObservable; let effects: DatasetEffects; - let datasetApi: jasmine.SpyObj; + let datasetApi: jasmine.SpyObj; beforeEach(() => { TestBed.configureTestingModule({ @@ -80,29 +79,27 @@ describe("DatasetEffects", () => { ], }), { - provide: DatasetApi, + provide: DatasetsService, useValue: jasmine.createSpyObj("datasetApi", [ - "create", - "fullquery", - "fullfacet", - "metadataKeys", - "find", - "findOne", - "findById", - "patchAttributes", - "createAttachments", - "updateByIdAttachments", - "destroyByIdAttachments", - "reduceDataset", - "appendToArrayField", - "count", + "datasetsControllerCreate", + "datasetsControllerFullquery", + "datasetsControllerFullfacet", + "datasetsControllerMetadataKeys", + "datasetsControllerFindAll", + "datasetsControllerFindById", + "datasetsControllerFindByIdAndUpdate", + "datasetsControllerCreateAttachment", + "datasetsControllerFindOneAttachmentAndUpdate", + "datasetsControllerFindOneAttachmentAndRemove", + "datasetsControllerAppendToArrayField", + "datasetsControllerCount", ]), }, ], }); effects = TestBed.inject(DatasetEffects); - datasetApi = injectedStub(DatasetApi); + datasetApi = injectedStub(DatasetsService); }); const injectedStub = (service: Type): jasmine.SpyObj => @@ -116,7 +113,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: datasets }); - datasetApi.fullquery.and.returnValue(response); + datasetApi.datasetsControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchDatasets$).toBeObservable(expected); @@ -128,7 +125,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.fullquery.and.returnValue(response); + datasetApi.datasetsControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchDatasets$).toBeObservable(expected); @@ -163,7 +160,7 @@ describe("DatasetEffects", () => { ]; actions = hot("-a", { a: action }); const response = cold("-a|", { a: responseArray }); - datasetApi.fullfacet.and.returnValue(response); + datasetApi.datasetsControllerFullfacet.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchFacetCounts$).toBeObservable(expected); @@ -175,7 +172,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.fullfacet.and.returnValue(response); + datasetApi.datasetsControllerFullfacet.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchFacetCounts$).toBeObservable(expected); @@ -192,7 +189,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: metadataKeys }); - datasetApi.metadataKeys.and.returnValue(response); + datasetApi.datasetsControllerMetadataKeys.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchMetadataKeys$).toBeObservable(expected); @@ -204,7 +201,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.metadataKeys.and.returnValue(response); + datasetApi.datasetsControllerMetadataKeys.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchMetadataKeys$).toBeObservable(expected); @@ -287,7 +284,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: dataset }); - datasetApi.findById.and.returnValue(response); + datasetApi.datasetsControllerFindById.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchDataset$).toBeObservable(expected); @@ -299,7 +296,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.findById.and.returnValue(response); + datasetApi.datasetsControllerFindById.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchDataset$).toBeObservable(expected); @@ -316,7 +313,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: relatedDatasets }); - datasetApi.find.and.returnValue(response); + datasetApi.datasetsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchRelatedDatasets$).toBeObservable(expected); @@ -327,7 +324,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.find.and.returnValue(response); + datasetApi.datasetsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchRelatedDatasets$).toBeObservable(expected); @@ -344,7 +341,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: { count } }); - datasetApi.count.and.returnValue(response); + datasetApi.datasetsControllerCount.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchRelatedDatasetsCount$).toBeObservable(expected); @@ -355,7 +352,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.count.and.returnValue(response); + datasetApi.datasetsControllerCount.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchRelatedDatasetsCount$).toBeObservable(expected); @@ -375,7 +372,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: derivedDataset }); - datasetApi.create.and.returnValue(response); + datasetApi.datasetsControllerCreate.and.returnValue(response); const expected = cold("--(bcd)", { b: outcome1, @@ -391,7 +388,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.create.and.returnValue(response); + datasetApi.datasetsControllerCreate.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.addDataset$).toBeObservable(expected); @@ -411,7 +408,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: dataset }); - datasetApi.patchAttributes.and.returnValue(response); + datasetApi.datasetsControllerFindByIdAndUpdate.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.updateProperty$).toBeObservable(expected); @@ -426,7 +423,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.patchAttributes.and.returnValue(response); + datasetApi.datasetsControllerFindByIdAndUpdate.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.updateProperty$).toBeObservable(expected); @@ -434,15 +431,13 @@ describe("DatasetEffects", () => { }); describe("addAttachment$", () => { - const attachment = new Attachment(); - it("should result in a addAttachmentCompleteAction", () => { const action = fromActions.addAttachmentAction({ attachment }); const outcome = fromActions.addAttachmentCompleteAction({ attachment }); actions = hot("-a", { a: action }); const response = cold("-a|", { a: attachment }); - datasetApi.createAttachments.and.returnValue(response); + datasetApi.datasetsControllerCreateAttachment.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.addAttachment$).toBeObservable(expected); @@ -454,7 +449,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.createAttachments.and.returnValue(response); + datasetApi.datasetsControllerCreateAttachment.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.addAttachment$).toBeObservable(expected); @@ -465,13 +460,14 @@ describe("DatasetEffects", () => { const datasetId = "testPid"; const attachmentId = "testId"; const caption = "test"; - const attachment = new Attachment(); + const ownerGroup = "test"; it("should result in an addAttachmentCaptionCompleteAction", () => { const action = fromActions.updateAttachmentCaptionAction({ datasetId, attachmentId, caption, + ownerGroup, }); const outcome = fromActions.updateAttachmentCaptionCompleteAction({ attachment, @@ -479,7 +475,9 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: attachment }); - datasetApi.updateByIdAttachments.and.returnValue(response); + datasetApi.datasetsControllerFindOneAttachmentAndUpdate.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.updateAttachmentCaption$).toBeObservable(expected); @@ -490,12 +488,15 @@ describe("DatasetEffects", () => { datasetId, attachmentId, caption, + ownerGroup, }); const outcome = fromActions.updateAttachmentCaptionFailedAction(); actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.updateByIdAttachments.and.returnValue(response); + datasetApi.datasetsControllerFindOneAttachmentAndUpdate.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.updateAttachmentCaption$).toBeObservable(expected); @@ -517,7 +518,9 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: attachmentId }); - datasetApi.destroyByIdAttachments.and.returnValue(response); + datasetApi.datasetsControllerFindOneAttachmentAndRemove.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.removeAttachment$).toBeObservable(expected); @@ -532,40 +535,15 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.destroyByIdAttachments.and.returnValue(response); + datasetApi.datasetsControllerFindOneAttachmentAndRemove.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.removeAttachment$).toBeObservable(expected); }); }); - describe("reduceDataset$", () => { - it("should result in a reduceDatasetCompleteAction", () => { - const result = { status: "success" }; - const action = fromActions.reduceDatasetAction({ dataset }); - const outcome = fromActions.reduceDatasetCompleteAction({ result }); - - actions = hot("-a", { a: action }); - const response = cold("-a|", { a: result }); - datasetApi.reduceDataset.and.returnValue(response); - - const expected = cold("--b", { b: outcome }); - expect(effects.reduceDataset$).toBeObservable(expected); - }); - - it("should result in a reduceDatasetFailedAction", () => { - const action = fromActions.reduceDatasetAction({ dataset }); - const outcome = fromActions.reduceDatasetFailedAction(); - - actions = hot("-a", { a: action }); - const response = cold("-#", {}); - datasetApi.reduceDataset.and.returnValue(response); - - const expected = cold("--b", { b: outcome }); - expect(effects.reduceDataset$).toBeObservable(expected); - }); - }); - describe("appendToArrayField$", () => { it("should result in a appendToDatasetArrayFieldCompleteAction", () => { const pid = "string"; @@ -580,7 +558,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", {}); - datasetApi.appendToArrayField.and.returnValue(response); + datasetApi.datasetsControllerAppendToArrayField.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.appendToArrayField$).toBeObservable(expected); @@ -599,7 +577,7 @@ describe("DatasetEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.appendToArrayField.and.returnValue(response); + datasetApi.datasetsControllerAppendToArrayField.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.appendToArrayField$).toBeObservable(expected); @@ -689,7 +667,6 @@ describe("DatasetEffects", () => { describe("ofType addAttachmentAction", () => { it("should dispatch a loadingAction", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentAction({ attachment }); const outcome = loadingAction(); @@ -705,10 +682,13 @@ describe("DatasetEffects", () => { const datasetId = "testId"; const attachmentId = "testId"; const caption = "test"; + const ownerGroup = "test"; + const action = fromActions.updateAttachmentCaptionAction({ datasetId, attachmentId, caption, + ownerGroup, }); const outcome = loadingAction(); @@ -901,7 +881,6 @@ describe("DatasetEffects", () => { describe("ofType addAttachmentCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentCompleteAction({ attachment }); const outcome = loadingCompleteAction(); @@ -926,7 +905,6 @@ describe("DatasetEffects", () => { describe("ofType updateAttachmentCaptionCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const attachment = new Attachment(); const action = fromActions.updateAttachmentCaptionCompleteAction({ attachment, }); diff --git a/src/app/state-management/effects/datasets.effects.ts b/src/app/state-management/effects/datasets.effects.ts index bd07d7b6f..8fe795f40 100644 --- a/src/app/state-management/effects/datasets.effects.ts +++ b/src/app/state-management/effects/datasets.effects.ts @@ -1,14 +1,14 @@ import { Injectable } from "@angular/core"; import { Actions, concatLatestFrom, createEffect, ofType } from "@ngrx/effects"; import { - DatasetApi, - Dataset, - LoopBackFilter, - OrigDatablock, Attachment, + CreateAttachmentDto, Datablock, - DerivedDataset, -} from "shared/sdk"; + DatasetsService, + OrigDatablock, + OutputDatasetObsoleteDto, + UpdateAttachmentDto, +} from "@scicatproject/scicat-sdk-ts"; import { Store } from "@ngrx/store"; import { selectFullqueryParams, @@ -53,14 +53,16 @@ export class DatasetEffects { fromActions.sortByColumnAction, ), concatLatestFrom(() => this.fullqueryParams$), - map(([action, params]) => params), + map(([, params]) => params), mergeMap(({ query, limits }) => - this.datasetApi.fullquery(query, limits).pipe( - map((datasets) => - fromActions.fetchDatasetsCompleteAction({ datasets }), + this.datasetsService + .datasetsControllerFullquery(JSON.stringify(limits), query) + .pipe( + map((datasets) => + fromActions.fetchDatasetsCompleteAction({ datasets }), + ), + catchError(() => of(fromActions.fetchDatasetsFailedAction())), ), - catchError(() => of(fromActions.fetchDatasetsFailedAction())), - ), ), ); }); @@ -73,19 +75,24 @@ export class DatasetEffects { fromActions.sortByColumnAction, ), concatLatestFrom(() => this.fullfacetParams$), - map(([action, params]) => params), + map(([, params]) => params), mergeMap(({ fields, facets }) => - this.datasetApi.fullfacet(fields, facets).pipe( - map((res) => { - const { all, ...facetCounts } = res[0]; - const allCounts = all && all.length > 0 ? all[0].totalSets : 0; - return fromActions.fetchFacetCountsCompleteAction({ - facetCounts, - allCounts, - }); - }), - catchError(() => of(fromActions.fetchFacetCountsFailedAction())), - ), + this.datasetsService + .datasetsControllerFullfacet( + JSON.stringify(facets), + JSON.stringify(fields), + ) + .pipe( + map((res) => { + const { all, ...facetCounts } = res[0]; + const allCounts = all && all.length > 0 ? all[0].totalSets : 0; + return fromActions.fetchFacetCountsCompleteAction({ + facetCounts, + allCounts, + }); + }), + catchError(() => of(fromActions.fetchFacetCountsFailedAction())), + ), ), ); }); @@ -94,17 +101,17 @@ export class DatasetEffects { return this.actions$.pipe( ofType(fromActions.fetchMetadataKeysAction), concatLatestFrom(() => this.fullqueryParams$), - map(([action, params]) => params), + map(([, params]) => params), mergeMap(({ query }) => { const parsedQuery = JSON.parse(query); - // TODO: remove this line below after metadataKey endpoint is refactored in the backend - // parsedQuery.metadataKey = ""; - return this.datasetApi.metadataKeys(JSON.stringify(parsedQuery)).pipe( - map((metadataKeys) => - fromActions.fetchMetadataKeysCompleteAction({ metadataKeys }), - ), - catchError(() => of(fromActions.fetchMetadataKeysFailedAction())), - ); + return this.datasetsService + .datasetsControllerMetadataKeys(JSON.stringify(parsedQuery)) + .pipe( + map((metadataKeys) => + fromActions.fetchMetadataKeysCompleteAction({ metadataKeys }), + ), + catchError(() => of(fromActions.fetchMetadataKeysFailedAction())), + ); }), ); }); @@ -133,10 +140,8 @@ export class DatasetEffects { return this.actions$.pipe( ofType(fromActions.fetchDatasetAction), switchMap(({ pid }) => { - return this.datasetApi.findById(encodeURIComponent(pid)).pipe( - map((dataset: Dataset) => - fromActions.fetchDatasetCompleteAction({ dataset }), - ), + return this.datasetsService.datasetsControllerFindById(pid).pipe( + map((dataset) => fromActions.fetchDatasetCompleteAction({ dataset })), catchError(() => of(fromActions.fetchDatasetFailedAction())), ); }), @@ -146,8 +151,8 @@ export class DatasetEffects { return this.actions$.pipe( ofType(fromActions.fetchDatablocksAction), switchMap(({ pid, filters }) => { - return this.datasetApi - .getDatablocks(encodeURIComponent(pid), filters) + return this.datasetsService + .datasetsControllerFindAllDatablocks(pid, filters) .pipe( map((datablocks: Datablock[]) => fromActions.fetchDatablocksCompleteAction({ datablocks }), @@ -161,9 +166,9 @@ export class DatasetEffects { fetchOrigDatablocksOfDataset$ = createEffect(() => { return this.actions$.pipe( ofType(fromActions.fetchOrigDatablocksAction), - switchMap(({ pid, filters }) => { - return this.datasetApi - .getOrigdatablocks(encodeURIComponent(pid), {}) + switchMap(({ pid }) => { + return this.datasetsService + .datasetsControllerFindAllOrigDatablocks(pid) .pipe( map((origdatablocks: OrigDatablock[]) => fromActions.fetchOrigDatablocksCompleteAction({ origdatablocks }), @@ -178,8 +183,8 @@ export class DatasetEffects { return this.actions$.pipe( ofType(fromActions.fetchAttachmentsAction), switchMap(({ pid, filters }) => { - return this.datasetApi - .getAttachments(encodeURIComponent(pid), filters) + return this.datasetsService + .datasetsControllerFindAllAttachments(pid, filters) .pipe( map((attachments: Attachment[]) => fromActions.fetchAttachmentsCompleteAction({ attachments }), @@ -197,8 +202,8 @@ export class DatasetEffects { this.currentDataset$, this.relatedDatasetsFilters$, ]), - switchMap(([_, dataset, filters]) => { - const queryFilter: LoopBackFilter = { + switchMap(([, dataset, filters]) => { + const queryFilter = { where: {}, limits: { skip: filters.skip, @@ -214,15 +219,21 @@ export class DatasetEffects { } if (dataset.type === "derived") { queryFilter.where = { - pid: { $in: (dataset as unknown as DerivedDataset).inputDatasets }, + pid: { $in: dataset.inputDatasets }, }; } - return this.datasetApi.find(queryFilter).pipe( - map((relatedDatasets: Dataset[]) => - fromActions.fetchRelatedDatasetsCompleteAction({ relatedDatasets }), - ), - catchError(() => of(fromActions.fetchRelatedDatasetsFailedAction())), - ); + return this.datasetsService + .datasetsControllerFindAll(JSON.stringify(queryFilter)) + .pipe( + map((relatedDatasets) => + fromActions.fetchRelatedDatasetsCompleteAction({ + relatedDatasets, + }), + ), + catchError(() => + of(fromActions.fetchRelatedDatasetsFailedAction()), + ), + ); }), ); }); @@ -231,8 +242,8 @@ export class DatasetEffects { return this.actions$.pipe( ofType(fromActions.fetchRelatedDatasetsAction), concatLatestFrom(() => [this.currentDataset$]), - switchMap(([_, dataset]) => { - const queryFilter: LoopBackFilter = { + switchMap(([, dataset]) => { + const queryFilter = { where: {}, }; if (dataset.type === "raw") { @@ -243,19 +254,21 @@ export class DatasetEffects { } if (dataset.type === "derived") { queryFilter.where = { - pid: { $in: (dataset as unknown as DerivedDataset).inputDatasets }, + pid: { $in: dataset.inputDatasets }, }; } - return this.datasetApi.count(queryFilter).pipe( - map(({ count }) => - fromActions.fetchRelatedDatasetsCountCompleteAction({ - count, - }), - ), - catchError(() => - of(fromActions.fetchRelatedDatasetsCountFailedAction()), - ), - ); + return this.datasetsService + .datasetsControllerCount(JSON.stringify(queryFilter)) + .pipe( + map(({ count }) => + fromActions.fetchRelatedDatasetsCountCompleteAction({ + count, + }), + ), + catchError(() => + of(fromActions.fetchRelatedDatasetsCountFailedAction()), + ), + ); }), ); }); @@ -264,9 +277,11 @@ export class DatasetEffects { return this.actions$.pipe( ofType(fromActions.addDatasetAction), mergeMap(({ dataset }) => - this.datasetApi.create(dataset).pipe( + this.datasetsService.datasetsControllerCreate(dataset).pipe( mergeMap((res) => [ - fromActions.addDatasetCompleteAction({ dataset: res }), + fromActions.addDatasetCompleteAction({ + dataset: res, + }), fromActions.fetchDatasetsAction(), fromActions.fetchDatasetAction({ pid: res.pid }), ]), @@ -280,13 +295,15 @@ export class DatasetEffects { return this.actions$.pipe( ofType(fromActions.updatePropertyAction), switchMap(({ pid, property }) => - this.datasetApi.patchAttributes(encodeURIComponent(pid), property).pipe( - switchMap(() => [ - fromActions.updatePropertyCompleteAction(), - fromActions.fetchDatasetAction({ pid }), - ]), - catchError(() => of(fromActions.updatePropertyFailedAction())), - ), + this.datasetsService + .datasetsControllerFindByIdAndUpdate(pid, property) + .pipe( + switchMap(() => [ + fromActions.updatePropertyCompleteAction(), + fromActions.fetchDatasetAction({ pid }), + ]), + catchError(() => of(fromActions.updatePropertyFailedAction())), + ), ), ); }); @@ -295,16 +312,12 @@ export class DatasetEffects { return this.actions$.pipe( ofType(fromActions.addAttachmentAction), switchMap(({ attachment }) => { - const { - id, - rawDatasetId, - derivedDatasetId, - proposalId, - sampleId, - ...theRest - } = attachment; - return this.datasetApi - .createAttachments(encodeURIComponent(theRest.datasetId!), theRest) + const { id, proposalId, sampleId, ...theRest } = attachment; + return this.datasetsService + .datasetsControllerCreateAttachment( + theRest.datasetId, + theRest as CreateAttachmentDto, + ) .pipe( map((res) => fromActions.addAttachmentCompleteAction({ attachment: res }), @@ -318,13 +331,13 @@ export class DatasetEffects { updateAttachmentCaption$ = createEffect(() => { return this.actions$.pipe( ofType(fromActions.updateAttachmentCaptionAction), - switchMap(({ datasetId, attachmentId, caption }) => { - const data = { caption }; - return this.datasetApi - .updateByIdAttachments( - encodeURIComponent(datasetId), - encodeURIComponent(attachmentId), - data, + switchMap(({ datasetId, attachmentId, caption, ownerGroup }) => { + const data = { caption, ownerGroup }; + return this.datasetsService + .datasetsControllerFindOneAttachmentAndUpdate( + datasetId, + attachmentId, + data as UpdateAttachmentDto, ) .pipe( map((attachment) => @@ -342,8 +355,8 @@ export class DatasetEffects { return this.actions$.pipe( ofType(fromActions.removeAttachmentAction), switchMap(({ datasetId, attachmentId }) => - this.datasetApi - .destroyByIdAttachments(encodeURIComponent(datasetId), attachmentId) + this.datasetsService + .datasetsControllerFindOneAttachmentAndRemove(datasetId, attachmentId) .pipe( map(() => fromActions.removeAttachmentCompleteAction({ attachmentId }), @@ -354,28 +367,18 @@ export class DatasetEffects { ); }); - reduceDataset$ = createEffect(() => { - return this.actions$.pipe( - ofType(fromActions.reduceDatasetAction), - mergeMap(({ dataset }) => - this.datasetApi.reduceDataset(dataset).pipe( - map((result) => fromActions.reduceDatasetCompleteAction({ result })), - catchError(() => of(fromActions.reduceDatasetFailedAction())), - ), - ), - ); - }); - appendToArrayField$ = createEffect(() => { return this.actions$.pipe( ofType(fromActions.appendToDatasetArrayFieldAction), mergeMap(({ pid, fieldName, data }) => - this.datasetApi.appendToArrayField(pid, fieldName, data).pipe( - map(() => fromActions.appendToDatasetArrayFieldCompleteAction()), - catchError(() => - of(fromActions.appendToDatasetArrayFieldFailedAction()), + this.datasetsService + .datasetsControllerAppendToArrayField(pid, fieldName, data) + .pipe( + map(() => fromActions.appendToDatasetArrayFieldCompleteAction()), + catchError(() => + of(fromActions.appendToDatasetArrayFieldFailedAction()), + ), ), - ), ), ); }); @@ -472,17 +475,17 @@ export class DatasetEffects { constructor( private actions$: Actions, - private datasetApi: DatasetApi, + private datasetsService: DatasetsService, private store: Store, ) {} - private storeBatch(batch: Dataset[], userId: string) { + private storeBatch(batch: OutputDatasetObsoleteDto[], userId: string) { const json = JSON.stringify(batch); localStorage.setItem("batch", json); localStorage.setItem("batchUser", userId); } - private retrieveBatch(ofUserId: string): Dataset[] { + private retrieveBatch(ofUserId: string): OutputDatasetObsoleteDto[] { const json = localStorage.getItem("batch"); const userId = localStorage.getItem("batchUser"); diff --git a/src/app/state-management/effects/instruments.effects.spec.ts b/src/app/state-management/effects/instruments.effects.spec.ts index 4393c9a95..8c392f1b9 100644 --- a/src/app/state-management/effects/instruments.effects.spec.ts +++ b/src/app/state-management/effects/instruments.effects.spec.ts @@ -1,6 +1,5 @@ -import { Observable } from "rxjs"; import { InstrumentEffects } from "./instruments.effects"; -import { InstrumentApi, Instrument } from "shared/sdk"; +import { InstrumentsService } from "@scicatproject/scicat-sdk-ts"; import { TestBed } from "@angular/core/testing"; import { provideMockActions } from "@ngrx/effects/testing"; import * as fromActions from "state-management/actions/instruments.actions"; @@ -12,11 +11,15 @@ import { loadingCompleteAction, } from "state-management/actions/user.actions"; import { Type } from "@angular/core"; +import { TestObservable } from "jasmine-marbles/src/test-observables"; +import { mockInstrument as instrument } from "shared/MockStubs"; describe("InstrumentEffects", () => { - let actions: Observable; + let actions: TestObservable; let effects: InstrumentEffects; - let instrumentApi: jasmine.SpyObj; + let instrumentApi: jasmine.SpyObj; + + const instruments = [instrument]; beforeEach(() => { TestBed.configureTestingModule({ @@ -32,18 +35,18 @@ describe("InstrumentEffects", () => { ], }), { - provide: InstrumentApi, + provide: InstrumentsService, useValue: jasmine.createSpyObj("instrumentApi", [ - "find", - "findById", - "patchAttributes", + "instrumentsControllerFindAll", + "instrumentsControllerFindById", + "instrumentsControllerUpdate", ]), }, ], }); effects = TestBed.inject(InstrumentEffects); - instrumentApi = injectedStub(InstrumentApi); + instrumentApi = injectedStub(InstrumentsService); }); const injectedStub = (service: Type): jasmine.SpyObj => @@ -52,7 +55,6 @@ describe("InstrumentEffects", () => { describe("fetchInstruments$", () => { describe("ofType fetchInstrumentAction", () => { it("should result in a fetchInstrumentsCompleteAction and a fetchCountAction", () => { - const instruments = [new Instrument()]; const action = fromActions.fetchInstrumentsAction(); const outcome1 = fromActions.fetchInstrumentsCompleteAction({ instruments, @@ -61,7 +63,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: instruments }); - instrumentApi.find.and.returnValue(response); + instrumentApi.instrumentsControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchInstruments$).toBeObservable(expected); @@ -73,7 +75,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - instrumentApi.find.and.returnValue(response); + instrumentApi.instrumentsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchInstruments$).toBeObservable(expected); @@ -85,7 +87,6 @@ describe("InstrumentEffects", () => { const limit = 25; it("should result in a fetchInstrumentsCompleteAction and a fetchCountAction", () => { - const instruments = [new Instrument()]; const action = fromActions.changePageAction({ page, limit }); const outcome1 = fromActions.fetchInstrumentsCompleteAction({ instruments, @@ -94,7 +95,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: instruments }); - instrumentApi.find.and.returnValue(response); + instrumentApi.instrumentsControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchInstruments$).toBeObservable(expected); @@ -106,7 +107,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - instrumentApi.find.and.returnValue(response); + instrumentApi.instrumentsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchInstruments$).toBeObservable(expected); @@ -117,7 +118,6 @@ describe("InstrumentEffects", () => { const limit = 25; it("should result in a fetchInstrumentsCompleteAction and a fetchCountAction", () => { - const instruments = [new Instrument()]; const action = fromActions.changePageAction({ page, limit }); const outcome1 = fromActions.fetchInstrumentsCompleteAction({ instruments, @@ -126,7 +126,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: instruments }); - instrumentApi.find.and.returnValue(response); + instrumentApi.instrumentsControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchInstruments$).toBeObservable(expected); @@ -138,7 +138,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - instrumentApi.find.and.returnValue(response); + instrumentApi.instrumentsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchInstruments$).toBeObservable(expected); @@ -150,7 +150,6 @@ describe("InstrumentEffects", () => { const direction = "asc"; it("should result in a fetchInstrumentsCompleteAction and a fetchCountAction", () => { - const instruments = [new Instrument()]; const action = fromActions.sortByColumnAction({ column, direction }); const outcome1 = fromActions.fetchInstrumentsCompleteAction({ instruments, @@ -159,7 +158,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: instruments }); - instrumentApi.find.and.returnValue(response); + instrumentApi.instrumentsControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchInstruments$).toBeObservable(expected); @@ -171,7 +170,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - instrumentApi.find.and.returnValue(response); + instrumentApi.instrumentsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchInstruments$).toBeObservable(expected); @@ -181,7 +180,6 @@ describe("InstrumentEffects", () => { describe("fetchCount$", () => { it("should result in a fetchCountCompleteAction", () => { - const instruments = [new Instrument()]; const action = fromActions.fetchCountAction(); const outcome = fromActions.fetchCountCompleteAction({ count: instruments.length, @@ -189,7 +187,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: instruments }); - instrumentApi.find.and.returnValue(response); + instrumentApi.instrumentsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); @@ -201,7 +199,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - instrumentApi.find.and.returnValue(response); + instrumentApi.instrumentsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); @@ -212,13 +210,12 @@ describe("InstrumentEffects", () => { const pid = "testPid"; it("should result in a fetchInstrumentCompleteAction", () => { - const instrument = new Instrument(); const action = fromActions.fetchInstrumentAction({ pid }); const outcome = fromActions.fetchInstrumentCompleteAction({ instrument }); actions = hot("-a", { a: action }); const response = cold("-a|", { a: instrument }); - instrumentApi.findById.and.returnValue(response); + instrumentApi.instrumentsControllerFindById.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchInstrument$).toBeObservable(expected); @@ -230,7 +227,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - instrumentApi.findById.and.returnValue(response); + instrumentApi.instrumentsControllerFindById.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchInstrument$).toBeObservable(expected); @@ -242,7 +239,6 @@ describe("InstrumentEffects", () => { const customMetadata = {}; it("should result in a saveCustomMetadataCompleteAction", () => { - const instrument = new Instrument(); const action = fromActions.saveCustomMetadataAction({ pid, customMetadata, @@ -253,7 +249,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: instrument }); - instrumentApi.patchAttributes.and.returnValue(response); + instrumentApi.instrumentsControllerUpdate.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.saveCustomMetadata$).toBeObservable(expected); @@ -268,7 +264,7 @@ describe("InstrumentEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - instrumentApi.patchAttributes.and.returnValue(response); + instrumentApi.instrumentsControllerUpdate.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.saveCustomMetadata$).toBeObservable(expected); @@ -334,7 +330,6 @@ describe("InstrumentEffects", () => { describe("loadingComplete$", () => { describe("ofType fetchInstrumentsCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const instruments = [new Instrument()]; const action = fromActions.fetchInstrumentsCompleteAction({ instruments, }); @@ -386,7 +381,6 @@ describe("InstrumentEffects", () => { describe("ofType fetchInstrumentCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const instrument = new Instrument(); const action = fromActions.fetchInstrumentCompleteAction({ instrument, }); @@ -413,7 +407,6 @@ describe("InstrumentEffects", () => { describe("ofType saveCustomMetadataCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const instrument = new Instrument(); const action = fromActions.saveCustomMetadataCompleteAction({ instrument, }); diff --git a/src/app/state-management/effects/instruments.effects.ts b/src/app/state-management/effects/instruments.effects.ts index 565e5bb26..292350d41 100644 --- a/src/app/state-management/effects/instruments.effects.ts +++ b/src/app/state-management/effects/instruments.effects.ts @@ -1,6 +1,6 @@ import { Injectable } from "@angular/core"; import { Actions, createEffect, ofType, concatLatestFrom } from "@ngrx/effects"; -import { InstrumentApi, Instrument } from "shared/sdk"; +import { Instrument, InstrumentsService } from "@scicatproject/scicat-sdk-ts"; import * as fromActions from "state-management/actions/instruments.actions"; import { switchMap, map, catchError, mergeMap } from "rxjs/operators"; import { of } from "rxjs"; @@ -25,13 +25,15 @@ export class InstrumentEffects { concatLatestFrom(() => this.filters$), map(([action, filters]) => filters), switchMap(({ sortField: order, skip, limit }) => - this.instrumentApi.find({ order, limit, skip }).pipe( - mergeMap((instruments: Instrument[]) => [ - fromActions.fetchInstrumentsCompleteAction({ instruments }), - fromActions.fetchCountAction(), - ]), - catchError(() => of(fromActions.fetchInstrumentsFailedAction())), - ), + this.instrumentsService + .instrumentsControllerFindAll(JSON.stringify({ order, limit, skip })) + .pipe( + mergeMap((instruments: Instrument[]) => [ + fromActions.fetchInstrumentsCompleteAction({ instruments }), + fromActions.fetchCountAction(), + ]), + catchError(() => of(fromActions.fetchInstrumentsFailedAction())), + ), ), ); }); @@ -40,8 +42,8 @@ export class InstrumentEffects { return this.actions$.pipe( ofType(fromActions.fetchCountAction), switchMap(() => - this.instrumentApi.find().pipe( - map((instruments) => + this.instrumentsService.instrumentsControllerFindAll().pipe( + map((instruments: Instrument[]) => fromActions.fetchCountCompleteAction({ count: instruments.length }), ), catchError(() => of(fromActions.fetchCountFailedAction())), @@ -54,7 +56,7 @@ export class InstrumentEffects { return this.actions$.pipe( ofType(fromActions.fetchInstrumentAction), switchMap(({ pid }) => - this.instrumentApi.findById(encodeURIComponent(pid)).pipe( + this.instrumentsService.instrumentsControllerFindById(pid).pipe( map((instrument: Instrument) => fromActions.fetchInstrumentCompleteAction({ instrument }), ), @@ -68,8 +70,10 @@ export class InstrumentEffects { return this.actions$.pipe( ofType(fromActions.saveCustomMetadataAction), switchMap(({ pid, customMetadata }) => - this.instrumentApi - .patchAttributes(encodeURIComponent(pid), { customMetadata }) + this.instrumentsService + .instrumentsControllerUpdate(pid, { + customMetadata, + }) .pipe( map((instrument: Instrument) => fromActions.saveCustomMetadataCompleteAction({ instrument }), @@ -110,7 +114,7 @@ export class InstrumentEffects { constructor( private actions$: Actions, - private instrumentApi: InstrumentApi, + private instrumentsService: InstrumentsService, private store: Store, ) {} } diff --git a/src/app/state-management/effects/jobs.effects.spec.ts b/src/app/state-management/effects/jobs.effects.spec.ts index c67d08655..139074016 100644 --- a/src/app/state-management/effects/jobs.effects.spec.ts +++ b/src/app/state-management/effects/jobs.effects.spec.ts @@ -1,5 +1,3 @@ -import { JobInterface, Job, JobApi } from "shared/sdk"; -import { Observable } from "rxjs"; import { JobEffects } from "./jobs.effects"; import { TestBed } from "@angular/core/testing"; import { provideMockActions } from "@ngrx/effects/testing"; @@ -15,19 +13,32 @@ import { } from "state-management/actions/user.actions"; import { MessageType } from "state-management/models"; import { Type } from "@angular/core"; - -const data: JobInterface = { +import { + CreateJobDto, + JobClass, + JobsService, +} from "@scicatproject/scicat-sdk-ts"; +import { TestObservable } from "jasmine-marbles/src/test-observables"; +import { createMock } from "shared/MockStubs"; + +const job = createMock({ + _id: "testId", id: "testId", emailJobInitiator: "test@email.com", type: "archive", - datasetList: {}, -}; -const job = new Job(data); + datasetList: [], + creationTime: "", + executionTime: "", + jobParams: {}, + jobResultObject: {}, + jobStatusMessage: "", + ownerGroup: "", +}); describe("JobEffects", () => { - let actions: Observable; + let actions: TestObservable; let effects: JobEffects; - let jobApi: jasmine.SpyObj; + let jobApi: jasmine.SpyObj; beforeEach(() => { TestBed.configureTestingModule({ @@ -38,19 +49,18 @@ describe("JobEffects", () => { selectors: [{ selector: selectQueryParams, value: {} }], }), { - provide: JobApi, + provide: JobsService, useValue: jasmine.createSpyObj("jobApi", [ - "find", - "count", - "findById", - "create", + "jobsControllerFindAll", + "jobsControllerFindOne", + "jobsControllerCreate", ]), }, ], }); effects = TestBed.inject(JobEffects); - jobApi = injectedStub(JobApi); + jobApi = injectedStub(JobsService); }); const injectedStub = (service: Type): jasmine.SpyObj => @@ -66,7 +76,7 @@ describe("JobEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: jobs }); - jobApi.find.and.returnValue(response); + jobApi.jobsControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchJobs$).toBeObservable(expected); @@ -78,7 +88,7 @@ describe("JobEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - jobApi.find.and.returnValue(response); + jobApi.jobsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchJobs$).toBeObservable(expected); @@ -97,7 +107,7 @@ describe("JobEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: jobs }); - jobApi.find.and.returnValue(response); + jobApi.jobsControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchJobs$).toBeObservable(expected); @@ -109,7 +119,7 @@ describe("JobEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - jobApi.find.and.returnValue(response); + jobApi.jobsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchJobs$).toBeObservable(expected); @@ -128,7 +138,7 @@ describe("JobEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: jobs }); - jobApi.find.and.returnValue(response); + jobApi.jobsControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchJobs$).toBeObservable(expected); @@ -140,7 +150,7 @@ describe("JobEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - jobApi.find.and.returnValue(response); + jobApi.jobsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchJobs$).toBeObservable(expected); @@ -158,7 +168,7 @@ describe("JobEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: jobs }); - jobApi.find.and.returnValue(response); + jobApi.jobsControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchJobs$).toBeObservable(expected); @@ -170,7 +180,7 @@ describe("JobEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - jobApi.find.and.returnValue(response); + jobApi.jobsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchJobs$).toBeObservable(expected); @@ -178,33 +188,6 @@ describe("JobEffects", () => { }); }); - describe("fetchCount$", () => { - it("should result in a fetchCountCompleteAction", () => { - const count = 100; - const action = fromActions.fetchCountAction(); - const outcome = fromActions.fetchCountCompleteAction({ count }); - - actions = hot("-a", { a: action }); - const response = cold("-a|", { a: { count } }); - jobApi.count.and.returnValue(response); - - const expected = cold("--b", { b: outcome }); - expect(effects.fetchCount$).toBeObservable(expected); - }); - - it("should result in a fetchCountFailedAction", () => { - const action = fromActions.fetchCountAction(); - const outcome = fromActions.fetchCountFailedAction(); - - actions = hot("-a", { a: action }); - const response = cold("-#", {}); - jobApi.count.and.returnValue(response); - - const expected = cold("--b", { b: outcome }); - expect(effects.fetchCount$).toBeObservable(expected); - }); - }); - describe("updateUserJobsLimit$", () => { it("should result in an updateUserSettingsAction", () => { const page = 0; @@ -229,7 +212,7 @@ describe("JobEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: job }); - jobApi.findById.and.returnValue(response); + jobApi.jobsControllerFindOne.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchJob$).toBeObservable(expected); @@ -241,7 +224,7 @@ describe("JobEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - jobApi.findById.and.returnValue(response); + jobApi.jobsControllerFindOne.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchJob$).toBeObservable(expected); @@ -250,12 +233,12 @@ describe("JobEffects", () => { describe("submitJob$", () => { it("should result in a submitJobCompleteAction", () => { - const action = fromActions.submitJobAction({ job }); + const action = fromActions.submitJobAction({ job: job as CreateJobDto }); const outcome = fromActions.submitJobCompleteAction({ job }); actions = hot("-a", { a: action }); const response = cold("-a|", { a: job }); - jobApi.create.and.returnValue(response); + jobApi.jobsControllerCreate.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.submitJob$).toBeObservable(expected); @@ -337,7 +320,9 @@ describe("JobEffects", () => { describe("ofType submitJobAction", () => { it("should dispatch a loadingAction", () => { - const action = fromActions.submitJobAction({ job }); + const action = fromActions.submitJobAction({ + job: job as CreateJobDto, + }); const outcome = loadingAction(); actions = hot("-a", { a: action }); diff --git a/src/app/state-management/effects/jobs.effects.ts b/src/app/state-management/effects/jobs.effects.ts index a1f8ffbad..e1e32fb2f 100644 --- a/src/app/state-management/effects/jobs.effects.ts +++ b/src/app/state-management/effects/jobs.effects.ts @@ -1,6 +1,10 @@ import { Injectable } from "@angular/core"; import { Actions, createEffect, ofType, concatLatestFrom } from "@ngrx/effects"; -import { JobApi, Job } from "shared/sdk"; +import { + CreateJobDto, + JobClass, + JobsService, +} from "@scicatproject/scicat-sdk-ts"; import { Store } from "@ngrx/store"; import { selectQueryParams } from "state-management/selectors/jobs.selectors"; import * as fromActions from "state-management/actions/jobs.actions"; @@ -29,8 +33,8 @@ export class JobEffects { concatLatestFrom(() => this.queryParams$), map(([action, params]) => params), switchMap((params) => - this.jobApi.find(params).pipe( - switchMap((jobs: Job[]) => [ + this.jobsService.jobsControllerFindAll(JSON.stringify(params)).pipe( + switchMap((jobs) => [ fromActions.fetchJobsCompleteAction({ jobs }), fromActions.fetchCountAction(), ]), @@ -40,22 +44,6 @@ export class JobEffects { ); }); - fetchCount$ = createEffect(() => { - return this.actions$.pipe( - ofType(fromActions.fetchCountAction), - concatLatestFrom(() => this.queryParams$), - map(([action, params]) => params), - switchMap(({ where }) => - this.jobApi.count(where).pipe( - map((res) => - fromActions.fetchCountCompleteAction({ count: res.count }), - ), - catchError(() => of(fromActions.fetchCountFailedAction())), - ), - ), - ); - }); - updateUserJobsLimit$ = createEffect(() => { return this.actions$.pipe( ofType(fromActions.changePageAction), @@ -69,8 +57,8 @@ export class JobEffects { return this.actions$.pipe( ofType(fromActions.fetchJobAction), switchMap(({ jobId }) => - this.jobApi.findById(jobId).pipe( - map((job: Job) => fromActions.fetchJobCompleteAction({ job })), + this.jobsService.jobsControllerFindOne(jobId).pipe( + map((job: JobClass) => fromActions.fetchJobCompleteAction({ job })), catchError(() => of(fromActions.fetchJobFailedAction())), ), ), @@ -81,7 +69,7 @@ export class JobEffects { return this.actions$.pipe( ofType(fromActions.submitJobAction), switchMap(({ job }) => - this.jobApi.create(job).pipe( + this.jobsService.jobsControllerCreate(job).pipe( map((res) => fromActions.submitJobCompleteAction({ job: res })), catchError((err) => of(fromActions.submitJobFailedAction({ err }))), ), @@ -146,7 +134,7 @@ export class JobEffects { constructor( private actions$: Actions, - private jobApi: JobApi, + private jobsService: JobsService, private store: Store, ) {} } diff --git a/src/app/state-management/effects/logbooks.effects.spec.ts b/src/app/state-management/effects/logbooks.effects.spec.ts index d81e5b463..6c041bdd3 100644 --- a/src/app/state-management/effects/logbooks.effects.spec.ts +++ b/src/app/state-management/effects/logbooks.effects.spec.ts @@ -1,9 +1,8 @@ import { TestBed } from "@angular/core/testing"; import { provideMockActions } from "@ngrx/effects/testing"; import { hot, cold } from "jasmine-marbles"; -import { Observable } from "rxjs"; import { LogbookEffects } from "./logbooks.effects"; -import { LogbookApi, Logbook } from "shared/sdk"; +import { Logbook, LogbooksService } from "@scicatproject/scicat-sdk-ts"; import * as fromActions from "state-management/actions/logbooks.actions"; import { loadingAction, @@ -12,20 +11,24 @@ import { import { provideMockStore } from "@ngrx/store/testing"; import { selectFilters } from "state-management/selectors/logbooks.selectors"; import { Type } from "@angular/core"; +import { TestObservable } from "jasmine-marbles/src/test-observables"; +import { createMock } from "shared/MockStubs"; +import { HttpClientTestingModule } from "@angular/common/http/testing"; -const logbook: Logbook = { +const logbook = createMock({ name: "test", roomId: "!test@site", messages: [], -}; +}); describe("LogbookEffects", () => { - let actions: Observable; + let actions: TestObservable; let effects: LogbookEffects; - let logbookApi: jasmine.SpyObj; + let logbookApi: jasmine.SpyObj; beforeEach(() => { TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], providers: [ LogbookEffects, provideMockActions(() => actions), @@ -43,14 +46,17 @@ describe("LogbookEffects", () => { ], }), { - provide: LogbookApi, - useValue: jasmine.createSpyObj("logbookApi", ["find", "findByName"]), + provide: LogbooksService, + useValue: jasmine.createSpyObj("logbookApi", [ + "logbooksControllerFindAll", + "logbooksControllerFindByName", + ]), }, ], }); effects = TestBed.inject(LogbookEffects); - logbookApi = injectedStub(LogbookApi); + logbookApi = injectedStub(LogbooksService); }); const injectedStub = (service: Type): jasmine.SpyObj => @@ -64,7 +70,7 @@ describe("LogbookEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: logbooks }); - logbookApi.find.and.returnValue(response); + logbookApi.logbooksControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchLogbooks$).toBeObservable(expected); @@ -76,7 +82,7 @@ describe("LogbookEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - logbookApi.find.and.returnValue(response); + logbookApi.logbooksControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchLogbooks$).toBeObservable(expected); @@ -93,7 +99,7 @@ describe("LogbookEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: logbook }); - logbookApi.findByName.and.returnValue(response); + logbookApi.logbooksControllerFindByName.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchLogbook$).toBeObservable(expected); @@ -105,7 +111,7 @@ describe("LogbookEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - logbookApi.findByName.and.returnValue(response); + logbookApi.logbooksControllerFindByName.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchLogbook$).toBeObservable(expected); @@ -121,7 +127,7 @@ describe("LogbookEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: logbook }); - logbookApi.findByName.and.returnValue(response); + logbookApi.logbooksControllerFindByName.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); @@ -133,7 +139,7 @@ describe("LogbookEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - logbookApi.findByName.and.returnValue(response); + logbookApi.logbooksControllerFindByName.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); diff --git a/src/app/state-management/effects/logbooks.effects.ts b/src/app/state-management/effects/logbooks.effects.ts index 806a81b5e..e23bd906d 100644 --- a/src/app/state-management/effects/logbooks.effects.ts +++ b/src/app/state-management/effects/logbooks.effects.ts @@ -1,6 +1,10 @@ import { Injectable } from "@angular/core"; import { createEffect, Actions, ofType, concatLatestFrom } from "@ngrx/effects"; -import { LogbookApi, Logbook } from "shared/sdk"; +import { + DatasetsService, + Logbook, + LogbooksService, +} from "@scicatproject/scicat-sdk-ts"; import * as fromActions from "state-management/actions/logbooks.actions"; import { mergeMap, catchError, map, timeout } from "rxjs/operators"; import { of } from "rxjs"; @@ -20,7 +24,7 @@ export class LogbookEffects { return this.actions$.pipe( ofType(fromActions.fetchLogbooksAction), mergeMap(() => - this.logbookApi.find().pipe( + this.logbooksService.logbooksControllerFindAll().pipe( map((logbooks: Logbook[]) => fromActions.fetchLogbooksCompleteAction({ logbooks }), ), @@ -35,11 +39,11 @@ export class LogbookEffects { ofType(fromActions.fetchLogbookAction), concatLatestFrom(() => this.filters$), mergeMap(([{ name }, filters]) => { - return this.logbookApi - .findByName(encodeURIComponent(name), JSON.stringify(filters)) + return this.logbooksService + .logbooksControllerFindByName(name, JSON.stringify(filters)) .pipe( timeout(3000), - mergeMap((logbook) => [ + mergeMap((logbook: Logbook) => [ fromActions.fetchLogbookCompleteAction({ logbook }), fromActions.fetchCountAction({ name }), ]), @@ -54,8 +58,8 @@ export class LogbookEffects { ofType(fromActions.fetchDatasetLogbookAction), concatLatestFrom(() => this.filters$), mergeMap(([{ pid }, filters]) => - this.logbookApi - .findDatasetLogbook(encodeURIComponent(pid), JSON.stringify(filters)) + this.datasetsService + .datasetsControllerFindLogbookByPid(pid, JSON.stringify(filters)) .pipe( timeout(3000), mergeMap((logbook) => [ @@ -76,12 +80,12 @@ export class LogbookEffects { const { skip, limit, sortField, ...theRest } = filters; return ( name - ? this.logbookApi.findByName( - encodeURIComponent(name), + ? this.logbooksService.logbooksControllerFindByName( + name, JSON.stringify(theRest), ) - : this.logbookApi.findDatasetLogbook( - encodeURIComponent(pid), + : this.datasetsService.datasetsControllerFindLogbookByPid( + pid, JSON.stringify(theRest), ) ).pipe( @@ -123,7 +127,8 @@ export class LogbookEffects { constructor( private actions$: Actions, - private logbookApi: LogbookApi, + private logbooksService: LogbooksService, + private datasetsService: DatasetsService, private store: Store, ) {} } diff --git a/src/app/state-management/effects/policies.effects.spec.ts b/src/app/state-management/effects/policies.effects.spec.ts index 4cc682368..8b7dfe92c 100644 --- a/src/app/state-management/effects/policies.effects.spec.ts +++ b/src/app/state-management/effects/policies.effects.spec.ts @@ -1,6 +1,4 @@ -import { Observable } from "rxjs"; import { PolicyEffects } from "./policies.effects"; -import { PolicyApi, PolicyInterface, Policy } from "shared/sdk"; import { TestBed } from "@angular/core/testing"; import { provideMockActions } from "@ngrx/effects/testing"; import { provideMockStore } from "@ngrx/store/testing"; @@ -16,17 +14,35 @@ import { loadingCompleteAction, } from "state-management/actions/user.actions"; import { Type } from "@angular/core"; - -const data: PolicyInterface = { - id: "testId", - ownerGroup: "testGroup", -}; -const policy = new Policy(data); +import { PoliciesService, Policy } from "@scicatproject/scicat-sdk-ts"; +import { TestObservable } from "jasmine-marbles/src/test-observables"; +import { createMock } from "shared/MockStubs"; + +const policy = createMock({ + manager: ["adminIngestor"], + tapeRedundancy: "low", + autoArchiveDelay: 7, + archiveEmailNotification: false, + archiveEmailsToBeNotified: [], + retrieveEmailNotification: false, + retrieveEmailsToBeNotified: [], + ownerGroup: "", + accessGroups: [], + _id: "", + autoArchive: false, + createdAt: "", + createdBy: "", + embargoPeriod: 0, + isPublished: false, + updatedAt: "", + updatedBy: "", + instrumentGroup: "", +}); describe("PolicyEffects", () => { - let actions: Observable; + let actions: TestObservable; let effects: PolicyEffects; - let policyApi: jasmine.SpyObj; + let policyApi: jasmine.SpyObj; beforeEach(() => { TestBed.configureTestingModule({ @@ -41,18 +57,18 @@ describe("PolicyEffects", () => { ], }), { - provide: PolicyApi, + provide: PoliciesService, useValue: jasmine.createSpyObj("policyApi", [ - "find", - "count", - "updatewhere", + "policiesControllerFindAll", + "policiesControllerCount", + "policiesControllerUpdateWhere", ]), }, ], }); effects = TestBed.inject(PolicyEffects); - policyApi = injectedStub(PolicyApi); + policyApi = injectedStub(PoliciesService); }); const injectedStub = (service: Type): jasmine.SpyObj => @@ -69,7 +85,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: policies }); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--(bcd)", { b: outcome1, @@ -85,7 +101,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchPolicies$).toBeObservable(expected); @@ -104,7 +120,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: policies }); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--(bcd)", { b: outcome1, @@ -122,7 +138,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchPolicies$).toBeObservable(expected); @@ -141,7 +157,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: policies }); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--(bcd)", { b: outcome1, @@ -159,7 +175,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchPolicies$).toBeObservable(expected); @@ -175,7 +191,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: { count } }); - policyApi.count.and.returnValue(response); + policyApi.policiesControllerCount.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); @@ -187,7 +203,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - policyApi.count.and.returnValue(response); + policyApi.policiesControllerCount.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); @@ -206,7 +222,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: policies }); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchEditablePolicies$).toBeObservable(expected); @@ -218,7 +234,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchEditablePolicies$).toBeObservable(expected); @@ -238,7 +254,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: policies }); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchEditablePolicies$).toBeObservable(expected); @@ -252,7 +268,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchEditablePolicies$).toBeObservable(expected); @@ -275,7 +291,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: policies }); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchEditablePolicies$).toBeObservable(expected); @@ -292,7 +308,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - policyApi.find.and.returnValue(response); + policyApi.policiesControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchEditablePolicies$).toBeObservable(expected); @@ -308,7 +324,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: { count } }); - policyApi.count.and.returnValue(response); + policyApi.policiesControllerCount.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchEditableCount$).toBeObservable(expected); @@ -320,7 +336,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - policyApi.count.and.returnValue(response); + policyApi.policiesControllerCount.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchEditableCount$).toBeObservable(expected); @@ -336,7 +352,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: { submissionResponse: policy } }); - policyApi.updatewhere.and.returnValue(response); + policyApi.policiesControllerUpdateWhere.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.submitPolicy$).toBeObservable(expected); @@ -349,7 +365,7 @@ describe("PolicyEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - policyApi.updatewhere.and.returnValue(response); + policyApi.policiesControllerUpdateWhere.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.submitPolicy$).toBeObservable(expected); @@ -420,19 +436,6 @@ describe("PolicyEffects", () => { }); describe("loadingComplete$", () => { - /*describe("ofType fetchPoliciesCompleteAction", () => { - it("should dispatch a loadingCompleteAction", () => { - const policies = [policy]; - const action = fromActions.fetchPoliciesCompleteAction({ policies }); - const outcome = loadingCompleteAction(); - - actions = hot("-a", { a: action }); - - const expected = cold("-b", { b: outcome }); - expect(effects.loadingComplete$).toBeObservable(expected); - }); - });*/ - describe("ofType fetchPoliciesFailedAction", () => { it("should dispatch a loadingCompleteAction", () => { const action = fromActions.fetchPoliciesFailedAction(); diff --git a/src/app/state-management/effects/policies.effects.ts b/src/app/state-management/effects/policies.effects.ts index 5e4798069..327ae3d20 100644 --- a/src/app/state-management/effects/policies.effects.ts +++ b/src/app/state-management/effects/policies.effects.ts @@ -1,6 +1,9 @@ import { Injectable } from "@angular/core"; import { Actions, createEffect, ofType, concatLatestFrom } from "@ngrx/effects"; -import { PolicyApi, Policy } from "shared/sdk"; +import { + PoliciesService, + UpdateWherePolicyDto, +} from "@scicatproject/scicat-sdk-ts"; import { Store } from "@ngrx/store"; import { selectQueryParams, @@ -37,8 +40,8 @@ export class PolicyEffects { concatLatestFrom(() => this.queryParams$), map(([action, params]) => params), switchMap((params) => - this.policyApi.find(params).pipe( - mergeMap((policies: Policy[]) => [ + this.policiesService.policiesControllerFindAll(params).pipe( + mergeMap((policies) => [ fromActions.fetchPoliciesCompleteAction({ policies }), fromActions.fetchCountAction(), fromActions.fetchEditablePoliciesAction(), @@ -53,7 +56,7 @@ export class PolicyEffects { return this.actions$.pipe( ofType(fromActions.fetchCountAction), switchMap(() => - this.policyApi.count().pipe( + this.policiesService.policiesControllerCount().pipe( map(({ count }) => fromActions.fetchCountCompleteAction({ count })), catchError(() => of(fromActions.fetchCountFailedAction())), ), @@ -79,8 +82,8 @@ export class PolicyEffects { const { order, skip, limit } = params; filter = { where: { manager: email }, order, skip, limit }; } - return this.policyApi.find(filter).pipe( - mergeMap((policies: Policy[]) => [ + return this.policiesService.policiesControllerFindAll(filter).pipe( + mergeMap((policies) => [ fromActions.fetchEditablePoliciesCompleteAction({ policies }), fromActions.fetchEditableCountAction(), ]), @@ -102,7 +105,7 @@ export class PolicyEffects { const email = profile.email.toLowerCase(); filter = { manager: email }; } - return this.policyApi.count(filter).pipe( + return this.policiesService.policiesControllerCount(filter).pipe( map(({ count }) => fromActions.fetchEditableCountCompleteAction({ count }), ), @@ -116,15 +119,20 @@ export class PolicyEffects { return this.actions$.pipe( ofType(fromActions.submitPolicyAction), switchMap(({ ownerList, policy }) => - this.policyApi.updatewhere(ownerList.join(), policy).pipe( - mergeMap(({ submissionResponse }) => [ - fromActions.submitPolicyCompleteAction({ - policy: submissionResponse, - }), - fromActions.fetchPoliciesAction(), - ]), - catchError(() => of(fromActions.submitPolicyFailedAction())), - ), + this.policiesService + .policiesControllerUpdateWhere({ + data: policy, + ownerGroupList: ownerList.join(), + }) + .pipe( + mergeMap(({ submissionResponse }) => [ + fromActions.submitPolicyCompleteAction({ + policy: submissionResponse, + }), + fromActions.fetchPoliciesAction(), + ]), + catchError(() => of(fromActions.submitPolicyFailedAction())), + ), ), ); }); @@ -160,7 +168,7 @@ export class PolicyEffects { constructor( private actions$: Actions, - private policyApi: PolicyApi, + private policiesService: PoliciesService, private store: Store, ) {} } diff --git a/src/app/state-management/effects/proposals.effects.spec.ts b/src/app/state-management/effects/proposals.effects.spec.ts index 66ac4f86c..adb49035b 100644 --- a/src/app/state-management/effects/proposals.effects.spec.ts +++ b/src/app/state-management/effects/proposals.effects.spec.ts @@ -1,12 +1,4 @@ -import { - ProposalInterface, - Proposal, - ProposalApi, - DatasetApi, - Dataset, - Attachment, -} from "shared/sdk"; -import { Observable, of, throwError } from "rxjs"; +import { of, throwError } from "rxjs"; import { ProposalEffects } from "./proposals.effects"; import { TestBed } from "@angular/core/testing"; import { provideMockStore } from "@ngrx/store/testing"; @@ -18,25 +10,42 @@ import { } from "state-management/selectors/proposals.selectors"; import * as fromActions from "state-management/actions/proposals.actions"; import { hot, cold } from "jasmine-marbles"; +import { Type } from "@angular/core"; +import { + DatasetsService, + ProposalClass, + ProposalsService, +} from "@scicatproject/scicat-sdk-ts"; +import { TestObservable } from "jasmine-marbles/src/test-observables"; +import { + createMock, + mockDataset as dataset, + mockAttachment as attachment, +} from "shared/MockStubs"; import { loadingAction, loadingCompleteAction, } from "state-management/actions/user.actions"; -import { Type } from "@angular/core"; -const data: ProposalInterface = { +const proposal = createMock({ proposalId: "testId", email: "testEmail", ownerGroup: "testGroup", - attachments: [], -}; -const proposal = new Proposal(data); + accessGroups: [], + createdAt: "", + createdBy: "", + isPublished: false, + title: "", + type: "", + updatedAt: "", + updatedBy: "", +}); describe("ProposalEffects", () => { - let actions: Observable; + let actions: TestObservable; let effects: ProposalEffects; - let proposalApi: jasmine.SpyObj; - let datasetApi: jasmine.SpyObj; + let proposalApi: jasmine.SpyObj; + let datasetApi: jasmine.SpyObj; beforeEach(() => { TestBed.configureTestingModule({ @@ -57,26 +66,29 @@ describe("ProposalEffects", () => { ], }), { - provide: ProposalApi, + provide: ProposalsService, useValue: jasmine.createSpyObj("proposalApi", [ - "fullquery", - "findById", - "findByIdAccess", - "createAttachments", - "updateByIdAttachments", - "destroyByIdAttachments", + "proposalsControllerFullquery", + "proposalsControllerFullfacet", + "proposalsControllerFindById", + "proposalsControllerFindByIdAccess", + "proposalsControllerCreateAttachment", + "proposalsControllerFindOneAttachmentAndUpdate", + "proposalsControllerFindOneAttachmentAndRemove", ]), }, { - provide: DatasetApi, - useValue: jasmine.createSpyObj("datasetApi", ["find"]), + provide: DatasetsService, + useValue: jasmine.createSpyObj("datasetApi", [ + "datasetsControllerFindAll", + ]), }, ], }); effects = TestBed.inject(ProposalEffects); - proposalApi = injectedStub(ProposalApi); - datasetApi = injectedStub(DatasetApi); + proposalApi = injectedStub(ProposalsService); + datasetApi = injectedStub(DatasetsService); }); const injectedStub = (service: Type): jasmine.SpyObj => @@ -94,7 +106,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: proposals }); - proposalApi.fullquery.and.returnValue(response); + proposalApi.proposalsControllerFullquery.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchProposals$).toBeObservable(expected); @@ -106,7 +118,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - proposalApi.fullquery.and.returnValue(response); + proposalApi.proposalsControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchProposals$).toBeObservable(expected); @@ -127,7 +139,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: proposals }); - proposalApi.fullquery.and.returnValue(response); + proposalApi.proposalsControllerFullquery.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchProposals$).toBeObservable(expected); @@ -139,7 +151,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - proposalApi.fullquery.and.returnValue(response); + proposalApi.proposalsControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchProposals$).toBeObservable(expected); @@ -160,7 +172,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: proposals }); - proposalApi.fullquery.and.returnValue(response); + proposalApi.proposalsControllerFullquery.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchProposals$).toBeObservable(expected); @@ -172,7 +184,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - proposalApi.fullquery.and.returnValue(response); + proposalApi.proposalsControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchProposals$).toBeObservable(expected); @@ -190,7 +202,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: proposals }); - proposalApi.fullquery.and.returnValue(response); + proposalApi.proposalsControllerFullquery.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchProposals$).toBeObservable(expected); @@ -202,7 +214,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - proposalApi.fullquery.and.returnValue(response); + proposalApi.proposalsControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchProposals$).toBeObservable(expected); @@ -218,21 +230,26 @@ describe("ProposalEffects", () => { count: proposals.length, }); + const responseArray = [ + { + all: [{ totalSets: proposals.length }], + }, + ]; actions = hot("-a", { a: action }); - const response = cold("-a|", { a: proposals }); - proposalApi.fullquery.and.returnValue(response); + const response = cold("-a|", { a: responseArray }); + proposalApi.proposalsControllerFullfacet.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); }); - it("should result in a fetchProposalsFailedAction", () => { + it("should result in a fetchCountFailedAction", () => { const action = fromActions.fetchCountAction(); const outcome = fromActions.fetchCountFailedAction(); actions = hot("-a", { a: action }); const response = cold("-#", {}); - proposalApi.fullquery.and.returnValue(response); + proposalApi.proposalsControllerFullfacet.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); @@ -242,20 +259,21 @@ describe("ProposalEffects", () => { describe("fetchProposal$", () => { const proposalId = "testId"; const permission = { - accepted: { canAccess: true }, - rejected: { canAccess: false }, + accepted: { canAccess: true } as any, + rejected: { canAccess: false } as any, }; + // TODO: For now the tests are passing but check the types and fix any types it("should result in a fetchProposalCompleteAction", () => { const action = fromActions.fetchProposalAction({ proposalId }); const outcome = fromActions.fetchProposalCompleteAction({ proposal }); - proposalApi.findByIdAccess + proposalApi.proposalsControllerFindByIdAccess .withArgs(proposalId) .and.returnValue(of(permission.accepted)); - proposalApi.findById + proposalApi.proposalsControllerFindById .withArgs(encodeURIComponent(proposalId)) - .and.returnValue(of(proposal)); + .and.returnValue(of(proposal as any)); actions = hot("a", { a: action }); const expected = cold("b", { b: outcome }); @@ -265,15 +283,17 @@ describe("ProposalEffects", () => { it("should result in a fetchProposalFailedAction", () => { const action = fromActions.fetchProposalAction({ proposalId }); - const failure = fromActions.fetchProposalFailedAction(); + const outcome = fromActions.fetchProposalFailedAction(); - proposalApi.findByIdAccess + proposalApi.proposalsControllerFindByIdAccess .withArgs(proposalId) .and.returnValue(of(permission.accepted)); - proposalApi.findById.and.returnValue(throwError(() => new Error())); + proposalApi.proposalsControllerFindById.and.returnValue( + throwError(() => new Error()), + ); actions = hot("a", { a: action }); - const expected = cold("b", { b: failure }); + const expected = cold("b", { b: outcome }); expect(effects.fetchProposal$).toBeObservable(expected); }); @@ -281,7 +301,7 @@ describe("ProposalEffects", () => { it("should do nothing if findByIdAccess returns false", () => { const action = fromActions.fetchProposalAction({ proposalId }); - proposalApi.findByIdAccess + proposalApi.proposalsControllerFindByIdAccess .withArgs(proposalId) .and.returnValue(of(permission.rejected)); @@ -289,22 +309,22 @@ describe("ProposalEffects", () => { const expected = cold("------"); expect(effects.fetchProposal$).toBeObservable(expected); - expect(proposalApi.findById).not.toHaveBeenCalled(); + expect(proposalApi.proposalsControllerFindById).not.toHaveBeenCalled(); }); it("should result in fetchProposalAccessFailedAction if findByIdAccess failed", () => { const action = fromActions.fetchProposalAction({ proposalId }); - const failure = fromActions.fetchProposalAccessFailedAction(); + const outcome = fromActions.fetchProposalAccessFailedAction(); - proposalApi.findByIdAccess + proposalApi.proposalsControllerFindByIdAccess .withArgs(proposalId) .and.returnValue(throwError(() => new Error())); actions = hot("a", { a: action }); - const expected = cold("b", { b: failure }); + const expected = cold("b", { b: outcome }); expect(effects.fetchProposal$).toBeObservable(expected); - expect(proposalApi.findById).not.toHaveBeenCalled(); + expect(proposalApi.proposalsControllerFindById).not.toHaveBeenCalled(); }); }); @@ -312,7 +332,7 @@ describe("ProposalEffects", () => { const proposalId = "testId"; it("should result in a fetchProposalDatasetsCompleteAction and a fetchProposalDatasetsCountAction", () => { - const datasets = [new Dataset()]; + const datasets = [dataset]; const action = fromActions.fetchProposalDatasetsAction({ proposalId }); const outcome1 = fromActions.fetchProposalDatasetsCompleteAction({ datasets, @@ -323,7 +343,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: datasets }); - datasetApi.find.and.returnValue(response); + datasetApi.datasetsControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchProposalDatasets$).toBeObservable(expected); @@ -335,7 +355,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.find.and.returnValue(response); + datasetApi.datasetsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchProposalDatasets$).toBeObservable(expected); @@ -346,7 +366,7 @@ describe("ProposalEffects", () => { const proposalId = "testId"; it("should result in a fetchProposalDatasetsCountCompleteAction", () => { - const datasets = [new Dataset()]; + const datasets = [dataset]; const count = 1; const action = fromActions.fetchProposalDatasetsCountAction({ proposalId, @@ -357,7 +377,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: datasets }); - datasetApi.find.and.returnValue(response); + datasetApi.datasetsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchProposalDatasetsCount$).toBeObservable(expected); @@ -371,7 +391,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.find.and.returnValue(response); + datasetApi.datasetsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchProposalDatasetsCount$).toBeObservable(expected); @@ -379,15 +399,13 @@ describe("ProposalEffects", () => { }); describe("addAttachment$", () => { - const attachment = new Attachment(); - it("should result in an addAttachmentCompleteAction", () => { const action = fromActions.addAttachmentAction({ attachment }); const outcome = fromActions.addAttachmentCompleteAction({ attachment }); actions = hot("-a", { a: action }); const response = cold("-a|", { a: attachment }); - proposalApi.createAttachments.and.returnValue(response); + proposalApi.proposalsControllerCreateAttachment.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.addAttachment$).toBeObservable(expected); @@ -399,7 +417,7 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - proposalApi.createAttachments.and.returnValue(response); + proposalApi.proposalsControllerCreateAttachment.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.addAttachment$).toBeObservable(expected); @@ -412,7 +430,6 @@ describe("ProposalEffects", () => { const caption = "test"; it("should result in an updateAttachmentCaptionCompleteAction", () => { - const attachment = new Attachment(); const action = fromActions.updateAttachmentCaptionAction({ proposalId, attachmentId, @@ -424,7 +441,9 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: attachment }); - proposalApi.updateByIdAttachments.and.returnValue(response); + proposalApi.proposalsControllerFindOneAttachmentAndUpdate.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.updateAttachmentCaption$).toBeObservable(expected); @@ -440,7 +459,9 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - proposalApi.updateByIdAttachments.and.returnValue(response); + proposalApi.proposalsControllerFindOneAttachmentAndUpdate.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.updateAttachmentCaption$).toBeObservable(expected); @@ -462,7 +483,9 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: attachmentId }); - proposalApi.destroyByIdAttachments.and.returnValue(response); + proposalApi.proposalsControllerFindOneAttachmentAndRemove.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.removeAttachment$).toBeObservable(expected); @@ -477,7 +500,9 @@ describe("ProposalEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - proposalApi.destroyByIdAttachments.and.returnValue(response); + proposalApi.proposalsControllerFindOneAttachmentAndRemove.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.removeAttachment$).toBeObservable(expected); @@ -552,7 +577,6 @@ describe("ProposalEffects", () => { describe("ofType addAttachmentAction", () => { it("should dispatch a loadingAction", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentAction({ attachment }); const outcome = loadingAction(); @@ -677,7 +701,7 @@ describe("ProposalEffects", () => { describe("ofType fetchProposalDatasetsCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const datasets = [new Dataset()]; + const datasets = [dataset]; const action = fromActions.fetchProposalDatasetsCompleteAction({ datasets, }); @@ -731,7 +755,6 @@ describe("ProposalEffects", () => { describe("ofType addAttachmentCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentCompleteAction({ attachment }); const outcome = loadingCompleteAction(); @@ -756,7 +779,6 @@ describe("ProposalEffects", () => { describe("ofType updateAttachmentCaptionCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const attachment = new Attachment(); const action = fromActions.updateAttachmentCaptionCompleteAction({ attachment, }); diff --git a/src/app/state-management/effects/proposals.effects.ts b/src/app/state-management/effects/proposals.effects.ts index 55fa5aeb9..216eae775 100644 --- a/src/app/state-management/effects/proposals.effects.ts +++ b/src/app/state-management/effects/proposals.effects.ts @@ -1,6 +1,10 @@ import { Injectable } from "@angular/core"; import { Actions, createEffect, ofType, concatLatestFrom } from "@ngrx/effects"; -import { DatasetApi, ProposalApi, Proposal, Dataset } from "shared/sdk"; +import { + DatasetsService, + ProposalClass, + ProposalsService, +} from "@scicatproject/scicat-sdk-ts"; import { Action, Store } from "@ngrx/store"; import * as fromActions from "state-management/actions/proposals.actions"; import { @@ -30,13 +34,15 @@ export class ProposalEffects { concatLatestFrom(() => this.fullqueryParams$), map(([action, params]) => params), mergeMap(({ query, limits }) => - this.proposalApi.fullquery(query, limits).pipe( - mergeMap((proposals) => [ - fromActions.fetchProposalsCompleteAction({ proposals }), - fromActions.fetchCountAction(), - ]), - catchError(() => of(fromActions.fetchProposalsFailedAction())), - ), + this.proposalsService + .proposalsControllerFullquery(JSON.stringify(limits), query) + .pipe( + mergeMap((proposals) => [ + fromActions.fetchProposalsCompleteAction({ proposals }), + fromActions.fetchCountAction(), + ]), + catchError(() => of(fromActions.fetchProposalsFailedAction())), + ), ), ); }); @@ -47,10 +53,13 @@ export class ProposalEffects { concatLatestFrom(() => this.fullqueryParams$), map(([action, params]) => params), switchMap(({ query }) => - this.proposalApi.fullquery(query).pipe( - map((proposals) => - fromActions.fetchCountCompleteAction({ count: proposals.length }), - ), + this.proposalsService.proposalsControllerFullfacet(query).pipe( + map((res) => { + const { all } = res[0]; + const allCounts = all && all.length > 0 ? all[0].totalSets : 0; + + return fromActions.fetchCountCompleteAction({ count: allCounts }); + }), catchError(() => of(fromActions.fetchCountFailedAction())), ), ), @@ -76,15 +85,17 @@ export class ProposalEffects { ofType(fromActions.fetchProposalDatasetsAction), concatLatestFrom(() => this.datasetQueryParams$), switchMap(([{ proposalId }, { limits }]) => - this.datasetApi - .find({ - where: { proposalId }, - skip: limits.skip, - limit: limits.limit, - order: limits.order, - }) + this.datasetsService + .datasetsControllerFindAll( + JSON.stringify({ + where: { proposalId }, + skip: limits.skip, + limit: limits.limit, + order: limits.order, + }), + ) .pipe( - mergeMap((datasets: Dataset[]) => [ + mergeMap((datasets) => [ fromActions.fetchProposalDatasetsCompleteAction({ datasets }), fromActions.fetchProposalDatasetsCountAction({ proposalId }), ]), @@ -100,16 +111,18 @@ export class ProposalEffects { return this.actions$.pipe( ofType(fromActions.fetchProposalDatasetsCountAction), switchMap(({ proposalId }) => - this.datasetApi.find({ where: { proposalId } }).pipe( - map((datasets) => - fromActions.fetchProposalDatasetsCountCompleteAction({ - count: datasets.length, - }), - ), - catchError(() => - of(fromActions.fetchProposalDatasetsCountFailedAction()), + this.datasetsService + .datasetsControllerFindAll(JSON.stringify({ where: { proposalId } })) + .pipe( + map((datasets) => + fromActions.fetchProposalDatasetsCountCompleteAction({ + count: datasets.length, + }), + ), + catchError(() => + of(fromActions.fetchProposalDatasetsCountFailedAction()), + ), ), - ), ), ); }); @@ -118,10 +131,9 @@ export class ProposalEffects { return this.actions$.pipe( ofType(fromActions.addAttachmentAction), switchMap(({ attachment }) => { - const { id, rawDatasetId, derivedDatasetId, sampleId, ...theRest } = - attachment; - return this.proposalApi - .createAttachments(encodeURIComponent(theRest.proposalId), theRest) + const { id, sampleId, ...theRest } = attachment; + return this.proposalsService + .proposalsControllerCreateAttachment(theRest.proposalId, theRest) .pipe( map((res) => fromActions.addAttachmentCompleteAction({ attachment: res }), @@ -137,10 +149,10 @@ export class ProposalEffects { ofType(fromActions.updateAttachmentCaptionAction), switchMap(({ proposalId, attachmentId, caption }) => { const newCaption = { caption }; - return this.proposalApi - .updateByIdAttachments( - encodeURIComponent(proposalId), - encodeURIComponent(attachmentId), + return this.proposalsService + .proposalsControllerFindOneAttachmentAndUpdate( + proposalId, + attachmentId, newCaption, ) .pipe( @@ -161,8 +173,8 @@ export class ProposalEffects { return this.actions$.pipe( ofType(fromActions.updateProposalPropertyAction), switchMap(({ proposalId, property }) => - this.proposalApi - .patchAttributes(encodeURIComponent(proposalId), property) + this.proposalsService + .proposalsControllerUpdate(proposalId, property) .pipe( switchMap(() => [ fromActions.updateProposalPropertyCompleteAction(), @@ -180,10 +192,10 @@ export class ProposalEffects { return this.actions$.pipe( ofType(fromActions.removeAttachmentAction), switchMap(({ proposalId, attachmentId }) => - this.proposalApi - .destroyByIdAttachments( - encodeURIComponent(proposalId), - encodeURIComponent(attachmentId), + this.proposalsService + .proposalsControllerFindOneAttachmentAndRemove( + proposalId, + attachmentId, ) .pipe( map((res) => @@ -243,35 +255,35 @@ export class ProposalEffects { constructor( private actions$: Actions, - private datasetApi: DatasetApi, - private proposalApi: ProposalApi, + private datasetsService: DatasetsService, + private proposalsService: ProposalsService, private store: Store, ) {} private createProposalFetchEffect( triggerAction: string, - completeAction: (props: { proposal: Proposal }) => Action, + completeAction: (props: { proposal: ProposalClass }) => Action, failedAction: () => Action, accessFailedAction: () => Action, ) { return createEffect(() => { return this.actions$.pipe( ofType(triggerAction), - switchMap>(({ proposalId }) => - this.proposalApi.findByIdAccess(encodeURIComponent(proposalId)).pipe( - filter( - (permission: { canAccess: boolean }) => permission.canAccess, + switchMap>(({ proposalId }) => + this.proposalsService + .proposalsControllerFindByIdAccess(proposalId) + .pipe( + filter((permission) => permission.canAccess), + switchMap(() => + this.proposalsService + .proposalsControllerFindById(proposalId) + .pipe( + map((proposal) => completeAction({ proposal })), + catchError(() => of(failedAction())), + ), + ), + catchError(() => of(accessFailedAction())), ), - switchMap(() => - this.proposalApi - .findById(encodeURIComponent(proposalId)) - .pipe( - map((proposal) => completeAction({ proposal })), - catchError(() => of(failedAction())), - ), - ), - catchError(() => of(accessFailedAction())), - ), ), ); }); diff --git a/src/app/state-management/effects/published-data.effects.spec.ts b/src/app/state-management/effects/published-data.effects.spec.ts index 654be9ed2..2db4e549d 100644 --- a/src/app/state-management/effects/published-data.effects.spec.ts +++ b/src/app/state-management/effects/published-data.effects.spec.ts @@ -1,10 +1,4 @@ -import { Observable } from "rxjs"; import { PublishedDataEffects } from "./published-data.effects"; -import { - PublishedDataApi, - PublishedDataInterface, - PublishedData, -} from "shared/sdk"; import { TestBed } from "@angular/core/testing"; import { provideMockActions } from "@ngrx/effects/testing"; import { provideMockStore } from "@ngrx/store/testing"; @@ -19,9 +13,14 @@ import { } from "state-management/actions/user.actions"; import { Type } from "@angular/core"; import { Router } from "@angular/router"; -import { MockRouter } from "shared/MockStubs"; +import { MockRouter, createMock } from "shared/MockStubs"; +import { + PublishedData, + PublishedDataService, +} from "@scicatproject/scicat-sdk-ts"; +import { TestObservable } from "jasmine-marbles/src/test-observables"; -const data: PublishedDataInterface = { +const publishedData = createMock({ doi: "testDOI", affiliation: "test affiliation", creator: ["test creator"], @@ -32,13 +31,19 @@ const data: PublishedDataInterface = { dataDescription: "test description", resourceType: "test type", pidArray: ["testPid"], -}; -const publishedData = new PublishedData(data); + createdAt: "", + registeredTime: "", + updatedAt: "", + url: "", + numberOfFiles: 1, + sizeOfArchive: 1, + status: "pending_registration", +}); describe("PublishedDataEffects", () => { - let actions: Observable; + let actions: TestObservable; let effects: PublishedDataEffects; - let publishedDataApi: jasmine.SpyObj; + let publishedDataApi: jasmine.SpyObj; beforeEach(() => { TestBed.configureTestingModule({ @@ -49,13 +54,13 @@ describe("PublishedDataEffects", () => { selectors: [{ selector: selectQueryParams, value: {} }], }), { - provide: PublishedDataApi, + provide: PublishedDataService, useValue: jasmine.createSpyObj("publsihedDataApi", [ - "find", - "count", - "findById", - "create", - "register", + "publishedDataControllerFindAll", + "publishedDataControllerCount", + "publishedDataControllerFindOne", + "publishedDataControllerCreate", + "publishedDataControllerRegister", ]), }, { provide: Router, useClass: MockRouter }, @@ -63,7 +68,7 @@ describe("PublishedDataEffects", () => { }); effects = TestBed.inject(PublishedDataEffects); - publishedDataApi = injectedStub(PublishedDataApi); + publishedDataApi = injectedStub(PublishedDataService); }); const injectedStub = (service: Type): jasmine.SpyObj => @@ -81,7 +86,9 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: allPublishedData }); - publishedDataApi.find.and.returnValue(response); + publishedDataApi.publishedDataControllerFindAll.and.returnValue( + response, + ); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchAllPublishedData$).toBeObservable(expected); @@ -93,7 +100,9 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - publishedDataApi.find.and.returnValue(response); + publishedDataApi.publishedDataControllerFindAll.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.fetchAllPublishedData$).toBeObservable(expected); @@ -114,7 +123,9 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: allPublishedData }); - publishedDataApi.find.and.returnValue(response); + publishedDataApi.publishedDataControllerFindAll.and.returnValue( + response, + ); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchAllPublishedData$).toBeObservable(expected); @@ -126,7 +137,9 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - publishedDataApi.find.and.returnValue(response); + publishedDataApi.publishedDataControllerFindAll.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.fetchAllPublishedData$).toBeObservable(expected); @@ -142,7 +155,7 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: { count } }); - publishedDataApi.count.and.returnValue(response); + publishedDataApi.publishedDataControllerCount.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); @@ -154,7 +167,7 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - publishedDataApi.count.and.returnValue(response); + publishedDataApi.publishedDataControllerCount.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); @@ -171,7 +184,7 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: publishedData }); - publishedDataApi.findById.and.returnValue(response); + publishedDataApi.publishedDataControllerFindOne.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchPublishedData$).toBeObservable(expected); @@ -184,7 +197,7 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - publishedDataApi.findById.and.returnValue(response); + publishedDataApi.publishedDataControllerFindOne.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchPublishedData$).toBeObservable(expected); @@ -202,7 +215,7 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: publishedData }); - publishedDataApi.create.and.returnValue(response); + publishedDataApi.publishedDataControllerCreate.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, @@ -217,7 +230,7 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - publishedDataApi.create.and.returnValue(response); + publishedDataApi.publishedDataControllerCreate.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.publishDataset$).toBeObservable(expected); @@ -271,7 +284,9 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: publishedData }); - publishedDataApi.register.and.returnValue(response); + publishedDataApi.publishedDataControllerRegister.and.returnValue( + response, + ); const expected = cold("--(bc)", { b: outcome, c: outcome1 }); expect(effects.registerPublishedData$).toBeObservable(expected); @@ -284,7 +299,9 @@ describe("PublishedDataEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - publishedDataApi.register.and.returnValue(response); + publishedDataApi.publishedDataControllerRegister.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.registerPublishedData$).toBeObservable(expected); @@ -331,7 +348,6 @@ describe("PublishedDataEffects", () => { describe("ofType publishedDatasetAction", () => { it("should dispatch a loadingAction", () => { - const id = "testId"; const action = fromActions.publishDatasetAction({ data: publishedData, }); diff --git a/src/app/state-management/effects/published-data.effects.ts b/src/app/state-management/effects/published-data.effects.ts index 0bb79007c..7b510ef60 100644 --- a/src/app/state-management/effects/published-data.effects.ts +++ b/src/app/state-management/effects/published-data.effects.ts @@ -1,6 +1,9 @@ import { Injectable } from "@angular/core"; import { Actions, createEffect, ofType, concatLatestFrom } from "@ngrx/effects"; -import { PublishedDataApi, PublishedData } from "shared/sdk"; +import { + PublishedData, + PublishedDataService, +} from "@scicatproject/scicat-sdk-ts"; import { Store } from "@ngrx/store"; import { selectCurrentPublishedData, @@ -38,13 +41,19 @@ export class PublishedDataEffects { concatLatestFrom(() => this.queryParams$), map(([action, params]) => params), mergeMap((params) => - this.publishedDataApi.find(params).pipe( - mergeMap((publishedData: PublishedData[]) => [ - fromActions.fetchAllPublishedDataCompleteAction({ publishedData }), - fromActions.fetchCountAction(), - ]), - catchError(() => of(fromActions.fetchAllPublishedDataFailedAction())), - ), + this.publishedDataService + .publishedDataControllerFindAll("", "", JSON.stringify(params)) + .pipe( + mergeMap((publishedData) => [ + fromActions.fetchAllPublishedDataCompleteAction({ + publishedData, + }), + fromActions.fetchCountAction(), + ]), + catchError(() => + of(fromActions.fetchAllPublishedDataFailedAction()), + ), + ), ), ); }); @@ -53,7 +62,7 @@ export class PublishedDataEffects { return this.actions$.pipe( ofType(fromActions.fetchCountAction), switchMap(() => - this.publishedDataApi.count().pipe( + this.publishedDataService.publishedDataControllerCount().pipe( map(({ count }) => fromActions.fetchCountCompleteAction({ count })), catchError(() => of(fromActions.fetchCountFailedAction())), ), @@ -65,14 +74,14 @@ export class PublishedDataEffects { return this.actions$.pipe( ofType(fromActions.fetchPublishedDataAction), switchMap(({ id }) => - this.publishedDataApi - .findById(encodeURIComponent(id)) - .pipe( - map((publishedData: PublishedData) => - fromActions.fetchPublishedDataCompleteAction({ publishedData }), - ), - catchError(() => of(fromActions.fetchPublishedDataFailedAction())), + this.publishedDataService.publishedDataControllerFindOne(id).pipe( + map((publishedData: PublishedData) => + fromActions.fetchPublishedDataCompleteAction({ + publishedData, + }), ), + catchError(() => of(fromActions.fetchPublishedDataFailedAction())), + ), ), ); }); @@ -85,7 +94,7 @@ export class PublishedDataEffects { filter(([_, publishedData]) => !!publishedData), exhaustMap(([_, publishedData]) => this.router.navigateByUrl( - "/publishedDatasets/" + encodeURIComponent(publishedData!.doi), + "/publishedDatasets/" + encodeURIComponent(publishedData.doi), ), ), ); @@ -97,8 +106,8 @@ export class PublishedDataEffects { return this.actions$.pipe( ofType(fromActions.publishDatasetAction), switchMap(({ data }) => - this.publishedDataApi.create(data).pipe( - mergeMap((publishedData: PublishedData) => [ + this.publishedDataService.publishedDataControllerCreate(data).pipe( + mergeMap((publishedData) => [ fromActions.publishDatasetCompleteAction({ publishedData }), fromActions.fetchPublishedDataAction({ id: publishedData.doi }), ]), @@ -140,9 +149,11 @@ export class PublishedDataEffects { return this.actions$.pipe( ofType(fromActions.registerPublishedDataAction), switchMap(({ doi }) => - this.publishedDataApi.register(encodeURIComponent(doi)).pipe( - mergeMap((publishedData) => [ - fromActions.registerPublishedDataCompleteAction({ publishedData }), + this.publishedDataService.publishedDataControllerRegister(doi).pipe( + mergeMap((publishedData: PublishedData) => [ + fromActions.registerPublishedDataCompleteAction({ + publishedData, + }), fromActions.fetchPublishedDataAction({ id: doi }), ]), catchError(() => of(fromActions.registerPublishedDataFailedAction())), @@ -155,7 +166,7 @@ export class PublishedDataEffects { return this.actions$.pipe( ofType(fromActions.resyncPublishedDataAction), switchMap(({ doi, data }) => - this.publishedDataApi.resync(encodeURIComponent(doi), data).pipe( + this.publishedDataService.publishedDataControllerResync(doi, data).pipe( mergeMap((publishedData) => [ fromActions.resyncPublishedDataCompleteAction(publishedData), fromActions.fetchPublishedDataAction({ id: doi }), @@ -216,7 +227,7 @@ export class PublishedDataEffects { constructor( private actions$: Actions, - private publishedDataApi: PublishedDataApi, + private publishedDataService: PublishedDataService, private router: Router, private store: Store, ) {} diff --git a/src/app/state-management/effects/samples.effects.spec.ts b/src/app/state-management/effects/samples.effects.spec.ts index 31b458cad..7626a7931 100644 --- a/src/app/state-management/effects/samples.effects.spec.ts +++ b/src/app/state-management/effects/samples.effects.spec.ts @@ -1,13 +1,5 @@ -import { Observable, of, throwError } from "rxjs"; +import { of, throwError } from "rxjs"; import { SampleEffects } from "./samples.effects"; -import { - SampleApi, - DatasetApi, - SampleInterface, - Sample, - Dataset, - Attachment, -} from "shared/sdk"; import { TestBed } from "@angular/core/testing"; import { provideMockActions } from "@ngrx/effects/testing"; import { provideMockStore } from "@ngrx/store/testing"; @@ -22,18 +14,34 @@ import { loadingCompleteAction, } from "state-management/actions/user.actions"; import { Type } from "@angular/core"; +import { + DatasetsService, + SampleClass, + SamplesService, +} from "@scicatproject/scicat-sdk-ts"; +import { TestObservable } from "jasmine-marbles/src/test-observables"; +import { + createMock, + mockDataset as dataset, + mockAttachment as attachment, +} from "shared/MockStubs"; -const data: SampleInterface = { +const sample = createMock({ sampleId: "testId", ownerGroup: "testGroup", -}; -const sample = new Sample(data); + createdBy: "", + updatedBy: "", + createdAt: new Date().toString(), + updatedAt: new Date().toString(), + accessGroups: [], + isPublished: false, +}); describe("SampleEffects", () => { - let actions: Observable; + let actions: TestObservable; let effects: SampleEffects; - let sampleApi: jasmine.SpyObj; - let datasetApi: jasmine.SpyObj; + let sampleApi: jasmine.SpyObj; + let datasetApi: jasmine.SpyObj; beforeEach(() => { TestBed.configureTestingModule({ @@ -50,29 +58,30 @@ describe("SampleEffects", () => { ], }), { - provide: SampleApi, + provide: SamplesService, useValue: jasmine.createSpyObj("sampleApi", [ - "fullquery", - "findById", - "findByIdAccess", - "metadataKeys", - "patchAttributes", - "create", - "createAttachments", - "updateByIdAttachments", - "destroyByIdAttachments", + "samplesControllerFullquery", + "samplesControllerFindById", + "samplesControllerFindByIdAccess", + "samplesControllerMetadataKeys", + "samplesControllerUpdate", + "samplesControllerCreate", + "samplesControllerCreateAttachments", + "samplesControllerFindOneAttachmentAndRemove", ]), }, { - provide: DatasetApi, - useValue: jasmine.createSpyObj("datasetApi", ["find"]), + provide: DatasetsService, + useValue: jasmine.createSpyObj("datasetApi", [ + "datasetsControllerFindAll", + ]), }, ], }); effects = TestBed.inject(SampleEffects); - sampleApi = injectedStub(SampleApi); - datasetApi = injectedStub(DatasetApi); + sampleApi = injectedStub(SamplesService); + datasetApi = injectedStub(DatasetsService); }); const injectedStub = (service: Type): jasmine.SpyObj => @@ -88,7 +97,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: samples }); - sampleApi.fullquery.and.returnValue(response); + sampleApi.samplesControllerFullquery.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchSamples$).toBeObservable(expected); @@ -100,7 +109,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - sampleApi.fullquery.and.returnValue(response); + sampleApi.samplesControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchSamples$).toBeObservable(expected); @@ -119,7 +128,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: samples }); - sampleApi.fullquery.and.returnValue(response); + sampleApi.samplesControllerFullquery.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchSamples$).toBeObservable(expected); @@ -131,7 +140,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - sampleApi.fullquery.and.returnValue(response); + sampleApi.samplesControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchSamples$).toBeObservable(expected); @@ -150,7 +159,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: samples }); - sampleApi.fullquery.and.returnValue(response); + sampleApi.samplesControllerFullquery.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchSamples$).toBeObservable(expected); @@ -162,7 +171,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - sampleApi.fullquery.and.returnValue(response); + sampleApi.samplesControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchSamples$).toBeObservable(expected); @@ -180,7 +189,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: samples }); - sampleApi.fullquery.and.returnValue(response); + sampleApi.samplesControllerFullquery.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchSamples$).toBeObservable(expected); @@ -192,7 +201,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - sampleApi.fullquery.and.returnValue(response); + sampleApi.samplesControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchSamples$).toBeObservable(expected); @@ -210,7 +219,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: samples }); - sampleApi.fullquery.and.returnValue(response); + sampleApi.samplesControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); @@ -222,7 +231,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - sampleApi.fullquery.and.returnValue(response); + sampleApi.samplesControllerFullquery.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCount$).toBeObservable(expected); @@ -239,7 +248,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: metadataKeys }); - sampleApi.metadataKeys.and.returnValue(response); + sampleApi.samplesControllerMetadataKeys.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchMetadataKeys$).toBeObservable(expected); @@ -251,7 +260,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - sampleApi.metadataKeys.and.returnValue(response); + sampleApi.samplesControllerMetadataKeys.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchMetadataKeys$).toBeObservable(expected); @@ -260,21 +269,22 @@ describe("SampleEffects", () => { describe("fetchSample$", () => { const sampleId = "testId"; + // TODO: Try to fix the any types here const permission = { - accepted: { canAccess: true }, - rejected: { canAccess: false }, + accepted: { canAccess: true } as any, + rejected: { canAccess: false } as any, }; it("should result in a fetchSampleCompleteAction", () => { const action = fromActions.fetchSampleAction({ sampleId }); const outcome = fromActions.fetchSampleCompleteAction({ sample }); - sampleApi.findByIdAccess + sampleApi.samplesControllerFindByIdAccess .withArgs(sampleId) .and.returnValue(of(permission.accepted)); - sampleApi.findById + sampleApi.samplesControllerFindById .withArgs(encodeURIComponent(sampleId)) - .and.returnValue(of(sample)); + .and.returnValue(of(sample as any)); actions = hot("a", { a: action }); const expected = cold("b", { b: outcome }); @@ -286,10 +296,12 @@ describe("SampleEffects", () => { const action = fromActions.fetchSampleAction({ sampleId }); const failure = fromActions.fetchSampleFailedAction(); - sampleApi.findByIdAccess + sampleApi.samplesControllerFindByIdAccess .withArgs(sampleId) .and.returnValue(of(permission.accepted)); - sampleApi.findById.and.returnValue(throwError(() => new Error())); + sampleApi.samplesControllerFindById.and.returnValue( + throwError(() => new Error()), + ); actions = hot("a", { a: action }); const expected = cold("b", { b: failure }); @@ -300,7 +312,7 @@ describe("SampleEffects", () => { it("should do nothing if findByIdAccess returns false", () => { const action = fromActions.fetchSampleAction({ sampleId }); - sampleApi.findByIdAccess + sampleApi.samplesControllerFindByIdAccess .withArgs(sampleId) .and.returnValue(of(permission.rejected)); @@ -308,14 +320,14 @@ describe("SampleEffects", () => { const expected = cold("------"); expect(effects.fetchSample$).toBeObservable(expected); - expect(sampleApi.findById).not.toHaveBeenCalled(); + expect(sampleApi.samplesControllerFindById).not.toHaveBeenCalled(); }); it("should result in fetchSampleAccessFailedAction if findByIdAccess failed", () => { const action = fromActions.fetchSampleAction({ sampleId }); const failure = fromActions.fetchSampleAccessFailedAction(); - sampleApi.findByIdAccess + sampleApi.samplesControllerFindByIdAccess .withArgs(sampleId) .and.returnValue(throwError(() => new Error())); @@ -323,7 +335,7 @@ describe("SampleEffects", () => { const expected = cold("b", { b: failure }); expect(effects.fetchSample$).toBeObservable(expected); - expect(sampleApi.findById).not.toHaveBeenCalled(); + expect(sampleApi.samplesControllerFindById).not.toHaveBeenCalled(); }); }); @@ -331,7 +343,7 @@ describe("SampleEffects", () => { const sampleId = "testId"; it("should result in a fetchSampleDatasetsCompleteAction and a fetchSampleDatasetsCountAction", () => { - const datasets = [new Dataset()]; + const datasets = [dataset]; const action = fromActions.fetchSampleDatasetsAction({ sampleId }); const outcome1 = fromActions.fetchSampleDatasetsCompleteAction({ datasets, @@ -340,7 +352,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: datasets }); - datasetApi.find.and.returnValue(response); + datasetApi.datasetsControllerFindAll.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.fetchSampleDatasets$).toBeObservable(expected); @@ -352,7 +364,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.find.and.returnValue(response); + datasetApi.datasetsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchSampleDatasets$).toBeObservable(expected); @@ -364,7 +376,7 @@ describe("SampleEffects", () => { it("should result in a fetchSampleDatasetsCountCompleteAction", () => { const count = 1; - const datasets = [new Dataset()]; + const datasets = [dataset]; const action = fromActions.fetchSampleDatasetsCountAction({ sampleId }); const outcome = fromActions.fetchSampleDatasetsCountCompleteAction({ count, @@ -372,7 +384,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: datasets }); - datasetApi.find.and.returnValue(response); + datasetApi.datasetsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchSampleDatasetsCount$).toBeObservable(expected); @@ -384,7 +396,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - datasetApi.find.and.returnValue(response); + datasetApi.datasetsControllerFindAll.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchSampleDatasetsCount$).toBeObservable(expected); @@ -399,7 +411,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: sample }); - sampleApi.create.and.returnValue(response); + sampleApi.samplesControllerCreate.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.addSample$).toBeObservable(expected); @@ -411,7 +423,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - sampleApi.create.and.returnValue(response); + sampleApi.samplesControllerCreate.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.addSample$).toBeObservable(expected); @@ -430,7 +442,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: sample }); - sampleApi.patchAttributes.and.returnValue(response); + sampleApi.samplesControllerUpdate.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.saveCharacteristics$).toBeObservable(expected); @@ -447,7 +459,7 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - sampleApi.patchAttributes.and.returnValue(response); + sampleApi.samplesControllerUpdate.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.saveCharacteristics$).toBeObservable(expected); @@ -455,15 +467,13 @@ describe("SampleEffects", () => { }); describe("addAttachment$", () => { - const attachment = new Attachment(); - it("should result in a addAttachmentCompleteAction", () => { const action = fromActions.addAttachmentAction({ attachment }); const outcome = fromActions.addAttachmentCompleteAction({ attachment }); actions = hot("-a", { a: action }); const response = cold("-a|", { a: attachment }); - sampleApi.createAttachments.and.returnValue(response); + sampleApi.samplesControllerCreateAttachments.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.addAttachment$).toBeObservable(expected); @@ -475,54 +485,13 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - sampleApi.createAttachments.and.returnValue(response); + sampleApi.samplesControllerCreateAttachments.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.addAttachment$).toBeObservable(expected); }); }); - describe("updateAttachmentCaption$", () => { - const attachment = new Attachment(); - const sampleId = "testId"; - const attachmentId = "testId"; - const caption = "test"; - - it("should result in a updateAttachmentCaptionCompleteAction", () => { - const action = fromActions.updateAttachmentCaptionAction({ - sampleId, - attachmentId, - caption, - }); - const outcome = fromActions.updateAttachmentCaptionCompleteAction({ - attachment, - }); - - actions = hot("-a", { a: action }); - const response = cold("-a|", { a: attachment }); - sampleApi.updateByIdAttachments.and.returnValue(response); - - const expected = cold("--b", { b: outcome }); - expect(effects.updateAttachmentCaption$).toBeObservable(expected); - }); - - it("should result in a updateAttachmentCaptionFailedAction", () => { - const action = fromActions.updateAttachmentCaptionAction({ - sampleId, - attachmentId, - caption, - }); - const outcome = fromActions.updateAttachmentCaptionFailedAction(); - - actions = hot("-a", { a: action }); - const response = cold("-#", {}); - sampleApi.updateByIdAttachments.and.returnValue(response); - - const expected = cold("--b", { b: outcome }); - expect(effects.updateAttachmentCaption$).toBeObservable(expected); - }); - }); - describe("removeAttachment$", () => { const sampleId = "testId"; const attachmentId = "testId"; @@ -538,7 +507,9 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: attachmentId }); - sampleApi.destroyByIdAttachments.and.returnValue(response); + sampleApi.samplesControllerFindOneAttachmentAndRemove.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.removeAttachment$).toBeObservable(expected); @@ -553,7 +524,9 @@ describe("SampleEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - sampleApi.destroyByIdAttachments.and.returnValue(response); + sampleApi.samplesControllerFindOneAttachmentAndRemove.and.returnValue( + response, + ); const expected = cold("--b", { b: outcome }); expect(effects.removeAttachment$).toBeObservable(expected); @@ -655,7 +628,6 @@ describe("SampleEffects", () => { describe("ofType addAttachmentAction", () => { it("should dispatch a loadingAction", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentAction({ attachment }); const outcome = loadingAction(); @@ -780,7 +752,7 @@ describe("SampleEffects", () => { describe("ofType fetchSampleDatasetsCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const datasets = [new Dataset()]; + const datasets = [dataset]; const action = fromActions.fetchSampleDatasetsCompleteAction({ datasets, }); @@ -884,7 +856,6 @@ describe("SampleEffects", () => { describe("ofType addAttachmentCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const attachment = new Attachment(); const action = fromActions.addAttachmentCompleteAction({ attachment }); const outcome = loadingCompleteAction(); @@ -909,7 +880,6 @@ describe("SampleEffects", () => { describe("ofType updateAttachmentCaptionCompleteAction", () => { it("should dispatch a loadingCompleteAction", () => { - const attachment = new Attachment(); const action = fromActions.updateAttachmentCaptionCompleteAction({ attachment, }); diff --git a/src/app/state-management/effects/samples.effects.ts b/src/app/state-management/effects/samples.effects.ts index 2cd9168d2..cd08ad6f0 100644 --- a/src/app/state-management/effects/samples.effects.ts +++ b/src/app/state-management/effects/samples.effects.ts @@ -1,6 +1,10 @@ import { Injectable } from "@angular/core"; import { Actions, createEffect, ofType, concatLatestFrom } from "@ngrx/effects"; -import { DatasetApi, SampleApi, Sample, Dataset, Attachment } from "shared/sdk"; +import { + CreateSubAttachmentDto, + DatasetsService, + SamplesService, +} from "@scicatproject/scicat-sdk-ts"; import { Store } from "@ngrx/store"; import { selectFullqueryParams, @@ -30,13 +34,15 @@ export class SampleEffects { concatLatestFrom(() => this.fullqueryParams$), map(([action, params]) => params), mergeMap(({ query, limits }) => - this.sampleApi.fullquery(query, limits).pipe( - mergeMap((samples) => [ - fromActions.fetchSamplesCompleteAction({ samples }), - fromActions.fetchSamplesCountAction(), - ]), - catchError(() => of(fromActions.fetchSamplesFailedAction())), - ), + this.sampleApi + .samplesControllerFullquery(JSON.stringify(limits), query) + .pipe( + mergeMap((samples) => [ + fromActions.fetchSamplesCompleteAction({ samples }), + fromActions.fetchSamplesCountAction(), + ]), + catchError(() => of(fromActions.fetchSamplesFailedAction())), + ), ), ); }); @@ -47,7 +53,7 @@ export class SampleEffects { concatLatestFrom(() => this.fullqueryParams$), map(([action, params]) => params), mergeMap(({ query }) => - this.sampleApi.fullquery(query).pipe( + this.sampleApi.samplesControllerFullquery(query).pipe( map((samples) => fromActions.fetchSamplesCountCompleteAction({ count: samples.length, @@ -67,12 +73,14 @@ export class SampleEffects { mergeMap(({ query }) => { const parsedQuery = JSON.parse(query); parsedQuery.metadataKey = ""; - return this.sampleApi.metadataKeys(JSON.stringify(parsedQuery)).pipe( - map((metadataKeys) => - fromActions.fetchMetadataKeysCompleteAction({ metadataKeys }), - ), - catchError(() => of(fromActions.fetchMetadataKeysFailedAction())), - ); + return this.sampleApi + .samplesControllerMetadataKeys(JSON.stringify(parsedQuery)) + .pipe( + map((metadataKeys) => + fromActions.fetchMetadataKeysCompleteAction({ metadataKeys }), + ), + catchError(() => of(fromActions.fetchMetadataKeysFailedAction())), + ); }), ); }); @@ -81,11 +89,11 @@ export class SampleEffects { return this.actions$.pipe( ofType(fromActions.fetchSampleAction), switchMap(({ sampleId }) => { - return this.sampleApi.findByIdAccess(sampleId).pipe( - filter((permission: { canAccess: boolean }) => permission.canAccess), + return this.sampleApi.samplesControllerFindByIdAccess(sampleId).pipe( + filter((permission) => permission.canAccess), switchMap(() => - this.sampleApi.findById(sampleId).pipe( - map((sample: Sample) => + this.sampleApi.samplesControllerFindById(sampleId).pipe( + map((sample) => fromActions.fetchSampleCompleteAction({ sample }), ), catchError(() => of(fromActions.fetchSampleFailedAction())), @@ -101,14 +109,16 @@ export class SampleEffects { return this.actions$.pipe( ofType(fromActions.fetchSampleAttachmentsAction), switchMap(({ sampleId }) => { - return this.sampleApi.getAttachments(sampleId).pipe( - map((attachments: Attachment[]) => - fromActions.fetchSampleAttachmentsCompleteAction({ attachments }), - ), - catchError(() => - of(fromActions.fetchSampleAttachmentsFailedAction()), - ), - ); + return this.sampleApi + .samplesControllerFindAllAttachments(sampleId) + .pipe( + map((attachments) => + fromActions.fetchSampleAttachmentsCompleteAction({ attachments }), + ), + catchError(() => + of(fromActions.fetchSampleAttachmentsFailedAction()), + ), + ); }), ); }); @@ -119,9 +129,16 @@ export class SampleEffects { concatLatestFrom(() => this.datasetsQueryParams$), mergeMap(([{ sampleId }, { order, skip, limit }]) => this.datasetApi - .find({ where: { sampleId }, order, skip, limit }) + .datasetsControllerFindAll( + JSON.stringify({ + where: { sampleId }, + order, + skip, + limit, + }), + ) .pipe( - mergeMap((datasets: Dataset[]) => [ + mergeMap((datasets) => [ fromActions.fetchSampleDatasetsCompleteAction({ datasets }), fromActions.fetchSampleDatasetsCountAction({ sampleId }), ]), @@ -135,16 +152,18 @@ export class SampleEffects { return this.actions$.pipe( ofType(fromActions.fetchSampleDatasetsCountAction), switchMap(({ sampleId }) => - this.datasetApi.find({ where: { sampleId } }).pipe( - map((datasets) => - fromActions.fetchSampleDatasetsCountCompleteAction({ - count: datasets.length, - }), - ), - catchError(() => - of(fromActions.fetchSampleDatasetsCountFailedAction()), + this.datasetApi + .datasetsControllerFindAll(JSON.stringify({ where: { sampleId } })) + .pipe( + map((datasets) => + fromActions.fetchSampleDatasetsCountCompleteAction({ + count: datasets.length, + }), + ), + catchError(() => + of(fromActions.fetchSampleDatasetsCountFailedAction()), + ), ), - ), ), ); }); @@ -154,11 +173,11 @@ export class SampleEffects { ofType(fromActions.saveCharacteristicsAction), switchMap(({ sampleId, characteristics }) => this.sampleApi - .patchAttributes(sampleId, { + .samplesControllerUpdate(sampleId, { sampleCharacteristics: characteristics, }) .pipe( - map((sample: Sample) => + map((sample) => fromActions.saveCharacteristicsCompleteAction({ sample }), ), catchError(() => of(fromActions.saveCharacteristicsFailedAction())), @@ -171,7 +190,7 @@ export class SampleEffects { return this.actions$.pipe( ofType(fromActions.addSampleAction), mergeMap(({ sample }) => - this.sampleApi.create(sample).pipe( + this.sampleApi.samplesControllerCreate(sample).pipe( mergeMap((res) => [ fromActions.addSampleCompleteAction({ sample: res }), fromActions.fetchSamplesAction(), @@ -186,16 +205,12 @@ export class SampleEffects { return this.actions$.pipe( ofType(fromActions.addAttachmentAction), switchMap(({ attachment }) => { - const { - id, - datasetId, - rawDatasetId, - derivedDatasetId, - proposalId, - ...theRest - } = attachment; + const { id, datasetId, proposalId, ...theRest } = attachment; return this.sampleApi - .createAttachments(encodeURIComponent(theRest.sampleId!), theRest) + .samplesControllerCreateAttachments( + theRest.sampleId, + theRest as CreateSubAttachmentDto, + ) .pipe( map((res) => fromActions.addAttachmentCompleteAction({ attachment: res }), @@ -206,40 +221,12 @@ export class SampleEffects { ); }); - updateAttachmentCaption$ = createEffect(() => { - return this.actions$.pipe( - ofType(fromActions.updateAttachmentCaptionAction), - switchMap(({ sampleId, attachmentId, caption }) => { - const newCaption = { caption }; - return this.sampleApi - .updateByIdAttachments( - encodeURIComponent(sampleId), - encodeURIComponent(attachmentId), - newCaption, - ) - .pipe( - map((res) => - fromActions.updateAttachmentCaptionCompleteAction({ - attachment: res, - }), - ), - catchError(() => - of(fromActions.updateAttachmentCaptionFailedAction()), - ), - ); - }), - ); - }); - removeAttachment$ = createEffect(() => { return this.actions$.pipe( ofType(fromActions.removeAttachmentAction), switchMap(({ sampleId, attachmentId }) => this.sampleApi - .destroyByIdAttachments( - encodeURIComponent(sampleId), - encodeURIComponent(attachmentId), - ) + .samplesControllerFindOneAttachmentAndRemove(sampleId, attachmentId) .pipe( map(() => fromActions.removeAttachmentCompleteAction({ attachmentId }), @@ -298,8 +285,8 @@ export class SampleEffects { constructor( private actions$: Actions, - private datasetApi: DatasetApi, - private sampleApi: SampleApi, + private datasetApi: DatasetsService, + private sampleApi: SamplesService, private store: Store, ) {} } diff --git a/src/app/state-management/effects/user.effects.spec.ts b/src/app/state-management/effects/user.effects.spec.ts index 47a025979..8477cf12b 100644 --- a/src/app/state-management/effects/user.effects.spec.ts +++ b/src/app/state-management/effects/user.effects.spec.ts @@ -1,15 +1,13 @@ -import { Observable } from "rxjs"; import { UserEffects } from "./user.effects"; import { - UserApi, - UserIdentityApi, - User, + UsersService, + UserIdentitiesService, UserIdentity, - AccessToken, - LoopBackAuth, - SDKToken, - UserSetting, -} from "shared/sdk"; + ReturnedUserDto, + UserSettings, + Configuration, + AuthService as SharedAuthService, +} from "@scicatproject/scicat-sdk-ts"; import { ADAuthService } from "users/adauth.service"; import { TestBed } from "@angular/core/testing"; import { provideMockActions } from "@ngrx/effects/testing"; @@ -40,6 +38,9 @@ import { Type } from "@angular/core"; import { HttpErrorResponse } from "@angular/common/http"; import { AppConfigService } from "app-config.service"; import { HttpClientTestingModule } from "@angular/common/http/testing"; +import { AuthService, SDKToken } from "shared/services/auth/auth.service"; +import { TestObservable } from "jasmine-marbles/src/test-observables"; +import { mockUser } from "shared/MockStubs"; class AppConfigServiceMock { getConfig() { @@ -55,12 +56,13 @@ class AppConfigServiceMock { } describe("UserEffects", () => { - let actions: Observable; + let actions: TestObservable; let effects: UserEffects; let activeDirAuthService: jasmine.SpyObj; - let loopBackAuth: jasmine.SpyObj; - let userApi: jasmine.SpyObj; - let userIdentityApi: jasmine.SpyObj; + let authService: jasmine.SpyObj; + let userApi: jasmine.SpyObj; + let sharedAuthService: jasmine.SpyObj; + let userIdentityApi: jasmine.SpyObj; let router: jasmine.SpyObj; const error = new HttpErrorResponse({}); beforeEach(() => { @@ -79,33 +81,46 @@ describe("UserEffects", () => { provide: AppConfigService, useClass: AppConfigServiceMock, }, + { + provide: Configuration, + useClass: Configuration, + }, { provide: ADAuthService, useValue: jasmine.createSpyObj("activeDirAuthService", ["login"]), }, { - provide: LoopBackAuth, - useValue: jasmine.createSpyObj("loopBackAuth", ["setToken", "clear"]), + provide: AuthService, + useValue: jasmine.createSpyObj("authService", [ + "setToken", + "clear", + "isAuthenticated", + "getCurrentUserData", + "getCurrentUserId", + "getToken", + ]), + }, + { + provide: SharedAuthService, + useValue: jasmine.createSpyObj("sharedAuthService", [ + "authControllerLogin", + "authControllerLogout", + ]), }, { - provide: UserApi, + provide: UsersService, useValue: jasmine.createSpyObj("userApi", [ - "findById", - "login", - "isAuthenticated", - "logout", - "getCurrent", - "getSettings", - "updateSettings", - "partialUpdateExternalSettings", - "partialUpdateSettings", - "getCurrentToken", - "getCurrentId", + "usersControllerFindById", + "usersControllerGetSettings", + "usersControllerPatchExternalSettings", + "usersControllerGetMyUser", ]), }, { - provide: UserIdentityApi, - useValue: jasmine.createSpyObj("userIdentityApi", ["findOne"]), + provide: UserIdentitiesService, + useValue: jasmine.createSpyObj("userIdentityApi", [ + "userIdentitiesControllerFindOne", + ]), }, { provide: Router, @@ -116,9 +131,10 @@ describe("UserEffects", () => { effects = TestBed.inject(UserEffects); activeDirAuthService = injectedStub(ADAuthService); - loopBackAuth = injectedStub(LoopBackAuth); - userApi = injectedStub(UserApi); - userIdentityApi = injectedStub(UserIdentityApi); + authService = injectedStub(AuthService); + sharedAuthService = injectedStub(SharedAuthService); + userApi = injectedStub(UsersService); + userIdentityApi = injectedStub(UserIdentitiesService); router = injectedStub(Router); }); @@ -202,7 +218,7 @@ describe("UserEffects", () => { }); it("should result in a fetchUserCompleteAction, loginCompleteAction, fetchUserIdentityAction and a fetchUserSettingsAction", () => { - const user = new User(); + const user = mockUser; user.id = "testId"; const accountType = "external"; const action = fromActions.fetchUserAction({ adLoginResponse }); @@ -213,8 +229,8 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: user }); - loopBackAuth.setToken(token); - userApi.findById.and.returnValue(response); + authService.setToken(token); + userApi.usersControllerFindById.and.returnValue(response); const expected = cold("--(bcde)", { b: outcome1, @@ -231,8 +247,8 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}, error); - loopBackAuth.setToken(token); - userApi.findById.and.returnValue(response); + authService.setToken(token); + userApi.usersControllerFindById.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchUser$).toBeObservable(expected); @@ -247,7 +263,7 @@ describe("UserEffects", () => { }); it("should result in a fetchUserCompleteAction and a loginCompleteAction", () => { - const user = new User(); + let user: ReturnedUserDto; const accountType = "external"; const action = fromActions.loginOIDCAction({ oidcLoginResponse }); const outcome1 = fromActions.fetchUserCompleteAction(); @@ -255,8 +271,8 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: user }); - loopBackAuth.setToken(token); - userApi.findById.and.returnValue(response); + authService.setToken(token); + userApi.usersControllerFindById.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.oidcFetchUser$).toBeObservable(expected); @@ -268,8 +284,8 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}, error); - loopBackAuth.setToken(token); - userApi.findById.and.returnValue(response); + authService.setToken(token); + userApi.usersControllerFindById.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.oidcFetchUser$).toBeObservable(expected); @@ -288,7 +304,7 @@ describe("UserEffects", () => { }; it("should result in a funcLoginSuccessAction and a loginCompleteAction", () => { - const user = new User(); + const user = mockUser; const accountType = "functional"; const action = fromActions.funcLoginAction({ form }); const outcome1 = fromActions.funcLoginSuccessAction(); @@ -296,7 +312,7 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: { user } }); - userApi.login.and.returnValue(response); + sharedAuthService.authControllerLogin.and.returnValue(response); const expected = cold("--(bc)", { b: outcome1, c: outcome2 }); expect(effects.funcLogin$).toBeObservable(expected); @@ -308,7 +324,7 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}, error); - userApi.login.and.returnValue(response); + sharedAuthService.authControllerLogin.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.funcLogin$).toBeObservable(expected); @@ -392,8 +408,8 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: { logoutURL: "" } }); - userApi.isAuthenticated.and.returnValue(true); - userApi.logout.and.returnValue(response); + authService.isAuthenticated.and.returnValue(true); + sharedAuthService.authControllerLogout.and.returnValue(response); const expected = cold("--(bcdefghij)", { b: outcome1, @@ -415,8 +431,8 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - userApi.isAuthenticated.and.returnValue(true); - userApi.logout.and.returnValue(response); + authService.isAuthenticated.and.returnValue(true); + sharedAuthService.authControllerLogout.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.logout$).toBeObservable(expected); @@ -429,7 +445,7 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); - expect(effects.logoutNavigate$).toBeObservable(actions as any); + expect(effects.logoutNavigate$).toBeObservable(actions); expect(router.navigate).toHaveBeenCalledTimes(1); expect(router.navigate).toHaveBeenCalledWith(["/login"]); }); @@ -437,16 +453,17 @@ describe("UserEffects", () => { describe("fetchCurrentUser$", () => { it("should result in a fetchCurrentUserCompleteAction, a fetchUserIdentityAction, and a fetchUserSettingsAction", () => { - const user = new User(); + const user = mockUser; user.id = "testId"; - const token: AccessToken = { + const token = { id: "testId", ttl: 100, scopes: ["string"], created: new Date(), userId: "testId", user: "testUser", - }; + rememberMe: false, + } as unknown as SDKToken; const action = fromActions.fetchCurrentUserAction(); const outcome1 = fromActions.fetchCurrentUserCompleteAction({ user }); const outcome2 = fromActions.fetchUserIdentityAction({ id: user.id }); @@ -454,10 +471,10 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: user }); - userApi.getCurrentToken.and.returnValue(token); - userApi.isAuthenticated.and.returnValue(true); - userApi.getCurrentId.and.returnValue(user.id); - userApi.getCurrent.and.returnValue(response); + authService.getToken.and.returnValue(token); + authService.isAuthenticated.and.returnValue(true); + authService.getCurrentUserId.and.returnValue(user.id); + userApi.usersControllerGetMyUser.and.returnValue(response); const expected = cold("--(bcd)", { b: outcome1, @@ -468,58 +485,76 @@ describe("UserEffects", () => { }); it("should result in a fetchCurrentUserFailedAction", () => { - const user = new User(); + const user = mockUser; user.id = "testId"; - const token: AccessToken = { + const token = { id: "testId", ttl: 3600, scopes: ["string"], created: new Date(), userId: "testId", user: "testUser", - }; + } as unknown as SDKToken; const action = fromActions.fetchCurrentUserAction(); const outcome = fromActions.fetchCurrentUserFailedAction(); actions = hot("-a", { a: action }); const response = cold("-#", {}); - userApi.getCurrentToken.and.returnValue(token); - userApi.isAuthenticated.and.returnValue(true); - userApi.getCurrentId.and.returnValue(user.id); - userApi.getCurrent.and.returnValue(response); + authService.getToken.and.returnValue(token); + authService.isAuthenticated.and.returnValue(true); + authService.getCurrentUserId.and.returnValue(user.id); + userApi.usersControllerGetMyUser.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchCurrentUser$).toBeObservable(expected); }); it("should not call getCurrent() if token is expired", () => { - const user = new User(); + const user = mockUser; user.id = "testId"; - const token: AccessToken = { + const token = { id: "testId", ttl: 100, scopes: ["string"], created: new Date(1611438651), userId: "testId", user: "testUser", - }; + } as unknown as SDKToken; const action = fromActions.fetchCurrentUserAction(); actions = hot("-a", { a: action }); - userApi.getCurrentToken.and.returnValue(token); - userApi.isAuthenticated.and.returnValue(false); + authService.getToken.and.returnValue(token); + authService.isAuthenticated.and.returnValue(false); const expected = cold(""); expect(effects.fetchCurrentUser$).toBeObservable(expected); - expect(userApi.getCurrent).not.toHaveBeenCalled(); + expect(authService.getCurrentUserData).not.toHaveBeenCalled(); }); }); describe("fetchUserIdentity$", () => { it("should result in a fetchUserIdentityCompleteAction", () => { const id = "testId"; - const userIdentity = new UserIdentity(); + const userIdentity: UserIdentity = { + authStrategy: "", + created: "", + credentials: {}, + externalId: "", + modified: "", + profile: { + accessGroups: [], + displayName: "", + email: "", + emails: [], + id: "testId", + oidcClaims: [], + thumbnailPhoto: "", + username: "", + }, + provider: "", + userId: "testId", + }; const action = fromActions.fetchUserIdentityAction({ id }); const outcome = fromActions.fetchUserIdentityCompleteAction({ userIdentity, @@ -527,7 +562,7 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: userIdentity }); - userIdentityApi.findOne.and.returnValue(response); + userIdentityApi.userIdentitiesControllerFindOne.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchUserIdentity$).toBeObservable(expected); @@ -540,7 +575,7 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - userIdentityApi.findOne.and.returnValue(response); + userIdentityApi.userIdentitiesControllerFindOne.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchUserIdentity$).toBeObservable(expected); @@ -551,13 +586,13 @@ describe("UserEffects", () => { const id = "testId"; it("should result in a fetchUserSettingsCompleteAction", () => { - const userSettings = new UserSetting({ + const userSettings = { columns: [], datasetCount: 25, jobCount: 25, userId: "testId", id: "testId", - }); + } as unknown as UserSettings; const action = fromActions.fetchUserSettingsAction({ id }); const outcome = fromActions.fetchUserSettingsCompleteAction({ userSettings, @@ -565,7 +600,7 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: userSettings }); - userApi.getSettings.and.returnValue(response); + userApi.usersControllerGetSettings.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchUserSettings$).toBeObservable(expected); @@ -577,7 +612,7 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - userApi.getSettings.and.returnValue(response); + userApi.usersControllerGetSettings.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.fetchUserSettings$).toBeObservable(expected); @@ -590,7 +625,8 @@ describe("UserEffects", () => { columns: [], datasetCount: 10, jobCount: 10, - } as UserSetting; + } as unknown as UserSettings; + const action = fromActions.fetchUserSettingsCompleteAction({ userSettings, }); @@ -668,6 +704,7 @@ describe("UserEffects", () => { const property = { columns: [] }; it("should result in an updateUserSettingsCompleteAction", () => { + // TODO: try to fix the types here instead of using type casting and conversion const userSettings = { columns: [], filters: [], @@ -676,7 +713,7 @@ describe("UserEffects", () => { jobCount: 25, userId: "testId", id: "testId", - } as UserSetting; + } as unknown as UserSettings; const apiResponse = { datasetCount: 25, @@ -696,7 +733,7 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-a|", { a: apiResponse }); - userApi.partialUpdateExternalSettings.and.returnValue(response); + userApi.usersControllerPatchExternalSettings.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.updateUserSettings$).toBeObservable(expected); @@ -708,7 +745,7 @@ describe("UserEffects", () => { actions = hot("-a", { a: action }); const response = cold("-#", {}); - userApi.partialUpdateExternalSettings.and.returnValue(response); + userApi.usersControllerPatchExternalSettings.and.returnValue(response); const expected = cold("--b", { b: outcome }); expect(effects.updateUserSettings$).toBeObservable(expected); @@ -717,19 +754,19 @@ describe("UserEffects", () => { describe("fetchScicatToken$", () => { it("should result in a fetchScicatTokenCompleteAction", () => { - const token: AccessToken = { + const token = { id: "testId", ttl: 100, scopes: ["string"], created: new Date(), userId: "testId", user: "testUser", - }; + } as unknown as SDKToken; const action = fromActions.fetchScicatTokenAction(); const outcome = fromActions.fetchScicatTokenCompleteAction({ token }); actions = hot("-a", { a: action }); - userApi.getCurrentToken.and.returnValue(token); + authService.getToken.and.returnValue(token); const expected = cold("-b", { b: outcome }); expect(effects.fetchScicatToken$).toBeObservable(expected); diff --git a/src/app/state-management/effects/user.effects.ts b/src/app/state-management/effects/user.effects.ts index 8a0cb9b1d..de518c160 100644 --- a/src/app/state-management/effects/user.effects.ts +++ b/src/app/state-management/effects/user.effects.ts @@ -1,14 +1,15 @@ import { Injectable } from "@angular/core"; import { Actions, ofType, createEffect, concatLatestFrom } from "@ngrx/effects"; import { ADAuthService } from "users/adauth.service"; +import { AuthService, SDKToken } from "shared/services/auth/auth.service"; import { - LoopBackAuth, - UserApi, - UserIdentityApi, - SDKToken, - User, - UserIdentity, -} from "shared/sdk"; + ReturnedUserDto, + UsersService, + AuthService as SharedAuthService, + UserSettings, + Configuration, + UserIdentitiesService, +} from "@scicatproject/scicat-sdk-ts"; import { Router } from "@angular/router"; import * as fromActions from "state-management/actions/user.actions"; import { @@ -67,7 +68,7 @@ export class UserEffects { adLogin$ = createEffect(() => { return this.actions$.pipe( ofType(fromActions.activeDirLoginAction), - switchMap(({ username, password, rememberMe }) => + switchMap(({ username, password }) => this.activeDirAuthService.login(username, password).pipe( switchMap(({ body }) => [ fromActions.activeDirLoginSuccessAction(), @@ -85,27 +86,28 @@ export class UserEffects { return this.actions$.pipe( ofType(fromActions.loginOIDCAction), switchMap(({ oidcLoginResponse }) => { - const accessTokenPrefix = - this.configService.getConfig().accessTokenPrefix; const token = new SDKToken({ - id: accessTokenPrefix + oidcLoginResponse.accessToken, + id: oidcLoginResponse.accessToken, userId: oidcLoginResponse.userId, ttl: oidcLoginResponse.ttl, created: oidcLoginResponse.created, }); - this.loopBackAuth.setToken(token); - return this.userApi.findById(oidcLoginResponse.userId).pipe( - switchMap((user: User) => [ - fromActions.fetchUserCompleteAction(), - fromActions.loginCompleteAction({ - user, - accountType: "external", - }), - ]), - catchError((error: HttpErrorResponse) => - of(fromActions.fetchUserFailedAction({ error })), - ), - ); + this.authService.setToken(token); + this.apiConfigService.accessToken = token.id; + return this.usersService + .usersControllerFindById(oidcLoginResponse.userId) + .pipe( + switchMap((user: ReturnedUserDto) => [ + fromActions.fetchUserCompleteAction(), + fromActions.loginCompleteAction({ + user, + accountType: "external", + }), + ]), + catchError((error: HttpErrorResponse) => + of(fromActions.fetchUserFailedAction({ error })), + ), + ); }), ); }); @@ -114,29 +116,30 @@ export class UserEffects { return this.actions$.pipe( ofType(fromActions.fetchUserAction), switchMap(({ adLoginResponse }) => { - const accessTokenPrefix = - this.configService.getConfig().accessTokenPrefix; const token = new SDKToken({ - id: accessTokenPrefix + adLoginResponse.access_token, + id: adLoginResponse.access_token, userId: adLoginResponse.userId, ttl: adLoginResponse.ttl, created: adLoginResponse.created, }); - this.loopBackAuth.setToken(token); - return this.userApi.findById(adLoginResponse.userId).pipe( - switchMap((user: User) => [ - fromActions.fetchUserCompleteAction(), - fromActions.loginCompleteAction({ - user, - accountType: "external", - }), - fromActions.fetchUserIdentityAction({ id: user.id }), - fromActions.fetchUserSettingsAction({ id: user.id }), - ]), - catchError((error: HttpErrorResponse) => - of(fromActions.fetchUserFailedAction({ error })), - ), - ); + this.authService.setToken(token); + this.apiConfigService.accessToken = token.id; + return this.usersService + .usersControllerFindById(adLoginResponse.userId) + .pipe( + switchMap((user: ReturnedUserDto) => [ + fromActions.fetchUserCompleteAction(), + fromActions.loginCompleteAction({ + user, + accountType: "external", + }), + fromActions.fetchUserIdentityAction({ id: user.id }), + fromActions.fetchUserSettingsAction({ id: user.id }), + ]), + catchError((error: HttpErrorResponse) => + of(fromActions.fetchUserFailedAction({ error })), + ), + ); }), ); }); @@ -146,14 +149,23 @@ export class UserEffects { ofType(fromActions.funcLoginAction), map((action) => action.form), switchMap(({ username, password, rememberMe }) => - this.userApi.login({ username, password, rememberMe }).pipe( - switchMap(({ user }) => [ - fromActions.funcLoginSuccessAction(), - fromActions.loginCompleteAction({ - user, - accountType: "functional", - }), - ]), + this.sharedAuthService.authControllerLogin({ username, password }).pipe( + switchMap((loginResponse) => { + this.apiConfigService.accessToken = loginResponse.access_token; + this.authService.setToken({ + ...loginResponse, + created: new Date(loginResponse.created), + rememberMe, + scopes: null, + }); + return [ + fromActions.funcLoginSuccessAction(), + fromActions.loginCompleteAction({ + user: loginResponse.user, + accountType: "functional", + }), + ]; + }), catchError((error: HttpErrorResponse) => { return of(fromActions.funcLoginFailedAction({ error })); }), @@ -203,20 +215,23 @@ export class UserEffects { logout$ = createEffect(() => { return this.actions$.pipe( ofType(fromActions.logoutAction), - filter(() => this.userApi.isAuthenticated()), + filter(() => this.authService.isAuthenticated()), switchMap(() => - this.userApi.logout().pipe( - switchMap(({ logoutURL }) => [ - clearDatasetsStateAction(), - clearInstrumentsStateAction(), - clearJobsStateAction(), - clearLogbooksStateAction(), - clearPoliciesStateAction(), - clearProposalsStateAction(), - clearPublishedDataStateAction(), - clearSamplesStateAction(), - fromActions.logoutCompleteAction({ logoutURL }), - ]), + this.sharedAuthService.authControllerLogout().pipe( + switchMap(({ logoutURL }) => { + this.authService.clear(); + return [ + clearDatasetsStateAction(), + clearInstrumentsStateAction(), + clearJobsStateAction(), + clearLogbooksStateAction(), + clearPoliciesStateAction(), + clearProposalsStateAction(), + clearPublishedDataStateAction(), + clearSamplesStateAction(), + fromActions.logoutCompleteAction({ logoutURL }), + ]; + }), catchError(() => of(fromActions.logoutFailedAction())), ), ), @@ -245,7 +260,7 @@ export class UserEffects { return this.actions$.pipe( ofType(fromActions.fetchCurrentUserAction), filter(() => { - const { created, ttl, id } = this.userApi.getCurrentToken(); + const { created, ttl, id } = this.authService.getToken(); const currentTimeStamp = Math.floor(new Date().getTime()); const createdTimeStamp = Math.floor(new Date(created).getTime()); @@ -253,14 +268,14 @@ export class UserEffects { const isTokenExpired = currentTimeStamp >= expirationTimeStamp; if (id && ttl && isTokenExpired) { - this.loopBackAuth.clear(); + this.authService.clear(); } - return this.userApi.isAuthenticated(); + return this.authService.isAuthenticated(); }), switchMap(() => - this.userApi.getCurrent().pipe( - switchMap((user) => [ + this.usersService.usersControllerGetMyUser().pipe( + switchMap((user: ReturnedUserDto) => [ fromActions.fetchCurrentUserCompleteAction({ user }), fromActions.fetchUserIdentityAction({ id: user.id }), fromActions.fetchUserSettingsAction({ id: user.id }), @@ -275,10 +290,14 @@ export class UserEffects { return this.actions$.pipe( ofType(fromActions.fetchUserIdentityAction), switchMap(({ id }) => - this.userIdentityApi - .findOne({ where: { userId: id } }) + this.userIdentityService + .userIdentitiesControllerFindOne( + JSON.stringify({ + where: { userId: id }, + }), + ) .pipe( - map((userIdentity: UserIdentity) => + map((userIdentity) => fromActions.fetchUserIdentityCompleteAction({ userIdentity }), ), catchError(() => of(fromActions.fetchUserIdentityFailedAction())), @@ -291,8 +310,8 @@ export class UserEffects { return this.actions$.pipe( ofType(fromActions.fetchUserSettingsAction), switchMap(({ id }) => - this.userApi.getSettings(id, null).pipe( - map((userSettings) => { + this.usersService.usersControllerGetSettings(id, null).pipe( + map((userSettings: UserSettings) => { const config = this.configService.getConfig(); const externalSettings = userSettings.externalSettings || {}; @@ -340,7 +359,7 @@ export class UserEffects { ofType(fromActions.fetchUserSettingsCompleteAction), mergeMap(({ userSettings }) => [ fromActions.updateFilterConfigs({ - filterConfigs: userSettings.filters, + filterConfigs: (userSettings as any).filters, }), ]), ); @@ -352,7 +371,8 @@ export class UserEffects { mergeMap(({ userSettings }) => { const actions = []; - userSettings.conditions + // TODO: Check with the types here. This is working better as it is now with the conditions and filters. We are leaving it for now as it was from before. + (userSettings as any).conditions .filter((condition) => condition.enabled) .forEach((condition) => { actions.push( @@ -368,7 +388,7 @@ export class UserEffects { actions.push( fromActions.updateConditionsConfigs({ - conditionConfigs: userSettings.conditions, + conditionConfigs: (userSettings as any).conditions, }), ); @@ -432,20 +452,25 @@ export class UserEffects { // using the partialUpdateExternalSettings API, which does not enforce validation. const apiCall$ = useExternalSettings - ? this.userApi.partialUpdateExternalSettings( + ? this.usersService.usersControllerPatchExternalSettings( user?.id, - JSON.stringify(newProperty), + JSON.stringify(newProperty) as any, ) - : this.userApi.partialUpdateSettings( + : this.usersService.usersControllerPatchSettings( user?.id, - JSON.stringify(newProperty), + JSON.stringify(newProperty) as any, ); return apiCall$.pipe( - map((userSettings) => { - userSettings["conditions"] = - userSettings.externalSettings.conditions; - userSettings["filters"] = userSettings.externalSettings.filters; - userSettings["columns"] = userSettings.externalSettings.columns; + map((userSettings: UserSettings) => { + userSettings["conditions"] = ( + userSettings.externalSettings as any + ).conditions; + userSettings["filters"] = ( + userSettings.externalSettings as any + ).filters; + userSettings["columns"] = ( + userSettings.externalSettings as any + ).columns; delete userSettings.externalSettings; return fromActions.updateUserSettingsCompleteAction({ userSettings, @@ -461,7 +486,7 @@ export class UserEffects { return this.actions$.pipe( ofType(fromActions.fetchScicatTokenAction), switchMap(() => - of(this.userApi.getCurrentToken()).pipe( + of(this.authService.getToken()).pipe( map((token) => fromActions.fetchScicatTokenCompleteAction({ token })), catchError(() => of(fromActions.fetchScicatTokenFailedAction())), ), @@ -506,10 +531,12 @@ export class UserEffects { private actions$: Actions, private activeDirAuthService: ADAuthService, private configService: AppConfigService, - private loopBackAuth: LoopBackAuth, + private apiConfigService: Configuration, + private authService: AuthService, private router: Router, private store: Store, - private userApi: UserApi, - private userIdentityApi: UserIdentityApi, + private usersService: UsersService, + private sharedAuthService: SharedAuthService, + private userIdentityService: UserIdentitiesService, ) {} } diff --git a/src/app/state-management/models/index.ts b/src/app/state-management/models/index.ts index 80b06f35c..08fd5021c 100644 --- a/src/app/state-management/models/index.ts +++ b/src/app/state-management/models/index.ts @@ -1,40 +1,7 @@ -import { - User, - UserIdentity, - UserSetting, - Job, - Dataset, - RawDataset, - Proposal, - Policy, - Sample, - Logbook, - PublishedData, - Attachment, - Instrument, -} from "shared/sdk/models"; -export { - User, - UserIdentity, - UserSetting, - Job, - Dataset, - RawDataset, - Proposal, - Policy, - Sample, - Logbook, - PublishedData, - Attachment, - Instrument, -}; - -import { DatasetInterface } from "shared/sdk"; import { ConditionConfig, FilterConfig, } from "shared/modules/filters/filters.module"; -export { DatasetInterface }; export interface Settings { tapeCopies: string; diff --git a/src/app/state-management/reducers/datasets.reducer.spec.ts b/src/app/state-management/reducers/datasets.reducer.spec.ts index 2185bf67d..510d1d4a3 100644 --- a/src/app/state-management/reducers/datasets.reducer.spec.ts +++ b/src/app/state-management/reducers/datasets.reducer.spec.ts @@ -1,41 +1,39 @@ import * as fromDatasets from "./datasets.reducer"; import * as fromActions from "../actions/datasets.actions"; -import { - Dataset, - DatasetInterface, - Attachment, - DerivedDatasetInterface, - DerivedDataset, -} from "shared/sdk/models"; import { FacetCounts, initialDatasetState, } from "state-management/state/datasets.store"; import { ArchViewMode, ScientificCondition } from "../models"; +import { createMock, mockAttachment as attachment } from "shared/MockStubs"; +import { OutputDatasetObsoleteDto } from "@scicatproject/scicat-sdk-ts"; -const derivedData: DerivedDatasetInterface = { +const derivedDataset = createMock({ + pid: "testPid", investigator: "", inputDatasets: [], usedSoftware: [], owner: "", contactEmail: "", sourceFolder: "", - creationTime: new Date(), + creationTime: new Date().toString(), type: "derived", ownerGroup: "", -}; -const derivedDataset = new DerivedDataset({ pid: "testPid", ...derivedData }); - -const data: DatasetInterface = { - owner: "", - contactEmail: "", - sourceFolder: "", - creationTime: new Date(), - type: "", - ownerGroup: "", + numberOfFilesArchived: 0, + accessGroups: [], + createdAt: "", + createdBy: "", + creationLocation: "", + principalInvestigator: "", + updatedAt: "", + updatedBy: "", attachments: [], -}; -const dataset = new Dataset({ pid: "testPid", ...data }); +}); + +const dataset = createMock({ + ...derivedDataset, + type: "raw", +}); describe("DatasetsReducer", () => { describe("on fetchDatasetsCompleteAction", () => { @@ -126,7 +124,7 @@ describe("DatasetsReducer", () => { describe("on prefillBatchCompleteAction", () => { it("should set batch property", () => { - const batch: Dataset[] = []; + const batch = []; const action = fromActions.prefillBatchCompleteAction({ batch }); const state = fromDatasets.datasetsReducer(initialDatasetState, action); @@ -183,7 +181,7 @@ describe("DatasetsReducer", () => { }); const state = fromDatasets.datasetsReducer(initialDatasetState, action); - expect(state.currentSet).toEqual(derivedDataset as unknown as Dataset); + expect(state.currentSet).toEqual(derivedDataset); }); }); @@ -191,7 +189,6 @@ describe("DatasetsReducer", () => { it("should add attachment to currentSet property", () => { initialDatasetState.currentSet = dataset; - const attachment = new Attachment(); const action = fromActions.addAttachmentCompleteAction({ attachment }); const state = fromDatasets.datasetsReducer(initialDatasetState, action); @@ -203,7 +200,6 @@ describe("DatasetsReducer", () => { it("should add new caption to an attachment", () => { initialDatasetState.currentSet = dataset; - const attachment = new Attachment(); const action = fromActions.updateAttachmentCaptionCompleteAction({ attachment, }); @@ -217,7 +213,6 @@ describe("DatasetsReducer", () => { it("should add attachment to currentSet property", () => { initialDatasetState.currentSet = dataset; - const attachment = new Attachment(); const attachmentId = "testId"; attachment.id = attachmentId; initialDatasetState.currentSet.attachments = [attachment]; diff --git a/src/app/state-management/reducers/datasets.reducer.ts b/src/app/state-management/reducers/datasets.reducer.ts index b79962278..e2e0ec8d6 100644 --- a/src/app/state-management/reducers/datasets.reducer.ts +++ b/src/app/state-management/reducers/datasets.reducer.ts @@ -4,11 +4,8 @@ import { DatasetState, } from "state-management/state/datasets.store"; import * as fromActions from "state-management/actions/datasets.actions"; -import { - ArchViewMode, - Dataset, - ScientificCondition, -} from "state-management/models"; +import { ArchViewMode, ScientificCondition } from "state-management/models"; +import { DatasetClass } from "@scicatproject/scicat-sdk-ts"; const reducer = createReducer( initialDatasetState, @@ -131,7 +128,7 @@ const reducer = createReducer( fromActions.addDatasetCompleteAction, (state, { dataset }): DatasetState => ({ ...state, - currentSet: dataset as unknown as Dataset, + currentSet: dataset, }), ), diff --git a/src/app/state-management/reducers/instruments.reducer.spec.ts b/src/app/state-management/reducers/instruments.reducer.spec.ts index c19ae08ee..bd21ce69e 100644 --- a/src/app/state-management/reducers/instruments.reducer.spec.ts +++ b/src/app/state-management/reducers/instruments.reducer.spec.ts @@ -1,12 +1,12 @@ import * as fromActions from "state-management/actions/instruments.actions"; -import { Instrument } from "shared/sdk"; import { instrumentsReducer } from "./instruments.reducer"; import { initialInstrumentState } from "state-management/state/instruments.store"; +import { mockInstrument as instrument } from "shared/MockStubs"; describe("InstrumentsReducer", () => { describe("on fetchInstrumentsCompleteAction", () => { it("should set instruments property", () => { - const instruments = [new Instrument()]; + const instruments = [instrument]; const action = fromActions.fetchInstrumentsCompleteAction({ instruments, }); @@ -28,7 +28,6 @@ describe("InstrumentsReducer", () => { describe("on fetchInstrumentCompleteAction", () => { it("should set currentInstrument property", () => { - const instrument = new Instrument(); const action = fromActions.fetchInstrumentCompleteAction({ instrument, }); @@ -40,7 +39,6 @@ describe("InstrumentsReducer", () => { describe("on saveCustomMetadataCompleteAction", () => { it("should set currentInstrument property", () => { - const instrument = new Instrument(); const action = fromActions.saveCustomMetadataCompleteAction({ instrument, }); diff --git a/src/app/state-management/reducers/jobs.reducer.spec.ts b/src/app/state-management/reducers/jobs.reducer.spec.ts index 21460d7c7..4a0157e02 100644 --- a/src/app/state-management/reducers/jobs.reducer.spec.ts +++ b/src/app/state-management/reducers/jobs.reducer.spec.ts @@ -1,15 +1,22 @@ import { jobsReducer } from "./jobs.reducer"; -import { JobInterface, Job } from "shared/sdk"; import * as fromActions from "../actions/jobs.actions"; import { initialJobsState } from "state-management/state/jobs.store"; +import { createMock } from "shared/MockStubs"; +import { JobClass } from "@scicatproject/scicat-sdk-ts"; -const data: JobInterface = { +const job = createMock({ + _id: "testId", id: "testId", emailJobInitiator: "test@email.com", type: "archive", - datasetList: {}, -}; -const job = new Job(data); + datasetList: [], + creationTime: "", + executionTime: "", + jobParams: {}, + jobResultObject: {}, + jobStatusMessage: "", + ownerGroup: "", +}); describe("jobsReducer", () => { describe("on fetchJobsCompleteAction", () => { diff --git a/src/app/state-management/reducers/logbooks.reducer.spec.ts b/src/app/state-management/reducers/logbooks.reducer.spec.ts index d4a52d083..90ba8391a 100644 --- a/src/app/state-management/reducers/logbooks.reducer.spec.ts +++ b/src/app/state-management/reducers/logbooks.reducer.spec.ts @@ -1,17 +1,24 @@ import { logbooksReducer } from "./logbooks.reducer"; import { initialLogbookState } from "../state/logbooks.store"; import * as fromActions from "../actions/logbooks.actions"; -import { Logbook, LogbookFilters } from "../models"; +import { LogbookFilters } from "../models"; +import { createMock } from "shared/MockStubs"; +import { Logbook } from "@scicatproject/scicat-sdk-ts"; describe("LogbooksReducer", () => { + const logbook = createMock({ + name: "test", + roomId: "!test@site", + messages: [], + }); + describe("on fetchLogbooksComplete", () => { it("should set logbooks", () => { const firstTestMessage = { content: "First message" }; const secondTestMessage = { content: "Second message" }; const logbooks = [ - new Logbook({ - roomId: "testId", - name: "testName", + createMock({ + ...logbook, messages: [firstTestMessage, secondTestMessage], }), ]; @@ -37,7 +44,6 @@ describe("LogbooksReducer", () => { describe("on fetchLogbookCompleteAction", () => { it("should set currentLogbook", () => { - const logbook = new Logbook(); const action = fromActions.fetchLogbookCompleteAction({ logbook }); const state = logbooksReducer(initialLogbookState, action); diff --git a/src/app/state-management/reducers/policies.reducer.spec.ts b/src/app/state-management/reducers/policies.reducer.spec.ts index 743d7e55d..8e710e257 100644 --- a/src/app/state-management/reducers/policies.reducer.spec.ts +++ b/src/app/state-management/reducers/policies.reducer.spec.ts @@ -1,12 +1,12 @@ import * as fromActions from "state-management/actions/policies.actions"; import { policiesReducer } from "./policies.reducer"; -import { Policy } from "shared/sdk"; import { initialPolicyState } from "state-management/state/policies.store"; +import { mockPolicy as policy } from "shared/MockStubs"; describe("PoliciesReducer", () => { describe("on fetchPoliciesCompleteAction", () => { it("should set policies", () => { - const policies = [new Policy()]; + const policies = [policy]; const action = fromActions.fetchPoliciesCompleteAction({ policies }); const state = policiesReducer(initialPolicyState, action); @@ -26,7 +26,7 @@ describe("PoliciesReducer", () => { describe("on fetchEditablePoliciesCompleteAction", () => { it("should set editablePolicies", () => { - const policies = [new Policy()]; + const policies = [policy]; const action = fromActions.fetchEditablePoliciesCompleteAction({ policies, }); @@ -48,7 +48,6 @@ describe("PoliciesReducer", () => { describe("on selectPolicyAction", () => { it("should set selectedPolicies", () => { - const policy = new Policy(); const action = fromActions.selectPolicyAction({ policy }); const state = policiesReducer(initialPolicyState, action); @@ -56,8 +55,8 @@ describe("PoliciesReducer", () => { }); it("should return same state if policy already selected", () => { - const policy = new Policy(); - policy.id = "1"; + const testPolicy = { ...policy }; + testPolicy._id = "1"; initialPolicyState.selectedPolicies = [policy]; const action = fromActions.selectPolicyAction({ policy }); @@ -67,8 +66,8 @@ describe("PoliciesReducer", () => { }); it("should add different policies to selectedPolicies", () => { - const firstPolicy = new Policy(); - firstPolicy.id = "1"; + const firstPolicy = { ...policy }; + firstPolicy._id = "1"; const firstSelectAction = fromActions.selectPolicyAction({ policy: firstPolicy, }); @@ -76,8 +75,8 @@ describe("PoliciesReducer", () => { initialPolicyState, firstSelectAction, ); - const secondPolicy = new Policy(); - secondPolicy.id = "2"; + const secondPolicy = { ...policy }; + secondPolicy._id = "2"; const secondSelectAction = fromActions.selectPolicyAction({ policy: secondPolicy, }); @@ -90,8 +89,8 @@ describe("PoliciesReducer", () => { describe("on deselectPolicyAction", () => { it("should remove policy from selectedPolicies", () => { - const policy = new Policy(); - policy.id = "testId"; + const testPolicy = { ...policy }; + testPolicy._id = "testId"; initialPolicyState.selectedPolicies = [policy]; const action = fromActions.deselectPolicyAction({ policy }); @@ -103,7 +102,7 @@ describe("PoliciesReducer", () => { describe("on selectAllPoliciesAction", () => { it("should add all editable policies to selectedPolicies", () => { - const policies = [new Policy()]; + const policies = [policy]; initialPolicyState.editablePolicies = policies; const action = fromActions.selectAllPoliciesAction(); const state = policiesReducer(initialPolicyState, action); @@ -114,7 +113,7 @@ describe("PoliciesReducer", () => { describe("on clearSelectionAction", () => { it("should set selectedPolicies to an empty array", () => { - initialPolicyState.selectedPolicies = [new Policy()]; + initialPolicyState.selectedPolicies = [policy]; const action = fromActions.clearSelectionAction(); const state = policiesReducer(initialPolicyState, action); diff --git a/src/app/state-management/reducers/policies.reducer.ts b/src/app/state-management/reducers/policies.reducer.ts index 1de8609c2..35ad7ddf1 100644 --- a/src/app/state-management/reducers/policies.reducer.ts +++ b/src/app/state-management/reducers/policies.reducer.ts @@ -41,7 +41,7 @@ const reducer = createReducer( on(fromActions.selectPolicyAction, (state, { policy }): PolicyState => { const alreadySelected = state.selectedPolicies.find( - (existing) => existing.id === policy.id, + (existing) => existing._id === policy._id, ); if (alreadySelected) { return state; @@ -52,7 +52,7 @@ const reducer = createReducer( }), on(fromActions.deselectPolicyAction, (state, { policy }): PolicyState => { const selectedPolicies = state.selectedPolicies.filter( - (selectedPolicy) => selectedPolicy.id !== policy.id, + (selectedPolicy) => selectedPolicy._id !== policy._id, ); return { ...state, selectedPolicies }; }), diff --git a/src/app/state-management/reducers/proposals.reducer.spec.ts b/src/app/state-management/reducers/proposals.reducer.spec.ts index ba07f5e73..715503639 100644 --- a/src/app/state-management/reducers/proposals.reducer.spec.ts +++ b/src/app/state-management/reducers/proposals.reducer.spec.ts @@ -4,16 +4,46 @@ import { ProposalFilters, } from "../state/proposals.store"; import * as fromActions from "../actions/proposals.actions"; -import { Attachment, Dataset, DatasetInterface, Proposal } from "../models"; -import { ProposalInterface } from "shared/sdk"; +import { createMock } from "shared/MockStubs"; +import { + OutputDatasetObsoleteDto, + ProposalClass, +} from "@scicatproject/scicat-sdk-ts"; -const proposalData: ProposalInterface = { +const proposal = createMock({ proposalId: "testId", email: "testEmail", ownerGroup: "testGroup", + accessGroups: [], + createdAt: "", + createdBy: "", + isPublished: false, + title: "Test proposal", + type: "", + updatedAt: "", + updatedBy: "", +}); + +const dataset = createMock({ + ownerGroup: "testGroup", + owner: "testOwner", + contactEmail: "testEmail", + sourceFolder: "testFolder", + creationTime: new Date(2019, 10, 7).toString(), + type: "raw", + pid: "testPid", attachments: [], -}; -const proposal = new Proposal(proposalData); + createdAt: "", + createdBy: "", + creationLocation: "", + inputDatasets: [], + investigator: "", + numberOfFilesArchived: 0, + principalInvestigator: "", + updatedAt: "", + updatedBy: "", + usedSoftware: [], +}); describe("ProposalsReducer", () => { describe("on fetchProposalsCompleteAction", () => { @@ -47,15 +77,7 @@ describe("ProposalsReducer", () => { describe("on fetchProposalDatasetsCompleteAction", () => { it("should set datasets", () => { - const data: DatasetInterface = { - ownerGroup: "testGroup", - owner: "testOwner", - contactEmail: "testEmail", - sourceFolder: "testFolder", - creationTime: new Date(2019, 10, 7), - type: "raw", - }; - const datasets = [new Dataset(data)]; + const datasets = [dataset]; const action = fromActions.fetchProposalDatasetsCompleteAction({ datasets, }); @@ -77,48 +99,48 @@ describe("ProposalsReducer", () => { }); }); - describe("on addAttachmentCompleteAction", () => { - it("should set attachments of currentProposal", () => { - initialProposalsState.currentProposal = proposal; - const attachment = new Attachment(); - const action = fromActions.addAttachmentCompleteAction({ attachment }); - const state = proposalsReducer(initialProposalsState, action); - - expect(state.currentProposal.attachments).toContain(attachment); - }); - }); - - describe("on updateAttachmentCaptionCompleteAction", () => { - it("should set attachments of currentProposal", () => { - const attachment = new Attachment(); - initialProposalsState.currentProposal = proposal; - initialProposalsState.currentProposal.attachments = [attachment]; - - const action = fromActions.updateAttachmentCaptionCompleteAction({ - attachment, - }); - const state = proposalsReducer(initialProposalsState, action); - - expect(state.currentProposal.attachments).toEqual([attachment]); - }); - }); - - describe("on removeAttachmentCompleteAction", () => { - it("should remove an attachment from currentProposal", () => { - const attachmentId = "testId"; - const attachment = new Attachment(); - attachment.id = attachmentId; - initialProposalsState.currentProposal = proposal; - initialProposalsState.currentProposal.attachments = [attachment]; - - const action = fromActions.removeAttachmentCompleteAction({ - attachmentId, - }); - const state = proposalsReducer(initialProposalsState, action); - - expect(state.currentProposal.attachments.length).toEqual(0); - }); - }); + // TODO: Check if this is needed as there are no more attachments on the ProposalClass model + // describe("on addAttachmentCompleteAction", () => { + // it("should set attachments of currentProposal", () => { + // initialProposalsState.currentProposal = proposal; + // const action = fromActions.addAttachmentCompleteAction({ attachment }); + // const state = proposalsReducer(initialProposalsState, action); + + // expect(state.currentProposal.attachments).toContain(attachment); + // }); + // }); + + // describe("on updateAttachmentCaptionCompleteAction", () => { + // it("should set attachments of currentProposal", () => { + // const attachment = new Attachment(); + // initialProposalsState.currentProposal = proposal; + // initialProposalsState.currentProposal.attachments = [attachment]; + + // const action = fromActions.updateAttachmentCaptionCompleteAction({ + // attachment, + // }); + // const state = proposalsReducer(initialProposalsState, action); + + // expect(state.currentProposal.attachments).toEqual([attachment]); + // }); + // }); + + // describe("on removeAttachmentCompleteAction", () => { + // it("should remove an attachment from currentProposal", () => { + // const attachmentId = "testId"; + // const attachment = new Attachment(); + // attachment.id = attachmentId; + // initialProposalsState.currentProposal = proposal; + // initialProposalsState.currentProposal.attachments = [attachment]; + + // const action = fromActions.removeAttachmentCompleteAction({ + // attachmentId, + // }); + // const state = proposalsReducer(initialProposalsState, action); + + // expect(state.currentProposal.attachments.length).toEqual(0); + // }); + // }); describe("on prefillFiltersAction", () => { it("should set filters and set hasPrefilledFilters to true", () => { diff --git a/src/app/state-management/reducers/proposals.reducer.ts b/src/app/state-management/reducers/proposals.reducer.ts index bf343e896..f79431054 100644 --- a/src/app/state-management/reducers/proposals.reducer.ts +++ b/src/app/state-management/reducers/proposals.reducer.ts @@ -62,7 +62,8 @@ const reducer = createReducer( fromActions.addAttachmentCompleteAction, (state, { attachment }): ProposalsState => { if (state.currentProposal) { - const attachments = state.currentProposal.attachments; + // TODO: Check this type here because on the proposals there are no attachements. Maybe we need to improve the backend type instead of returning ProposalClass + const attachments = (state.currentProposal as any).attachments; attachments.push(attachment); const currentProposal = { ...state.currentProposal, attachments }; return { ...state, currentProposal }; @@ -75,7 +76,7 @@ const reducer = createReducer( fromActions.updateAttachmentCaptionCompleteAction, (state, { attachment }): ProposalsState => { if (state.currentProposal) { - const attachments = state.currentProposal.attachments.filter( + const attachments = (state.currentProposal as any).attachments.filter( (existingAttachment) => existingAttachment.id !== attachment.id, ); attachments.push(attachment); @@ -90,7 +91,7 @@ const reducer = createReducer( fromActions.removeAttachmentCompleteAction, (state, { attachmentId }): ProposalsState => { if (state.currentProposal) { - const attachments = state.currentProposal.attachments.filter( + const attachments = (state.currentProposal as any).attachments.filter( (attachment) => attachment.id !== attachmentId, ); const currentProposal = { ...state.currentProposal, attachments }; diff --git a/src/app/state-management/reducers/published-data.reducer.spec.ts b/src/app/state-management/reducers/published-data.reducer.spec.ts index c60b465ff..cc785bea7 100644 --- a/src/app/state-management/reducers/published-data.reducer.spec.ts +++ b/src/app/state-management/reducers/published-data.reducer.spec.ts @@ -1,9 +1,10 @@ import { initialPublishedDataState } from "state-management/state/published-data.store"; import * as fromActions from "state-management/actions/published-data.actions"; import { publishedDataReducer } from "./published-data.reducer"; -import { PublishedData, PublishedDataInterface } from "shared/sdk"; +import { createMock } from "shared/MockStubs"; +import { PublishedData } from "@scicatproject/scicat-sdk-ts"; -const data: PublishedDataInterface = { +const publishedData = createMock({ doi: "testDOI", affiliation: "test affiliation", creator: ["test creator"], @@ -14,8 +15,14 @@ const data: PublishedDataInterface = { dataDescription: "test description", resourceType: "test type", pidArray: ["testPid"], -}; -const publishedData = new PublishedData(data); + createdAt: "", + registeredTime: "", + updatedAt: "", + url: "", + numberOfFiles: 1, + sizeOfArchive: 1, + status: "pending_registration", +}); describe("PublishedData Reducer", () => { describe("on fetchAllPublishedDataCompleteAction", () => { diff --git a/src/app/state-management/reducers/samples.reducer.spec.ts b/src/app/state-management/reducers/samples.reducer.spec.ts index 89337e827..38296e0af 100644 --- a/src/app/state-management/reducers/samples.reducer.spec.ts +++ b/src/app/state-management/reducers/samples.reducer.spec.ts @@ -1,21 +1,24 @@ import { samplesReducer } from "./samples.reducer"; import { initialSampleState } from "../state/samples.store"; import * as fromActions from "../actions/samples.actions"; +import { SampleFilters, ScientificCondition } from "../models"; import { - Attachment, - Sample, - Dataset, - SampleFilters, - ScientificCondition, -} from "../models"; -import { SampleInterface } from "shared/sdk"; - -const data: SampleInterface = { + createMock, + mockDataset as dataset, + mockAttachment as attachment, +} from "shared/MockStubs"; +import { SampleClass } from "@scicatproject/scicat-sdk-ts"; + +const sample = createMock({ sampleId: "testId", ownerGroup: "testGroup", - attachments: [], -}; -const sample = new Sample(data); + createdBy: "", + updatedBy: "", + createdAt: new Date().toString(), + updatedAt: new Date().toString(), + accessGroups: [], + isPublished: false, +}); describe("SamplesReducer", () => { describe("on fetchSamplesCompleteAction", () => { @@ -61,7 +64,7 @@ describe("SamplesReducer", () => { describe("on fetchSampleDatasetsCompleteAction", () => { it("should set datasets", () => { - const datasets = [new Dataset()]; + const datasets = [dataset]; const action = fromActions.fetchSampleDatasetsCompleteAction({ datasets, }); @@ -105,7 +108,6 @@ describe("SamplesReducer", () => { it("should set attachments for currentSample", () => { initialSampleState.currentSample = sample; - const attachment = new Attachment(); const action = fromActions.addAttachmentCompleteAction({ attachment, }); @@ -119,7 +121,6 @@ describe("SamplesReducer", () => { it("should set attachments for currentSample", () => { initialSampleState.currentSample = sample; - const attachment = new Attachment(); const action = fromActions.updateAttachmentCaptionCompleteAction({ attachment, }); @@ -132,7 +133,6 @@ describe("SamplesReducer", () => { describe("on removeAttachmentCompleteAction", () => { it("should set attachments for currentSample", () => { initialSampleState.currentSample = sample; - const attachment = new Attachment(); const attachmentId = "testId"; attachment.id = attachmentId; initialSampleState.attachments = [attachment]; diff --git a/src/app/state-management/reducers/user.reducer.spec.ts b/src/app/state-management/reducers/user.reducer.spec.ts index 720d9a3eb..4b9699c89 100644 --- a/src/app/state-management/reducers/user.reducer.spec.ts +++ b/src/app/state-management/reducers/user.reducer.spec.ts @@ -1,16 +1,10 @@ import { userReducer } from "./user.reducer"; import { initialUserState } from "../state/user.store"; import * as fromActions from "../actions/user.actions"; -import { - User, - MessageType, - Message, - Settings, - UserIdentity, - TableColumn, -} from "../models"; -import { AccessToken, UserSetting } from "shared/sdk"; +import { MessageType, Message, Settings, TableColumn } from "../models"; import { HttpErrorResponse } from "@angular/common/http"; +import { ReturnedUserDto, UserIdentity } from "@scicatproject/scicat-sdk-ts"; +import { SDKToken } from "shared/services/auth/auth.service"; describe("UserReducer", () => { describe("on setDatasetTableColumnsAction", () => { @@ -42,7 +36,12 @@ describe("UserReducer", () => { describe("on loginCompletAction", () => { it("should set currentUser, accountType, and set isLoggingIn to false and isLoggedIn to true", () => { - const user = new User(); + const user: ReturnedUserDto = { + id: "", + authStrategy: "", + email: "", + username: "", + }; const accountType = "test"; const action = fromActions.loginCompleteAction({ user, accountType }); const state = userReducer(initialUserState, action); @@ -67,7 +66,12 @@ describe("UserReducer", () => { describe("on fetchCurrentUserCompleteAction", () => { it("should set currentUser and set isLoggedIn to true", () => { - const user = new User(); + const user: ReturnedUserDto = { + id: "", + authStrategy: "", + email: "", + username: "", + }; const action = fromActions.fetchCurrentUserCompleteAction({ user }); const state = userReducer(initialUserState, action); @@ -78,7 +82,25 @@ describe("UserReducer", () => { describe("on fetchUserIdentityCompleteAction", () => { it("should set profile", () => { - const userIdentity = new UserIdentity(); + const userIdentity: UserIdentity = { + authStrategy: "", + created: "", + credentials: {}, + externalId: "", + modified: "", + profile: { + accessGroups: [], + displayName: "", + email: "", + emails: [], + id: "", + oidcClaims: [], + thumbnailPhoto: "", + username: "", + }, + provider: "", + userId: "", + }; const action = fromActions.fetchUserIdentityCompleteAction({ userIdentity, }); @@ -90,13 +112,14 @@ describe("UserReducer", () => { describe("on fetchUserSettingsCompleteAction", () => { it("should set jobCount and datasetCount settings, and columns if not empty", () => { - const userSettings = new UserSetting({ + const userSettings = { columns: [{ name: "test", order: 0, type: "standard", enabled: true }], datasetCount: 50, jobCount: 50, userId: "testId", + externalSettings: {}, id: "testId", - }); + }; const action = fromActions.fetchUserSettingsCompleteAction({ userSettings, }); @@ -104,17 +127,20 @@ describe("UserReducer", () => { expect(state.settings.datasetCount).toEqual(userSettings.datasetCount); expect(state.settings.jobCount).toEqual(userSettings.jobCount); - expect(state.columns).toEqual(userSettings.columns); + expect(state.columns).toEqual( + (userSettings as { columns: TableColumn[] }).columns, + ); }); it("should set jobCount and datasetCount settings, and not columns if empty", () => { - const userSettings = new UserSetting({ + const userSettings = { columns: [], datasetCount: 50, jobCount: 50, userId: "testId", id: "testId", - }); + externalSettings: {}, + }; const action = fromActions.fetchUserSettingsCompleteAction({ userSettings, }); @@ -128,13 +154,14 @@ describe("UserReducer", () => { describe("on updateUserSettingsCompleteAction", () => { it("should set jobCount and datasetCount settings, and columns if not empty", () => { - const userSettings = new UserSetting({ + const userSettings = { columns: [{ name: "test", order: 0, type: "standard", enabled: true }], datasetCount: 50, jobCount: 50, userId: "testId", + externalSettings: {}, id: "testId", - }); + }; const action = fromActions.updateUserSettingsCompleteAction({ userSettings, }); @@ -142,17 +169,20 @@ describe("UserReducer", () => { expect(state.settings.datasetCount).toEqual(userSettings.datasetCount); expect(state.settings.jobCount).toEqual(userSettings.jobCount); - expect(state.columns).toEqual(userSettings.columns); + expect(state.columns).toEqual( + (userSettings as { columns: TableColumn[] }).columns, + ); }); it("should set jobCount and datasetCount settings, and not columns if empty", () => { - const userSettings = new UserSetting({ + const userSettings = { columns: [], datasetCount: 50, jobCount: 50, userId: "testId", + externalSettings: {}, id: "testId", - }); + }; const action = fromActions.updateUserSettingsCompleteAction({ userSettings, }); @@ -166,7 +196,20 @@ describe("UserReducer", () => { describe("on fetchScicatTokenCompleteAction", () => { it("should set scicatToken", () => { - const token = new AccessToken(); + const token: SDKToken = { + id: "testId", + ttl: 100, + scopes: ["string"], + created: new Date(), + userId: "testId", + rememberMe: false, + user: { + id: "test", + email: "test@test.com", + username: "testUsername", + authStrategy: "local", + }, + }; const action = fromActions.fetchScicatTokenCompleteAction({ token }); const state = userReducer(initialUserState, action); diff --git a/src/app/state-management/reducers/user.reducer.ts b/src/app/state-management/reducers/user.reducer.ts index 54a8db1bb..4a4eae19d 100644 --- a/src/app/state-management/reducers/user.reducer.ts +++ b/src/app/state-management/reducers/user.reducer.ts @@ -61,7 +61,7 @@ const reducer = createReducer( on( fromActions.fetchUserSettingsCompleteAction, (state, { userSettings }): UserState => { - const { datasetCount, jobCount, columns } = userSettings; + const { datasetCount, jobCount, columns } = userSettings as any; const settings = { ...state.settings, datasetCount, jobCount }; if (columns.length > 0) { return { ...state, settings, columns }; @@ -74,7 +74,7 @@ const reducer = createReducer( on( fromActions.updateUserSettingsCompleteAction, (state, { userSettings }): UserState => { - const { datasetCount, jobCount, columns = [] } = userSettings; + const { datasetCount, jobCount, columns = [] } = userSettings as any; const settings = { ...state.settings, datasetCount, jobCount }; if (columns.length > 0) { return { ...state, settings, columns }; diff --git a/src/app/state-management/selectors/datasets.selectors.spec.ts b/src/app/state-management/selectors/datasets.selectors.spec.ts index c4ee8006a..95b8ea6df 100644 --- a/src/app/state-management/selectors/datasets.selectors.spec.ts +++ b/src/app/state-management/selectors/datasets.selectors.spec.ts @@ -1,8 +1,7 @@ import * as fromDatasetSelectors from "./datasets.selectors"; -import { ArchViewMode, Dataset } from "../models"; +import { ArchViewMode } from "../models"; import { DatasetState } from "../state/datasets.store"; - -const dataset = new Dataset(); +import { mockDataset as dataset } from "shared/MockStubs"; const initialDatasetState: DatasetState = { datasets: [], diff --git a/src/app/state-management/selectors/instruments.selectors.spec.ts b/src/app/state-management/selectors/instruments.selectors.spec.ts index 365aff987..f8f9d6fc5 100644 --- a/src/app/state-management/selectors/instruments.selectors.spec.ts +++ b/src/app/state-management/selectors/instruments.selectors.spec.ts @@ -1,8 +1,7 @@ import { InstrumentState } from "state-management/state/instruments.store"; import * as fromSelectors from "./instruments.selectors"; -import { GenericFilters, Instrument } from "state-management/models"; - -const instrument = new Instrument(); +import { GenericFilters } from "state-management/models"; +import { mockInstrument as instrument } from "shared/MockStubs"; const instrumentFilters: GenericFilters = { sortField: "name desc", diff --git a/src/app/state-management/selectors/jobs.selectors.spec.ts b/src/app/state-management/selectors/jobs.selectors.spec.ts index c20da5203..7f866bd6f 100644 --- a/src/app/state-management/selectors/jobs.selectors.spec.ts +++ b/src/app/state-management/selectors/jobs.selectors.spec.ts @@ -1,15 +1,22 @@ import * as fromSelectors from "./jobs.selectors"; import { JobsState } from "../state/jobs.store"; -import { JobInterface, Job } from "shared/sdk"; +import { createMock } from "shared/MockStubs"; +import { JobClass } from "@scicatproject/scicat-sdk-ts"; -const data: JobInterface = { - id: "testId", +const job = createMock({ emailJobInitiator: "test@email.com", type: "archive", - datasetList: {}, -}; -const job = new Job(data); + _id: "", + id: "", + creationTime: "", + executionTime: "", + jobParams: {}, + jobResultObject: {}, + jobStatusMessage: "", + ownerGroup: "", + datasetList: [], +}); const jobFilters = { mode: null, diff --git a/src/app/state-management/selectors/logbooks.selectors.spec.ts b/src/app/state-management/selectors/logbooks.selectors.spec.ts index 618d723bc..9477cbbf7 100644 --- a/src/app/state-management/selectors/logbooks.selectors.spec.ts +++ b/src/app/state-management/selectors/logbooks.selectors.spec.ts @@ -1,9 +1,8 @@ +import { mockLogbook as logbook } from "shared/MockStubs"; import * as fromSelectors from "./logbooks.selectors"; -import { LogbookFilters, Logbook } from "state-management/models"; +import { LogbookFilters } from "state-management/models"; import { LogbookState } from "state-management/state/logbooks.store"; -const logbook = new Logbook(); - const logbookFilters: LogbookFilters = { textSearch: "test", showBotMessages: true, diff --git a/src/app/state-management/selectors/proposals.selectors.spec.ts b/src/app/state-management/selectors/proposals.selectors.spec.ts index 9ae84a756..ab8491753 100644 --- a/src/app/state-management/selectors/proposals.selectors.spec.ts +++ b/src/app/state-management/selectors/proposals.selectors.spec.ts @@ -1,21 +1,34 @@ import * as fromSelectors from "./proposals.selectors"; -import { Proposal, ProposalInterface, Attachment } from "shared/sdk/models"; import { ProposalsState } from "state-management/state/proposals.store"; +import { createMock } from "shared/MockStubs"; +import { ProposalClass } from "@scicatproject/scicat-sdk-ts"; -const data: ProposalInterface = { +const proposal = createMock({ proposalId: "testId", email: "testEmail", ownerGroup: "testGroup", -}; -const parentProposalData: ProposalInterface = { + accessGroups: [], + createdAt: "", + createdBy: "", + isPublished: false, + title: "test", + type: "", + updatedAt: "", + updatedBy: "", +}); +const parentProposal = createMock({ proposalId: "parentTestId", email: "parentTestEmail", ownerGroup: "parentTestGroup", -}; -const proposal = new Proposal(data); -const parentProposal = new Proposal(parentProposalData); -const attachments = [new Attachment()]; -proposal.attachments = attachments; + accessGroups: [], + createdAt: "", + createdBy: "", + isPublished: false, + title: "test", + type: "", + updatedAt: "", + updatedBy: "", +}); const initialProposalsState: ProposalsState = { proposals: [], @@ -63,16 +76,6 @@ describe("Proposal Selectors", () => { }); }); - describe("selectCurrentAttachments", () => { - it("should select attachments from current proposal", () => { - expect( - fromSelectors.selectCurrentAttachments.projector( - initialProposalsState.currentProposal, - ), - ).toEqual(attachments); - }); - }); - describe("selectProposalDatasets", () => { it("should select datasets belonging to current proposal", () => { expect( diff --git a/src/app/state-management/selectors/proposals.selectors.ts b/src/app/state-management/selectors/proposals.selectors.ts index 3e36a0448..51b4ce3a6 100644 --- a/src/app/state-management/selectors/proposals.selectors.ts +++ b/src/app/state-management/selectors/proposals.selectors.ts @@ -20,7 +20,8 @@ export const selectParentProposal = createSelector( export const selectCurrentAttachments = createSelector( selectCurrentProposal, - (proposal) => (proposal ? proposal.attachments : []), + // TODO: Check if this is still relevant because proposal doesn't have attachments in the schema + (proposal) => (proposal ? (proposal as any).attachments : []), ); export const selectProposalDatasets = createSelector( diff --git a/src/app/state-management/selectors/published-data.selectors.spec.ts b/src/app/state-management/selectors/published-data.selectors.spec.ts index 8ca7089c8..3a5eeaff5 100644 --- a/src/app/state-management/selectors/published-data.selectors.spec.ts +++ b/src/app/state-management/selectors/published-data.selectors.spec.ts @@ -1,9 +1,10 @@ -import { PublishedDataInterface, PublishedData } from "shared/sdk"; import { GenericFilters } from "state-management/models"; import { PublishedDataState } from "state-management/state/published-data.store"; import * as fromSelectors from "./published-data.selectors"; +import { createMock } from "shared/MockStubs"; +import { PublishedData } from "@scicatproject/scicat-sdk-ts"; -const data: PublishedDataInterface = { +const publishedData = createMock({ doi: "testDOI", affiliation: "test affiliation", creator: ["test creator"], @@ -14,8 +15,14 @@ const data: PublishedDataInterface = { dataDescription: "test description", resourceType: "test type", pidArray: ["testPid"], -}; -const publishedData = new PublishedData(data); + createdAt: "", + registeredTime: "", + updatedAt: "", + url: "", + numberOfFiles: 1, + sizeOfArchive: 1, + status: "pending_registration", +}); const filters: GenericFilters = { sortField: "publicationYear desc", diff --git a/src/app/state-management/selectors/samples.selectors.spec.ts b/src/app/state-management/selectors/samples.selectors.spec.ts index 11e4fdd1b..192d9eff9 100644 --- a/src/app/state-management/selectors/samples.selectors.spec.ts +++ b/src/app/state-management/selectors/samples.selectors.spec.ts @@ -1,14 +1,19 @@ import * as fromSelectors from "./samples.selectors"; import { SampleState } from "state-management/state/samples.store"; -import { SampleInterface, Sample } from "shared/sdk"; import { initialUserState } from "state-management/state/user.store"; +import { createMock } from "shared/MockStubs"; +import { SampleClass } from "@scicatproject/scicat-sdk-ts"; -const data: SampleInterface = { +const sample = createMock({ sampleId: "testId", ownerGroup: "testGroup", - attachments: [], -}; -const sample = new Sample(data); + createdBy: "", + updatedBy: "", + createdAt: new Date().toString(), + updatedAt: new Date().toString(), + accessGroups: [], + isPublished: false, +}); const initialSampleState: SampleState = { samples: [], diff --git a/src/app/state-management/selectors/user.selectors.spec.ts b/src/app/state-management/selectors/user.selectors.spec.ts index 6bd2bc708..1b92e0ed6 100644 --- a/src/app/state-management/selectors/user.selectors.spec.ts +++ b/src/app/state-management/selectors/user.selectors.spec.ts @@ -1,56 +1,47 @@ import * as fromSelectors from "./user.selectors"; import { UserState } from "../state/user.store"; -import { User, UserIdentity, Settings } from "../models"; -import { AccessToken } from "shared/sdk"; -import { LocationFilterComponent } from "../../shared/modules/filters/location-filter.component"; -import { PidFilterComponent } from "../../shared/modules/filters/pid-filter.component"; -import { PidFilterContainsComponent } from "../../shared/modules/filters/pid-filter-contains.component"; -import { PidFilterStartsWithComponent } from "../../shared/modules/filters/pid-filter-startsWith.component"; -import { GroupFilterComponent } from "../../shared/modules/filters/group-filter.component"; -import { TypeFilterComponent } from "../../shared/modules/filters/type-filter.component"; -import { KeywordFilterComponent } from "../../shared/modules/filters/keyword-filter.component"; -import { DateRangeFilterComponent } from "../../shared/modules/filters/date-range-filter.component"; -import { TextFilterComponent } from "../../shared/modules/filters/text-filter.component"; - -const user = new User({ +import { Settings } from "../models"; +import { ReturnedUserDto, UserIdentity } from "@scicatproject/scicat-sdk-ts"; +import { SDKToken } from "shared/services/auth/auth.service"; + +const user: ReturnedUserDto = { id: "testId", realm: "testRealm", username: "testName", email: "test@email.com", emailVerified: true, - password: "testPassword", - accessTokens: [], - identities: [], - credentials: [], -}); + authStrategy: "local", +}; const userIdentity: UserIdentity = { - id: "testId", - user, + ...user, provider: "testProvider", - authScheme: "testScheme", externalId: "testId", credentials: null, userId: "testId", - created: new Date(), - modified: new Date(), + created: new Date().toDateString(), + modified: new Date().toDateString(), profile: { id: "testId", displayName: "testName", email: "test@email.com", username: "testName", thumbnailPhoto: "data", + accessGroups: [], + emails: [], + oidcClaims: [], }, }; -const scicatToken: AccessToken = { +const scicatToken: SDKToken = { id: "testId", ttl: 100, scopes: ["string"], created: new Date(), userId: "testId", user: null, + rememberMe: false, }; const settings: Settings = { diff --git a/src/app/state-management/state/datasets.store.ts b/src/app/state-management/state/datasets.store.ts index ad84c0ea0..b1c9ce9b8 100644 --- a/src/app/state-management/state/datasets.store.ts +++ b/src/app/state-management/state/datasets.store.ts @@ -1,4 +1,6 @@ -import { DatasetFilters, Dataset, ArchViewMode } from "state-management/models"; +import { DatasetClass } from "@scicatproject/scicat-sdk-ts"; +import { DatasetFilters, ArchViewMode } from "state-management/models"; +import { OutputDatasetObsoleteDto } from "@scicatproject/scicat-sdk-ts"; export interface DateTriple { year: number; @@ -21,10 +23,10 @@ export interface Pagination { } export interface DatasetState { - datasets: Dataset[]; - selectedSets: Dataset[]; - currentSet: Dataset | undefined; - relatedDatasets: Dataset[]; + datasets: OutputDatasetObsoleteDto[]; + selectedSets: OutputDatasetObsoleteDto[]; + currentSet: OutputDatasetObsoleteDto | undefined; + relatedDatasets: OutputDatasetObsoleteDto[]; relatedDatasetsCount: number; totalCount: number; @@ -43,7 +45,7 @@ export interface DatasetState { sortField: string; }; - batch: Dataset[]; + batch: OutputDatasetObsoleteDto[]; openwhiskResult: Record | undefined; } diff --git a/src/app/state-management/state/instruments.store.ts b/src/app/state-management/state/instruments.store.ts index 5a261ac5c..fa1a2f16b 100644 --- a/src/app/state-management/state/instruments.store.ts +++ b/src/app/state-management/state/instruments.store.ts @@ -1,4 +1,5 @@ -import { Instrument, GenericFilters } from "../models"; +import { Instrument } from "@scicatproject/scicat-sdk-ts"; +import { GenericFilters } from "../models"; export interface InstrumentState { instruments: Instrument[]; diff --git a/src/app/state-management/state/jobs.store.ts b/src/app/state-management/state/jobs.store.ts index 82ea1b61a..365e0ede3 100644 --- a/src/app/state-management/state/jobs.store.ts +++ b/src/app/state-management/state/jobs.store.ts @@ -1,8 +1,9 @@ -import { Job, JobFilters } from "state-management/models"; +import { JobClass } from "@scicatproject/scicat-sdk-ts"; +import { JobFilters } from "state-management/models"; export interface JobsState { - jobs: Job[]; - currentJob: Job | undefined; + jobs: JobClass[]; + currentJob: JobClass | undefined; totalCount: number; diff --git a/src/app/state-management/state/logbooks.store.ts b/src/app/state-management/state/logbooks.store.ts index d3e580c4b..2f8f90210 100644 --- a/src/app/state-management/state/logbooks.store.ts +++ b/src/app/state-management/state/logbooks.store.ts @@ -1,8 +1,9 @@ -import { Logbook, LogbookFilters } from "state-management/models"; +import { Logbook } from "@scicatproject/scicat-sdk-ts"; +import { LogbookFilters } from "state-management/models"; export interface LogbookState { logbooks: Logbook[]; - currentLogbook: Logbook | undefined; + currentLogbook: any | undefined; totalCount: number; diff --git a/src/app/state-management/state/policies.store.ts b/src/app/state-management/state/policies.store.ts index 9dd018486..6c740123d 100644 --- a/src/app/state-management/state/policies.store.ts +++ b/src/app/state-management/state/policies.store.ts @@ -1,4 +1,5 @@ -import { GenericFilters, Policy } from "state-management/models"; +import { Policy } from "@scicatproject/scicat-sdk-ts"; +import { GenericFilters } from "state-management/models"; export interface PolicyState { policies: Policy[]; diff --git a/src/app/state-management/state/proposals.store.ts b/src/app/state-management/state/proposals.store.ts index d079192f9..ce4de4254 100644 --- a/src/app/state-management/state/proposals.store.ts +++ b/src/app/state-management/state/proposals.store.ts @@ -1,4 +1,7 @@ -import { Proposal, Dataset } from "../models"; +import { + OutputDatasetObsoleteDto, + ProposalClass, +} from "@scicatproject/scicat-sdk-ts"; export interface DateRange { begin: string; @@ -21,10 +24,10 @@ export interface ProposalDatesetFilters { } export interface ProposalsState { - proposals: Proposal[]; - currentProposal: Proposal | undefined; - parentProposal: Proposal | undefined; - datasets: Dataset[]; + proposals: ProposalClass[]; + currentProposal: ProposalClass | undefined; + parentProposal: ProposalClass | undefined; + datasets: OutputDatasetObsoleteDto[]; proposalsCount: number; datasetsCount: number; diff --git a/src/app/state-management/state/published-data.store.ts b/src/app/state-management/state/published-data.store.ts index a79b3cd3a..94f1fda50 100644 --- a/src/app/state-management/state/published-data.store.ts +++ b/src/app/state-management/state/published-data.store.ts @@ -1,4 +1,5 @@ -import { PublishedData, GenericFilters } from "state-management/models"; +import { PublishedData } from "@scicatproject/scicat-sdk-ts"; +import { GenericFilters } from "state-management/models"; export interface PublishedDataState { publishedData: PublishedData[]; diff --git a/src/app/state-management/state/samples.store.ts b/src/app/state-management/state/samples.store.ts index 139f9bb5a..56f394cbd 100644 --- a/src/app/state-management/state/samples.store.ts +++ b/src/app/state-management/state/samples.store.ts @@ -1,16 +1,15 @@ import { - Sample, - SampleFilters, - Dataset, - GenericFilters, Attachment, -} from "state-management/models"; + OutputDatasetObsoleteDto, + SampleClass, +} from "@scicatproject/scicat-sdk-ts"; +import { SampleFilters, GenericFilters } from "state-management/models"; export interface SampleState { - samples: Sample[]; + samples: SampleClass[]; attachments: Attachment[]; - currentSample: Sample | undefined; - datasets: Dataset[]; + currentSample: SampleClass | undefined; + datasets: OutputDatasetObsoleteDto[]; metadataKeys: string[]; samplesCount: number; diff --git a/src/app/state-management/state/user.store.ts b/src/app/state-management/state/user.store.ts index 664bf7dde..c159b9283 100644 --- a/src/app/state-management/state/user.store.ts +++ b/src/app/state-management/state/user.store.ts @@ -1,5 +1,6 @@ -import { Settings, Message, User, TableColumn } from "../models"; -import { AccessToken } from "shared/sdk"; +import { Settings, Message, TableColumn } from "../models"; +import { AccessTokenInterface } from "shared/services/auth/auth.service"; +import { ReturnedUserDto } from "@scicatproject/scicat-sdk-ts"; import { ConditionConfig, FilterConfig, @@ -7,11 +8,11 @@ import { // NOTE It IS ok to make up a state of other sub states export interface UserState { - currentUser: User | undefined; + currentUser: ReturnedUserDto | undefined; accountType?: string; profile?: any; - scicatToken: AccessToken; + scicatToken: AccessTokenInterface; settings: Settings; @@ -39,7 +40,7 @@ export const initialUserState: UserState = { scopes: ["string"], created: new Date(), userId: "", - user: {}, + user: { id: "", username: "", email: "", authStrategy: "" }, }, settings: { diff --git a/src/app/users/adauth.service.spec.ts b/src/app/users/adauth.service.spec.ts index a471a6f21..97eefdc9b 100644 --- a/src/app/users/adauth.service.spec.ts +++ b/src/app/users/adauth.service.spec.ts @@ -4,6 +4,7 @@ import { ADAuthService } from "./adauth.service"; import { MockHttp } from "shared/MockStubs"; import { AppConfigService } from "app-config.service"; +import { Configuration } from "@scicatproject/scicat-sdk-ts"; describe("ADAuthService", () => { let service: ADAuthService; @@ -20,6 +21,10 @@ describe("ADAuthService", () => { provide: AppConfigService, useValue: { getConfig }, }, + { + provide: Configuration, + useClass: Configuration, + }, { provide: HttpClient, useClass: MockHttp }, ], }); diff --git a/src/app/users/adauth.service.ts b/src/app/users/adauth.service.ts index c7c1a08eb..932379f8a 100644 --- a/src/app/users/adauth.service.ts +++ b/src/app/users/adauth.service.ts @@ -1,9 +1,9 @@ import { Injectable } from "@angular/core"; import { HttpClient, HttpResponse, HttpHeaders } from "@angular/common/http"; -import { LoopBackConfig } from "shared/sdk/lb.config"; import { Observable } from "rxjs"; import { timeout } from "rxjs/operators"; import { AppConfigService } from "app-config.service"; +import { Configuration } from "@scicatproject/scicat-sdk-ts"; export interface Credentials { username: string; @@ -24,6 +24,7 @@ export interface AccessToken { export class ADAuthService { constructor( private appConfigService: AppConfigService, + private apiConfig: Configuration, private http: HttpClient, ) {} @@ -46,7 +47,7 @@ export class ADAuthService { }; const appConfig = this.appConfigService.getConfig(); const headers = new HttpHeaders(); - const url = LoopBackConfig.getPath() + appConfig.externalAuthEndpoint; + const url = this.apiConfig.basePath + appConfig.externalAuthEndpoint; headers.append("Content-Type", "application/x-www-form-urlencoded"); return this.http .post(url, creds, { observe: "response" }) diff --git a/src/app/users/user-settings/user-settings.component.ts b/src/app/users/user-settings/user-settings.component.ts index 60d784940..b3f586d25 100644 --- a/src/app/users/user-settings/user-settings.component.ts +++ b/src/app/users/user-settings/user-settings.component.ts @@ -41,10 +41,9 @@ export class UserSettingsComponent implements OnInit { } ngOnInit() { - this.vm$.subscribe( - (settings) => - (this.tokenValue = settings.scicatToken.replace("Bearer ", "")), - ); + this.vm$.subscribe((settings) => { + this.tokenValue = settings.scicatToken; + }); this.store.dispatch(fetchCurrentUserAction()); this.store.dispatch(fetchScicatTokenAction());