@mikezimm/fps-core-v7 1.0.45 → 1.0.47
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/lib/banner/components/ItemPicker/functions/fetchFileList.d.ts.map +1 -1
- package/lib/banner/components/ItemPicker/functions/fetchFileList.js.map +1 -1
- package/lib/banner/components/ItemPicker/functions/fetchListList.d.ts.map +1 -1
- package/lib/banner/components/ItemPicker/functions/fetchListList.js.map +1 -1
- package/lib/components/atoms/easy-pages/interfaces/IEasyPagesPageHookProps.d.ts +1 -1
- package/lib/components/atoms/easy-pages/interfaces/IEasyPagesPageHookProps.d.ts.map +1 -1
- package/lib/components/molecules/AnyContent/IFPSFileObject.d.ts +10 -0
- package/lib/components/molecules/AnyContent/IFPSFileObject.d.ts.map +1 -1
- package/lib/components/molecules/AnyContent/IFPSFileObject.js +10 -0
- package/lib/components/molecules/AnyContent/IFPSFileObject.js.map +1 -1
- package/lib/components/molecules/SpHttp/IJSFetchReturn.d.ts +2 -1
- package/lib/components/molecules/SpHttp/IJSFetchReturn.d.ts.map +1 -1
- package/lib/components/molecules/SpHttp/IJSFetchReturn.js.map +1 -1
- package/lib/components/molecules/SpHttp/SpFetchCommon.d.ts.map +1 -1
- package/lib/components/molecules/SpHttp/SpFetchCommon.js +19 -2
- package/lib/components/molecules/SpHttp/SpFetchCommon.js.map +1 -1
- package/lib/components/molecules/SpHttp/digestValues/fromUrl/getThisFPSDigestValueFromUrl.d.ts.map +1 -1
- package/lib/components/molecules/SpHttp/digestValues/fromUrl/getThisFPSDigestValueFromUrl.js +5 -1
- package/lib/components/molecules/SpHttp/digestValues/fromUrl/getThisFPSDigestValueFromUrl.js.map +1 -1
- package/lib/components/molecules/SpHttp/doSpJsFetch copy.d.ts +1 -0
- package/lib/components/molecules/SpHttp/doSpJsFetch copy.d.ts.map +1 -0
- package/lib/components/molecules/SpHttp/doSpJsFetch copy.js +163 -0
- package/lib/components/molecules/SpHttp/doSpJsFetch copy.js.map +1 -0
- package/lib/components/molecules/SpHttp/doSpJsFetch.d.ts +36 -17
- package/lib/components/molecules/SpHttp/doSpJsFetch.d.ts.map +1 -1
- package/lib/components/molecules/SpHttp/doSpJsFetch.js +235 -58
- package/lib/components/molecules/SpHttp/doSpJsFetch.js.map +1 -1
- package/lib/components/molecules/SpHttp/doSpJsFileFetch.d.ts +3 -1
- package/lib/components/molecules/SpHttp/doSpJsFileFetch.d.ts.map +1 -1
- package/lib/components/molecules/SpHttp/doSpJsFileFetch.js +7 -8
- package/lib/components/molecules/SpHttp/doSpJsFileFetch.js.map +1 -1
- package/lib/components/molecules/SpHttp/headerInitUtilities.d.ts +21 -0
- package/lib/components/molecules/SpHttp/headerInitUtilities.d.ts.map +1 -0
- package/lib/components/molecules/SpHttp/headerInitUtilities.js +45 -0
- package/lib/components/molecules/SpHttp/headerInitUtilities.js.map +1 -0
- package/lib/components/molecules/SpHttp/helpers/check4ThisFPSDigestValue.d.ts.map +1 -1
- package/lib/components/molecules/SpHttp/helpers/check4ThisFPSDigestValue.js +8 -4
- package/lib/components/molecules/SpHttp/helpers/check4ThisFPSDigestValue.js.map +1 -1
- package/lib/components/molecules/process-results/CheckAnyResults.js +1 -1
- package/lib/components/molecules/process-results/CheckAnyResults.js.map +1 -1
- package/lib/components/molecules/process-results/CheckFpsTypesResults.d.ts +1 -0
- package/lib/components/molecules/process-results/CheckFpsTypesResults.d.ts.map +1 -0
- package/lib/components/molecules/process-results/CheckFpsTypesResults.js +45 -0
- package/lib/components/molecules/process-results/CheckFpsTypesResults.js.map +1 -0
- package/lib/components/molecules/process-results/CheckItemsResults.d.ts +1 -13
- package/lib/components/molecules/process-results/CheckItemsResults.d.ts.map +1 -1
- package/lib/components/molecules/process-results/CheckItemsResults.js +6 -5
- package/lib/components/molecules/process-results/CheckItemsResults.js.map +1 -1
- package/lib/components/molecules/process-results/IFpsItemsReturn.d.ts +14 -0
- package/lib/components/molecules/process-results/IFpsItemsReturn.d.ts.map +1 -0
- package/lib/components/molecules/process-results/IFpsItemsReturn.js +2 -0
- package/lib/components/molecules/process-results/IFpsItemsReturn.js.map +1 -0
- package/lib/components/molecules/process-results/Logging.d.ts +0 -2
- package/lib/components/molecules/process-results/Logging.d.ts.map +1 -1
- package/lib/components/molecules/process-results/Logging.js +47 -49
- package/lib/components/molecules/process-results/Logging.js.map +1 -1
- package/lib/components/molecules/process-results/createEmptyFpsErrorReturn.d.ts +1 -1
- package/lib/components/molecules/process-results/createEmptyFpsErrorReturn.d.ts.map +1 -1
- package/lib/components/molecules/process-results/createEmptyFpsItemsReturn.d.ts +1 -1
- package/lib/components/molecules/process-results/createEmptyFpsItemsReturn.d.ts.map +1 -1
- package/lib/components/molecules/process-results/createErrorFpsFileReturn.js +1 -1
- package/lib/components/molecules/process-results/createErrorFpsFileReturn.js.map +1 -1
- package/lib/components/molecules/process-results/createErrorFpsListItemsReturn.d.ts +1 -1
- package/lib/components/molecules/process-results/createErrorFpsListItemsReturn.d.ts.map +1 -1
- package/lib/components/molecules/state-source/IStateSource.d.ts +1 -1
- package/lib/components/molecules/state-source/IStateSource.d.ts.map +1 -1
- package/lib/restAPIs/lists/files/getFileEmbedUrl.d.ts +2 -3
- package/lib/restAPIs/lists/files/getFileEmbedUrl.d.ts.map +1 -1
- package/lib/restAPIs/lists/files/getFileEmbedUrl.js +10 -12
- package/lib/restAPIs/lists/files/getFileEmbedUrl.js.map +1 -1
- package/lib/restAPIs/lists/files/postSourceFilesAPI.d.ts +1 -1
- package/lib/restAPIs/lists/files/postSourceFilesAPI.d.ts.map +1 -1
- package/lib/restAPIs/lists/files/postSourceFilesAPI.js.map +1 -1
- package/lib/restAPIs/lists/items/getOnlySharedItems.d.ts +19 -0
- package/lib/restAPIs/lists/items/getOnlySharedItems.d.ts.map +1 -0
- package/lib/restAPIs/lists/items/getOnlySharedItems.js +89 -0
- package/lib/restAPIs/lists/items/getOnlySharedItems.js.map +1 -0
- package/lib/restAPIs/lists/items/getSourceItemsAPI.d.ts +1 -1
- package/lib/restAPIs/lists/items/getSourceItemsAPI.d.ts.map +1 -1
- package/lib/restAPIs/lists/items/getSourceItemsAPI.js +6 -4
- package/lib/restAPIs/lists/items/getSourceItemsAPI.js.map +1 -1
- package/lib/restAPIs/lists/items/postSourceItemsAPI.d.ts +1 -1
- package/lib/restAPIs/lists/items/postSourceItemsAPI.d.ts.map +1 -1
- package/lib/restAPIs/lists/items/postSourceItemsAPI.js +4 -5
- package/lib/restAPIs/lists/items/postSourceItemsAPI.js.map +1 -1
- package/lib/restAPIs/lists/items/updateAnyItemAPI.d.ts +19 -0
- package/lib/restAPIs/lists/items/updateAnyItemAPI.d.ts.map +1 -0
- package/lib/restAPIs/lists/items/updateAnyItemAPI.js +71 -0
- package/lib/restAPIs/lists/items/updateAnyItemAPI.js.map +1 -0
- package/lib/restAPIs/lists/items/updateCommandItemAPI.d.ts +44 -0
- package/lib/restAPIs/lists/items/updateCommandItemAPI.d.ts.map +1 -0
- package/lib/restAPIs/lists/items/updateCommandItemAPI.js +75 -0
- package/lib/restAPIs/lists/items/updateCommandItemAPI.js.map +1 -0
- package/lib/restAPIs/lists/lists/getSourceListsAPI.d.ts +2 -2
- package/lib/restAPIs/lists/lists/getSourceListsAPI.d.ts.map +1 -1
- package/lib/restAPIs/lists/lists/getSourceListsAPI.js +10 -13
- package/lib/restAPIs/lists/lists/getSourceListsAPI.js.map +1 -1
- package/lib/restAPIs/logging/saveErrorToLog.d.ts +2 -0
- package/lib/restAPIs/logging/saveErrorToLog.d.ts.map +1 -1
- package/lib/restAPIs/logging/saveErrorToLog.js +18 -9
- package/lib/restAPIs/logging/saveErrorToLog.js.map +1 -1
- package/lib/restAPIs/logging/saveErrorToLogOriginal.d.ts +1 -0
- package/lib/restAPIs/logging/saveErrorToLogOriginal.d.ts.map +1 -0
- package/lib/restAPIs/logging/saveErrorToLogOriginal.js +45 -0
- package/lib/restAPIs/logging/saveErrorToLogOriginal.js.map +1 -0
- package/lib/restAPIs/sites/groups/getGroupMembersAPI.js +4 -4
- package/lib/restAPIs/sites/groups/getGroupMembersAPI.js.map +1 -1
- package/lib/restAPIs/sites/groups/getWebAssociatedGroupAPI.js +5 -5
- package/lib/restAPIs/sites/groups/getWebAssociatedGroupAPI.js.map +1 -1
- package/lib/restAPIs/sites/groups/getWebGroupInfoAPI.js +4 -4
- package/lib/restAPIs/sites/groups/getWebGroupInfoAPI.js.map +1 -1
- package/lib/restAPIs/sites/sites/getSiteAPI.d.ts +1 -1
- package/lib/restAPIs/sites/sites/getSiteAPI.d.ts.map +1 -1
- package/lib/restAPIs/sites/sites/getSiteAPI.js +13 -12
- package/lib/restAPIs/sites/sites/getSiteAPI.js.map +1 -1
- package/lib/restAPIs/sites/users/getSiteUsersAPI.js +4 -4
- package/lib/restAPIs/sites/users/getSiteUsersAPI.js.map +1 -1
- package/lib/types/fps-returns/common/IFPSBaseContentType.d.ts +8 -0
- package/lib/types/fps-returns/common/IFPSBaseContentType.d.ts.map +1 -1
- package/lib/types/fps-returns/common/IFpsErrorObject.d.ts +5 -2
- package/lib/types/fps-returns/common/IFpsErrorObject.d.ts.map +1 -1
- package/lib/types/fps-returns/sites/IFpsSiteReturn.d.ts +1 -1
- package/lib/types/fps-returns/sites/IFpsSiteReturn.d.ts.map +1 -1
- package/lib/types/fps-returns/sites/groups/IGroupReturns.d.ts +1 -1
- package/lib/types/fps-returns/sites/groups/IGroupReturns.d.ts.map +1 -1
- package/lib/types/fps-returns/sites/update/IFPSItemUpdateResultObj.d.ts +2 -1
- package/lib/types/fps-returns/sites/update/IFPSItemUpdateResultObj.d.ts.map +1 -1
- package/lib/types/fps-returns/sites/users/IFpsUsersReturn.d.ts +1 -1
- package/lib/types/fps-returns/sites/users/IFpsUsersReturn.d.ts.map +1 -1
- package/lib/types/fps-returns/sites/users/ISiteUserResults.d.ts +1 -1
- package/lib/types/fps-returns/sites/users/ISiteUserResults.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -2,26 +2,38 @@
|
|
|
2
2
|
* 2024-09-15: Migrated to SAME FOLDER in fps-library-v2\src\components\molecules\SpHttp...
|
|
3
3
|
* export { IJSFetchReturn, createEmptyFetchReturn, doSpJsFetch }
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
import { createEmptyFetchReturn } from "./IJSFetchReturn";
|
|
18
|
-
import { addCatchResponseError, addUnknownFetchError } from "./SpFetchCommon";
|
|
5
|
+
import { check4This } from '../../../logic/Links/CheckSearch';
|
|
6
|
+
import { checkDeepProperty } from '../../../logic/Objects/deep';
|
|
7
|
+
import { makeAbsoluteUrl } from '../../../logic/Strings/getSiteCollectionUrlFromLink';
|
|
8
|
+
import { getSiteCollectionUrlFromLink } from '../../../logic/Strings/getSiteCollectionUrlFromLink';
|
|
9
|
+
import { saveErrorToLog } from '../../../restAPIs/logging/saveErrorToLog';
|
|
10
|
+
import { startPerformOpV2, updatePerformanceEndV2 } from '../Performance/functions';
|
|
11
|
+
import { checkItemsResults } from '../process-results/CheckItemsResults';
|
|
12
|
+
// import { saveErrorToLog } from '../process-results/Logging';
|
|
13
|
+
import { copyHeadersToReturns, createMinHeaders } from './headerInitUtilities';
|
|
14
|
+
import { check4ThisFPSDigestValue } from './helpers/check4ThisFPSDigestValue';
|
|
15
|
+
import { createEmptyFetchReturn } from './IJSFetchReturn';
|
|
16
|
+
import { addCatchResponseError, addUnknownFetchError } from './SpFetchCommon';
|
|
19
17
|
export async function doSpJsFetch(fetchAPI, digestValue, headerContentType) {
|
|
20
|
-
const
|
|
18
|
+
const headers = createMinHeaders(digestValue, headerContentType);
|
|
19
|
+
const results = await doSpJsFetchOrPost(fetchAPI, 'GET', headers, null);
|
|
21
20
|
return results;
|
|
22
21
|
}
|
|
22
|
+
// Helper function to introduce a delay
|
|
23
|
+
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
23
24
|
/**
|
|
25
|
+
*
|
|
24
26
|
* Pass in any SharePoint rest api url and it should return a result or a standard error return object
|
|
27
|
+
* 2024-12-09: changed from accepting headerContentType to headers.
|
|
28
|
+
* old default was: 'Content-Type': headerContentType ? headerContentType : 'application/json;odata=verbose',
|
|
29
|
+
* ALSO, NEED TO add requestDigest into customHeaders like this:
|
|
30
|
+
* headers[ 'X-RequestDigest' ] = digestValue
|
|
31
|
+
*
|
|
32
|
+
* for Updates:
|
|
33
|
+
* Use 'MERGE' for updating items
|
|
34
|
+
*
|
|
35
|
+
* customHeaders: HeadersInit update
|
|
36
|
+
*
|
|
25
37
|
*
|
|
26
38
|
* TOP THINGS TO Look for debugging
|
|
27
39
|
* 1. __metadata: for ALL SAVE ITEMS
|
|
@@ -31,23 +43,45 @@ export async function doSpJsFetch(fetchAPI, digestValue, headerContentType) {
|
|
|
31
43
|
* @param fetchAPI
|
|
32
44
|
* @returns
|
|
33
45
|
*/
|
|
34
|
-
export async function doSpJsFetchOrPost(fetchAPI, method
|
|
35
|
-
// Automatically added this because API's usually need full url.
|
|
36
|
-
if (fetchAPI.indexOf(CurrentHostName) === 0)
|
|
37
|
-
fetchAPI = `https://${fetchAPI}`;
|
|
46
|
+
export async function doSpJsFetchOrPost(fetchAPI, method, customHeaders, body, retryCount = 3, delayTime = 2000) {
|
|
47
|
+
// Automatically added this because API's usually need full url. - NOT Needed because makeAbsoluteUrl already does this
|
|
48
|
+
// if ( fetchAPI.indexOf( CurrentHostName ) === 0 ) fetchAPI = `https://${fetchAPI}`;
|
|
38
49
|
// Always make sure this is an absolute url by running through this first. Note, if the previous line executes, it should be good then.
|
|
39
50
|
fetchAPI = makeAbsoluteUrl(fetchAPI);
|
|
40
|
-
// Added to just check if digestValue exists and if so, use it here
|
|
41
|
-
if (!digestValue) {
|
|
42
|
-
digestValue = check4ThisFPSDigestValue(getSiteCollectionUrlFromLink(fetchAPI));
|
|
43
|
-
}
|
|
44
51
|
let results = createEmptyFetchReturn(fetchAPI, method);
|
|
45
52
|
const headers = {
|
|
46
|
-
Accept:
|
|
47
|
-
|
|
53
|
+
Accept: 'application/json;odata=nometadata',
|
|
54
|
+
'Content-Type': 'application/json;odata=verbose',
|
|
55
|
+
...customHeaders
|
|
48
56
|
};
|
|
49
|
-
if
|
|
57
|
+
// Add request digest for SharePoint operations if missing
|
|
58
|
+
const siteCollectionUrl = getSiteCollectionUrlFromLink(fetchAPI);
|
|
59
|
+
const digestValue = check4ThisFPSDigestValue(siteCollectionUrl);
|
|
60
|
+
// Added to just check if digestValue exists and if so, use it here
|
|
61
|
+
if (digestValue && !headers['X-RequestDigest']) {
|
|
50
62
|
headers['X-RequestDigest'] = digestValue;
|
|
63
|
+
}
|
|
64
|
+
// Adjust headers for specific SharePoint operations
|
|
65
|
+
if (method === 'MERGE') {
|
|
66
|
+
headers['X-HTTP-Method'] = 'MERGE';
|
|
67
|
+
// Ensure overwrite behavior
|
|
68
|
+
headers['IF-MATCH'] = '*';
|
|
69
|
+
// 2024-12-09: Untested -- Moved this further down so it is used for both MERGE (update) and POST (create)
|
|
70
|
+
// Ensure returning the updated object in case it's needed: Accept: application/json;odata=verbose
|
|
71
|
+
// (headers as Record<string, string>)['Accept'] = 'application/json;odata=verbose';
|
|
72
|
+
method = 'POST'; // SharePoint requires POST for MERGE
|
|
73
|
+
}
|
|
74
|
+
else if (method === 'DELETE') {
|
|
75
|
+
headers['IF-MATCH'] = '*'; // Required for DELETE
|
|
76
|
+
method = 'POST'; // SharePoint requires POST for DELETE
|
|
77
|
+
}
|
|
78
|
+
if (method === 'POST') {
|
|
79
|
+
// Ensure returning the created object in case it's needed: Prefer: return=representation
|
|
80
|
+
headers['Prefer'] = 'return=representation';
|
|
81
|
+
// Ensure returning the updated object in case it's needed: Accept: application/json;odata=verbose
|
|
82
|
+
headers['Accept'] = 'application/json;odata=verbose';
|
|
83
|
+
}
|
|
84
|
+
results.headers = copyHeadersToReturns(headers);
|
|
51
85
|
try {
|
|
52
86
|
// Added these hard coded alerts to help in reducing development errors and time - aka PivotTiles Permission Save and Groups APIs
|
|
53
87
|
if (method === 'POST') {
|
|
@@ -58,34 +92,113 @@ export async function doSpJsFetchOrPost(fetchAPI, method = `GET`, digestValue, h
|
|
|
58
92
|
console.log(`!!!!! doSpJsFetchOrPost - POST body NO __metadata !!!! `, body, fetchAPI);
|
|
59
93
|
}
|
|
60
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Status Codes Explanation
|
|
97
|
+
204 No Content: This status code means that the server successfully processed the request but is not returning any content. For example, this is common with DELETE or PUT/MERGE requests when updating an item without requesting the updated data.
|
|
98
|
+
201 Created: This status code is used when an item is successfully created, and, with the Prefer: return=representation header, SharePoint will include the full response with the item details.
|
|
99
|
+
200 OK: This status code may appear for updates or other operations when the Prefer header is not set to return=representation, and the response may include the updated item details.
|
|
100
|
+
1. 400 Bad Request
|
|
101
|
+
Meaning: The request is malformed or missing required data.
|
|
102
|
+
Example: Invalid JSON format, missing mandatory fields, or incorrect request body.
|
|
103
|
+
Resolution: Double-check the request payload, headers, and any required parameters.
|
|
104
|
+
2. 401 Unauthorized
|
|
105
|
+
Meaning: Authentication is required and has failed or not been provided.
|
|
106
|
+
Example: Missing or incorrect authentication tokens.
|
|
107
|
+
Resolution: Ensure that the request includes a valid authentication token or the correct credentials.
|
|
108
|
+
3. 403 Forbidden
|
|
109
|
+
Meaning: The user does not have permission to perform the operation.
|
|
110
|
+
Example: Attempting to access a list or site for which the user does not have the required permissions.
|
|
111
|
+
Resolution: Verify the user's permissions and access rights to the resource.
|
|
112
|
+
4. 404 Not Found
|
|
113
|
+
Meaning: The requested resource (e.g., a list or item) was not found.
|
|
114
|
+
Example: Trying to access a non-existent SharePoint list or item.
|
|
115
|
+
Resolution: Check the URL and ensure the resource exists.
|
|
116
|
+
5. 409 Conflict
|
|
117
|
+
Meaning: There is a conflict with the current state of the resource.
|
|
118
|
+
Example: Trying to create an item with a duplicate value that violates unique constraints.
|
|
119
|
+
Resolution: Verify the request data to avoid conflicts (e.g., ensure unique values where required).
|
|
120
|
+
6. 412 Precondition Failed
|
|
121
|
+
Meaning: A condition specified in the If-Match or If-None-Match header was not met.
|
|
122
|
+
Example: Trying to update an item using If-Match with an ETag that does not match the current value.
|
|
123
|
+
Resolution: Ensure that the If-Match or If-None-Match header matches the current ETag of the item.
|
|
124
|
+
7. 415 Unsupported Media Type
|
|
125
|
+
Meaning: The server does not support the media type of the request payload.
|
|
126
|
+
Example: Sending a request body with an unsupported Content-Type header.
|
|
127
|
+
Resolution: Ensure the Content-Type header matches the format (e.g., application/json for JSON payloads).
|
|
128
|
+
8. 429 Too Many Requests
|
|
129
|
+
Meaning: The user has sent too many requests in a given amount of time.
|
|
130
|
+
Example: Exceeding the SharePoint Online API rate limits.
|
|
131
|
+
Resolution: Implement retry logic and respect rate limits. Review Microsoft's API throttling documentation for details.
|
|
132
|
+
9. 500 Internal Server Error
|
|
133
|
+
Meaning: An error occurred on the server while processing the request.
|
|
134
|
+
Example: Server-side issues or unexpected failures.
|
|
135
|
+
Resolution: Retry the request after a short delay or check for known outages or service issues.
|
|
136
|
+
10. 503 Service Unavailable
|
|
137
|
+
Meaning: The server is currently unable to handle the request due to temporary overloading or maintenance.
|
|
138
|
+
Example: SharePoint Online service issues or server maintenance.
|
|
139
|
+
Resolution: Retry after some time or check the Microsoft 365 Service Health Dashboard for updates.
|
|
140
|
+
|
|
141
|
+
Common HTTP Headers for Handling Responses
|
|
142
|
+
Retry-After: Indicates how long to wait before making another request. This header is often seen with 429 Too Many Requests or 503 Service Unavailable.
|
|
143
|
+
*/
|
|
61
144
|
const response = await fetch(fetchAPI, {
|
|
62
145
|
method: method,
|
|
63
146
|
headers: headers,
|
|
64
147
|
// Added this during testing of PivotTiles permissionsSave
|
|
65
148
|
body: body && body !== undefined ? JSON.stringify(body) : null,
|
|
66
149
|
});
|
|
67
|
-
//
|
|
68
|
-
if (response.
|
|
150
|
+
// If the response status is 429, retry after a delay
|
|
151
|
+
if (response.status === 429 && retryCount > 0) {
|
|
152
|
+
console.warn(`429 Too Many Requests. Retrying in ${delayTime}ms...`);
|
|
153
|
+
await delay(delayTime); // Wait for the specified delay time
|
|
154
|
+
return doSpJsFetchOrPost(fetchAPI, method, headers, body, retryCount - 1, delayTime * 2); // Increase delay time exponentially
|
|
155
|
+
}
|
|
156
|
+
if (response.status === 204) {
|
|
157
|
+
/**
|
|
158
|
+
* 204 means there were no errors but nothing is returned...
|
|
159
|
+
* Some examples from ChatGPT:
|
|
160
|
+
* DELETE: When you delete an item or resource, a 204 status indicates that the deletion was successful, but there is no content in the response.
|
|
161
|
+
* PUT or MERGE: When updating an item or resource, a 204 status can indicate that the update was successful, but there is no new content to return.
|
|
162
|
+
* POST (with certain operations): Sometimes used for operations where the server processes the request but doesn't return any additional content.
|
|
163
|
+
*/
|
|
164
|
+
console.log('Operation was successful but there is no content to return.');
|
|
165
|
+
results.ok = true;
|
|
166
|
+
results.statusText = 'No Content Recieved';
|
|
167
|
+
results.statusNo = response.status;
|
|
168
|
+
results.status = 'Success';
|
|
169
|
+
// check if the response is OK
|
|
170
|
+
}
|
|
171
|
+
else if (response.ok) {
|
|
69
172
|
const data = await response.json();
|
|
70
173
|
const usesSearch = fetchAPI.indexOf(`_api/search`) > -1 ? true : false;
|
|
71
|
-
|
|
174
|
+
// 2024-12-09: Refactored this code from my original commented out below.... VVVVVV
|
|
175
|
+
if (usesSearch) {
|
|
72
176
|
results.rawSearchResults = data;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
177
|
+
const deepPropValue = checkDeepProperty(data, ['PrimaryQueryResult', 'RelevantResults', 'Table', 'Rows'], 'Actual');
|
|
178
|
+
if (deepPropValue) {
|
|
179
|
+
results.items = data.PrimaryQueryResult.RelevantResults.Table.Rows;
|
|
180
|
+
}
|
|
77
181
|
}
|
|
78
|
-
else if (
|
|
182
|
+
else if (data.value) {
|
|
183
|
+
results.items = data.value; // Standard SharePoint API response
|
|
79
184
|
}
|
|
80
185
|
else {
|
|
81
|
-
|
|
82
|
-
// Seems like query did not fail, so do nothing because array of items is already [].
|
|
83
|
-
// This is what happened when using fetchMySubsites and not having any subsites to return.
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
results.items = data.value ? data.value : data;
|
|
87
|
-
}
|
|
186
|
+
results.items = data; // Non-standard response
|
|
88
187
|
}
|
|
188
|
+
// 2024-12-09: Refactored ^^^^^^^^ from my original commented out below.... VVVVVV
|
|
189
|
+
// const deepPropValue = usesSearch === true ? checkDeepProperty( data, [ 'PrimaryQueryResult', 'RelevantResults', 'Table', 'Rows'], 'Actual' ) : undefined;
|
|
190
|
+
// // added logic to solve this: https://github.com/mikezimm/pivottiles7/issues/292
|
|
191
|
+
// if ( deepPropValue !== undefined && deepPropValue !== null ) {
|
|
192
|
+
// results.items = data.PrimaryQueryResult.RelevantResults.Table.Rows;
|
|
193
|
+
// } else if ( fetchAPI.indexOf('GetFolderByServerRelativeUrl') > 0 ) {
|
|
194
|
+
// } else {
|
|
195
|
+
// if ( usesSearch === true && data.ElapsedTime && !data.PrimaryQueryResult ) {
|
|
196
|
+
// // Seems like query did not fail, so do nothing because array of items is already [].
|
|
197
|
+
// // This is what happened when using fetchMySubsites and not having any subsites to return.
|
|
198
|
+
// } else {
|
|
199
|
+
// results.items = data.value ? data.value : data;
|
|
200
|
+
// }
|
|
201
|
+
// }
|
|
89
202
|
results.ok = true;
|
|
90
203
|
results.statusText = response.statusText;
|
|
91
204
|
results.statusNo = response.status;
|
|
@@ -94,7 +207,12 @@ export async function doSpJsFetchOrPost(fetchAPI, method = `GET`, digestValue, h
|
|
|
94
207
|
console.log(`fps-core-v7 Success: doSpJsFetchOrPost ~ 131 results`, results);
|
|
95
208
|
}
|
|
96
209
|
else {
|
|
210
|
+
// Handle cases where the response isn't JSON (e.g., empty or text response)
|
|
211
|
+
const text = await response.text();
|
|
212
|
+
console.warn('Non-JSON response received:', text);
|
|
97
213
|
results = await addCatchResponseError(results, response, digestValue);
|
|
214
|
+
// 2024-12-09: Copied this over from updateCommandItems so it will always capture the errors somewhere
|
|
215
|
+
saveErrorToLog(results.errorInfo, results.errorInput);
|
|
98
216
|
}
|
|
99
217
|
return results;
|
|
100
218
|
}
|
|
@@ -112,50 +230,109 @@ export async function doSpJsFetchOrPost(fetchAPI, method = `GET`, digestValue, h
|
|
|
112
230
|
}
|
|
113
231
|
}
|
|
114
232
|
/**
|
|
233
|
+
* doSpJsFetchOrPostAndCheck does: the fetch, checkItemsResults, adds fpsContentTypes and performance
|
|
234
|
+
*
|
|
235
|
+
* Use 'MERGE' for updating items
|
|
236
|
+
*
|
|
115
237
|
* Steps to use this vs the No Check:
|
|
116
238
|
* 1. Update call
|
|
117
239
|
const result: IFpsUsersReturn = await doSpJsFetchOrPostAndCheck( fetchAPI, 'GET', digestValue, '', false, true, null ) as unknown as IFpsUsersReturn;
|
|
118
|
-
|
|
119
|
-
* 2. move results to the object you want
|
|
120
|
-
result.users = result.items ? result.items : [];
|
|
121
|
-
|
|
122
|
-
3. update fpsContentType
|
|
123
|
-
result.fpsContentType = [ 'user' ];
|
|
124
240
|
*
|
|
125
|
-
* 4.
|
|
241
|
+
* 4. re-assign performance object, update label
|
|
126
242
|
result.unifiedPerformanceOps.fetch.label = 'GroupName';
|
|
127
|
-
|
|
243
|
+
initialResult.fetchOp = initialResult.unifiedPerformanceOps.fetch;
|
|
128
244
|
*
|
|
129
245
|
* Things to remove from the older version calls
|
|
130
246
|
* const performanceSettings: IPerformanceSettings = { label: 'FetchCheck', includeMsStr: true, updateMiliseconds: true, op: 'fetch' };
|
|
131
247
|
* const fetchOp = performanceSettings ? startPerformOpV2( performanceSettings ) : null;
|
|
132
|
-
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
* DONE HERE based on 'type' property: move results to the object you want
|
|
251
|
+
result.users = result.items ? result.items : [];
|
|
252
|
+
|
|
253
|
+
DONE HERE based on 'type' property: update fpsContentType
|
|
254
|
+
result.fpsContentType = [ 'user' ];
|
|
255
|
+
|
|
133
256
|
* initialResult.unifiedPerformanceOps.fetch = performanceSettings ?
|
|
134
257
|
updatePerformanceEndV2( { op: fetchOp as IPerformanceOp, updateMiliseconds: performanceSettings.updateMiliseconds, count: initialResult.items ? initialResult.items.length : 0 })
|
|
135
|
-
: null as any; // 2024-09-29: set null as any to pass build error
|
|
136
|
-
|
|
137
|
-
initialResult.fetchOp = initialResult.unifiedPerformanceOps.fetch;
|
|
258
|
+
: null as any; // 2024-09-29: set null as any to pass build error
|
|
138
259
|
*
|
|
139
260
|
*
|
|
140
|
-
* @param
|
|
261
|
+
* @param fetchAPI
|
|
141
262
|
* @param method
|
|
142
263
|
* @param digestValue
|
|
143
264
|
* @param headerContentType
|
|
265
|
+
* @param type
|
|
266
|
+
* @param alertMe
|
|
267
|
+
* @param consoleLog
|
|
144
268
|
* @param body
|
|
269
|
+
* @returns
|
|
145
270
|
*/
|
|
146
|
-
export async function doSpJsFetchOrPostAndCheck(fetchAPI, method
|
|
271
|
+
export async function doSpJsFetchOrPostAndCheck(fetchAPI, method, digestValue, headerContentType, alertMe, consoleLog, type, body) {
|
|
147
272
|
const performanceSettings = { label: 'FetchCheck', includeMsStr: true, updateMiliseconds: true, op: 'fetch' };
|
|
148
273
|
const fetchOp = performanceSettings ? startPerformOpV2(performanceSettings) : null;
|
|
149
|
-
|
|
274
|
+
const headers = createMinHeaders(digestValue, headerContentType);
|
|
275
|
+
let initialResult = await doSpJsFetchOrPost(fetchAPI, method, headers, body);
|
|
150
276
|
initialResult.fetchAPI = fetchAPI;
|
|
151
277
|
initialResult.method = method;
|
|
152
278
|
initialResult = checkItemsResults(initialResult, `fps-core-v7: doSpJsFetchOrPostAndCheck ~ 161`, alertMe, consoleLog);
|
|
279
|
+
// Moved outside of type so it can also be used to update the results cound in performance
|
|
280
|
+
const values = initialResult.item ? initialResult.item : initialResult.items ? initialResult.items : null;
|
|
281
|
+
const isArray = Array.isArray(values) === true ? true : false;
|
|
282
|
+
/**
|
|
283
|
+
* Added to automatically add fpsContentType based on the type, and results to the appropriate key
|
|
284
|
+
*/
|
|
285
|
+
if (type) {
|
|
286
|
+
if (!initialResult.fpsContentType)
|
|
287
|
+
initialResult.fpsContentType = [];
|
|
288
|
+
// Need to add if it's a file because it is also an item
|
|
289
|
+
if (type === 'file' || type === 'files')
|
|
290
|
+
initialResult.fpsContentType.push('item');
|
|
291
|
+
const typeNoS = type.endsWith('s') === true ? type.substring(0, type.length - 2) : type;
|
|
292
|
+
if (initialResult.fpsContentType.indexOf(typeNoS) < 0)
|
|
293
|
+
initialResult.fpsContentType.push(typeNoS);
|
|
294
|
+
initialResult[`${typeNoS}${isArray === true && type.endsWith('s') === true ? 's' : ''}`] = values;
|
|
295
|
+
}
|
|
153
296
|
initialResult.unifiedPerformanceOps.fetch = performanceSettings ?
|
|
154
|
-
updatePerformanceEndV2({ op: fetchOp, updateMiliseconds: performanceSettings.updateMiliseconds, count:
|
|
297
|
+
updatePerformanceEndV2({ op: fetchOp, updateMiliseconds: performanceSettings.updateMiliseconds, count: isArray === true ? values.length : values ? 1 : 0 })
|
|
155
298
|
: null; // 2024-09-29: set null as any to pass build error.
|
|
299
|
+
// export type IJSFetchMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'MERGE' ;
|
|
156
300
|
initialResult.fetchOp = initialResult.unifiedPerformanceOps.fetch;
|
|
157
|
-
if (method === 'POST')
|
|
301
|
+
if (method === 'POST') {
|
|
158
302
|
initialResult.saveOp = initialResult.unifiedPerformanceOps.fetch;
|
|
303
|
+
}
|
|
304
|
+
else if (method === 'DELETE') {
|
|
305
|
+
initialResult.deleteOp = initialResult.unifiedPerformanceOps.fetch;
|
|
306
|
+
}
|
|
307
|
+
else if (method === 'MERGE') {
|
|
308
|
+
initialResult.saveOp = initialResult.unifiedPerformanceOps.fetch;
|
|
309
|
+
}
|
|
159
310
|
return initialResult;
|
|
160
311
|
}
|
|
312
|
+
// export function checkFpsTypesResults ( type: IFPSBaseContentTypesAll,
|
|
313
|
+
// export async function doSpJsFetchOrPostAndCheckTypes(
|
|
314
|
+
// fetchAPI: string, method: IJSFetchMethodNoPUT,
|
|
315
|
+
// digestValue: string, headerContentType: string,
|
|
316
|
+
// alertMe: boolean | undefined, consoleLog: boolean | undefined,
|
|
317
|
+
// type: IFPSBaseContentTypesAll, body: any ): Promise<IFpsItemsReturn> {
|
|
318
|
+
// const performanceSettings: IPerformanceSettings = { label: 'FetchCheck', includeMsStr: true, updateMiliseconds: true, op: 'fetch' };
|
|
319
|
+
// const fetchOp = performanceSettings ? startPerformOpV2( performanceSettings ) : null;
|
|
320
|
+
// const headers: HeadersInit = createMinHeaders( digestValue, headerContentType );
|
|
321
|
+
// let initialResult: IFpsItemsReturn = await doSpJsFetchOrPost( fetchAPI, method, headers, body );
|
|
322
|
+
// initialResult.fetchAPI = fetchAPI;
|
|
323
|
+
// initialResult.method = method;
|
|
324
|
+
// initialResult = checkItemsResults( initialResult, `fps-core-v7: doSpJsFetchOrPostAndCheck ~ 161`, alertMe, consoleLog );
|
|
325
|
+
// const values = initialResult.item ? initialResult.item : initialResult.items ? initialResult.items : null;
|
|
326
|
+
// const isArray: boolean = Array.isArray( values ) === true ? true : false;
|
|
327
|
+
// initialResult[ `${type}${ isArray === true && type.endsWith('s') === true ? 's' : '' }` as 'item' ] = values;
|
|
328
|
+
// initialResult.unifiedPerformanceOps.fetch = performanceSettings ?
|
|
329
|
+
// updatePerformanceEndV2( { op: fetchOp as IPerformanceOp, updateMiliseconds: performanceSettings.updateMiliseconds, count: initialResult.items ? initialResult.items.length : 0 })
|
|
330
|
+
// : null as any; // 2024-09-29: set null as any to pass build error.
|
|
331
|
+
// // export type IJSFetchMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'MERGE' ;
|
|
332
|
+
// initialResult.fetchOp = initialResult.unifiedPerformanceOps.fetch;
|
|
333
|
+
// if ( method === 'POST' ) { initialResult.saveOp = initialResult.unifiedPerformanceOps.fetch; }
|
|
334
|
+
// else if ( method === 'DELETE' ) { initialResult.deleteOp = initialResult.unifiedPerformanceOps.fetch; }
|
|
335
|
+
// else if ( method === 'MERGE' ) { initialResult.saveOp = initialResult.unifiedPerformanceOps.fetch; }
|
|
336
|
+
// return initialResult;
|
|
337
|
+
// }
|
|
161
338
|
//# sourceMappingURL=doSpJsFetch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doSpJsFetch.js","sourceRoot":"","sources":["../../../../src/components/molecules/SpHttp/doSpJsFetch.ts"],"names":[],"mappings":"AACA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"doSpJsFetch.js","sourceRoot":"","sources":["../../../../src/components/molecules/SpHttp/doSpJsFetch.ts"],"names":[],"mappings":"AACA;;;GAGG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,qDAAqD,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,+DAA+D;AAC/D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAuC,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAgB,EAAE,WAAmB,EAAE,iBAAyB;IAChG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AG,aAAa,CAAC,qBAAqB,CAAC,KAAK,CAAC;IAClE,IAAK,MAAM,KAAK,MAAM,EAAG;QAAE,aAAa,CAAC,MAAM,GAAG,aAAa,CAAC,qBAAqB,CAAC,KAAK,CAAC;KAAE;SACzF,IAAK,MAAM,KAAK,QAAQ,EAAG;QAAE,aAAa,CAAC,QAAQ,GAAG,aAAa,CAAC,qBAAqB,CAAC,KAAK,CAAC;KAAE;SAClG,IAAK,MAAM,KAAK,OAAO,EAAG;QAAE,aAAa,CAAC,MAAM,GAAG,aAAa,CAAC,qBAAqB,CAAC,KAAK,CAAC;KAAE;IACpG,OAAO,aAAa,CAAC;AAEvB,CAAC;AAED,wEAAwE;AACxE,wDAAwD;AACxD,mDAAmD;AACnD,oDAAoD;AACpD,mEAAmE;AACnE,2EAA2E;AAE3E,yIAAyI;AACzI,0FAA0F;AAC1F,qFAAqF;AAErF,qGAAqG;AACrG,uCAAuC;AACvC,mCAAmC;AAEnC,6HAA6H;AAE7H,+GAA+G;AAE/G,8EAA8E;AAC9E,kHAAkH;AAElH,sEAAsE;AACtE,wLAAwL;AACxL,2EAA2E;AAE3E,kFAAkF;AAClF,uEAAuE;AACvE,mGAAmG;AACnG,4GAA4G;AAC5G,yGAAyG;AACzG,0BAA0B;AAE1B,IAAI"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { IJSFetchReturn } from "./IJSFetchReturn";
|
|
6
6
|
/**
|
|
7
|
+
* 2024-12-10: This does NOT have 429 retry yet.
|
|
8
|
+
* See doSpJsFetch for an example of how to handle that
|
|
7
9
|
*
|
|
8
10
|
* @param fetchAPI
|
|
9
11
|
* @param digestValue - REQUIRES digestValue
|
|
@@ -18,5 +20,5 @@ export declare function doSpJsFileFetch(fetchAPI: string, digestValue: string, h
|
|
|
18
20
|
* @param digestValue - REQUIRES digestValue for POST operations
|
|
19
21
|
* @returns
|
|
20
22
|
*/
|
|
21
|
-
export declare function doSpJsFileFetchOrPost(fetchAPI: string, method: "
|
|
23
|
+
export declare function doSpJsFileFetchOrPost(fetchAPI: string, method: "GET" | "POST" | undefined, digestValue: string, headerContentType: string, blob: Blob): Promise<IJSFetchReturn>;
|
|
22
24
|
//# sourceMappingURL=doSpJsFileFetch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doSpJsFileFetch.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/SpHttp/doSpJsFileFetch.ts"],"names":[],"mappings":"AACA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"doSpJsFileFetch.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/SpHttp/doSpJsFileFetch.ts"],"names":[],"mappings":"AACA;;;GAGG;AAoBH,OAAO,EAAE,cAAc,EAA0B,MAAM,kBAAkB,CAAC;AAG1E;;;;;;;;;GASG;AAEH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAI,OAAO,CAAC,cAAc,CAAC,CAG5I;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,4BAAwB,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAK,OAAO,CAAC,cAAc,CAAC,CA8EpL"}
|
|
@@ -2,23 +2,19 @@
|
|
|
2
2
|
* 2024-09-15: Migrated to SAME FOLDER in fps-library-v2\src\components\molecules\SpHttp...
|
|
3
3
|
* export { IJSFetchReturn, createEmptyFetchReturn, doSpJsFetch }
|
|
4
4
|
*/
|
|
5
|
-
// import { check4This } from "@mikezimm/fps-core-v7/lib/logic/Links/CheckSearch";
|
|
6
|
-
// import { checkDeepProperty } from "@mikezimm/fps-core-v7/lib/logic/Objects/deep";
|
|
7
|
-
// import { getFullUrlFromSlashSitesUrl } from "@mikezimm/fps-core-v7/lib/logic/Strings/getFullUrlFromSlashSitesUrl";
|
|
8
|
-
// import { getSiteCollectionUrlFromLink } from "@mikezimm/fps-core-v7/lib/logic/Strings/getSiteCollectionUrlFromLink";
|
|
9
|
-
// import { check4ThisFPSDigestValue } from "@mikezimm/fps-core-v7/lib/components/molecules/SpHttp/helpers/check4ThisFPSDigestValue";
|
|
10
|
-
// import { IJSFetchReturn, createEmptyFetchReturn } from "./IJSFetchReturn";
|
|
11
|
-
// import { addCatchResponseError, addUnknownFetchError } from "./SpFetchCommon";
|
|
12
5
|
import { check4This } from "../../../logic/Links/CheckSearch";
|
|
13
6
|
import { checkDeepProperty } from "../../../logic/Objects/deep";
|
|
14
7
|
import { makeAbsoluteUrl } from "../../../logic/Strings/getSiteCollectionUrlFromLink";
|
|
15
8
|
import { getSiteCollectionUrlFromLink } from "../../../logic/Strings/getSiteCollectionUrlFromLink";
|
|
9
|
+
import { saveErrorToLog } from "../../../restAPIs/logging/saveErrorToLog";
|
|
16
10
|
import { CurrentHostName } from "../source-props/WindowLocationConstants";
|
|
17
11
|
// import { CurrentHostName } from "../../../logic/Strings/getSiteCollectionUrlFromLink";
|
|
18
12
|
import { check4ThisFPSDigestValue } from "./helpers/check4ThisFPSDigestValue";
|
|
19
13
|
import { createEmptyFetchReturn } from "./IJSFetchReturn";
|
|
20
14
|
import { addCatchResponseError, addUnknownFetchError } from "./SpFetchCommon";
|
|
21
15
|
/**
|
|
16
|
+
* 2024-12-10: This does NOT have 429 retry yet.
|
|
17
|
+
* See doSpJsFetch for an example of how to handle that
|
|
22
18
|
*
|
|
23
19
|
* @param fetchAPI
|
|
24
20
|
* @param digestValue - REQUIRES digestValue
|
|
@@ -97,7 +93,10 @@ export async function doSpJsFileFetchOrPost(fetchAPI, method = `GET`, digestValu
|
|
|
97
93
|
return results;
|
|
98
94
|
}
|
|
99
95
|
catch (e) {
|
|
100
|
-
|
|
96
|
+
results = addUnknownFetchError(results, e);
|
|
97
|
+
// 2024-12-09: Copied this over from updateCommandItems so it will always capture the errors somewhere
|
|
98
|
+
saveErrorToLog(results.errorInfo, results.errorInput);
|
|
99
|
+
return results;
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
//# sourceMappingURL=doSpJsFileFetch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doSpJsFileFetch.js","sourceRoot":"","sources":["../../../../src/components/molecules/SpHttp/doSpJsFileFetch.ts"],"names":[],"mappings":"AACA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"doSpJsFileFetch.js","sourceRoot":"","sources":["../../../../src/components/molecules/SpHttp/doSpJsFileFetch.ts"],"names":[],"mappings":"AACA;;;GAGG;AAYH,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,qDAAqD,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,yFAAyF;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAkB,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE9E;;;;;;;;;GASG;AAEH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAgB,EAAE,WAAmB,EAAE,iBAAyB,EAAE,IAAU;IAChH,MAAM,OAAO,GAAmB,MAAM,qBAAqB,CAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,CAAE,CAAC;IACrH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAE,QAA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AAc,CAAE,OAAO,CAAC,SAA4B,EAAE,OAAO,CAAC,UAA4B,CAAE,CAAC;QAE7F,OAAO,OAAO,CAAC;KAEhB;AAEH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* copyHeadersToReturns:
|
|
3
|
+
*
|
|
4
|
+
* 2024-12-09: Created this function in order to copy headers object to the return results.
|
|
5
|
+
* Typescript was not liking just assigning it so ChatGPT suggested this as the most robust way to handle it.
|
|
6
|
+
*
|
|
7
|
+
* @param headers
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function copyHeadersToReturns(headers: HeadersInit): Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* createMinHeaders
|
|
13
|
+
*
|
|
14
|
+
* 2024-12-09: Created this function in order to create HeadersInit with proper typings
|
|
15
|
+
*
|
|
16
|
+
* @param digestValue
|
|
17
|
+
* @param headerContentType
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function createMinHeaders(digestValue: string, headerContentType: string): HeadersInit;
|
|
21
|
+
//# sourceMappingURL=headerInitUtilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerInitUtilities.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/SpHttp/headerInitUtilities.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAejF;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,WAAW,CAK5F"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* copyHeadersToReturns:
|
|
3
|
+
*
|
|
4
|
+
* 2024-12-09: Created this function in order to copy headers object to the return results.
|
|
5
|
+
* Typescript was not liking just assigning it so ChatGPT suggested this as the most robust way to handle it.
|
|
6
|
+
*
|
|
7
|
+
* @param headers
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export function copyHeadersToReturns(headers) {
|
|
11
|
+
if (headers instanceof Headers) {
|
|
12
|
+
// Convert Headers instance to a Record<string, string>
|
|
13
|
+
const record = {};
|
|
14
|
+
headers.forEach((value, key) => {
|
|
15
|
+
record[key] = value;
|
|
16
|
+
});
|
|
17
|
+
return record;
|
|
18
|
+
}
|
|
19
|
+
else if (Array.isArray(headers)) {
|
|
20
|
+
// Convert array of tuples to a Record<string, string>
|
|
21
|
+
return Object.fromEntries(headers);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// Assume it's already a Record<string, string>
|
|
25
|
+
return headers;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* createMinHeaders
|
|
30
|
+
*
|
|
31
|
+
* 2024-12-09: Created this function in order to create HeadersInit with proper typings
|
|
32
|
+
*
|
|
33
|
+
* @param digestValue
|
|
34
|
+
* @param headerContentType
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export function createMinHeaders(digestValue, headerContentType) {
|
|
38
|
+
const headers = {};
|
|
39
|
+
if (digestValue)
|
|
40
|
+
headers['X-RequestDigest'] = digestValue;
|
|
41
|
+
if (headerContentType)
|
|
42
|
+
headers['Content-Type'] = headerContentType;
|
|
43
|
+
return headers;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=headerInitUtilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerInitUtilities.js","sourceRoot":"","sources":["../../../../src/components/molecules/SpHttp/headerInitUtilities.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACvD,IAAI,OAAO,YAAY,OAAO,EAAE;QAC9B,uDAAuD;QACvD,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;KACf;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACjC,sDAAsD;QACtD,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;KACpC;SAAM;QACL,+CAA+C;QAC/C,OAAO,OAAO,CAAC;KAChB;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB,EAAE,iBAAyB;IAC7E,MAAM,OAAO,GAAgB,EAAE,CAAC;IAChC,IAAI,WAAW;QAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,WAAW,CAAC;IAC1D,IAAI,iBAAiB;QAAE,OAAO,CAAC,cAAc,CAAC,GAAG,iBAAiB,CAAC;IACnE,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check4ThisFPSDigestValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/SpHttp/helpers/check4ThisFPSDigestValue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,kBAAkB,EAAG,MAAM,qDAAqD,CAAC;AAM5G,wBAAgB,wBAAwB,CAAE,WAAW,EAAE,MAAM,GAAI,MAAM,CAGtE;AACD;;;;;;;;;GASG;AAEH,wBAAgB,mBAAmB,CAAE,WAAW,EAAE,MAAM,GAAI,kBAAkB,
|
|
1
|
+
{"version":3,"file":"check4ThisFPSDigestValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/SpHttp/helpers/check4ThisFPSDigestValue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,kBAAkB,EAAG,MAAM,qDAAqD,CAAC;AAM5G,wBAAgB,wBAAwB,CAAE,WAAW,EAAE,MAAM,GAAI,MAAM,CAGtE;AACD;;;;;;;;;GASG;AAEH,wBAAgB,mBAAmB,CAAE,WAAW,EAAE,MAAM,GAAI,kBAAkB,CAwF7E"}
|
|
@@ -82,10 +82,14 @@ export function check4ThisFPSDigest(absoluteUrl) {
|
|
|
82
82
|
// site.queries ++;
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 2024-12-15: Moved this check outside of last curley for the first site.
|
|
88
|
+
* Prior to this, it was always getting skipped because the length was 0 and caused an error
|
|
89
|
+
*/
|
|
90
|
+
if (!returnDigest) {
|
|
91
|
+
returnDigest = { url: absoluteUrl, digestValue: '', time: startTime, new: 0, queries: 0, idx: fpsWindowProps.sites.length };
|
|
92
|
+
fpsWindowProps.sites.push(returnDigest);
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
return returnDigest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check4ThisFPSDigestValue.js","sourceRoot":"","sources":["../../../../../src/components/molecules/SpHttp/helpers/check4ThisFPSDigestValue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AACtH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,UAAU,GAAG,MAAM,kCAAkC,CAAC;AAC/D,gGAAgG;AAChG,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEjF,MAAM,UAAU,wBAAwB,CAAE,WAAmB;IAC3D,MAAM,MAAM,GAAuB,mBAAmB,CAAE,WAAW,CAAE,CAAC;IACtE,OAAO,MAAM,CAAC,WAAW,CAAC;AAC5B,CAAC;AACD;;;;;;;;;GASG;AAEH,MAAM,UAAU,mBAAmB,CAAE,WAAmB;IAEtD,MA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AG,cAAc,CAAC,WAAW,CAAC;KAE3C;SAAM;QACL,8BAA8B;QAC9B,IAAK,cAAc,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAG;YACrC,wBAAwB;YACxB,cAAc,CAAC,KAAK,CAAC,GAAG,CAAE,CAAE,IAAI,EAAI,EAAE;gBACpC,IAAK,SAAS,GAAG,IAAI,CAAC,IAAI,GAAG,UAAU,EAAG;oBACxC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;oBACtB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;iBACf;YACH,CAAC,CAAC,CAAC;YAEH,2DAA2D;YAC3D,cAAc,CAAC,KAAK,CAAC,GAAG,CAAE,CAAE,IAAI,EAAI,EAAE;gBACpC,IAAK,CAAC,YAAY,IAAI,IAAI,CAAC,GAAG,KAAK,WAAW,EAAG;oBAC/C,YAAY,GAAG,IAAI,CAAC;oBACpB,mBAAmB;iBACpB;YACH,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"check4ThisFPSDigestValue.js","sourceRoot":"","sources":["../../../../../src/components/molecules/SpHttp/helpers/check4ThisFPSDigestValue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AACtH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,UAAU,GAAG,MAAM,kCAAkC,CAAC;AAC/D,gGAAgG;AAChG,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEjF,MAAM,UAAU,wBAAwB,CAAE,WAAmB;IAC3D,MAAM,MAAM,GAAuB,mBAAmB,CAAE,WAAW,CAAE,CAAC;IACtE,OAAO,MAAM,CAAC,WAAW,CAAC;AAC5B,CAAC;AACD;;;;;;;;;GASG;AAEH,MAAM,UAAU,mBAAmB,CAAE,WAAmB;IAEtD,M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