@futura-dev/microsoft-sdk 0.0.3 → 1.2.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/.github/workflows/deploy-npm-package.yml +19 -0
- package/dist/graph-api/graph-api.module.d.ts +11 -0
- package/dist/graph-api/graph-api.module.d.ts.map +1 -0
- package/dist/graph-api/graph-api.module.js +33 -0
- package/dist/graph-api/graph-api.module.js.map +1 -0
- package/dist/graph-api/graph-api.service.d.ts +52 -0
- package/dist/graph-api/graph-api.service.d.ts.map +1 -0
- package/dist/graph-api/graph-api.service.js +108 -0
- package/dist/graph-api/graph-api.service.js.map +1 -0
- package/dist/{microsoft-api → graph-api}/types.d.ts +60 -0
- package/dist/graph-api/types.d.ts.map +1 -0
- package/dist/{microsoft-api → graph-api}/types.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/sharepoint-api/sharepoint-api.module.d.ts +12 -0
- package/dist/sharepoint-api/sharepoint-api.module.d.ts.map +1 -0
- package/dist/sharepoint-api/sharepoint-api.module.js +33 -0
- package/dist/sharepoint-api/sharepoint-api.module.js.map +1 -0
- package/dist/sharepoint-api/sharepoint-api.service.d.ts +39 -0
- package/dist/sharepoint-api/sharepoint-api.service.d.ts.map +1 -0
- package/dist/sharepoint-api/sharepoint-api.service.js +129 -0
- package/dist/sharepoint-api/sharepoint-api.service.js.map +1 -0
- package/dist/sharepoint-api/types.d.ts +163 -0
- package/dist/sharepoint-api/types.d.ts.map +1 -0
- package/dist/sharepoint-api/types.js +3 -0
- package/dist/sharepoint-api/types.js.map +1 -0
- package/package.json +10 -6
- package/src/graph-api/graph-api.module.ts +28 -0
- package/src/graph-api/graph-api.service.ts +100 -0
- package/src/{microsoft-api → graph-api}/types.ts +4 -0
- package/src/index.ts +6 -5
- package/src/sharepoint-api/sharepoint-api.module.ts +30 -0
- package/src/sharepoint-api/sharepoint-api.service.ts +110 -0
- package/src/sharepoint-api/types.ts +108 -0
- package/dist/microsoft-api/microsoft-api.module.d.ts +0 -3
- package/dist/microsoft-api/microsoft-api.module.d.ts.map +0 -1
- package/dist/microsoft-api/microsoft-api.module.js +0 -27
- package/dist/microsoft-api/microsoft-api.module.js.map +0 -1
- package/dist/microsoft-api/microsoft-api.service.d.ts +0 -36
- package/dist/microsoft-api/microsoft-api.service.d.ts.map +0 -1
- package/dist/microsoft-api/microsoft-api.service.js +0 -273
- package/dist/microsoft-api/microsoft-api.service.js.map +0 -1
- package/dist/microsoft-api/types.d.ts.map +0 -1
- package/src/microsoft-api/microsoft-api.module.ts +0 -14
- package/src/microsoft-api/microsoft-api.service.ts +0 -299
- /package/dist/{microsoft-api → graph-api}/types.js +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
type MicrosoftGraphIdentitySet = {
|
|
2
|
+
id: string;
|
|
3
|
+
email: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export type ListWebhook = {
|
|
7
|
+
value: {
|
|
8
|
+
subscriptionId: string;
|
|
9
|
+
clientState: null;
|
|
10
|
+
expirationDateTime: string;
|
|
11
|
+
resource: string;
|
|
12
|
+
tenantId: string;
|
|
13
|
+
siteUrl: string;
|
|
14
|
+
webId: string;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
export type ListLog = {
|
|
18
|
+
'odata.type': string;
|
|
19
|
+
'odata.id': string;
|
|
20
|
+
'odata.editLink': string;
|
|
21
|
+
ChangeToken: {
|
|
22
|
+
StringValue: `${number};${number};${string};${string};${string}`;
|
|
23
|
+
};
|
|
24
|
+
ChangeType: number;
|
|
25
|
+
SiteId: string;
|
|
26
|
+
Time: string;
|
|
27
|
+
Editor: string;
|
|
28
|
+
EditorEmailHint: null | any;
|
|
29
|
+
ItemId: number;
|
|
30
|
+
ListId: string;
|
|
31
|
+
ServerRelativeUrl: string;
|
|
32
|
+
SharedByUser: null | any;
|
|
33
|
+
SharedWithUsers: null | any;
|
|
34
|
+
UniqueId: string;
|
|
35
|
+
WebId: string;
|
|
36
|
+
};
|
|
37
|
+
export type ListItem<T> = {
|
|
38
|
+
'@odata.context': string;
|
|
39
|
+
'@odata.etag': string;
|
|
40
|
+
createdDateTime: string;
|
|
41
|
+
eTag: string;
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
lastModifiedDateTime: string;
|
|
45
|
+
description: string;
|
|
46
|
+
webUrl: string;
|
|
47
|
+
createdBy: {
|
|
48
|
+
user: MicrosoftGraphIdentitySet;
|
|
49
|
+
};
|
|
50
|
+
lastModifiedBy: {
|
|
51
|
+
user: MicrosoftGraphIdentitySet;
|
|
52
|
+
};
|
|
53
|
+
parentReference: {
|
|
54
|
+
id: string;
|
|
55
|
+
siteId: string;
|
|
56
|
+
};
|
|
57
|
+
contentType: {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
};
|
|
61
|
+
'fields@odata.context': string;
|
|
62
|
+
fields: T;
|
|
63
|
+
};
|
|
64
|
+
export type HRListItem = ListItem<{
|
|
65
|
+
'@odata.etag': string;
|
|
66
|
+
Title: string;
|
|
67
|
+
Attachments: boolean;
|
|
68
|
+
LinkTitle: string;
|
|
69
|
+
Position: string;
|
|
70
|
+
Progress: string;
|
|
71
|
+
RecruiterLookupId: string;
|
|
72
|
+
Email: string;
|
|
73
|
+
Telefono: string;
|
|
74
|
+
ApplicationDate: string;
|
|
75
|
+
PhoneScreenDate: string;
|
|
76
|
+
PhoneScreenerLookupId: string;
|
|
77
|
+
InterviewDate: string;
|
|
78
|
+
Interviewers: {
|
|
79
|
+
LookupId: number;
|
|
80
|
+
LookupValue: string;
|
|
81
|
+
Email: string;
|
|
82
|
+
};
|
|
83
|
+
Notes: string;
|
|
84
|
+
Profilo_x0020_LinkedIn: string;
|
|
85
|
+
Curriculum_x0020_URL: string;
|
|
86
|
+
id: string;
|
|
87
|
+
ContentType: string;
|
|
88
|
+
Modified: string;
|
|
89
|
+
Created: string;
|
|
90
|
+
AuthorLookupId: string;
|
|
91
|
+
EditorLookupId: string;
|
|
92
|
+
_UIVersionString: string;
|
|
93
|
+
Edit: string;
|
|
94
|
+
LinkTitleNoMenu: string;
|
|
95
|
+
ItemChildCount: string;
|
|
96
|
+
FolderChildCount: string;
|
|
97
|
+
_ComplianceFlags: string;
|
|
98
|
+
_ComplianceTag: string;
|
|
99
|
+
_ComplianceTagWrittenTime: string;
|
|
100
|
+
_ComplianceTagUserId: string;
|
|
101
|
+
}>;
|
|
102
|
+
export type ColumnValue = {
|
|
103
|
+
columnGroup: string;
|
|
104
|
+
description: string;
|
|
105
|
+
displayName: string;
|
|
106
|
+
enforceUniqueValues: boolean;
|
|
107
|
+
hidden: boolean;
|
|
108
|
+
id: string;
|
|
109
|
+
indexed: boolean;
|
|
110
|
+
name: string;
|
|
111
|
+
readOnly: boolean;
|
|
112
|
+
required: boolean;
|
|
113
|
+
geolocation?: Record<string, never>;
|
|
114
|
+
boolean?: Record<string, never>;
|
|
115
|
+
calculated?: {
|
|
116
|
+
format: string;
|
|
117
|
+
formula: string;
|
|
118
|
+
outputType: 'boolean' | 'currency' | 'dateTime' | 'number' | 'text';
|
|
119
|
+
};
|
|
120
|
+
choice?: {
|
|
121
|
+
allowTextEntry: boolean;
|
|
122
|
+
choices: string[];
|
|
123
|
+
displayAs: 'checkBoxes' | 'dropDownMenu' | 'radioButtons';
|
|
124
|
+
};
|
|
125
|
+
currency?: {
|
|
126
|
+
locale: string;
|
|
127
|
+
};
|
|
128
|
+
dateTime?: {
|
|
129
|
+
displayAs: 'default' | 'friendly' | 'standard';
|
|
130
|
+
format: string;
|
|
131
|
+
};
|
|
132
|
+
lookup?: {
|
|
133
|
+
allowMultipleValues: boolean;
|
|
134
|
+
allowUnlimitedLength: boolean;
|
|
135
|
+
columnName: string;
|
|
136
|
+
listId: string;
|
|
137
|
+
primaryLookupColumnId: string;
|
|
138
|
+
};
|
|
139
|
+
number?: {
|
|
140
|
+
decimalPlaces: string;
|
|
141
|
+
displayAs: 'number' | 'percentage';
|
|
142
|
+
maximum: number;
|
|
143
|
+
minimum: number;
|
|
144
|
+
};
|
|
145
|
+
personOrGroup?: {
|
|
146
|
+
allowMultipleSelection: boolean;
|
|
147
|
+
displayAs: string;
|
|
148
|
+
chooseFromType: 'peopleAndGroups' | 'peopleOnly';
|
|
149
|
+
};
|
|
150
|
+
text?: {
|
|
151
|
+
allowMultipleLines: boolean;
|
|
152
|
+
appendChangesToExistingText: boolean;
|
|
153
|
+
linesForEditing: number;
|
|
154
|
+
maxLength: number;
|
|
155
|
+
textType: 'plain' | 'richText';
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
export type GetColumnsResponse = {
|
|
159
|
+
'@odata.context': string;
|
|
160
|
+
value: ColumnValue[];
|
|
161
|
+
};
|
|
162
|
+
export {};
|
|
163
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sharepoint-api/types.ts"],"names":[],"mappings":"AAAA,KAAK,yBAAyB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE;QACL,cAAc,EAAE,MAAM,CAAC;QACvB,WAAW,EAAE,IAAI,CAAC;QAClB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;I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C;IAAC,aAAa,CAAC,EAAE;QAAE,sBAAsB,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,iBAAiB,GAAG,YAAY,CAAC;KAAE,CAAC;IAAC,IAAI,CAAC,EAAE;QAAE,kBAAkB,EAAE,OAAO,CAAC;QAAC,2BAA2B,EAAE,OAAO,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,GAAG,UAAU,CAAC;KAAE,CAAC;CAAE,CAAC;AAAC,MAAM,MAAM,kBAAkB,GAAG;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,EAAE,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/sharepoint-api/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -2,27 +2,31 @@
|
|
|
2
2
|
"name": "@futura-dev/microsoft-sdk",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "1.2.0",
|
|
6
6
|
"main": "dist/index",
|
|
7
7
|
"types": "dist/index",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
-
"build": "
|
|
11
|
-
"prepublish": "npm run build",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"prepublish": "rimraf dist && npm run build",
|
|
12
12
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [],
|
|
15
15
|
"author": "",
|
|
16
|
-
"license": "
|
|
16
|
+
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@azure/identity": "^3.1.4",
|
|
18
19
|
"@azure/msal-node": "^1.17.2",
|
|
19
|
-
"@
|
|
20
|
+
"@microsoft/microsoft-graph-client": "^3.0.5",
|
|
20
21
|
"@nestjs/common": "^9.4.0",
|
|
21
|
-
"
|
|
22
|
+
"@nestjs/core": "^9.4.0",
|
|
23
|
+
"rxjs": "^7.8.1",
|
|
22
24
|
"typescript": "^5.0.4"
|
|
23
25
|
},
|
|
24
26
|
"devDependencies": {
|
|
25
27
|
"@types/node": "^18.16.3",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
29
|
+
"eslint": "^8.40.0",
|
|
26
30
|
"rimraf": "^5.0.0"
|
|
27
31
|
}
|
|
28
32
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DynamicModule, Module, Provider } from '@nestjs/common';
|
|
2
|
+
import { GraphApiService } from './graph-api.service';
|
|
3
|
+
|
|
4
|
+
export type GraphModuleOptions = {
|
|
5
|
+
tenantId: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
clientSecret: string;
|
|
8
|
+
scopes: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@Module({})
|
|
12
|
+
export class GraphApiModule {
|
|
13
|
+
static forFeature(token: string, options: GraphModuleOptions): DynamicModule {
|
|
14
|
+
|
|
15
|
+
const provider: Provider = {
|
|
16
|
+
provide: token,
|
|
17
|
+
useFactory: async () => {
|
|
18
|
+
return new GraphApiService({ ...options });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
module: GraphApiModule,
|
|
23
|
+
imports: [],
|
|
24
|
+
providers: [provider],
|
|
25
|
+
exports: [provider]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { GraphModuleOptions } from "./graph-api.module";
|
|
3
|
+
import { Client } from '@microsoft/microsoft-graph-client'
|
|
4
|
+
import * as msal from "@azure/msal-node";
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class GraphApiService {
|
|
8
|
+
|
|
9
|
+
private readonly tenant_id: string;
|
|
10
|
+
private readonly client_id: string;
|
|
11
|
+
private readonly client_secret: string;
|
|
12
|
+
private readonly scopes: string[];
|
|
13
|
+
private readonly msal_client: msal.ConfidentialClientApplication;
|
|
14
|
+
private readonly graph_client: Client;
|
|
15
|
+
|
|
16
|
+
constructor(readonly options: GraphModuleOptions) {
|
|
17
|
+
this.tenant_id = options.tenantId;
|
|
18
|
+
this.client_id = options.clientId;
|
|
19
|
+
this.client_secret = options.clientSecret;
|
|
20
|
+
this.scopes = options.scopes?.split(" ") || ["https://graph.microsoft.com/.default"];
|
|
21
|
+
|
|
22
|
+
// init msal client
|
|
23
|
+
this.msal_client = new msal.ConfidentialClientApplication({
|
|
24
|
+
auth: {
|
|
25
|
+
authority: `https://login.microsoftonline.com/${this.tenant_id}`,
|
|
26
|
+
clientId: `${this.client_id}`,
|
|
27
|
+
clientSecret: `${this.client_secret}`,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
// init graph client
|
|
31
|
+
this.graph_client = Client.init({
|
|
32
|
+
authProvider: async (resolve) => {
|
|
33
|
+
this.msal_client.acquireTokenByClientCredential({
|
|
34
|
+
scopes: this.scopes,
|
|
35
|
+
})
|
|
36
|
+
.then((token) => resolve(null, token.accessToken))
|
|
37
|
+
.catch(error => resolve(error, null))
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param options
|
|
45
|
+
*/
|
|
46
|
+
getListItem = async (options: {
|
|
47
|
+
siteId: string;
|
|
48
|
+
listId: string;
|
|
49
|
+
itemId: string;
|
|
50
|
+
}) => {
|
|
51
|
+
return this.graph_client
|
|
52
|
+
.api(`https://graph.microsoft.com/beta/sites/${options.siteId}/lists/${options.listId}/items/${options.itemId}?expand=fields`)
|
|
53
|
+
.get()
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param options
|
|
59
|
+
*/
|
|
60
|
+
getListColumns = async <T>(options: {
|
|
61
|
+
siteId: string
|
|
62
|
+
listId: string
|
|
63
|
+
}) => {
|
|
64
|
+
return this.graph_client
|
|
65
|
+
.api(`https://graph.microsoft.com/beta/sites/${options.siteId}/lists/${options.listId}/columns`)
|
|
66
|
+
.get();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param options
|
|
72
|
+
*/
|
|
73
|
+
createListItemFile = async (options: {
|
|
74
|
+
siteId: string,
|
|
75
|
+
driveId: string,
|
|
76
|
+
itemId: string,
|
|
77
|
+
fileName: string
|
|
78
|
+
file: Buffer
|
|
79
|
+
}) => {
|
|
80
|
+
return this.graph_client
|
|
81
|
+
.api(`https://graph.microsoft.com/beta/sites/${options.siteId}/drives/${options.driveId}/items/${options.itemId}:/${options.fileName}:/content`)
|
|
82
|
+
.put(options.file);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @param options
|
|
88
|
+
*/
|
|
89
|
+
createListItem = async (options: {
|
|
90
|
+
siteId: string,
|
|
91
|
+
listId: string,
|
|
92
|
+
body: { fields: Record<string, any> }
|
|
93
|
+
}) => {
|
|
94
|
+
return this.graph_client
|
|
95
|
+
.api(`https://graph.microsoft.com/beta/sites/${options.siteId}/lists/${options.listId}/items`)
|
|
96
|
+
.post(options.body)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
}
|
|
@@ -100,5 +100,9 @@ export type HRListItem = ListItem<{
|
|
|
100
100
|
_ComplianceFlags: string;
|
|
101
101
|
_ComplianceTag: string;
|
|
102
102
|
_ComplianceTagWrittenTime: string;
|
|
103
|
+
|
|
103
104
|
_ComplianceTagUserId: string;
|
|
104
105
|
}>;
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
export type ColumnValue = { columnGroup: string; description: string; displayName: string; enforceUniqueValues: boolean; hidden: boolean; id: string; indexed: boolean; name: string; readOnly: boolean; required: boolean; geolocation?: Record<string, never>; boolean?: Record<string, never>; calculated?: { format: string; formula: string; outputType: 'boolean' | 'currency' | 'dateTime' | 'number' | 'text'; }; choice?: { allowTextEntry: boolean; choices: string[]; displayAs: 'checkBoxes' | 'dropDownMenu' | 'radioButtons'; }; currency?: { locale: string; }; dateTime?: { displayAs: 'default' | 'friendly' | 'standard'; format: string; }; lookup?: { allowMultipleValues: boolean; allowUnlimitedLength: boolean; columnName: string; listId: string; primaryLookupColumnId: string; }; number?: { decimalPlaces: string; displayAs: 'number' | 'percentage'; maximum: number; minimum: number; }; personOrGroup?: { allowMultipleSelection: boolean; displayAs: string; chooseFromType: 'peopleAndGroups' | 'peopleOnly'; }; text?: { allowMultipleLines: boolean; appendChangesToExistingText: boolean; linesForEditing: number; maxLength: number; textType: 'plain' | 'richText'; }; }; export type GetColumnsResponse = { '@odata.context': string; value: ColumnValue[]; };
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { GraphApiService } from "./graph-api/graph-api.service";
|
|
2
|
+
import { GraphApiModule } from "./graph-api/graph-api.module";
|
|
3
|
+
import { SharepointApiService } from "./sharepoint-api/sharepoint-api.service";
|
|
4
|
+
import { SharepointApiModule } from "./sharepoint-api/sharepoint-api.module";
|
|
4
5
|
|
|
5
|
-
export {
|
|
6
|
-
export type { ListWebhook, ListLog, ListItem, HRListItem }
|
|
6
|
+
export { GraphApiService, GraphApiModule, SharepointApiService, SharepointApiModule }
|
|
7
|
+
// export type { ListWebhook, ListLog, ListItem, HRListItem }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DynamicModule, Module, Provider } from '@nestjs/common';
|
|
2
|
+
import { SharepointApiService } from './sharepoint-api.service';
|
|
3
|
+
|
|
4
|
+
export type SharepointModuleOptions = {
|
|
5
|
+
tenantId: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
thumbprint: string;
|
|
8
|
+
privateKey: string;
|
|
9
|
+
scopes: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@Module({})
|
|
13
|
+
export class SharepointApiModule {
|
|
14
|
+
static forFeature(token: string, options: SharepointModuleOptions): DynamicModule {
|
|
15
|
+
|
|
16
|
+
const provider: Provider = {
|
|
17
|
+
provide: token,
|
|
18
|
+
useFactory: async () => {
|
|
19
|
+
return new SharepointApiService({ ...options });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
module: SharepointApiModule,
|
|
25
|
+
imports: [],
|
|
26
|
+
providers: [provider],
|
|
27
|
+
exports: [provider]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import * as msal from "@azure/msal-node";
|
|
3
|
+
import { SharepointModuleOptions } from "./sharepoint-api.module";
|
|
4
|
+
import { Client } from "@microsoft/microsoft-graph-client";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class SharepointApiService {
|
|
9
|
+
|
|
10
|
+
private readonly tenant_id: string;
|
|
11
|
+
private readonly client_id: string;
|
|
12
|
+
private readonly thumbprint: string;
|
|
13
|
+
private readonly private_key: string;
|
|
14
|
+
private readonly scopes: string[];
|
|
15
|
+
private readonly msal_client: msal.ConfidentialClientApplication;
|
|
16
|
+
private readonly sharepoint_client: Client;
|
|
17
|
+
|
|
18
|
+
constructor(readonly options: SharepointModuleOptions) {
|
|
19
|
+
this.tenant_id = options.tenantId;
|
|
20
|
+
this.client_id = options.clientId;
|
|
21
|
+
this.scopes = options.scopes.split(" ") || [""];
|
|
22
|
+
this.thumbprint = options.thumbprint;
|
|
23
|
+
this.private_key = options.privateKey;
|
|
24
|
+
|
|
25
|
+
// init msal client
|
|
26
|
+
this.msal_client = new msal.ConfidentialClientApplication({
|
|
27
|
+
auth: {
|
|
28
|
+
authority: `https://login.microsoftonline.com/${this.tenant_id}`,
|
|
29
|
+
clientId: `${this.client_id}`,
|
|
30
|
+
clientCertificate: {
|
|
31
|
+
thumbprint: this.thumbprint,
|
|
32
|
+
privateKey: this.private_key
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
// init graph client
|
|
37
|
+
this.sharepoint_client = Client.init({
|
|
38
|
+
authProvider: async (resolve) => {
|
|
39
|
+
this.msal_client.acquireTokenByClientCredential({
|
|
40
|
+
scopes: this.scopes,
|
|
41
|
+
})
|
|
42
|
+
.then((token) => resolve(null, token.accessToken))
|
|
43
|
+
.catch(error => resolve(error, null))
|
|
44
|
+
},
|
|
45
|
+
customHosts: new Set(["futuraitsrl.sharepoint.com"])
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param listId
|
|
52
|
+
*/
|
|
53
|
+
getListSubscriptions = async (listId: string) => {
|
|
54
|
+
return this.sharepoint_client
|
|
55
|
+
.api(`https://futuraitsrl.sharepoint.com/sites/hr/_api/web/lists('${listId}')/subscriptions`)
|
|
56
|
+
.get()
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param listId
|
|
62
|
+
* @param notificationUrl
|
|
63
|
+
* @param expirationTimestamp
|
|
64
|
+
*/
|
|
65
|
+
createListSubscription = async (
|
|
66
|
+
listId: string,
|
|
67
|
+
notificationUrl: string,
|
|
68
|
+
expirationTimestamp: number,
|
|
69
|
+
) => {
|
|
70
|
+
// read key from files
|
|
71
|
+
return this.sharepoint_client.api(`https://futuraitsrl.sharepoint.com/sites/hr/_api/web/lists('${listId}')/subscriptions`).post({
|
|
72
|
+
resource:
|
|
73
|
+
'https://futuraitsrl.sharepoint.com/sites/hr/Lists/Recruiting%20Board/AllItems.aspx',
|
|
74
|
+
notificationUrl: `${notificationUrl}`,
|
|
75
|
+
expirationDateTime: new Date(expirationTimestamp).toISOString(),
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param listId
|
|
82
|
+
* @param subscriptionId
|
|
83
|
+
*/
|
|
84
|
+
deleteListSubscription = async (listId: string, subscriptionId: string) => {
|
|
85
|
+
return this.sharepoint_client
|
|
86
|
+
.api(`https://futuraitsrl.sharepoint.com/sites/hr/_api/web/lists('${listId}')/subscriptions('${subscriptionId}')`)
|
|
87
|
+
.delete();
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @param options
|
|
93
|
+
*/
|
|
94
|
+
getListLogs = async (options: { listId: string; from: Date }) => {
|
|
95
|
+
const startTick = options.from.getTime() * 10000 + 621355968000000000;
|
|
96
|
+
const start = `1;3;${options.listId};${startTick};-1`;
|
|
97
|
+
return this.sharepoint_client.api(`https://futuraitsrl.sharepoint.com/sites/hr/_api/web/Lists(guid'${options.listId}')/getChanges`).post({
|
|
98
|
+
query: {
|
|
99
|
+
Add: true,
|
|
100
|
+
Alert: true,
|
|
101
|
+
DeleteObject: true,
|
|
102
|
+
Update: true,
|
|
103
|
+
Item: true,
|
|
104
|
+
ChangeTokenStart: {
|
|
105
|
+
StringValue: start,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
type MicrosoftGraphIdentitySet = {
|
|
2
|
+
id: string;
|
|
3
|
+
email: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type ListWebhook = {
|
|
8
|
+
value: {
|
|
9
|
+
subscriptionId: string;
|
|
10
|
+
clientState: null;
|
|
11
|
+
expirationDateTime: string;
|
|
12
|
+
resource: string;
|
|
13
|
+
tenantId: string;
|
|
14
|
+
siteUrl: string;
|
|
15
|
+
webId: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type ListLog = {
|
|
20
|
+
'odata.type': string;
|
|
21
|
+
'odata.id': string;
|
|
22
|
+
'odata.editLink': string;
|
|
23
|
+
ChangeToken: {
|
|
24
|
+
StringValue: `${number};${number};${string};${string};${string}`;
|
|
25
|
+
};
|
|
26
|
+
ChangeType: number;
|
|
27
|
+
SiteId: string;
|
|
28
|
+
Time: string;
|
|
29
|
+
Editor: string;
|
|
30
|
+
EditorEmailHint: null | any;
|
|
31
|
+
ItemId: number;
|
|
32
|
+
ListId: string;
|
|
33
|
+
ServerRelativeUrl: string;
|
|
34
|
+
SharedByUser: null | any;
|
|
35
|
+
SharedWithUsers: null | any;
|
|
36
|
+
UniqueId: string;
|
|
37
|
+
WebId: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type ListItem<T> = {
|
|
41
|
+
'@odata.context': string;
|
|
42
|
+
'@odata.etag': string;
|
|
43
|
+
createdDateTime: string;
|
|
44
|
+
eTag: string;
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
lastModifiedDateTime: string;
|
|
48
|
+
description: string;
|
|
49
|
+
webUrl: string;
|
|
50
|
+
createdBy: {
|
|
51
|
+
user: MicrosoftGraphIdentitySet;
|
|
52
|
+
};
|
|
53
|
+
lastModifiedBy: {
|
|
54
|
+
user: MicrosoftGraphIdentitySet;
|
|
55
|
+
};
|
|
56
|
+
parentReference: {
|
|
57
|
+
id: string;
|
|
58
|
+
siteId: string;
|
|
59
|
+
};
|
|
60
|
+
contentType: {
|
|
61
|
+
id: string;
|
|
62
|
+
name: string;
|
|
63
|
+
};
|
|
64
|
+
'fields@odata.context': string;
|
|
65
|
+
fields: T;
|
|
66
|
+
};
|
|
67
|
+
export type HRListItem = ListItem<{
|
|
68
|
+
'@odata.etag': string;
|
|
69
|
+
Title: string;
|
|
70
|
+
Attachments: boolean;
|
|
71
|
+
LinkTitle: string;
|
|
72
|
+
Position: string;
|
|
73
|
+
Progress: string;
|
|
74
|
+
RecruiterLookupId: string;
|
|
75
|
+
Email: string;
|
|
76
|
+
Telefono: string;
|
|
77
|
+
ApplicationDate: string;
|
|
78
|
+
PhoneScreenDate: string;
|
|
79
|
+
PhoneScreenerLookupId: string;
|
|
80
|
+
InterviewDate: string;
|
|
81
|
+
Interviewers: {
|
|
82
|
+
LookupId: number;
|
|
83
|
+
LookupValue: string;
|
|
84
|
+
Email: string;
|
|
85
|
+
};
|
|
86
|
+
Notes: string;
|
|
87
|
+
Profilo_x0020_LinkedIn: string;
|
|
88
|
+
Curriculum_x0020_URL: string;
|
|
89
|
+
id: string;
|
|
90
|
+
ContentType: string;
|
|
91
|
+
Modified: string;
|
|
92
|
+
Created: string;
|
|
93
|
+
AuthorLookupId: string;
|
|
94
|
+
EditorLookupId: string;
|
|
95
|
+
_UIVersionString: string;
|
|
96
|
+
Edit: string;
|
|
97
|
+
LinkTitleNoMenu: string;
|
|
98
|
+
ItemChildCount: string;
|
|
99
|
+
FolderChildCount: string;
|
|
100
|
+
_ComplianceFlags: string;
|
|
101
|
+
_ComplianceTag: string;
|
|
102
|
+
_ComplianceTagWrittenTime: string;
|
|
103
|
+
|
|
104
|
+
_ComplianceTagUserId: string;
|
|
105
|
+
}>;
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
export type ColumnValue = { columnGroup: string; description: string; displayName: string; enforceUniqueValues: boolean; hidden: boolean; id: string; indexed: boolean; name: string; readOnly: boolean; required: boolean; geolocation?: Record<string, never>; boolean?: Record<string, never>; calculated?: { format: string; formula: string; outputType: 'boolean' | 'currency' | 'dateTime' | 'number' | 'text'; }; choice?: { allowTextEntry: boolean; choices: string[]; displayAs: 'checkBoxes' | 'dropDownMenu' | 'radioButtons'; }; currency?: { locale: string; }; dateTime?: { displayAs: 'default' | 'friendly' | 'standard'; format: string; }; lookup?: { allowMultipleValues: boolean; allowUnlimitedLength: boolean; columnName: string; listId: string; primaryLookupColumnId: string; }; number?: { decimalPlaces: string; displayAs: 'number' | 'percentage'; maximum: number; minimum: number; }; personOrGroup?: { allowMultipleSelection: boolean; displayAs: string; chooseFromType: 'peopleAndGroups' | 'peopleOnly'; }; text?: { allowMultipleLines: boolean; appendChangesToExistingText: boolean; linesForEditing: number; maxLength: number; textType: 'plain' | 'richText'; }; }; export type GetColumnsResponse = { '@odata.context': string; value: ColumnValue[]; };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"microsoft-api.module.d.ts","sourceRoot":"","sources":["../../src/microsoft-api/microsoft-api.module.ts"],"names":[],"mappings":"AAIA,qBASa,kBAAkB;CAAG"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.MicrosoftApiModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const axios_1 = require("@nestjs/axios");
|
|
12
|
-
const microsoft_api_service_1 = require("./microsoft-api.service");
|
|
13
|
-
let MicrosoftApiModule = class MicrosoftApiModule {
|
|
14
|
-
};
|
|
15
|
-
MicrosoftApiModule = __decorate([
|
|
16
|
-
(0, common_1.Module)({
|
|
17
|
-
imports: [
|
|
18
|
-
axios_1.HttpModule.register({
|
|
19
|
-
headers: {},
|
|
20
|
-
}),
|
|
21
|
-
],
|
|
22
|
-
providers: [microsoft_api_service_1.MicrosoftApiService],
|
|
23
|
-
exports: [microsoft_api_service_1.MicrosoftApiService],
|
|
24
|
-
})
|
|
25
|
-
], MicrosoftApiModule);
|
|
26
|
-
exports.MicrosoftApiModule = MicrosoftApiModule;
|
|
27
|
-
//# sourceMappingURL=microsoft-api.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"microsoft-api.module.js","sourceRoot":"","sources":["../../src/microsoft-api/microsoft-api.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yCAA2C;AAC3C,mEAA8D;AAW9D,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;CAAG,CAAA;AAArB,kBAAkB;IAT9B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,kBAAU,CAAC,QAAQ,CAAC;gBAClB,OAAO,EAAE,EAAE;aACZ,CAAC;SACH;QACD,SAAS,EAAE,CAAC,2CAAmB,CAAC;QAChC,OAAO,EAAE,CAAC,2CAAmB,CAAC;KAC/B,CAAC;GACW,kBAAkB,CAAG;AAArB,gDAAkB"}
|