@lindle/sharepoint_requests 0.1.19 → 0.1.21
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/index.d.mts +490 -0
- package/dist/index.d.ts +481 -8
- package/dist/index.js +892 -5
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +863 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -5
- package/src/index.ts +29 -3
- package/src/root/index.ts +31 -11
- package/src/root/instance.ts +7 -0
- package/src/root/internal/context.ts +0 -1
- package/src/root/internal/digest.ts +16 -10
- package/src/root/internal/emailRequests.ts +2 -5
- package/src/root/internal/listRequests/createAttachment.ts +2 -2
- package/src/root/internal/listRequests/createListItem.ts +3 -18
- package/src/root/internal/listRequests/deleteFile.ts +1 -2
- package/src/root/internal/listRequests/deleteItem.ts +1 -1
- package/src/root/internal/listRequests/getListItems.ts +34 -7
- package/src/root/internal/listRequests/resolveMetadataType.ts +14 -0
- package/src/root/internal/listRequests/updateListItem.ts +3 -19
- package/src/root/internal/listRequests/uploadFile.ts +8 -13
- package/src/root/internal/userRequests.ts +52 -28
- package/src/types.ts +15 -2
- package/dist/root/index.d.ts +0 -163
- package/dist/root/instance.d.ts +0 -3
- package/dist/root/internal/context.d.ts +0 -11
- package/dist/root/internal/digest.d.ts +0 -2
- package/dist/root/internal/emailRequests.d.ts +0 -10
- package/dist/root/internal/listRequests/createAttachment.d.ts +0 -3
- package/dist/root/internal/listRequests/createListItem.d.ts +0 -3
- package/dist/root/internal/listRequests/deleteFile.d.ts +0 -3
- package/dist/root/internal/listRequests/deleteItem.d.ts +0 -3
- package/dist/root/internal/listRequests/getFiles.d.ts +0 -8
- package/dist/root/internal/listRequests/getListItems.d.ts +0 -8
- package/dist/root/internal/listRequests/getOnly.d.ts +0 -3
- package/dist/root/internal/listRequests/index.d.ts +0 -9
- package/dist/root/internal/listRequests/normalizePayload.d.ts +0 -4
- package/dist/root/internal/listRequests/updateListItem.d.ts +0 -3
- package/dist/root/internal/listRequests/uploadFile.d.ts +0 -6
- package/dist/root/internal/listRequests/utils.d.ts +0 -2
- package/dist/root/internal/odata.d.ts +0 -5
- package/dist/root/internal/sharepointUrl.d.ts +0 -2
- package/dist/root/internal/userRequests.d.ts +0 -15
- package/dist/sharepoint_requests.cjs.development.js +0 -1497
- package/dist/sharepoint_requests.cjs.development.js.map +0 -1
- package/dist/sharepoint_requests.cjs.production.min.js +0 -2
- package/dist/sharepoint_requests.cjs.production.min.js.map +0 -1
- package/dist/sharepoint_requests.esm.js +0 -1490
- package/dist/sharepoint_requests.esm.js.map +0 -1
- package/dist/types.d.ts +0 -260
|
@@ -10,7 +10,7 @@ const SUPPORTED_VERSION: SHAREPOINT_VER = '2013';
|
|
|
10
10
|
export async function uploadFile<V extends SHAREPOINT_VER = '2013'>(
|
|
11
11
|
context: RequestContext<V>,
|
|
12
12
|
{ file, folderPath, overwrite = true }: UploadFileProps
|
|
13
|
-
): Promise<
|
|
13
|
+
): Promise<{ response: AxiosResponse; itemId?: ItemID }> {
|
|
14
14
|
if (context.sharepointVersion !== SUPPORTED_VERSION) {
|
|
15
15
|
throw new Error(
|
|
16
16
|
'uploadFile is only supported for SharePoint 2013 REST endpoints.'
|
|
@@ -22,7 +22,6 @@ export async function uploadFile<V extends SHAREPOINT_VER = '2013'>(
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
let requestUrl = `${buildListByTitleEndpoint(context.listName)}/RootFolder`;
|
|
25
|
-
|
|
26
25
|
requestUrl += buildLibraryPath(folderPath);
|
|
27
26
|
|
|
28
27
|
const encodedFileName = encodeFileName(file.name);
|
|
@@ -30,37 +29,33 @@ export async function uploadFile<V extends SHAREPOINT_VER = '2013'>(
|
|
|
30
29
|
overwrite ? 'true' : 'false'
|
|
31
30
|
})?$expand=ListItemAllFields&$select=ListItemAllFields/Id`;
|
|
32
31
|
|
|
33
|
-
const digest = await fetchDigest(context.instance
|
|
32
|
+
const digest = await fetchDigest(context.instance);
|
|
34
33
|
|
|
35
|
-
const response =
|
|
34
|
+
const response = await context.instance.post(requestUrl, file, {
|
|
36
35
|
headers: {
|
|
37
36
|
'Content-Type': file.type || 'application/octet-stream',
|
|
38
37
|
'X-RequestDigest': digest,
|
|
39
38
|
},
|
|
40
|
-
|
|
41
|
-
})) as AxiosResponse & { itemId?: ItemID };
|
|
39
|
+
});
|
|
42
40
|
|
|
43
41
|
const responseData = response.data?.d ?? response.data;
|
|
44
42
|
const listItemFields = responseData?.ListItemAllFields;
|
|
45
|
-
|
|
43
|
+
let itemId: ItemID | undefined =
|
|
46
44
|
listItemFields?.Id ??
|
|
47
45
|
listItemFields?.ID ??
|
|
48
46
|
responseData?.Id ??
|
|
49
47
|
responseData?.ID;
|
|
50
48
|
|
|
51
|
-
if (typeof itemId
|
|
52
|
-
response.itemId = itemId;
|
|
53
|
-
} else if (listItemFields?.__deferred?.uri) {
|
|
49
|
+
if (typeof itemId === 'undefined' && listItemFields?.__deferred?.uri) {
|
|
54
50
|
const listItemResponse = await context.instance.get(
|
|
55
51
|
listItemFields.__deferred.uri
|
|
56
52
|
);
|
|
57
53
|
const deferredId =
|
|
58
54
|
listItemResponse.data?.d?.Id ?? listItemResponse.data?.Id;
|
|
59
|
-
|
|
60
55
|
if (typeof deferredId !== 'undefined') {
|
|
61
|
-
|
|
56
|
+
itemId = deferredId;
|
|
62
57
|
}
|
|
63
58
|
}
|
|
64
59
|
|
|
65
|
-
return response;
|
|
60
|
+
return { response, itemId };
|
|
66
61
|
}
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { PersonField, UserPermision, UserProfile } from '../../types';
|
|
2
|
+
import { PermissionLabel, PersonField, UserPermision, UserProfile } from '../../types';
|
|
3
3
|
import { RequestContext } from './context';
|
|
4
4
|
import { escapeODataStringLiteral } from './sharepointUrl';
|
|
5
5
|
|
|
6
6
|
type RoleDefinition = {
|
|
7
|
+
Name: string;
|
|
8
|
+
Description: string;
|
|
9
|
+
Hidden: boolean;
|
|
10
|
+
Id: number;
|
|
11
|
+
Order: number;
|
|
12
|
+
RoleTypeKind: number;
|
|
7
13
|
BasePermissions: {
|
|
8
14
|
High: string;
|
|
15
|
+
Low: string;
|
|
9
16
|
};
|
|
10
17
|
};
|
|
11
18
|
|
|
19
|
+
const PERMISSION_PRIORITY: PermissionLabel[] = [
|
|
20
|
+
'Full Control',
|
|
21
|
+
'Edit',
|
|
22
|
+
'Contribute',
|
|
23
|
+
'Read',
|
|
24
|
+
];
|
|
25
|
+
|
|
12
26
|
export async function typeAhead(
|
|
13
27
|
instance: AxiosInstance,
|
|
14
28
|
input: string,
|
|
@@ -70,24 +84,19 @@ export async function currentUserProperties(
|
|
|
70
84
|
instance: AxiosInstance
|
|
71
85
|
): Promise<UserProfile> {
|
|
72
86
|
const requestUrl = '_api/sp.userprofiles.peoplemanager/getmyproperties';
|
|
73
|
-
|
|
87
|
+
const response = await instance.get(requestUrl);
|
|
74
88
|
|
|
75
|
-
profile =
|
|
89
|
+
const profile = (response.data?.d ?? response.data) as UserProfile | undefined;
|
|
90
|
+
if (!profile) {
|
|
91
|
+
throw new Error('Unable to retrieve user profile.');
|
|
92
|
+
}
|
|
76
93
|
|
|
77
|
-
profile.UserProfileProperties
|
|
94
|
+
profile.UserProfileProperties?.results?.forEach(
|
|
78
95
|
(prop: { Key: string; Value: string }) => {
|
|
79
|
-
if (prop.Key === 'FirstName')
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (prop.Key === '
|
|
83
|
-
profile.LastName = prop.Value;
|
|
84
|
-
}
|
|
85
|
-
if (prop.Key === 'Country') {
|
|
86
|
-
profile.Country = prop.Value;
|
|
87
|
-
}
|
|
88
|
-
if (prop.Key === 'UserName') {
|
|
89
|
-
profile.UserName = prop.Value;
|
|
90
|
-
}
|
|
96
|
+
if (prop.Key === 'FirstName') profile.FirstName = prop.Value;
|
|
97
|
+
else if (prop.Key === 'LastName') profile.LastName = prop.Value;
|
|
98
|
+
else if (prop.Key === 'Country') profile.Country = prop.Value;
|
|
99
|
+
else if (prop.Key === 'UserName') profile.UserName = prop.Value;
|
|
91
100
|
}
|
|
92
101
|
);
|
|
93
102
|
|
|
@@ -109,33 +118,48 @@ export async function getSiteUser(
|
|
|
109
118
|
return response.data.d;
|
|
110
119
|
}
|
|
111
120
|
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const response = await instance.get(requestUrl);
|
|
121
|
+
async function roleDefinitions(instance: AxiosInstance): Promise<RoleDefinition[]> {
|
|
122
|
+
const response = await instance.get('_api/Web/RoleDefinitions');
|
|
115
123
|
return response.data.d.results as RoleDefinition[];
|
|
116
124
|
}
|
|
117
125
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
126
|
+
async function getEffectiveBasePermissions(
|
|
127
|
+
instance: AxiosInstance
|
|
128
|
+
): Promise<{ High: string; Low: string }> {
|
|
129
|
+
const response = await instance.get('_api/Web/effectiveBasePermissions');
|
|
121
130
|
return response.data.d.EffectiveBasePermissions;
|
|
122
131
|
}
|
|
123
132
|
|
|
124
133
|
export async function currentUserPermissions(
|
|
125
134
|
context: RequestContext
|
|
126
135
|
): Promise<UserPermision> {
|
|
127
|
-
const { High } = await getEffectiveBasePermissions(
|
|
136
|
+
const { High: userHigh, Low: userLow } = await getEffectiveBasePermissions(
|
|
137
|
+
context.instance
|
|
138
|
+
);
|
|
128
139
|
const definitions = await roleDefinitions(context.instance);
|
|
129
140
|
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
141
|
+
const userHighInt = parseInt(userHigh, 10);
|
|
142
|
+
const userLowInt = parseInt(userLow, 10);
|
|
143
|
+
|
|
144
|
+
const matching = definitions
|
|
145
|
+
.filter((def): def is RoleDefinition =>
|
|
146
|
+
PERMISSION_PRIORITY.includes(def.Name as PermissionLabel) &&
|
|
147
|
+
(userHighInt & parseInt(def.BasePermissions.High, 10)) === parseInt(def.BasePermissions.High, 10) &&
|
|
148
|
+
(userLowInt & parseInt(def.BasePermissions.Low, 10)) === parseInt(def.BasePermissions.Low, 10)
|
|
149
|
+
)
|
|
150
|
+
.sort(
|
|
151
|
+
(a, b) =>
|
|
152
|
+
PERMISSION_PRIORITY.indexOf(a.Name as PermissionLabel) -
|
|
153
|
+
PERMISSION_PRIORITY.indexOf(b.Name as PermissionLabel)
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const result = matching[0];
|
|
133
157
|
|
|
134
158
|
if (!result) {
|
|
135
159
|
throw new Error(
|
|
136
|
-
`Unable to resolve current user permission
|
|
160
|
+
`Unable to resolve current user permission. Effective: High="${userHigh}", Low="${userLow}"`
|
|
137
161
|
);
|
|
138
162
|
}
|
|
139
163
|
|
|
140
|
-
return result as UserPermision;
|
|
164
|
+
return result as unknown as UserPermision;
|
|
141
165
|
}
|
package/src/types.ts
CHANGED
|
@@ -238,7 +238,7 @@ export type MultiPersonField = {
|
|
|
238
238
|
|
|
239
239
|
export type PermissionLabel = 'Full Control' | 'Edit' | 'Contribute' | 'Read';
|
|
240
240
|
|
|
241
|
-
export type
|
|
241
|
+
export type UserPermission = {
|
|
242
242
|
BasePermissions: {
|
|
243
243
|
High: string;
|
|
244
244
|
Low: string;
|
|
@@ -255,7 +255,18 @@ export type UserPermision = {
|
|
|
255
255
|
__metadata: Metadata;
|
|
256
256
|
};
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
/** @deprecated Use `UserPermission` instead. */
|
|
259
|
+
export type UserPermision = UserPermission;
|
|
260
|
+
|
|
261
|
+
export type SPGroup = {
|
|
262
|
+
Id: number;
|
|
263
|
+
Title: string;
|
|
264
|
+
LoginName: string;
|
|
265
|
+
Description: string;
|
|
266
|
+
OwnerTitle: string;
|
|
267
|
+
PrincipalType: number;
|
|
268
|
+
__metadata: Metadata;
|
|
269
|
+
};
|
|
259
270
|
|
|
260
271
|
export type CurrentUser = {
|
|
261
272
|
Email: string;
|
|
@@ -265,6 +276,8 @@ export type CurrentUser = {
|
|
|
265
276
|
PrincipalType: number;
|
|
266
277
|
Title: string;
|
|
267
278
|
__metadata: Metadata;
|
|
279
|
+
/** Populated only when fetched with `expand: 'Groups'` */
|
|
280
|
+
Groups?: { results: SPGroup[] };
|
|
268
281
|
};
|
|
269
282
|
|
|
270
283
|
export type UserProfilePropKey =
|
package/dist/root/index.d.ts
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { CreateAxiosDefaults as AxiosConfig } from 'axios';
|
|
2
|
-
import { CreateFileProps, CurrentUser, DeleteFileProps, EmailProps, Field_Options, Folder_Options, ItemID, ListData, Options, PersonField, SHAREPOINT_VER, UploadFileProps, UserPermision, UserProfile } from '../types';
|
|
3
|
-
import { sendEmail as sendEmailRequest } from './internal/emailRequests';
|
|
4
|
-
type ListKey<T extends {
|
|
5
|
-
LISTS: Record<string, unknown>;
|
|
6
|
-
}> = Extract<keyof T['LISTS'], string>;
|
|
7
|
-
type EmailApi = ((from: string, to: string[] | string, subject: string | undefined, body: string) => ReturnType<typeof sendEmailRequest>) & {
|
|
8
|
-
send: (props: EmailProps) => ReturnType<typeof sendEmailRequest>;
|
|
9
|
-
};
|
|
10
|
-
declare class HTTPSharePointRequests<T extends {
|
|
11
|
-
LISTS: Record<string, unknown>;
|
|
12
|
-
FOLDERS?: Record<string, unknown>;
|
|
13
|
-
}> {
|
|
14
|
-
private readonly baseURL;
|
|
15
|
-
private readonly instance;
|
|
16
|
-
private readonly listItemEntityTypeCache;
|
|
17
|
-
readonly email: EmailApi;
|
|
18
|
-
constructor(baseURL: string, config?: AxiosConfig);
|
|
19
|
-
private createContext;
|
|
20
|
-
private resolveListItemEntityTypeFullName;
|
|
21
|
-
private buildListScope;
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated Use `from(listName, '2010')` instead.
|
|
24
|
-
*/
|
|
25
|
-
list<K extends ListKey<T>>(listName: K): {
|
|
26
|
-
create: (data: ListData<T["LISTS"][K]>) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
27
|
-
get: (options?: Options<T["LISTS"][K], "2010">) => Promise<{
|
|
28
|
-
data: (T["LISTS"][K] & Partial<import("../types").SPItem2010>) | (T["LISTS"][K] & Partial<import("../types").SPItem2010>)[];
|
|
29
|
-
meta: {
|
|
30
|
-
url: URL;
|
|
31
|
-
};
|
|
32
|
-
}>;
|
|
33
|
-
update: (id: ItemID, data: ListData<T["LISTS"][K]>, digest?: string) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
34
|
-
delete: (id: ItemID) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
35
|
-
remove: (id: ItemID) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
36
|
-
createFile: (props: CreateFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
37
|
-
uploadFile: (props: UploadFileProps) => Promise<import("axios").AxiosResponse<any, any, {}> & {
|
|
38
|
-
itemId?: ItemID;
|
|
39
|
-
}>;
|
|
40
|
-
deleteFile: (props: DeleteFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
41
|
-
removeFile: (props: DeleteFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
42
|
-
fields: (options?: Field_Options<T["LISTS"][K], "2010">) => {
|
|
43
|
-
get: () => Promise<any>;
|
|
44
|
-
};
|
|
45
|
-
items: {
|
|
46
|
-
create: (data: ListData<T["LISTS"][K]>) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
47
|
-
get: (options?: Options<T["LISTS"][K], "2010">) => Promise<{
|
|
48
|
-
data: (T["LISTS"][K] & Partial<import("../types").SPItem2010>) | (T["LISTS"][K] & Partial<import("../types").SPItem2010>)[];
|
|
49
|
-
meta: {
|
|
50
|
-
url: URL;
|
|
51
|
-
};
|
|
52
|
-
}>;
|
|
53
|
-
update: (id: ItemID, data: ListData<T["LISTS"][K]>, digest?: string) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
54
|
-
delete: (id: ItemID) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
55
|
-
remove: (id: ItemID) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
56
|
-
};
|
|
57
|
-
files: {
|
|
58
|
-
attach: (props: CreateFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
59
|
-
upload: (props: UploadFileProps) => Promise<import("axios").AxiosResponse<any, any, {}> & {
|
|
60
|
-
itemId?: ItemID;
|
|
61
|
-
}>;
|
|
62
|
-
delete: (props: DeleteFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
63
|
-
remove: (props: DeleteFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
from<K extends ListKey<T>, V extends SHAREPOINT_VER = '2013'>(listName: K, sharepointVersion?: V): {
|
|
67
|
-
create: (data: ListData<T["LISTS"][K]>) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
68
|
-
get: (options?: Options<T["LISTS"][K], V>) => Promise<{
|
|
69
|
-
data: (T["LISTS"][K] & Partial<import("../types").SPItem<V>>) | (T["LISTS"][K] & Partial<import("../types").SPItem<V>>)[];
|
|
70
|
-
meta: {
|
|
71
|
-
url: URL;
|
|
72
|
-
};
|
|
73
|
-
}>;
|
|
74
|
-
update: (id: ItemID, data: ListData<T["LISTS"][K]>, digest?: string) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
75
|
-
delete: (id: ItemID) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
76
|
-
remove: (id: ItemID) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
77
|
-
createFile: (props: CreateFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
78
|
-
uploadFile: (props: UploadFileProps) => Promise<import("axios").AxiosResponse<any, any, {}> & {
|
|
79
|
-
itemId?: ItemID;
|
|
80
|
-
}>;
|
|
81
|
-
deleteFile: (props: DeleteFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
82
|
-
removeFile: (props: DeleteFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
83
|
-
fields: (options?: Field_Options<T["LISTS"][K], V>) => {
|
|
84
|
-
get: () => Promise<any>;
|
|
85
|
-
};
|
|
86
|
-
items: {
|
|
87
|
-
create: (data: ListData<T["LISTS"][K]>) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
88
|
-
get: (options?: Options<T["LISTS"][K], V>) => Promise<{
|
|
89
|
-
data: (T["LISTS"][K] & Partial<import("../types").SPItem<V>>) | (T["LISTS"][K] & Partial<import("../types").SPItem<V>>)[];
|
|
90
|
-
meta: {
|
|
91
|
-
url: URL;
|
|
92
|
-
};
|
|
93
|
-
}>;
|
|
94
|
-
update: (id: ItemID, data: ListData<T["LISTS"][K]>, digest?: string) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
95
|
-
delete: (id: ItemID) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
96
|
-
remove: (id: ItemID) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
97
|
-
};
|
|
98
|
-
files: {
|
|
99
|
-
attach: (props: CreateFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
100
|
-
upload: (props: UploadFileProps) => Promise<import("axios").AxiosResponse<any, any, {}> & {
|
|
101
|
-
itemId?: ItemID;
|
|
102
|
-
}>;
|
|
103
|
-
delete: (props: DeleteFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
104
|
-
remove: (props: DeleteFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
field<K extends ListKey<T>, V extends SHAREPOINT_VER = '2013'>(listName: K, fieldName?: Extract<keyof T['LISTS'][K], string>, sharepointVersion?: V): Promise<any>;
|
|
108
|
-
lists(options?: Options<Record<string, unknown>, '2013'>): {
|
|
109
|
-
get: () => Promise<{
|
|
110
|
-
data: (Record<string, unknown> & Partial<import("../types").SPItem2013>) | (Record<string, unknown> & Partial<import("../types").SPItem2013>)[];
|
|
111
|
-
meta: {
|
|
112
|
-
url: URL;
|
|
113
|
-
};
|
|
114
|
-
}>;
|
|
115
|
-
};
|
|
116
|
-
getDigest(): Promise<string>;
|
|
117
|
-
folders(options?: Folder_Options<Record<string, unknown>>): {
|
|
118
|
-
get: () => Promise<{
|
|
119
|
-
data: any;
|
|
120
|
-
meta: {
|
|
121
|
-
url: URL;
|
|
122
|
-
};
|
|
123
|
-
}>;
|
|
124
|
-
};
|
|
125
|
-
folder(folderName?: string | string[]): {
|
|
126
|
-
get: (options?: Folder_Options<Record<string, unknown>>) => Promise<{
|
|
127
|
-
data: any;
|
|
128
|
-
meta: {
|
|
129
|
-
url: URL;
|
|
130
|
-
};
|
|
131
|
-
}>;
|
|
132
|
-
};
|
|
133
|
-
users(options?: Options<Record<string, unknown>, '2013'>): {
|
|
134
|
-
get: () => Promise<{
|
|
135
|
-
data: (Record<string, unknown> & Partial<import("../types").SPItem2013>) | (Record<string, unknown> & Partial<import("../types").SPItem2013>)[];
|
|
136
|
-
meta: {
|
|
137
|
-
url: URL;
|
|
138
|
-
};
|
|
139
|
-
}>;
|
|
140
|
-
};
|
|
141
|
-
sendEmail(props: EmailProps): Promise<import("axios").AxiosResponse<{
|
|
142
|
-
d: {
|
|
143
|
-
SendEmail: null;
|
|
144
|
-
};
|
|
145
|
-
}, any, {}>>;
|
|
146
|
-
readonly user: {
|
|
147
|
-
properties: () => {
|
|
148
|
-
get: () => Promise<UserProfile>;
|
|
149
|
-
};
|
|
150
|
-
searchSiteUser: (searchValue: string) => Promise<any>;
|
|
151
|
-
searchUser: (input: string, filter?: string) => Promise<PersonField>;
|
|
152
|
-
current: () => {
|
|
153
|
-
get: () => Promise<CurrentUser>;
|
|
154
|
-
};
|
|
155
|
-
currentPermission: () => {
|
|
156
|
-
get: () => Promise<UserPermision>;
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
getCurrentUser(): Promise<CurrentUser>;
|
|
160
|
-
currentUserProperties(): Promise<UserProfile>;
|
|
161
|
-
currentUserPermission(): Promise<UserPermision>;
|
|
162
|
-
}
|
|
163
|
-
export default HTTPSharePointRequests;
|
package/dist/root/instance.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { SHAREPOINT_VER } from '../../types';
|
|
3
|
-
export interface RequestContext<V extends SHAREPOINT_VER = '2013'> {
|
|
4
|
-
instance: AxiosInstance;
|
|
5
|
-
baseURL: string;
|
|
6
|
-
endpoint: string;
|
|
7
|
-
listName: string;
|
|
8
|
-
sharepointVersion: V;
|
|
9
|
-
listItemEntityTypeFullName?: string;
|
|
10
|
-
resolveListItemEntityType?: () => Promise<string>;
|
|
11
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { EmailProps } from '../../types';
|
|
3
|
-
import { RequestContext } from './context';
|
|
4
|
-
type SendEmailResponse = AxiosResponse<{
|
|
5
|
-
d: {
|
|
6
|
-
SendEmail: null;
|
|
7
|
-
};
|
|
8
|
-
}>;
|
|
9
|
-
export declare function sendEmail(context: RequestContext, { From, To, Subject, Body }: EmailProps): Promise<SendEmailResponse>;
|
|
10
|
-
export {};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { CreateFileProps, SHAREPOINT_VER } from '../../../types';
|
|
2
|
-
import { RequestContext } from '../context';
|
|
3
|
-
export declare function createAttachment<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, { file, itemId }: CreateFileProps): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { ListData, SHAREPOINT_VER } from '../../../types';
|
|
2
|
-
import { RequestContext } from '../context';
|
|
3
|
-
export declare function createListItem<D = Record<string, unknown>, V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, listData: ListData<D>): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { SHAREPOINT_VER, DeleteFileProps } from '../../../types';
|
|
2
|
-
import { RequestContext } from '../context';
|
|
3
|
-
export declare function deleteFile<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, { fileName, folderPath }: DeleteFileProps): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Folder_Options, SHAREPOINT_VER } from '../../../types';
|
|
2
|
-
import { RequestContext } from '../context';
|
|
3
|
-
export declare function getFiles<T, V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, options?: Folder_Options<T>): Promise<{
|
|
4
|
-
data: any;
|
|
5
|
-
meta: {
|
|
6
|
-
url: URL;
|
|
7
|
-
};
|
|
8
|
-
}>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Options, SPItem, SHAREPOINT_VER } from '../../../types';
|
|
2
|
-
import { RequestContext } from '../context';
|
|
3
|
-
export declare function getListItems<K, V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, options?: Options<K, V>): Promise<{
|
|
4
|
-
data: (K & Partial<SPItem<V>>) | (K & Partial<SPItem<V>>)[] | undefined;
|
|
5
|
-
meta: {
|
|
6
|
-
url: URL;
|
|
7
|
-
};
|
|
8
|
-
}>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { createListItem } from './createListItem';
|
|
2
|
-
export { createAttachment } from './createAttachment';
|
|
3
|
-
export { deleteItem } from './deleteItem';
|
|
4
|
-
export { deleteFile } from './deleteFile';
|
|
5
|
-
export { getFiles } from './getFiles';
|
|
6
|
-
export { getListItems } from './getListItems';
|
|
7
|
-
export { getOnly } from './getOnly';
|
|
8
|
-
export { updateListItem } from './updateListItem';
|
|
9
|
-
export { uploadFile } from './uploadFile';
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { ListData, SHAREPOINT_VER } from '../../../types';
|
|
2
|
-
import { RequestContext } from '../context';
|
|
3
|
-
export declare function updateListItem<D = Record<string, unknown>, V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, id: number | string, data: ListData<D>, digest?: string): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { ItemID, SHAREPOINT_VER, UploadFileProps } from '../../../types';
|
|
3
|
-
import { RequestContext } from '../context';
|
|
4
|
-
export declare function uploadFile<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, { file, folderPath, overwrite }: UploadFileProps): Promise<AxiosResponse & {
|
|
5
|
-
itemId?: ItemID;
|
|
6
|
-
}>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Folder_Options, Options, SHAREPOINT_VER } from '../../types';
|
|
2
|
-
type QueryableOptions<T, V extends SHAREPOINT_VER = '2013'> = Options<T, V> | Folder_Options<T>;
|
|
3
|
-
export declare function buildODataParams<T, V extends SHAREPOINT_VER = '2013'>(options: QueryableOptions<T, V> | undefined, orderBySeparator?: ',' | ' '): Record<string, string | number>;
|
|
4
|
-
export declare function appendParamsToUrl(baseUrl: URL, params: Record<string, string | number | undefined | null>): void;
|
|
5
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { PersonField, UserPermision, UserProfile } from '../../types';
|
|
3
|
-
import { RequestContext } from './context';
|
|
4
|
-
type RoleDefinition = {
|
|
5
|
-
BasePermissions: {
|
|
6
|
-
High: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
export declare function typeAhead(instance: AxiosInstance, input: string, filter?: string): Promise<PersonField>;
|
|
10
|
-
export declare function currentUserProperties(instance: AxiosInstance): Promise<UserProfile>;
|
|
11
|
-
export declare function getSiteUser(instance: AxiosInstance, searchValue: string): Promise<any>;
|
|
12
|
-
export declare function roleDefinitions(instance: AxiosInstance): Promise<RoleDefinition[]>;
|
|
13
|
-
export declare function getEffectiveBasePermissions(instance: AxiosInstance): Promise<any>;
|
|
14
|
-
export declare function currentUserPermissions(context: RequestContext): Promise<UserPermision>;
|
|
15
|
-
export {};
|