@lindle/sharepoint_requests 0.1.17 → 0.1.19
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/README.md +121 -116
- package/dist/index.d.ts +2 -2
- package/dist/root/index.d.ts +106 -31
- package/dist/root/internal/context.d.ts +2 -2
- package/dist/root/internal/digest.d.ts +1 -1
- package/dist/root/internal/emailRequests.d.ts +3 -3
- package/dist/root/internal/listRequests/createAttachment.d.ts +2 -2
- package/dist/root/internal/listRequests/createListItem.d.ts +3 -3
- package/dist/root/internal/listRequests/deleteFile.d.ts +2 -2
- package/dist/root/internal/listRequests/deleteItem.d.ts +2 -2
- package/dist/root/internal/listRequests/getFiles.d.ts +2 -2
- package/dist/root/internal/listRequests/getListItems.d.ts +3 -3
- package/dist/root/internal/listRequests/getOnly.d.ts +2 -2
- package/dist/root/internal/listRequests/normalizePayload.d.ts +4 -0
- package/dist/root/internal/listRequests/updateListItem.d.ts +3 -3
- package/dist/root/internal/listRequests/uploadFile.d.ts +3 -3
- package/dist/root/internal/odata.d.ts +1 -1
- package/dist/root/internal/sharepointUrl.d.ts +2 -0
- package/dist/root/internal/userRequests.d.ts +3 -3
- package/dist/sharepoint_requests.cjs.development.js +572 -229
- package/dist/sharepoint_requests.cjs.development.js.map +1 -1
- package/dist/sharepoint_requests.cjs.production.min.js +1 -1
- package/dist/sharepoint_requests.cjs.production.min.js.map +1 -1
- package/dist/sharepoint_requests.esm.js +572 -229
- package/dist/sharepoint_requests.esm.js.map +1 -1
- package/dist/types.d.ts +30 -11
- package/package.json +1 -1
- package/src/index.ts +3 -5
- package/src/root/index.ts +263 -144
- package/src/root/internal/context.ts +2 -2
- package/src/root/internal/digest.ts +4 -3
- package/src/root/internal/emailRequests.ts +4 -7
- package/src/root/internal/listRequests/createAttachment.ts +14 -3
- package/src/root/internal/listRequests/createListItem.ts +24 -13
- package/src/root/internal/listRequests/deleteFile.ts +4 -3
- package/src/root/internal/listRequests/deleteItem.ts +17 -3
- package/src/root/internal/listRequests/getFiles.ts +4 -10
- package/src/root/internal/listRequests/getListItems.ts +16 -9
- package/src/root/internal/listRequests/getOnly.ts +10 -7
- package/src/root/internal/listRequests/normalizePayload.ts +165 -0
- package/src/root/internal/listRequests/updateListItem.ts +31 -13
- package/src/root/internal/listRequests/uploadFile.ts +5 -8
- package/src/root/internal/listRequests/utils.ts +1 -1
- package/src/root/internal/odata.ts +2 -4
- package/src/root/internal/sharepointUrl.ts +7 -0
- package/src/root/internal/userRequests.ts +43 -11
- package/src/types.ts +138 -105
package/src/types.ts
CHANGED
|
@@ -1,121 +1,113 @@
|
|
|
1
|
-
export type Metadata = {
|
|
2
|
-
id?: string;
|
|
3
|
-
type?: string;
|
|
4
|
-
uri?: string;
|
|
5
|
-
etag?: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type SPItem2010 = {
|
|
9
|
-
Attachments: string;
|
|
10
|
-
ContentType: string;
|
|
11
|
-
ContentTypeID: string;
|
|
12
|
-
Created: string;
|
|
13
|
-
CreatedBy: PersonField & _Deferred;
|
|
14
|
-
CreatedById: string;
|
|
15
|
-
Modified: string;
|
|
16
|
-
ModifiedBy: PersonField & _Deferred;
|
|
17
|
-
ModifiedById: string;
|
|
18
|
-
Id: number;
|
|
19
|
-
Title: string;
|
|
20
|
-
Path: string;
|
|
21
|
-
Version: string;
|
|
22
|
-
Owshiddenversion: number;
|
|
23
|
-
__metadata: Metadata;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type SPItem2013 = {
|
|
27
|
-
__metadata: Metadata;
|
|
28
|
-
FirstUniqueAncestorSecurableObject: _Deferred;
|
|
29
|
-
RoleAssignments: _Deferred;
|
|
30
|
-
AttachmentFiles: _Deferred;
|
|
31
|
-
ContentType: _Deferred;
|
|
32
|
-
GetDlpPolicyTip: _Deferred;
|
|
33
|
-
FieldValuesAsHtml: _Deferred;
|
|
34
|
-
FieldValuesAsText: _Deferred;
|
|
35
|
-
FieldValuesForEdit: _Deferred;
|
|
36
|
-
File: _Deferred;
|
|
37
|
-
Folder: _Deferred;
|
|
38
|
-
ParentList: _Deferred;
|
|
39
|
-
FileSystemObjectType: number;
|
|
40
|
-
Id: number;
|
|
41
|
-
ContentTypeId: string;
|
|
42
|
-
Title: string;
|
|
43
|
-
PhotoRefId?: number;
|
|
44
|
-
ID: number;
|
|
45
|
-
Modified: string;
|
|
46
|
-
Created: string;
|
|
47
|
-
AuthorId: number;
|
|
48
|
-
EditorId: number;
|
|
49
|
-
OData__UIVersionString?: string;
|
|
50
|
-
Attachments: boolean;
|
|
51
|
-
GUID: string;
|
|
52
|
-
Author?: PersonField & _Deferred;
|
|
53
|
-
Editor?: PersonField & _Deferred;
|
|
54
|
-
[key: string]: unknown;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export type SPItem<V extends SHAREPOINT_VER = '2013'> = V extends '2010'
|
|
58
|
-
? SPItem2010
|
|
59
|
-
: SPItem2013;
|
|
60
|
-
|
|
61
|
-
type ListFields<K, V extends SHAREPOINT_VER = '2013'> =
|
|
62
|
-
| Extract<keyof K, string>
|
|
63
|
-
| Extract<keyof SPItem<V>, string>;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
export type Metadata = {
|
|
2
|
+
id?: string;
|
|
3
|
+
type?: string;
|
|
4
|
+
uri?: string;
|
|
5
|
+
etag?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type SPItem2010 = {
|
|
9
|
+
Attachments: string;
|
|
10
|
+
ContentType: string;
|
|
11
|
+
ContentTypeID: string;
|
|
12
|
+
Created: string;
|
|
13
|
+
CreatedBy: PersonField & _Deferred;
|
|
14
|
+
CreatedById: string;
|
|
15
|
+
Modified: string;
|
|
16
|
+
ModifiedBy: PersonField & _Deferred;
|
|
17
|
+
ModifiedById: string;
|
|
18
|
+
Id: number;
|
|
19
|
+
Title: string;
|
|
20
|
+
Path: string;
|
|
21
|
+
Version: string;
|
|
22
|
+
Owshiddenversion: number;
|
|
23
|
+
__metadata: Metadata;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type SPItem2013 = {
|
|
27
|
+
__metadata: Metadata;
|
|
28
|
+
FirstUniqueAncestorSecurableObject: _Deferred;
|
|
29
|
+
RoleAssignments: _Deferred;
|
|
30
|
+
AttachmentFiles: _Deferred;
|
|
31
|
+
ContentType: _Deferred;
|
|
32
|
+
GetDlpPolicyTip: _Deferred;
|
|
33
|
+
FieldValuesAsHtml: _Deferred;
|
|
34
|
+
FieldValuesAsText: _Deferred;
|
|
35
|
+
FieldValuesForEdit: _Deferred;
|
|
36
|
+
File: _Deferred;
|
|
37
|
+
Folder: _Deferred;
|
|
38
|
+
ParentList: _Deferred;
|
|
39
|
+
FileSystemObjectType: number;
|
|
40
|
+
Id: number;
|
|
41
|
+
ContentTypeId: string;
|
|
42
|
+
Title: string;
|
|
43
|
+
PhotoRefId?: number;
|
|
44
|
+
ID: number;
|
|
45
|
+
Modified: string;
|
|
46
|
+
Created: string;
|
|
47
|
+
AuthorId: number;
|
|
48
|
+
EditorId: number;
|
|
49
|
+
OData__UIVersionString?: string;
|
|
50
|
+
Attachments: boolean;
|
|
51
|
+
GUID: string;
|
|
52
|
+
Author?: PersonField & _Deferred;
|
|
53
|
+
Editor?: PersonField & _Deferred;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type SPItem<V extends SHAREPOINT_VER = '2013'> = V extends '2010'
|
|
58
|
+
? SPItem2010
|
|
59
|
+
: SPItem2013;
|
|
60
|
+
|
|
61
|
+
type ListFields<K, V extends SHAREPOINT_VER = '2013'> =
|
|
62
|
+
| Extract<keyof K, string>
|
|
63
|
+
| Extract<keyof SPItem<V>, string>;
|
|
64
|
+
|
|
65
|
+
type OrderByDirection = 'asc' | 'desc';
|
|
66
|
+
type OrderByExpression<F extends string> = F | (F | OrderByDirection)[];
|
|
67
|
+
|
|
68
|
+
export interface Options<K = any, V extends SHAREPOINT_VER = '2013'> {
|
|
69
|
+
expand?: ListFields<K, V>[] | ListFields<K, V>;
|
|
70
|
+
orderBy?: OrderByExpression<ListFields<K, V>>;
|
|
71
|
+
limit?: number;
|
|
72
|
+
filter?: string;
|
|
73
|
+
cols?: ListFields<K, V>[] | ListFields<K, V>;
|
|
71
74
|
skip?: number;
|
|
72
75
|
}
|
|
73
76
|
export interface Folder_Options<K = any> {
|
|
74
|
-
type
|
|
77
|
+
type?: 'Files' | 'Folders';
|
|
75
78
|
expand?: Extract<keyof K, string>[] | Extract<keyof K, string>;
|
|
76
|
-
orderBy?:
|
|
77
|
-
| Extract<keyof K, string>
|
|
78
|
-
| [Extract<keyof K, string>, 'asc' | 'desc'];
|
|
79
|
+
orderBy?: OrderByExpression<Extract<keyof K, string>>;
|
|
79
80
|
limit?: number;
|
|
80
81
|
filter?: string;
|
|
81
82
|
cols?: Extract<keyof K, string>[] | Extract<keyof K, string>;
|
|
82
83
|
skip?: number;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
export interface Field_Options<
|
|
86
|
-
K,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
fieldName?: Extract<keyof K, string>;
|
|
90
|
-
}
|
|
86
|
+
export interface Field_Options<K, V extends SHAREPOINT_VER = '2013'>
|
|
87
|
+
extends Omit<Options<K, V>, 'filter'> {
|
|
88
|
+
fieldName?: Extract<keyof K, string>;
|
|
89
|
+
}
|
|
91
90
|
|
|
92
91
|
export type SHAREPOINT_VER = '2010' | '2013';
|
|
93
92
|
|
|
94
|
-
export type IListName<T> =
|
|
93
|
+
export type IListName<T> = T extends { LISTS: Record<string, unknown> }
|
|
94
|
+
? Extract<keyof T['LISTS'], string>
|
|
95
|
+
: Extract<keyof T, string>;
|
|
95
96
|
|
|
96
|
-
export type ItemID = string | number;
|
|
97
|
-
export type CreateFileProps = {
|
|
98
|
-
file: File;
|
|
99
|
-
itemId: ItemID;
|
|
100
|
-
};
|
|
101
|
-
export type UploadFileProps = {
|
|
102
|
-
file: File;
|
|
103
|
-
folderPath?: string | string[];
|
|
104
|
-
overwrite?: boolean;
|
|
105
|
-
};
|
|
106
|
-
export type DeleteFileProps = {
|
|
107
|
-
fileName: string;
|
|
108
|
-
folderPath?: string | string[];
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export type ListData =
|
|
112
|
-
| {
|
|
113
|
-
[key: string]: any;
|
|
114
|
-
__metadata?: {
|
|
115
|
-
type: string;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
| any;
|
|
97
|
+
export type ItemID = string | number;
|
|
98
|
+
export type CreateFileProps = {
|
|
99
|
+
file: File;
|
|
100
|
+
itemId: ItemID;
|
|
101
|
+
};
|
|
102
|
+
export type UploadFileProps = {
|
|
103
|
+
file: File;
|
|
104
|
+
folderPath?: string | string[];
|
|
105
|
+
overwrite?: boolean;
|
|
106
|
+
};
|
|
107
|
+
export type DeleteFileProps = {
|
|
108
|
+
fileName: string;
|
|
109
|
+
folderPath?: string | string[];
|
|
110
|
+
};
|
|
119
111
|
|
|
120
112
|
export type EmailProps = {
|
|
121
113
|
From: string;
|
|
@@ -130,12 +122,51 @@ export type _Deferred = {
|
|
|
130
122
|
};
|
|
131
123
|
};
|
|
132
124
|
|
|
133
|
-
|
|
125
|
+
type LookupFieldMarker = {
|
|
126
|
+
__lookupFieldBrand?: true;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export type LookupField<T> = _Deferred & T & LookupFieldMarker;
|
|
134
130
|
export type ChoiceField<T> = _Deferred & {
|
|
135
131
|
Value: T;
|
|
136
132
|
__metadata: Metadata;
|
|
137
133
|
};
|
|
138
134
|
|
|
135
|
+
type MetadataEnvelope = {
|
|
136
|
+
__metadata?: {
|
|
137
|
+
type: string;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
type EnsureRecord<T> = T extends Record<string, unknown>
|
|
142
|
+
? T
|
|
143
|
+
: Record<string, unknown>;
|
|
144
|
+
|
|
145
|
+
type LookupCreateValue =
|
|
146
|
+
| number
|
|
147
|
+
| string
|
|
148
|
+
| null
|
|
149
|
+
| {
|
|
150
|
+
lookupId: number | string;
|
|
151
|
+
}
|
|
152
|
+
| {
|
|
153
|
+
LookupId: number | string;
|
|
154
|
+
}
|
|
155
|
+
| {
|
|
156
|
+
results: (number | string)[];
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
type NormalizeField<T> = T extends LookupField<unknown>
|
|
160
|
+
? LookupCreateValue | LookupField<unknown>
|
|
161
|
+
: T;
|
|
162
|
+
|
|
163
|
+
export type ListData<T = Record<string, unknown>> = Partial<
|
|
164
|
+
{
|
|
165
|
+
[K in keyof EnsureRecord<T>]: NormalizeField<EnsureRecord<T>[K]>;
|
|
166
|
+
}
|
|
167
|
+
> &
|
|
168
|
+
MetadataEnvelope;
|
|
169
|
+
|
|
139
170
|
export type PersonField = {
|
|
140
171
|
AboutMe?: string;
|
|
141
172
|
Account: string;
|
|
@@ -224,6 +255,8 @@ export type UserPermision = {
|
|
|
224
255
|
__metadata: Metadata;
|
|
225
256
|
};
|
|
226
257
|
|
|
258
|
+
export type UserPermission = UserPermision;
|
|
259
|
+
|
|
227
260
|
export type CurrentUser = {
|
|
228
261
|
Email: string;
|
|
229
262
|
Id: number;
|