@studyportals/crm-data-processor-interface 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +7 -0
- package/index.js +6 -0
- package/index.js.map +1 -0
- package/package.json +28 -0
- package/src/clients/crm-data-processor-client.d.ts +10 -0
- package/src/clients/crm-data-processor-client.js +37 -0
- package/src/clients/crm-data-processor-client.js.map +1 -0
- package/src/data/act-product.d.ts +5 -0
- package/src/data/act-product.js +3 -0
- package/src/data/act-product.js.map +1 -0
- package/src/data/products-response-body.d.ts +2 -0
- package/src/data/products-response-body.js +3 -0
- package/src/data/products-response-body.js.map +1 -0
- package/src/data/project-details-response-body.d.ts +2 -0
- package/src/data/project-details-response-body.js +3 -0
- package/src/data/project-details-response-body.js.map +1 -0
- package/src/data/project-details.d.ts +9 -0
- package/src/data/project-details.js +3 -0
- package/src/data/project-details.js.map +1 -0
- package/src/data/project-product.d.ts +7 -0
- package/src/data/project-product.js +3 -0
- package/src/data/project-product.js.map +1 -0
- package/vitest.config.d.ts +2 -0
- package/vitest.config.js +16 -0
- package/vitest.config.js.map +1 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CrmDataProcessorClient } from "./src/clients/crm-data-processor-client";
|
|
2
|
+
import { ActProduct } from "./src/data/act-product";
|
|
3
|
+
import { ProductsResponseBody } from "./src/data/products-response-body";
|
|
4
|
+
import { ProjectDetails } from "./src/data/project-details";
|
|
5
|
+
import { ProjectDetailsResponseBody } from "./src/data/project-details-response-body";
|
|
6
|
+
import { ProjectProduct } from "./src/data/project-product";
|
|
7
|
+
export { CrmDataProcessorClient, ProductsResponseBody, ActProduct, ProjectDetailsResponseBody, ProjectDetails, ProjectProduct };
|
package/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrmDataProcessorClient = void 0;
|
|
4
|
+
const crm_data_processor_client_1 = require("./src/clients/crm-data-processor-client");
|
|
5
|
+
Object.defineProperty(exports, "CrmDataProcessorClient", { enumerable: true, get: function () { return crm_data_processor_client_1.CrmDataProcessorClient; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,uFAAiF;AAQhF,uGARQ,kDAAsB,OAQR"}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@studyportals/crm-data-processor-interface",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"compile": "rm -fR dist && npx tsc",
|
|
6
|
+
"prepare-deployment": "npm run compile && cp package.json dist/package.json && rm -fR dist/tests",
|
|
7
|
+
"deploy": "npm run prepare-deployment && npm publish ./dist --access=public",
|
|
8
|
+
"deploy-patch": "npm version patch && npm run deploy",
|
|
9
|
+
"deploy-minor": "npm version minor && npm run deploy",
|
|
10
|
+
"deploy-major": "npm version major && npm run deploy",
|
|
11
|
+
"deploy-beta": "npm version prerelease && npm run prepare-deployment && npm publish ./dist --tag beta --access=public"
|
|
12
|
+
},
|
|
13
|
+
"author": "SPNightsWatch",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@studyportals/code-style": "*",
|
|
18
|
+
"@types/node": "^24.10.1",
|
|
19
|
+
"ts-node": "^10.9.2",
|
|
20
|
+
"typescript": "^5.9.3",
|
|
21
|
+
"vitest": "^4.0.14"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": "22.x",
|
|
26
|
+
"npm ": "10.x"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProjectDetailsResponseBody } from "../data/project-details-response-body";
|
|
2
|
+
import { ProductsResponseBody } from "../data/products-response-body";
|
|
3
|
+
export declare class CrmDataProcessorClient {
|
|
4
|
+
private readonly baseUrl;
|
|
5
|
+
private readonly jwtTokenProvider;
|
|
6
|
+
constructor(baseUrl: string, jwtTokenProvider: () => Promise<string>);
|
|
7
|
+
retrieveActiveProducts(): Promise<ProductsResponseBody>;
|
|
8
|
+
retrieveProjectDetails(): Promise<ProjectDetailsResponseBody>;
|
|
9
|
+
private sendGetRequest;
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrmDataProcessorClient = void 0;
|
|
4
|
+
class CrmDataProcessorClient {
|
|
5
|
+
baseUrl;
|
|
6
|
+
jwtTokenProvider;
|
|
7
|
+
constructor(baseUrl, jwtTokenProvider) {
|
|
8
|
+
this.baseUrl = baseUrl;
|
|
9
|
+
this.jwtTokenProvider = jwtTokenProvider;
|
|
10
|
+
}
|
|
11
|
+
async retrieveActiveProducts() {
|
|
12
|
+
const jwt = await this.jwtTokenProvider();
|
|
13
|
+
const url = new URL(this.baseUrl + `/products/active`);
|
|
14
|
+
return await this.sendGetRequest(url, jwt);
|
|
15
|
+
}
|
|
16
|
+
async retrieveProjectDetails() {
|
|
17
|
+
const jwt = await this.jwtTokenProvider();
|
|
18
|
+
const url = new URL(this.baseUrl + `/projects`);
|
|
19
|
+
return await this.sendGetRequest(url, jwt);
|
|
20
|
+
}
|
|
21
|
+
async sendGetRequest(url, jwt, headers) {
|
|
22
|
+
const response = await fetch(url, {
|
|
23
|
+
method: "GET",
|
|
24
|
+
headers: {
|
|
25
|
+
"Authorization": jwt,
|
|
26
|
+
...headers
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
const errorBody = await response.text().catch(() => "");
|
|
31
|
+
throw new Error(`Request failed with status ${response.status}: ${response.statusText}, with body: ${errorBody ? ` - ${errorBody}` : ""}`);
|
|
32
|
+
}
|
|
33
|
+
return await response.json();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.CrmDataProcessorClient = CrmDataProcessorClient;
|
|
37
|
+
//# sourceMappingURL=crm-data-processor-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crm-data-processor-client.js","sourceRoot":"","sources":["../../../src/clients/crm-data-processor-client.ts"],"names":[],"mappings":";;;AAGA,MAAa,sBAAsB;IAGhB;IACA;IAFlB,YACkB,OAAe,EACf,gBAAuC;QADvC,YAAO,GAAP,OAAO,CAAQ;QACf,qBAAgB,GAAhB,gBAAgB,CAAuB;IACrD,CAAC;IAEE,KAAK,CAAC,sBAAsB;QAClC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,kBAAkB,CAAC,CAAC;QACvD,OAAO,MAAM,IAAI,CAAC,cAAc,CAAuB,GAAG,EAAE,GAAG,CAAC,CAAC;IAClE,CAAC;IAEM,KAAK,CAAC,sBAAsB;QAClC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;QAChD,OAAO,MAAM,IAAI,CAAC,cAAc,CAA6B,GAAG,EAAE,GAAG,CAAC,CAAC;IACxE,CAAC;IAEO,KAAK,CAAC,cAAc,CAAI,GAAQ,EAAE,GAAW,EAAE,OAAgC;QACtF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YACjC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACR,eAAe,EAAE,GAAG;gBACpB,GAAG,OAAO;aACV;SACD,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YAClB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YACxD,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,gBAAgB,SAAS,CAAC,CAAC,CAAC,MAAM,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5I,CAAC;QAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAO,CAAC;IACnC,CAAC;CACD;AAnCD,wDAmCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"act-product.js","sourceRoot":"","sources":["../../../src/data/act-product.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"products-response-body.js","sourceRoot":"","sources":["../../../src/data/products-response-body.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-details-response-body.js","sourceRoot":"","sources":["../../../src/data/project-details-response-body.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-details.js","sourceRoot":"","sources":["../../../src/data/project-details.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-product.js","sourceRoot":"","sources":["../../../src/data/project-product.ts"],"names":[],"mappings":""}
|
package/vitest.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_1 = require("vitest/config");
|
|
4
|
+
exports.default = (0, config_1.defineConfig)({
|
|
5
|
+
test: {
|
|
6
|
+
globals: true, // If you want to use global APIs like 'describe', 'it', 'expect'
|
|
7
|
+
environment: 'node', // Or 'jsdom' if you're testing browser-specific code
|
|
8
|
+
include: ['**/*.{test,spec}.{ts,tsx}'], // Where your test files are located
|
|
9
|
+
setupFiles: [], // Optional: Path to a setup file that runs before all tests
|
|
10
|
+
coverage: {
|
|
11
|
+
provider: 'v8', // Or 'istanbul'
|
|
12
|
+
reporter: ['text', 'json', 'html'],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=vitest.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";;AAAA,0CAA6C;AAE7C,kBAAe,IAAA,qBAAY,EAAC;IAC3B,IAAI,EAAE;QACL,OAAO,EAAE,IAAI,EAAE,iEAAiE;QAChF,WAAW,EAAE,MAAM,EAAE,qDAAqD;QAC1E,OAAO,EAAE,CAAC,2BAA2B,CAAC,EAAE,oCAAoC;QAC5E,UAAU,EAAE,EAAE,EAAE,4DAA4D;QAC5E,QAAQ,EAAE;YACT,QAAQ,EAAE,IAAI,EAAE,gBAAgB;YAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAClC;KACD;CACD,CAAC,CAAC"}
|