@lindle/sharepoint_requests 0.1.14 → 0.1.16

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.
Files changed (37) hide show
  1. package/README.md +9 -0
  2. package/dist/index.d.ts +17 -17
  3. package/dist/root/index.d.ts +86 -81
  4. package/dist/root/instance.d.ts +3 -3
  5. package/dist/root/internal/context.d.ts +11 -9
  6. package/dist/root/internal/digest.d.ts +2 -2
  7. package/dist/root/internal/emailRequests.d.ts +10 -10
  8. package/dist/root/internal/listRequests/createAttachment.d.ts +3 -3
  9. package/dist/root/internal/listRequests/createListItem.d.ts +3 -3
  10. package/dist/root/internal/listRequests/deleteFile.d.ts +3 -0
  11. package/dist/root/internal/listRequests/deleteItem.d.ts +3 -3
  12. package/dist/root/internal/listRequests/getFiles.d.ts +8 -8
  13. package/dist/root/internal/listRequests/getListItems.d.ts +8 -8
  14. package/dist/root/internal/listRequests/getOnly.d.ts +3 -3
  15. package/dist/root/internal/listRequests/index.d.ts +9 -7
  16. package/dist/root/internal/listRequests/updateListItem.d.ts +3 -3
  17. package/dist/root/internal/listRequests/uploadFile.d.ts +3 -0
  18. package/dist/root/internal/listRequests/utils.d.ts +2 -0
  19. package/dist/root/internal/odata.d.ts +5 -5
  20. package/dist/root/internal/userRequests.d.ts +15 -15
  21. package/dist/sharepoint_requests.cjs.development.js +284 -50
  22. package/dist/sharepoint_requests.cjs.development.js.map +1 -1
  23. package/dist/sharepoint_requests.cjs.production.min.js +1 -1
  24. package/dist/sharepoint_requests.cjs.production.min.js.map +1 -1
  25. package/dist/sharepoint_requests.esm.js +284 -50
  26. package/dist/sharepoint_requests.esm.js.map +1 -1
  27. package/dist/types.d.ts +241 -232
  28. package/package.json +6 -3
  29. package/src/root/index.ts +55 -2
  30. package/src/root/internal/context.ts +2 -0
  31. package/src/root/internal/listRequests/createListItem.ts +18 -12
  32. package/src/root/internal/listRequests/deleteFile.ts +35 -0
  33. package/src/root/internal/listRequests/index.ts +2 -0
  34. package/src/root/internal/listRequests/updateListItem.ts +21 -3
  35. package/src/root/internal/listRequests/uploadFile.ts +42 -0
  36. package/src/root/internal/listRequests/utils.ts +33 -0
  37. package/src/types.ts +14 -5
package/dist/types.d.ts CHANGED
@@ -1,232 +1,241 @@
1
- export declare type Metadata = {
2
- id?: string;
3
- type?: string;
4
- uri?: string;
5
- etag?: string;
6
- };
7
- export declare type SPItem2010 = {
8
- Attachments: string;
9
- ContentType: string;
10
- ContentTypeID: string;
11
- Created: string;
12
- CreatedBy: PersonField & _Deferred;
13
- CreatedById: string;
14
- Modified: string;
15
- ModifiedBy: PersonField & _Deferred;
16
- ModifiedById: string;
17
- Id: number;
18
- Title: string;
19
- Path: string;
20
- Version: string;
21
- Owshiddenversion: number;
22
- __metadata: Metadata;
23
- };
24
- export declare type SPItem2013 = {
25
- __metadata: Metadata;
26
- FirstUniqueAncestorSecurableObject: _Deferred;
27
- RoleAssignments: _Deferred;
28
- AttachmentFiles: _Deferred;
29
- ContentType: _Deferred;
30
- GetDlpPolicyTip: _Deferred;
31
- FieldValuesAsHtml: _Deferred;
32
- FieldValuesAsText: _Deferred;
33
- FieldValuesForEdit: _Deferred;
34
- File: _Deferred;
35
- Folder: _Deferred;
36
- ParentList: _Deferred;
37
- FileSystemObjectType: number;
38
- Id: number;
39
- ContentTypeId: string;
40
- Title: string;
41
- PhotoRefId?: number;
42
- ID: number;
43
- Modified: string;
44
- Created: string;
45
- AuthorId: number;
46
- EditorId: number;
47
- OData__UIVersionString?: string;
48
- Attachments: boolean;
49
- GUID: string;
50
- Author?: PersonField & _Deferred;
51
- Editor?: PersonField & _Deferred;
52
- [key: string]: unknown;
53
- };
54
- export declare type SPItem<V extends SHAREPOINT_VER = '2013'> = V extends '2010' ? SPItem2010 : SPItem2013;
55
- declare type ListFields<K, V extends SHAREPOINT_VER = '2013'> = Extract<keyof K, string> | Extract<keyof SPItem<V>, string>;
56
- export interface Options<K = any, V extends SHAREPOINT_VER = '2013'> {
57
- expand?: ListFields<K, V>[] | ListFields<K, V>;
58
- orderBy?: ListFields<K, V> | [ListFields<K, V>, 'asc' | 'desc'];
59
- limit?: number;
60
- filter?: string;
61
- cols?: ListFields<K, V>[] | ListFields<K, V>;
62
- skip?: number;
63
- }
64
- export interface Folder_Options<K = any> {
65
- type: 'Files' | 'Folders';
66
- expand?: Extract<keyof K, string>[] | Extract<keyof K, string>;
67
- orderBy?: Extract<keyof K, string> | [Extract<keyof K, string>, 'asc' | 'desc'];
68
- limit?: number;
69
- filter?: string;
70
- cols?: Extract<keyof K, string>[] | Extract<keyof K, string>;
71
- skip?: number;
72
- }
73
- export interface Field_Options<K, V extends SHAREPOINT_VER = '2013'> extends Omit<Options<K, V>, 'filter'> {
74
- fieldName?: Extract<keyof K, string>;
75
- }
76
- export declare type SHAREPOINT_VER = '2010' | '2013';
77
- export declare type IListName<T> = Extract<keyof T, string>;
78
- export declare type ItemID = string | number;
79
- export declare type CreateFileProps = {
80
- file: File;
81
- itemId: ItemID;
82
- };
83
- export declare type ListData = {
84
- [key: string]: any;
85
- __metadata?: {
86
- type: string;
87
- };
88
- } | any;
89
- export declare type EmailProps = {
90
- From: string;
91
- To: string[] | string;
92
- Subject?: string;
93
- Body: string;
94
- };
95
- export declare type _Deferred = {
96
- __deferred: {
97
- uri: string;
98
- };
99
- };
100
- export declare type LookupField<T> = _Deferred & T;
101
- export declare type ChoiceField<T> = _Deferred & {
102
- Value: T;
103
- __metadata: Metadata;
104
- };
105
- export declare type PersonField = {
106
- AboutMe?: string;
107
- Account: string;
108
- AccountName: string;
109
- AdministrativeSupervisor: string;
110
- AskMeAbout?: string;
111
- AskMeAbout0?: string;
112
- Assistant?: string;
113
- Attachments: unknown;
114
- BuildingName: string;
115
- BusinessLine: string;
116
- CellPhone?: string;
117
- City?: string;
118
- Company: string;
119
- CompanyCode: string;
120
- ContentType: string;
121
- ContentTypeID: string;
122
- CostCenter: string;
123
- Country: string;
124
- Created: string;
125
- CreatedBy: PersonField;
126
- CreatedById: number;
127
- Deleted: boolean;
128
- Department: string;
129
- Department0?: string;
130
- Division: string;
131
- Fax?: string;
132
- FirstName: string;
133
- Hidden: boolean;
134
- Id?: string;
135
- Id0: number;
136
- Interests?: string;
137
- IsSiteAdmin: boolean;
138
- JobTitle?: string;
139
- LANID: string;
140
- LastName: string;
141
- Manager: string;
142
- MobilePhone: string;
143
- Modified: string;
144
- ModifiedBy: PersonField;
145
- ModifiedById: number;
146
- Name: string;
147
- Office: string;
148
- OfficeLocation?: string;
149
- Owshiddenversion: number;
150
- Pager?: string;
151
- Path: string;
152
- Picture: string;
153
- PictureExchangeSyncState: number;
154
- PicturePlaceholderState: number;
155
- PictureTimestamp: string;
156
- SIPAddress?: string;
157
- Schools?: string;
158
- Skills?: string;
159
- State: string;
160
- Title: string;
161
- UserName: string;
162
- Version: string;
163
- WebSite?: string;
164
- WorkEmail: string;
165
- WorkHistory?: string;
166
- WorkPhone?: string;
167
- __metadata: Metadata;
168
- };
169
- export declare type MultiPersonField = {
170
- results: PersonField[];
171
- };
172
- export declare type PermissionLabel = 'Full Control' | 'Edit' | 'Contribute' | 'Read';
173
- export declare type UserPermision = {
174
- BasePermissions: {
175
- High: string;
176
- Low: string;
177
- __metadata: {
178
- type: 'SP.BasePermissions';
179
- };
180
- };
181
- Description: string;
182
- Hidden: boolean;
183
- Id: number;
184
- Name: PermissionLabel;
185
- Order: number;
186
- RoleTypeKind: number;
187
- __metadata: Metadata;
188
- };
189
- export declare type CurrentUser = {
190
- Email: string;
191
- Id: number;
192
- IsHiddenInUI: boolean;
193
- LoginName: string;
194
- PrincipalType: number;
195
- Title: string;
196
- __metadata: Metadata;
197
- };
198
- export declare type UserProfilePropKey = 'UserProfile_GUID' | 'SID' | 'FirstName' | 'ADGuid' | 'SPS-PhoneticFirstName' | 'LastName' | 'XOM-LANID' | 'UserName' | 'SPS-PhoneticLastName' | 'AccountName' | 'PictureURL' | 'MiddleName' | 'PreferredName' | 'PhoenticName' | 'SPS-PhoneticDisplayName' | 'SPS-JobTitle' | 'Title' | 'BuildingName' | 'Office' | 'WorkPhone' | 'SPS-SipAddress' | 'CellPhone' | 'HomePhone' | 'Pager' | 'Fax' | 'WorkEmail' | 'SPS-Location' | 'State' | 'Country' | 'Assistant' | 'SPS-RegionalSettings-FollowWeb' | 'SPS-Locale' | 'SPS-CalendarType' | 'SPS-AltCalendarType' | 'SPS-AdjustHijriDays' | 'SPS-ShowWeeks' | 'SPS-WorkDays' | 'SPS-WorkDayStartHour' | 'SPS-WorkDayEndHour' | 'SPS-Time24' | 'SPS-FirstDayOfWeek' | 'SPS-FirstWeekOfYear' | 'SPS-RegionalSettings-Initialized' | 'SPS-TimeZone' | 'Company' | 'Division' | 'BusinessLine' | 'SPS-Department' | 'Department' | 'XOM-CompanyCode' | 'Manager' | 'SPS-Dotted-line' | 'XOM-CostCenter' | 'SPS-HireDate' | 'AboutMe' | 'SPS-Responsibility' | 'SPS-PastProjects' | 'WorkHistory' | 'SPS-Skills' | 'SPS-Interests' | 'SPS-School' | 'SPS-Birthday' | 'WebSite' | 'PersonalSpace' | 'PublicSiteRedirect' | 'QuickLinks' | 'SPS-DataSource' | 'SPS-Memberof' | 'SPS-Peers' | 'SPS-MySiteUpgrade' | 'SPS-DontSuggestList' | 'SPS-ProxyAddresses' | 'SPS-LastColleagueAdded' | 'SPS-OWAUrl' | 'SPS-ResourceSID' | 'SPS-ResourceAccountName' | 'SPS-MasterAccountName' | 'SPS-DistinguishedName' | 'SPS-SourceObjectDN' | 'SPS-LastKeywordAdded' | 'SPS-StatusNotes' | 'SPS-DisplayOrder' | 'SPS-ClaimID' | 'SPS-ClaimProviderID' | 'SPS-ClaimProviderType' | 'SPS-SavedAccountName' | 'SPS-SavedSID' | 'SPS-ObjectExists' | 'SPS-PersonalSiteCapabilities' | 'SPS-UserPrincipalName' | 'SPS-O15FirstRunExperience' | 'SPS-PersonalSiteInstantiationState' | 'SPS-PersonalSiteFirstCreationTime' | 'SPS-PersonalSiteLastCreationTime' | 'SPS-PersonalSiteNumberOfRetries' | 'SPS-PersonalSiteFirstCreationError' | 'SPS-FeedIdentifier' | 'SPS-HashTags' | 'SPS-PrivacyPeople' | 'SPS-EmailOptin' | 'SPS-PrivacyActivity' | 'SPS-PictureTimestamp' | 'SPS-PicturePlaceholderState' | 'SPS-PictureExchangeSyncState' | 'SPS-MUILanguages' | 'SPS-ContentLanguages' | 'OfficeGraphEnabled' | 'SPS-UserType' | 'SPS-HideFromAddressLists' | 'SPS-RecipientTypeDetails' | 'DelveFlags' | 'PulseMRUPeople' | 'msOnline-ObjectId' | 'SPS-PointPublishingUrl' | 'SPS-TenantInstanceId' | 'SPS-SharePointHomeExperienceState' | 'SPS-MultiGeoFlags' | 'PreferredDataLocation' | 'PrivacyNotified' | 'PrivacyNotifiedDate' | 'O365' | 'O365MigrationDate';
199
- export declare type UserProfile = {
200
- AccountName: string;
201
- Country: string;
202
- DisplayName: string;
203
- Email: string;
204
- ExtendedManagers: {
205
- results: string[];
206
- __metadata: Metadata;
207
- };
208
- ExtendedReports: {
209
- results: string[];
210
- __metadata: Metadata;
211
- };
212
- FirstName: string;
213
- IsFollowed: boolean;
214
- LastName: string;
215
- PersonalUrl: string;
216
- PictureUrl: string;
217
- Title: string;
218
- UserName: string;
219
- UserProfileProperties: {
220
- results: {
221
- Key: UserProfilePropKey;
222
- Value: string;
223
- ValueType: string;
224
- __metadata: {
225
- type: string;
226
- };
227
- }[];
228
- };
229
- UserUrl: string;
230
- __metadata: Metadata;
231
- };
232
- export {};
1
+ export type Metadata = {
2
+ id?: string;
3
+ type?: string;
4
+ uri?: string;
5
+ etag?: string;
6
+ };
7
+ export type SPItem2010 = {
8
+ Attachments: string;
9
+ ContentType: string;
10
+ ContentTypeID: string;
11
+ Created: string;
12
+ CreatedBy: PersonField & _Deferred;
13
+ CreatedById: string;
14
+ Modified: string;
15
+ ModifiedBy: PersonField & _Deferred;
16
+ ModifiedById: string;
17
+ Id: number;
18
+ Title: string;
19
+ Path: string;
20
+ Version: string;
21
+ Owshiddenversion: number;
22
+ __metadata: Metadata;
23
+ };
24
+ export type SPItem2013 = {
25
+ __metadata: Metadata;
26
+ FirstUniqueAncestorSecurableObject: _Deferred;
27
+ RoleAssignments: _Deferred;
28
+ AttachmentFiles: _Deferred;
29
+ ContentType: _Deferred;
30
+ GetDlpPolicyTip: _Deferred;
31
+ FieldValuesAsHtml: _Deferred;
32
+ FieldValuesAsText: _Deferred;
33
+ FieldValuesForEdit: _Deferred;
34
+ File: _Deferred;
35
+ Folder: _Deferred;
36
+ ParentList: _Deferred;
37
+ FileSystemObjectType: number;
38
+ Id: number;
39
+ ContentTypeId: string;
40
+ Title: string;
41
+ PhotoRefId?: number;
42
+ ID: number;
43
+ Modified: string;
44
+ Created: string;
45
+ AuthorId: number;
46
+ EditorId: number;
47
+ OData__UIVersionString?: string;
48
+ Attachments: boolean;
49
+ GUID: string;
50
+ Author?: PersonField & _Deferred;
51
+ Editor?: PersonField & _Deferred;
52
+ [key: string]: unknown;
53
+ };
54
+ export type SPItem<V extends SHAREPOINT_VER = '2013'> = V extends '2010' ? SPItem2010 : SPItem2013;
55
+ type ListFields<K, V extends SHAREPOINT_VER = '2013'> = Extract<keyof K, string> | Extract<keyof SPItem<V>, string>;
56
+ export interface Options<K = any, V extends SHAREPOINT_VER = '2013'> {
57
+ expand?: ListFields<K, V>[] | ListFields<K, V>;
58
+ orderBy?: ListFields<K, V> | [ListFields<K, V>, 'asc' | 'desc'];
59
+ limit?: number;
60
+ filter?: string;
61
+ cols?: ListFields<K, V>[] | ListFields<K, V>;
62
+ skip?: number;
63
+ }
64
+ export interface Folder_Options<K = any> {
65
+ type: 'Files' | 'Folders';
66
+ expand?: Extract<keyof K, string>[] | Extract<keyof K, string>;
67
+ orderBy?: Extract<keyof K, string> | [Extract<keyof K, string>, 'asc' | 'desc'];
68
+ limit?: number;
69
+ filter?: string;
70
+ cols?: Extract<keyof K, string>[] | Extract<keyof K, string>;
71
+ skip?: number;
72
+ }
73
+ export interface Field_Options<K, V extends SHAREPOINT_VER = '2013'> extends Omit<Options<K, V>, 'filter'> {
74
+ fieldName?: Extract<keyof K, string>;
75
+ }
76
+ export type SHAREPOINT_VER = '2010' | '2013';
77
+ export type IListName<T> = Extract<keyof T, string>;
78
+ export type ItemID = string | number;
79
+ export type CreateFileProps = {
80
+ file: File;
81
+ itemId: ItemID;
82
+ };
83
+ export type UploadFileProps = {
84
+ file: File;
85
+ folderPath?: string | string[];
86
+ overwrite?: boolean;
87
+ };
88
+ export type DeleteFileProps = {
89
+ fileName: string;
90
+ folderPath?: string | string[];
91
+ };
92
+ export type ListData = {
93
+ [key: string]: any;
94
+ __metadata?: {
95
+ type: string;
96
+ };
97
+ } | any;
98
+ export type EmailProps = {
99
+ From: string;
100
+ To: string[] | string;
101
+ Subject?: string;
102
+ Body: string;
103
+ };
104
+ export type _Deferred = {
105
+ __deferred: {
106
+ uri: string;
107
+ };
108
+ };
109
+ export type LookupField<T> = _Deferred & T;
110
+ export type ChoiceField<T> = _Deferred & {
111
+ Value: T;
112
+ __metadata: Metadata;
113
+ };
114
+ export type PersonField = {
115
+ AboutMe?: string;
116
+ Account: string;
117
+ AccountName: string;
118
+ AdministrativeSupervisor: string;
119
+ AskMeAbout?: string;
120
+ AskMeAbout0?: string;
121
+ Assistant?: string;
122
+ Attachments: unknown;
123
+ BuildingName: string;
124
+ BusinessLine: string;
125
+ CellPhone?: string;
126
+ City?: string;
127
+ Company: string;
128
+ CompanyCode: string;
129
+ ContentType: string;
130
+ ContentTypeID: string;
131
+ CostCenter: string;
132
+ Country: string;
133
+ Created: string;
134
+ CreatedBy: PersonField;
135
+ CreatedById: number;
136
+ Deleted: boolean;
137
+ Department: string;
138
+ Department0?: string;
139
+ Division: string;
140
+ Fax?: string;
141
+ FirstName: string;
142
+ Hidden: boolean;
143
+ Id?: string;
144
+ Id0: number;
145
+ Interests?: string;
146
+ IsSiteAdmin: boolean;
147
+ JobTitle?: string;
148
+ LANID: string;
149
+ LastName: string;
150
+ Manager: string;
151
+ MobilePhone: string;
152
+ Modified: string;
153
+ ModifiedBy: PersonField;
154
+ ModifiedById: number;
155
+ Name: string;
156
+ Office: string;
157
+ OfficeLocation?: string;
158
+ Owshiddenversion: number;
159
+ Pager?: string;
160
+ Path: string;
161
+ Picture: string;
162
+ PictureExchangeSyncState: number;
163
+ PicturePlaceholderState: number;
164
+ PictureTimestamp: string;
165
+ SIPAddress?: string;
166
+ Schools?: string;
167
+ Skills?: string;
168
+ State: string;
169
+ Title: string;
170
+ UserName: string;
171
+ Version: string;
172
+ WebSite?: string;
173
+ WorkEmail: string;
174
+ WorkHistory?: string;
175
+ WorkPhone?: string;
176
+ __metadata: Metadata;
177
+ };
178
+ export type MultiPersonField = {
179
+ results: PersonField[];
180
+ };
181
+ export type PermissionLabel = 'Full Control' | 'Edit' | 'Contribute' | 'Read';
182
+ export type UserPermision = {
183
+ BasePermissions: {
184
+ High: string;
185
+ Low: string;
186
+ __metadata: {
187
+ type: 'SP.BasePermissions';
188
+ };
189
+ };
190
+ Description: string;
191
+ Hidden: boolean;
192
+ Id: number;
193
+ Name: PermissionLabel;
194
+ Order: number;
195
+ RoleTypeKind: number;
196
+ __metadata: Metadata;
197
+ };
198
+ export type CurrentUser = {
199
+ Email: string;
200
+ Id: number;
201
+ IsHiddenInUI: boolean;
202
+ LoginName: string;
203
+ PrincipalType: number;
204
+ Title: string;
205
+ __metadata: Metadata;
206
+ };
207
+ export type UserProfilePropKey = 'UserProfile_GUID' | 'SID' | 'FirstName' | 'ADGuid' | 'SPS-PhoneticFirstName' | 'LastName' | 'XOM-LANID' | 'UserName' | 'SPS-PhoneticLastName' | 'AccountName' | 'PictureURL' | 'MiddleName' | 'PreferredName' | 'PhoenticName' | 'SPS-PhoneticDisplayName' | 'SPS-JobTitle' | 'Title' | 'BuildingName' | 'Office' | 'WorkPhone' | 'SPS-SipAddress' | 'CellPhone' | 'HomePhone' | 'Pager' | 'Fax' | 'WorkEmail' | 'SPS-Location' | 'State' | 'Country' | 'Assistant' | 'SPS-RegionalSettings-FollowWeb' | 'SPS-Locale' | 'SPS-CalendarType' | 'SPS-AltCalendarType' | 'SPS-AdjustHijriDays' | 'SPS-ShowWeeks' | 'SPS-WorkDays' | 'SPS-WorkDayStartHour' | 'SPS-WorkDayEndHour' | 'SPS-Time24' | 'SPS-FirstDayOfWeek' | 'SPS-FirstWeekOfYear' | 'SPS-RegionalSettings-Initialized' | 'SPS-TimeZone' | 'Company' | 'Division' | 'BusinessLine' | 'SPS-Department' | 'Department' | 'XOM-CompanyCode' | 'Manager' | 'SPS-Dotted-line' | 'XOM-CostCenter' | 'SPS-HireDate' | 'AboutMe' | 'SPS-Responsibility' | 'SPS-PastProjects' | 'WorkHistory' | 'SPS-Skills' | 'SPS-Interests' | 'SPS-School' | 'SPS-Birthday' | 'WebSite' | 'PersonalSpace' | 'PublicSiteRedirect' | 'QuickLinks' | 'SPS-DataSource' | 'SPS-Memberof' | 'SPS-Peers' | 'SPS-MySiteUpgrade' | 'SPS-DontSuggestList' | 'SPS-ProxyAddresses' | 'SPS-LastColleagueAdded' | 'SPS-OWAUrl' | 'SPS-ResourceSID' | 'SPS-ResourceAccountName' | 'SPS-MasterAccountName' | 'SPS-DistinguishedName' | 'SPS-SourceObjectDN' | 'SPS-LastKeywordAdded' | 'SPS-StatusNotes' | 'SPS-DisplayOrder' | 'SPS-ClaimID' | 'SPS-ClaimProviderID' | 'SPS-ClaimProviderType' | 'SPS-SavedAccountName' | 'SPS-SavedSID' | 'SPS-ObjectExists' | 'SPS-PersonalSiteCapabilities' | 'SPS-UserPrincipalName' | 'SPS-O15FirstRunExperience' | 'SPS-PersonalSiteInstantiationState' | 'SPS-PersonalSiteFirstCreationTime' | 'SPS-PersonalSiteLastCreationTime' | 'SPS-PersonalSiteNumberOfRetries' | 'SPS-PersonalSiteFirstCreationError' | 'SPS-FeedIdentifier' | 'SPS-HashTags' | 'SPS-PrivacyPeople' | 'SPS-EmailOptin' | 'SPS-PrivacyActivity' | 'SPS-PictureTimestamp' | 'SPS-PicturePlaceholderState' | 'SPS-PictureExchangeSyncState' | 'SPS-MUILanguages' | 'SPS-ContentLanguages' | 'OfficeGraphEnabled' | 'SPS-UserType' | 'SPS-HideFromAddressLists' | 'SPS-RecipientTypeDetails' | 'DelveFlags' | 'PulseMRUPeople' | 'msOnline-ObjectId' | 'SPS-PointPublishingUrl' | 'SPS-TenantInstanceId' | 'SPS-SharePointHomeExperienceState' | 'SPS-MultiGeoFlags' | 'PreferredDataLocation' | 'PrivacyNotified' | 'PrivacyNotifiedDate' | 'O365' | 'O365MigrationDate';
208
+ export type UserProfile = {
209
+ AccountName: string;
210
+ Country: string;
211
+ DisplayName: string;
212
+ Email: string;
213
+ ExtendedManagers: {
214
+ results: string[];
215
+ __metadata: Metadata;
216
+ };
217
+ ExtendedReports: {
218
+ results: string[];
219
+ __metadata: Metadata;
220
+ };
221
+ FirstName: string;
222
+ IsFollowed: boolean;
223
+ LastName: string;
224
+ PersonalUrl: string;
225
+ PictureUrl: string;
226
+ Title: string;
227
+ UserName: string;
228
+ UserProfileProperties: {
229
+ results: {
230
+ Key: UserProfilePropKey;
231
+ Value: string;
232
+ ValueType: string;
233
+ __metadata: {
234
+ type: string;
235
+ };
236
+ }[];
237
+ };
238
+ UserUrl: string;
239
+ __metadata: Metadata;
240
+ };
241
+ export {};
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.14",
2
+ "version": "0.1.16",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -37,8 +37,11 @@
37
37
  "husky": "^9.1.4",
38
38
  "size-limit": "^11.1.4",
39
39
  "tsdx": "^0.14.1",
40
- "tslib": "^2.6.3",
41
- "typescript": "^3.9.10"
40
+ "tslib": "^2.8.0",
41
+ "typescript": "^5.6.3"
42
+ },
43
+ "overrides": {
44
+ "typescript": "^5.6.3"
42
45
  },
43
46
  "dependencies": {
44
47
  "axios": "^1.7.4",
package/src/root/index.ts CHANGED
@@ -2,10 +2,12 @@ import { AxiosInstance, CreateAxiosDefaults as AxiosConfig } from 'axios';
2
2
  import instance from './instance';
3
3
  import {
4
4
  CreateFileProps,
5
+ DeleteFileProps,
5
6
  CurrentUser,
6
7
  EmailProps,
7
8
  Field_Options,
8
9
  Folder_Options,
10
+ UploadFileProps,
9
11
  IListName,
10
12
  ItemID,
11
13
  ListData,
@@ -20,10 +22,12 @@ import {
20
22
  createAttachment,
21
23
  createListItem,
22
24
  deleteItem,
25
+ deleteFile as deleteLibraryFile,
23
26
  getFiles,
24
27
  getListItems,
25
28
  getOnly,
26
29
  updateListItem,
30
+ uploadFile,
27
31
  } from './internal/listRequests';
28
32
  import { sendEmail as sendEmailRequest } from './internal/emailRequests';
29
33
  import {
@@ -32,6 +36,7 @@ import {
32
36
  getSiteUser as fetchSiteUser,
33
37
  typeAhead,
34
38
  } from './internal/userRequests';
39
+ import { fetchDigest } from './internal/digest';
35
40
 
36
41
  class HTTPSharePointRequests<
37
42
  T extends {
@@ -44,6 +49,7 @@ class HTTPSharePointRequests<
44
49
  private listName: string;
45
50
  private instance: AxiosInstance;
46
51
  private sharepointVersion: SHAREPOINT_VER;
52
+ private listItemEntityTypeFullName?: string;
47
53
 
48
54
  constructor(baseURL: string, config?: AxiosConfig) {
49
55
  this.baseURL = baseURL.endsWith('/') ? baseURL : `${baseURL}/`;
@@ -51,6 +57,7 @@ class HTTPSharePointRequests<
51
57
  this.listName = '';
52
58
  this.instance = instance(this.baseURL, config);
53
59
  this.sharepointVersion = '2013';
60
+ this.listItemEntityTypeFullName = undefined;
54
61
  }
55
62
 
56
63
  private getContext<V extends SHAREPOINT_VER = '2013'>(): RequestContext<V> {
@@ -60,9 +67,45 @@ class HTTPSharePointRequests<
60
67
  endpoint: this.endpoint,
61
68
  listName: this.listName,
62
69
  sharepointVersion: this.sharepointVersion as V,
70
+ listItemEntityTypeFullName: this.listItemEntityTypeFullName,
71
+ resolveListItemEntityType: this.resolveListItemEntityTypeFullName.bind(
72
+ this
73
+ ),
63
74
  };
64
75
  }
65
76
 
77
+ private async resolveListItemEntityTypeFullName(): Promise<string> {
78
+ if (this.listItemEntityTypeFullName) {
79
+ return this.listItemEntityTypeFullName;
80
+ }
81
+
82
+ if (!this.listName) {
83
+ throw new Error('List name is not set.');
84
+ }
85
+
86
+ if (this.sharepointVersion !== '2013') {
87
+ this.listItemEntityTypeFullName = `SP.Data.${this.listName}ListItem`;
88
+ return this.listItemEntityTypeFullName;
89
+ }
90
+
91
+ const response = await this.instance.get(
92
+ `_api/web/lists/GetByTitle('${this.listName}')?$select=ListItemEntityTypeFullName`
93
+ );
94
+
95
+ const entityType =
96
+ response.data?.d?.ListItemEntityTypeFullName ??
97
+ response.data?.ListItemEntityTypeFullName;
98
+
99
+ if (!entityType || typeof entityType !== 'string') {
100
+ throw new Error(
101
+ `Unable to resolve ListItemEntityTypeFullName for list "${this.listName}".`
102
+ );
103
+ }
104
+
105
+ this.listItemEntityTypeFullName = entityType;
106
+ return this.listItemEntityTypeFullName;
107
+ }
108
+
66
109
  /**
67
110
  * @deprecated Use `from` instead.
68
111
  */
@@ -70,6 +113,7 @@ class HTTPSharePointRequests<
70
113
  this.listName = listName;
71
114
  this.endpoint = `_vti_bin/ListData.svc/${listName}`;
72
115
  this.sharepointVersion = '2010';
116
+ this.listItemEntityTypeFullName = undefined;
73
117
  return this;
74
118
  }
75
119
 
@@ -81,7 +125,11 @@ class HTTPSharePointRequests<
81
125
  },
82
126
  };
83
127
 
84
- from<
128
+ public getDigest() {
129
+ return fetchDigest(this.instance, this.baseURL);
130
+ }
131
+
132
+ public from<
85
133
  K extends Extract<keyof T['LISTS'], string>,
86
134
  V extends SHAREPOINT_VER = '2013'
87
135
  >(listName: K, sharepoint_ver?: V) {
@@ -89,6 +137,7 @@ class HTTPSharePointRequests<
89
137
 
90
138
  this.listName = listName;
91
139
  this.sharepointVersion = version;
140
+ this.listItemEntityTypeFullName = undefined;
92
141
  this.endpoint =
93
142
  version === '2013'
94
143
  ? `_api/web/lists/GetByTitle('${this.listName}')/items`
@@ -105,12 +154,16 @@ class HTTPSharePointRequests<
105
154
  delete: (id: ItemID) => deleteItem(getContext(), id),
106
155
  createFile: (props: CreateFileProps) =>
107
156
  createAttachment(getContext(), props),
157
+ uploadFile: (props: UploadFileProps) => uploadFile(getContext(), props),
158
+ deleteFile: (props: DeleteFileProps) =>
159
+ deleteLibraryFile(getContext(), props),
108
160
  fields: (options?: Field_Options<T['LISTS'][K], V>) => {
109
161
  this.endpoint = !options?.fieldName
110
162
  ? `_api/web/lists/GetByTitle('${this.listName}')/fields`
111
163
  : `_api/web/lists/GetByTitle('${this.listName}')/fields/getbytitle('${options.fieldName}')`;
112
164
  return {
113
- get: () => getOnly<T['LISTS'][K], V>(this.instance, this.endpoint, options),
165
+ get: () =>
166
+ getOnly<T['LISTS'][K], V>(this.instance, this.endpoint, options),
114
167
  };
115
168
  },
116
169
  };
@@ -7,4 +7,6 @@ export interface RequestContext<V extends SHAREPOINT_VER = '2013'> {
7
7
  endpoint: string;
8
8
  listName: string;
9
9
  sharepointVersion: V;
10
+ listItemEntityTypeFullName?: string;
11
+ resolveListItemEntityType?: () => Promise<string>;
10
12
  }