@cemiar/cemiarlink-sdk 1.0.18 → 1.0.20
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/dist/models/sharepoint/Sharepoint.d.ts +25 -0
- package/dist/models/sharepoint/Sharepoint.js +2 -0
- package/dist/services/Epic.d.ts +1 -0
- package/dist/services/Epic.js +3 -0
- package/dist/services/SharepointService.d.ts +13 -0
- package/dist/services/SharepointService.js +44 -0
- package/package.json +2 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface SharepointConnection {
|
|
2
|
+
tenantId: string;
|
|
3
|
+
clientId: string;
|
|
4
|
+
secretName: string;
|
|
5
|
+
siteUrl: string;
|
|
6
|
+
driveName: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SharepointSearchRequest extends SharepointConnection {
|
|
9
|
+
keyword: string;
|
|
10
|
+
folderPath?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SharepointFileInfo {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
webUrl: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SharepointSearchResponse {
|
|
18
|
+
file: SharepointFileInfo | null;
|
|
19
|
+
}
|
|
20
|
+
export interface SharepointDownloadResult {
|
|
21
|
+
buffer: Buffer;
|
|
22
|
+
fileName: string;
|
|
23
|
+
fileId: string;
|
|
24
|
+
webUrl: string;
|
|
25
|
+
}
|
package/dist/services/Epic.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare class EpicService extends BaseEpicService {
|
|
|
51
51
|
updatePolicy(id: string, payload: object): Promise<string>;
|
|
52
52
|
issuePolicy(id: string, payload: object): Promise<string>;
|
|
53
53
|
cancelPolicy(id: string, payload: object): Promise<string>;
|
|
54
|
+
endorsePolicy(id: string, payload: object): Promise<string>;
|
|
54
55
|
createPolicy(payload: CreatePolicy): Promise<string | string[]>;
|
|
55
56
|
getPoliciesV2(queryParams: object): Promise<PolicyV2[]>;
|
|
56
57
|
getPolicyV2(id: string): Promise<PolicyV2>;
|
package/dist/services/Epic.js
CHANGED
|
@@ -66,6 +66,9 @@ class EpicService extends BaseEpicService_1.BaseEpicService {
|
|
|
66
66
|
async cancelPolicy(id, payload) {
|
|
67
67
|
return await this.put(`cancelPolicy/${id}`, payload);
|
|
68
68
|
}
|
|
69
|
+
async endorsePolicy(id, payload) {
|
|
70
|
+
return await this.put(`endorsePolicy/${id}`, payload);
|
|
71
|
+
}
|
|
69
72
|
async createPolicy(payload) {
|
|
70
73
|
return await this.post(`policy`, payload);
|
|
71
74
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { SharepointConnection, SharepointDownloadResult, SharepointFileInfo, SharepointSearchRequest } from '../models/sharepoint/Sharepoint';
|
|
3
|
+
/**
|
|
4
|
+
* SharepointService provides methods to interact with the SharePoint API for file search, download, and retrieval operations.
|
|
5
|
+
* It wraps Axios and offers methods to find files, download files by ID, and perform combined find-and-download requests.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SharepointService {
|
|
8
|
+
axiosInstance: AxiosInstance;
|
|
9
|
+
constructor(sharepointUrl: string | undefined, headers: any);
|
|
10
|
+
findFile(input: SharepointSearchRequest): Promise<SharepointFileInfo | null>;
|
|
11
|
+
downloadFileById(id: string, connection: SharepointConnection): Promise<Buffer>;
|
|
12
|
+
findAndDownload(input: SharepointSearchRequest): Promise<SharepointDownloadResult | null>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharepointService = void 0;
|
|
4
|
+
const AxiosClient_1 = require("../utils/AxiosClient");
|
|
5
|
+
/**
|
|
6
|
+
* SharepointService provides methods to interact with the SharePoint API for file search, download, and retrieval operations.
|
|
7
|
+
* It wraps Axios and offers methods to find files, download files by ID, and perform combined find-and-download requests.
|
|
8
|
+
*/
|
|
9
|
+
class SharepointService {
|
|
10
|
+
constructor(sharepointUrl, headers) {
|
|
11
|
+
this.axiosInstance = new AxiosClient_1.AxiosClient(sharepointUrl, headers).getInstance();
|
|
12
|
+
}
|
|
13
|
+
async findFile(input) {
|
|
14
|
+
var _a;
|
|
15
|
+
const { data } = await this.axiosInstance.post('sharepoint/files/search', input);
|
|
16
|
+
return (_a = data === null || data === void 0 ? void 0 : data.file) !== null && _a !== void 0 ? _a : null;
|
|
17
|
+
}
|
|
18
|
+
async downloadFileById(id, connection) {
|
|
19
|
+
const res = await this.axiosInstance.post(`sharepoint/files/download/${encodeURIComponent(id)}`, connection, { responseType: 'arraybuffer' });
|
|
20
|
+
return Buffer.from(res.data);
|
|
21
|
+
}
|
|
22
|
+
async findAndDownload(input) {
|
|
23
|
+
const res = await this.axiosInstance.post('sharepoint/files/find-and-download', input, {
|
|
24
|
+
responseType: 'arraybuffer',
|
|
25
|
+
validateStatus: (status) => status === 200 || status === 404,
|
|
26
|
+
});
|
|
27
|
+
if (res.status === 404)
|
|
28
|
+
return null;
|
|
29
|
+
const getHeader = (name) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const value = res.headers[name];
|
|
32
|
+
if (Array.isArray(value))
|
|
33
|
+
return (_a = value[0]) !== null && _a !== void 0 ? _a : '';
|
|
34
|
+
return typeof value === 'string' ? value : String(value !== null && value !== void 0 ? value : '');
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
buffer: Buffer.from(res.data),
|
|
38
|
+
fileName: decodeURIComponent(getHeader('x-sharepoint-file-name')),
|
|
39
|
+
fileId: getHeader('x-sharepoint-file-id'),
|
|
40
|
+
webUrl: getHeader('x-sharepoint-file-weburl'),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.SharepointService = SharepointService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cemiar/cemiarlink-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"description": "CemiarLink SDK to access CemiarLink API services",
|
|
5
5
|
"engines": {
|
|
6
6
|
"npm": ">=9.5.1",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"xlsx": "^0.18.5"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
+
"@types/node": "^18.19.0",
|
|
26
27
|
"ts-node": "^10.9.2"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|