@lindle/sharepoint_requests 0.1.18 → 0.1.20
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.mts +469 -0
- package/dist/index.d.ts +460 -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 +3 -5
- package/src/root/index.ts +281 -146
- package/src/root/instance.ts +7 -0
- package/src/root/internal/context.ts +2 -3
- package/src/root/internal/digest.ts +18 -11
- package/src/root/internal/emailRequests.ts +5 -11
- package/src/root/internal/listRequests/createAttachment.ts +16 -5
- package/src/root/internal/listRequests/createListItem.ts +18 -27
- package/src/root/internal/listRequests/deleteFile.ts +5 -5
- 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 +43 -9
- package/src/root/internal/listRequests/getOnly.ts +10 -7
- package/src/root/internal/listRequests/normalizePayload.ts +1 -1
- package/src/root/internal/listRequests/resolveMetadataType.ts +14 -0
- package/src/root/internal/listRequests/updateListItem.ts +24 -30
- package/src/root/internal/listRequests/uploadFile.ts +13 -21
- 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 +93 -37
- package/src/types.ts +154 -149
- package/dist/root/index.d.ts +0 -88
- 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/userRequests.d.ts +0 -15
- package/dist/sharepoint_requests.cjs.development.js +0 -1325
- 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 -1318
- package/dist/sharepoint_requests.esm.js.map +0 -1
- package/dist/types.d.ts +0 -256
|
@@ -1,1318 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosHeaders } from 'axios';
|
|
2
|
-
|
|
3
|
-
function _arrayLikeToArray(r, a) {
|
|
4
|
-
(null == a || a > r.length) && (a = r.length);
|
|
5
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
6
|
-
return n;
|
|
7
|
-
}
|
|
8
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
9
|
-
try {
|
|
10
|
-
var i = n[a](c),
|
|
11
|
-
u = i.value;
|
|
12
|
-
} catch (n) {
|
|
13
|
-
return void e(n);
|
|
14
|
-
}
|
|
15
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
16
|
-
}
|
|
17
|
-
function _asyncToGenerator(n) {
|
|
18
|
-
return function () {
|
|
19
|
-
var t = this,
|
|
20
|
-
e = arguments;
|
|
21
|
-
return new Promise(function (r, o) {
|
|
22
|
-
var a = n.apply(t, e);
|
|
23
|
-
function _next(n) {
|
|
24
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
25
|
-
}
|
|
26
|
-
function _throw(n) {
|
|
27
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
28
|
-
}
|
|
29
|
-
_next(void 0);
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function _createForOfIteratorHelperLoose(r, e) {
|
|
34
|
-
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
35
|
-
if (t) return (t = t.call(r)).next.bind(t);
|
|
36
|
-
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
37
|
-
t && (r = t);
|
|
38
|
-
var o = 0;
|
|
39
|
-
return function () {
|
|
40
|
-
return o >= r.length ? {
|
|
41
|
-
done: !0
|
|
42
|
-
} : {
|
|
43
|
-
done: !1,
|
|
44
|
-
value: r[o++]
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
49
|
-
}
|
|
50
|
-
function _extends() {
|
|
51
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
52
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
53
|
-
var t = arguments[e];
|
|
54
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
55
|
-
}
|
|
56
|
-
return n;
|
|
57
|
-
}, _extends.apply(null, arguments);
|
|
58
|
-
}
|
|
59
|
-
function _regenerator() {
|
|
60
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
61
|
-
var e,
|
|
62
|
-
t,
|
|
63
|
-
r = "function" == typeof Symbol ? Symbol : {},
|
|
64
|
-
n = r.iterator || "@@iterator",
|
|
65
|
-
o = r.toStringTag || "@@toStringTag";
|
|
66
|
-
function i(r, n, o, i) {
|
|
67
|
-
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
68
|
-
u = Object.create(c.prototype);
|
|
69
|
-
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
70
|
-
var i,
|
|
71
|
-
c,
|
|
72
|
-
u,
|
|
73
|
-
f = 0,
|
|
74
|
-
p = o || [],
|
|
75
|
-
y = !1,
|
|
76
|
-
G = {
|
|
77
|
-
p: 0,
|
|
78
|
-
n: 0,
|
|
79
|
-
v: e,
|
|
80
|
-
a: d,
|
|
81
|
-
f: d.bind(e, 4),
|
|
82
|
-
d: function (t, r) {
|
|
83
|
-
return i = t, c = 0, u = e, G.n = r, a;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
function d(r, n) {
|
|
87
|
-
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
88
|
-
var o,
|
|
89
|
-
i = p[t],
|
|
90
|
-
d = G.p,
|
|
91
|
-
l = i[2];
|
|
92
|
-
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
93
|
-
}
|
|
94
|
-
if (o || r > 1) return a;
|
|
95
|
-
throw y = !0, n;
|
|
96
|
-
}
|
|
97
|
-
return function (o, p, l) {
|
|
98
|
-
if (f > 1) throw TypeError("Generator is already running");
|
|
99
|
-
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
100
|
-
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
101
|
-
try {
|
|
102
|
-
if (f = 2, i) {
|
|
103
|
-
if (c || (o = "next"), t = i[o]) {
|
|
104
|
-
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
105
|
-
if (!t.done) return t;
|
|
106
|
-
u = t.value, c < 2 && (c = 0);
|
|
107
|
-
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
108
|
-
i = e;
|
|
109
|
-
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
110
|
-
} catch (t) {
|
|
111
|
-
i = e, c = 1, u = t;
|
|
112
|
-
} finally {
|
|
113
|
-
f = 1;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
value: t,
|
|
118
|
-
done: y
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
}(r, o, i), !0), u;
|
|
122
|
-
}
|
|
123
|
-
var a = {};
|
|
124
|
-
function Generator() {}
|
|
125
|
-
function GeneratorFunction() {}
|
|
126
|
-
function GeneratorFunctionPrototype() {}
|
|
127
|
-
t = Object.getPrototypeOf;
|
|
128
|
-
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
129
|
-
return this;
|
|
130
|
-
}), t),
|
|
131
|
-
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
132
|
-
function f(e) {
|
|
133
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
134
|
-
}
|
|
135
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
136
|
-
return this;
|
|
137
|
-
}), _regeneratorDefine(u, "toString", function () {
|
|
138
|
-
return "[object Generator]";
|
|
139
|
-
}), (_regenerator = function () {
|
|
140
|
-
return {
|
|
141
|
-
w: i,
|
|
142
|
-
m: f
|
|
143
|
-
};
|
|
144
|
-
})();
|
|
145
|
-
}
|
|
146
|
-
function _regeneratorDefine(e, r, n, t) {
|
|
147
|
-
var i = Object.defineProperty;
|
|
148
|
-
try {
|
|
149
|
-
i({}, "", {});
|
|
150
|
-
} catch (e) {
|
|
151
|
-
i = 0;
|
|
152
|
-
}
|
|
153
|
-
_regeneratorDefine = function (e, r, n, t) {
|
|
154
|
-
function o(r, n) {
|
|
155
|
-
_regeneratorDefine(e, r, function (e) {
|
|
156
|
-
return this._invoke(r, n, e);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
r ? i ? i(e, r, {
|
|
160
|
-
value: n,
|
|
161
|
-
enumerable: !t,
|
|
162
|
-
configurable: !t,
|
|
163
|
-
writable: !t
|
|
164
|
-
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
165
|
-
}, _regeneratorDefine(e, r, n, t);
|
|
166
|
-
}
|
|
167
|
-
function _unsupportedIterableToArray(r, a) {
|
|
168
|
-
if (r) {
|
|
169
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
170
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
171
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
var defaultConfig = {
|
|
176
|
-
headers: {
|
|
177
|
-
Accept: 'application/json; odata=verbose',
|
|
178
|
-
'Content-Type': 'application/json; odata=verbose'
|
|
179
|
-
},
|
|
180
|
-
timeout: 15000,
|
|
181
|
-
withCredentials: true
|
|
182
|
-
};
|
|
183
|
-
var instance = function instance(baseURL, config) {
|
|
184
|
-
var _config$headers;
|
|
185
|
-
var userHeaders = (config == null ? void 0 : config.headers) instanceof AxiosHeaders ? config.headers.toJSON() : (_config$headers = config == null ? void 0 : config.headers) != null ? _config$headers : {};
|
|
186
|
-
return axios.create(_extends({}, defaultConfig, config, {
|
|
187
|
-
baseURL: baseURL,
|
|
188
|
-
headers: _extends({}, defaultConfig.headers, userHeaders)
|
|
189
|
-
}));
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
function fetchDigest(_x, _x2) {
|
|
193
|
-
return _fetchDigest.apply(this, arguments);
|
|
194
|
-
}
|
|
195
|
-
function _fetchDigest() {
|
|
196
|
-
_fetchDigest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(instance, baseURL) {
|
|
197
|
-
var _response$data, response, formDigestValue, _t;
|
|
198
|
-
return _regenerator().w(function (_context) {
|
|
199
|
-
while (1) switch (_context.p = _context.n) {
|
|
200
|
-
case 0:
|
|
201
|
-
_context.p = 0;
|
|
202
|
-
_context.n = 1;
|
|
203
|
-
return instance.post(baseURL + "_api/contextinfo");
|
|
204
|
-
case 1:
|
|
205
|
-
response = _context.v;
|
|
206
|
-
formDigestValue = (_response$data = response.data) == null || (_response$data = _response$data.d) == null || (_response$data = _response$data.GetContextWebInformation) == null ? void 0 : _response$data.FormDigestValue;
|
|
207
|
-
if (formDigestValue) {
|
|
208
|
-
_context.n = 2;
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
throw new Error('Invalid response structure: Missing FormDigestValue');
|
|
212
|
-
case 2:
|
|
213
|
-
return _context.a(2, formDigestValue);
|
|
214
|
-
case 3:
|
|
215
|
-
_context.p = 3;
|
|
216
|
-
_t = _context.v;
|
|
217
|
-
console.error('Failed to retrieve the Form Digest Value:', _t);
|
|
218
|
-
throw new Error("Error retrieving Form Digest Value");
|
|
219
|
-
case 4:
|
|
220
|
-
return _context.a(2);
|
|
221
|
-
}
|
|
222
|
-
}, _callee, null, [[0, 3]]);
|
|
223
|
-
}));
|
|
224
|
-
return _fetchDigest.apply(this, arguments);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
var LOOKUP_ID_KEYS = ['lookupId', 'LookupId', 'lookupID', 'LookupID', 'Id', 'ID'];
|
|
228
|
-
function isPlainObject(value) {
|
|
229
|
-
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
230
|
-
}
|
|
231
|
-
function extractLookupPrimitive(value, allowGenericId) {
|
|
232
|
-
for (var _iterator = _createForOfIteratorHelperLoose(LOOKUP_ID_KEYS), _step; !(_step = _iterator()).done;) {
|
|
233
|
-
var key = _step.value;
|
|
234
|
-
if (!allowGenericId && (key === 'Id' || key === 'ID')) {
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
if (value[key] !== undefined && value[key] !== null) {
|
|
238
|
-
return value[key];
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return undefined;
|
|
242
|
-
}
|
|
243
|
-
function normalizeLookupValue(value) {
|
|
244
|
-
if (Array.isArray(value)) {
|
|
245
|
-
return {
|
|
246
|
-
results: value
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
if (isPlainObject(value)) {
|
|
250
|
-
if (Array.isArray(value.results)) {
|
|
251
|
-
return {
|
|
252
|
-
results: value.results
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
var primitive = extractLookupPrimitive(value, true);
|
|
256
|
-
if (primitive !== undefined) {
|
|
257
|
-
return primitive;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
if (typeof value === 'string') {
|
|
261
|
-
var trimmed = value.trim();
|
|
262
|
-
if (!trimmed) {
|
|
263
|
-
return value;
|
|
264
|
-
}
|
|
265
|
-
var numeric = Number(trimmed);
|
|
266
|
-
return Number.isNaN(numeric) ? trimmed : numeric;
|
|
267
|
-
}
|
|
268
|
-
return value;
|
|
269
|
-
}
|
|
270
|
-
function resolveLookupField(key, value) {
|
|
271
|
-
var lower = key.toLowerCase();
|
|
272
|
-
var endsWithId = lower.endsWith('id');
|
|
273
|
-
var endsWithRef = lower.endsWith('ref');
|
|
274
|
-
var endsWithLookup = lower.endsWith('lookup');
|
|
275
|
-
var hasLookupHint = endsWithId || endsWithRef || endsWithLookup;
|
|
276
|
-
if (value === undefined) {
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
if (Array.isArray(value)) {
|
|
280
|
-
var _targetKey = endsWithId ? key : key + "Id";
|
|
281
|
-
return {
|
|
282
|
-
key: _targetKey,
|
|
283
|
-
value: {
|
|
284
|
-
results: value
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
if (isPlainObject(value)) {
|
|
289
|
-
var primitive = extractLookupPrimitive(value, hasLookupHint);
|
|
290
|
-
if (primitive !== undefined) {
|
|
291
|
-
var _targetKey2 = endsWithId ? key : key + "Id";
|
|
292
|
-
return {
|
|
293
|
-
key: _targetKey2,
|
|
294
|
-
value: normalizeLookupValue(primitive)
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
if (Array.isArray(value.results)) {
|
|
298
|
-
var _targetKey3 = endsWithId ? key : key + "Id";
|
|
299
|
-
return {
|
|
300
|
-
key: _targetKey3,
|
|
301
|
-
value: {
|
|
302
|
-
results: value.results
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
if (!hasLookupHint) {
|
|
307
|
-
return null;
|
|
308
|
-
}
|
|
309
|
-
} else if (!hasLookupHint) {
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
var targetKey = endsWithId ? key : key + "Id";
|
|
313
|
-
if (value === null) {
|
|
314
|
-
return {
|
|
315
|
-
key: targetKey,
|
|
316
|
-
value: null
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
if (typeof value === 'number') {
|
|
320
|
-
return {
|
|
321
|
-
key: targetKey,
|
|
322
|
-
value: value
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
if (typeof value === 'string') {
|
|
326
|
-
var trimmed = value.trim();
|
|
327
|
-
if (!trimmed) {
|
|
328
|
-
return {
|
|
329
|
-
key: targetKey,
|
|
330
|
-
value: ''
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
var numeric = Number(trimmed);
|
|
334
|
-
return {
|
|
335
|
-
key: targetKey,
|
|
336
|
-
value: Number.isNaN(numeric) ? trimmed : numeric
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
return null;
|
|
340
|
-
}
|
|
341
|
-
function normalizeListPayload(data) {
|
|
342
|
-
var result = {};
|
|
343
|
-
if (!data) {
|
|
344
|
-
return result;
|
|
345
|
-
}
|
|
346
|
-
for (var _i = 0, _Object$entries = Object.entries(data); _i < _Object$entries.length; _i++) {
|
|
347
|
-
var _Object$entries$_i = _Object$entries[_i],
|
|
348
|
-
key = _Object$entries$_i[0],
|
|
349
|
-
value = _Object$entries$_i[1];
|
|
350
|
-
if (key === '__metadata') {
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
var lookupField = resolveLookupField(key, value);
|
|
354
|
-
if (lookupField) {
|
|
355
|
-
result[lookupField.key] = lookupField.value;
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
if (value !== undefined) {
|
|
359
|
-
result[key] = value;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
return result;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function resolveMetadataType(_x) {
|
|
366
|
-
return _resolveMetadataType.apply(this, arguments);
|
|
367
|
-
}
|
|
368
|
-
function _resolveMetadataType() {
|
|
369
|
-
_resolveMetadataType = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context) {
|
|
370
|
-
return _regenerator().w(function (_context) {
|
|
371
|
-
while (1) switch (_context.n) {
|
|
372
|
-
case 0:
|
|
373
|
-
if (!context.resolveListItemEntityType) {
|
|
374
|
-
_context.n = 1;
|
|
375
|
-
break;
|
|
376
|
-
}
|
|
377
|
-
return _context.a(2, context.resolveListItemEntityType());
|
|
378
|
-
case 1:
|
|
379
|
-
if (!context.listItemEntityTypeFullName) {
|
|
380
|
-
_context.n = 2;
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
return _context.a(2, context.listItemEntityTypeFullName);
|
|
384
|
-
case 2:
|
|
385
|
-
return _context.a(2, "SP.Data." + context.listName + "ListItem");
|
|
386
|
-
}
|
|
387
|
-
}, _callee);
|
|
388
|
-
}));
|
|
389
|
-
return _resolveMetadataType.apply(this, arguments);
|
|
390
|
-
}
|
|
391
|
-
function createListItem(_x2, _x3) {
|
|
392
|
-
return _createListItem.apply(this, arguments);
|
|
393
|
-
}
|
|
394
|
-
function _createListItem() {
|
|
395
|
-
_createListItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(context, listData) {
|
|
396
|
-
var metadataType, normalizedData, userMetadata, payload, response, _t, _t2, _t3, _t4, _t5;
|
|
397
|
-
return _regenerator().w(function (_context2) {
|
|
398
|
-
while (1) switch (_context2.n) {
|
|
399
|
-
case 0:
|
|
400
|
-
_context2.n = 1;
|
|
401
|
-
return resolveMetadataType(context);
|
|
402
|
-
case 1:
|
|
403
|
-
metadataType = _context2.v;
|
|
404
|
-
normalizedData = normalizeListPayload(listData);
|
|
405
|
-
userMetadata = listData.__metadata;
|
|
406
|
-
payload = _extends({}, normalizedData, {
|
|
407
|
-
__metadata: _extends({}, userMetadata && typeof userMetadata === 'object' ? userMetadata : {}, {
|
|
408
|
-
type: metadataType
|
|
409
|
-
})
|
|
410
|
-
});
|
|
411
|
-
_t = context;
|
|
412
|
-
_t2 = context.endpoint;
|
|
413
|
-
_t3 = JSON.stringify(payload);
|
|
414
|
-
_context2.n = 2;
|
|
415
|
-
return fetchDigest(context.instance, context.baseURL);
|
|
416
|
-
case 2:
|
|
417
|
-
_t4 = _context2.v;
|
|
418
|
-
_t5 = {
|
|
419
|
-
'X-RequestDigest': _t4
|
|
420
|
-
};
|
|
421
|
-
_context2.n = 3;
|
|
422
|
-
return _t.instance.call(_t, {
|
|
423
|
-
url: _t2,
|
|
424
|
-
method: 'POST',
|
|
425
|
-
data: _t3,
|
|
426
|
-
headers: _t5
|
|
427
|
-
});
|
|
428
|
-
case 3:
|
|
429
|
-
response = _context2.v;
|
|
430
|
-
return _context2.a(2, response);
|
|
431
|
-
}
|
|
432
|
-
}, _callee2);
|
|
433
|
-
}));
|
|
434
|
-
return _createListItem.apply(this, arguments);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
function createAttachment(_x, _x2) {
|
|
438
|
-
return _createAttachment.apply(this, arguments);
|
|
439
|
-
}
|
|
440
|
-
function _createAttachment() {
|
|
441
|
-
_createAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, _ref) {
|
|
442
|
-
var file, itemId, requestUrl, response, _t, _t2, _t3, _t4, _t5;
|
|
443
|
-
return _regenerator().w(function (_context) {
|
|
444
|
-
while (1) switch (_context.n) {
|
|
445
|
-
case 0:
|
|
446
|
-
file = _ref.file, itemId = _ref.itemId;
|
|
447
|
-
requestUrl = "_api/lists/getbytitle('" + context.listName + "')/items(" + itemId + ")/AttachmentFiles/add(FileName='" + file.name + "')";
|
|
448
|
-
_t = context.instance;
|
|
449
|
-
_t2 = requestUrl;
|
|
450
|
-
_t3 = file;
|
|
451
|
-
_context.n = 1;
|
|
452
|
-
return fetchDigest(context.instance, context.baseURL);
|
|
453
|
-
case 1:
|
|
454
|
-
_t4 = _context.v;
|
|
455
|
-
_t5 = {
|
|
456
|
-
'X-RequestDigest': _t4
|
|
457
|
-
};
|
|
458
|
-
_context.n = 2;
|
|
459
|
-
return _t.post.call(_t, _t2, _t3, {
|
|
460
|
-
headers: _t5,
|
|
461
|
-
withCredentials: true
|
|
462
|
-
});
|
|
463
|
-
case 2:
|
|
464
|
-
response = _context.v;
|
|
465
|
-
return _context.a(2, response);
|
|
466
|
-
}
|
|
467
|
-
}, _callee);
|
|
468
|
-
}));
|
|
469
|
-
return _createAttachment.apply(this, arguments);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
function deleteItem(_x, _x2) {
|
|
473
|
-
return _deleteItem.apply(this, arguments);
|
|
474
|
-
}
|
|
475
|
-
function _deleteItem() {
|
|
476
|
-
_deleteItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, id) {
|
|
477
|
-
var response;
|
|
478
|
-
return _regenerator().w(function (_context) {
|
|
479
|
-
while (1) switch (_context.n) {
|
|
480
|
-
case 0:
|
|
481
|
-
_context.n = 1;
|
|
482
|
-
return context.instance["delete"](context.endpoint + "(" + id + ")");
|
|
483
|
-
case 1:
|
|
484
|
-
response = _context.v;
|
|
485
|
-
return _context.a(2, response);
|
|
486
|
-
}
|
|
487
|
-
}, _callee);
|
|
488
|
-
}));
|
|
489
|
-
return _deleteItem.apply(this, arguments);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function buildLibraryPath(folderPath) {
|
|
493
|
-
if (!folderPath) {
|
|
494
|
-
return '';
|
|
495
|
-
}
|
|
496
|
-
var segments = Array.isArray(folderPath) ? folderPath : folderPath.split('/').filter(Boolean);
|
|
497
|
-
if (!segments.length) {
|
|
498
|
-
return '';
|
|
499
|
-
}
|
|
500
|
-
var escapedSegments = segments.map(function (segment) {
|
|
501
|
-
if (!segment.trim()) {
|
|
502
|
-
throw new Error('Folder path segments cannot be empty.');
|
|
503
|
-
}
|
|
504
|
-
var sanitized = segment.replace(/'/g, "''");
|
|
505
|
-
return "/Folders('" + encodeURIComponent(sanitized) + "')";
|
|
506
|
-
});
|
|
507
|
-
return escapedSegments.join('');
|
|
508
|
-
}
|
|
509
|
-
function encodeFileName(fileName) {
|
|
510
|
-
if (!fileName.trim()) {
|
|
511
|
-
throw new Error('File name cannot be empty.');
|
|
512
|
-
}
|
|
513
|
-
return encodeURIComponent(fileName.replace(/'/g, "''"));
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
var SUPPORTED_VERSION = '2013';
|
|
517
|
-
function deleteFile(_x, _x2) {
|
|
518
|
-
return _deleteFile.apply(this, arguments);
|
|
519
|
-
}
|
|
520
|
-
function _deleteFile() {
|
|
521
|
-
_deleteFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, _ref) {
|
|
522
|
-
var fileName, folderPath, encodedFileName, requestUrl, digest, response;
|
|
523
|
-
return _regenerator().w(function (_context) {
|
|
524
|
-
while (1) switch (_context.n) {
|
|
525
|
-
case 0:
|
|
526
|
-
fileName = _ref.fileName, folderPath = _ref.folderPath;
|
|
527
|
-
if (!(context.sharepointVersion !== SUPPORTED_VERSION)) {
|
|
528
|
-
_context.n = 1;
|
|
529
|
-
break;
|
|
530
|
-
}
|
|
531
|
-
throw new Error('deleteFile is only supported for SharePoint 2013 REST endpoints.');
|
|
532
|
-
case 1:
|
|
533
|
-
encodedFileName = encodeFileName(fileName);
|
|
534
|
-
requestUrl = "_api/web/lists/getbytitle('" + context.listName + "')/RootFolder";
|
|
535
|
-
requestUrl += buildLibraryPath(folderPath);
|
|
536
|
-
requestUrl += "/Files('" + encodedFileName + "')";
|
|
537
|
-
_context.n = 2;
|
|
538
|
-
return fetchDigest(context.instance, context.baseURL);
|
|
539
|
-
case 2:
|
|
540
|
-
digest = _context.v;
|
|
541
|
-
_context.n = 3;
|
|
542
|
-
return context.instance.post(requestUrl, undefined, {
|
|
543
|
-
headers: {
|
|
544
|
-
'X-HTTP-Method': 'DELETE',
|
|
545
|
-
'IF-MATCH': '*',
|
|
546
|
-
'X-RequestDigest': digest
|
|
547
|
-
},
|
|
548
|
-
withCredentials: true
|
|
549
|
-
});
|
|
550
|
-
case 3:
|
|
551
|
-
response = _context.v;
|
|
552
|
-
return _context.a(2, response);
|
|
553
|
-
}
|
|
554
|
-
}, _callee);
|
|
555
|
-
}));
|
|
556
|
-
return _deleteFile.apply(this, arguments);
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
function buildODataParams(options, orderBySeparator) {
|
|
560
|
-
if (orderBySeparator === void 0) {
|
|
561
|
-
orderBySeparator = ',';
|
|
562
|
-
}
|
|
563
|
-
var _ref = options || {},
|
|
564
|
-
expand = _ref.expand,
|
|
565
|
-
orderBy = _ref.orderBy,
|
|
566
|
-
limit = _ref.limit,
|
|
567
|
-
filter = _ref.filter,
|
|
568
|
-
cols = _ref.cols,
|
|
569
|
-
skip = _ref.skip;
|
|
570
|
-
var params = {
|
|
571
|
-
$expand: Array.isArray(expand) ? expand.join(',') : expand,
|
|
572
|
-
$top: limit,
|
|
573
|
-
$skip: skip,
|
|
574
|
-
$select: Array.isArray(cols) ? cols.join(',') : cols,
|
|
575
|
-
$filter: filter,
|
|
576
|
-
$orderby: Array.isArray(orderBy) ? orderBy.join(orderBySeparator) : orderBy
|
|
577
|
-
};
|
|
578
|
-
return params;
|
|
579
|
-
}
|
|
580
|
-
function appendParamsToUrl(baseUrl, params) {
|
|
581
|
-
Object.entries(params).forEach(function (_ref2) {
|
|
582
|
-
var key = _ref2[0],
|
|
583
|
-
value = _ref2[1];
|
|
584
|
-
if (value !== undefined && value !== null) {
|
|
585
|
-
baseUrl.searchParams.append(key, String(value));
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
function getFiles(_x, _x2) {
|
|
591
|
-
return _getFiles.apply(this, arguments);
|
|
592
|
-
}
|
|
593
|
-
function _getFiles() {
|
|
594
|
-
_getFiles = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, options) {
|
|
595
|
-
var params, url, response, data, meta;
|
|
596
|
-
return _regenerator().w(function (_context) {
|
|
597
|
-
while (1) switch (_context.n) {
|
|
598
|
-
case 0:
|
|
599
|
-
params = buildODataParams(options, ',');
|
|
600
|
-
url = new URL(context.endpoint, context.instance.defaults.baseURL);
|
|
601
|
-
appendParamsToUrl(url, params);
|
|
602
|
-
_context.n = 1;
|
|
603
|
-
return context.instance.request({
|
|
604
|
-
url: context.endpoint,
|
|
605
|
-
method: 'GET',
|
|
606
|
-
params: params
|
|
607
|
-
});
|
|
608
|
-
case 1:
|
|
609
|
-
response = _context.v;
|
|
610
|
-
data = options != null && options.limit || !response.data.d.results ? response.data.d : response.data.d.results;
|
|
611
|
-
meta = {
|
|
612
|
-
url: url
|
|
613
|
-
};
|
|
614
|
-
return _context.a(2, {
|
|
615
|
-
data: data,
|
|
616
|
-
meta: meta
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
}, _callee);
|
|
620
|
-
}));
|
|
621
|
-
return _getFiles.apply(this, arguments);
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
function getListItems(_x, _x2) {
|
|
625
|
-
return _getListItems.apply(this, arguments);
|
|
626
|
-
}
|
|
627
|
-
function _getListItems() {
|
|
628
|
-
_getListItems = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, options) {
|
|
629
|
-
var _ref, _response$data$d$resu, _response$data, _response$data2;
|
|
630
|
-
var params, url, response, rawData, cols, keys, filterItem, data, meta;
|
|
631
|
-
return _regenerator().w(function (_context) {
|
|
632
|
-
while (1) switch (_context.n) {
|
|
633
|
-
case 0:
|
|
634
|
-
params = buildODataParams(options, ' ');
|
|
635
|
-
url = new URL(context.endpoint, context.instance.defaults.baseURL);
|
|
636
|
-
appendParamsToUrl(url, params);
|
|
637
|
-
_context.n = 1;
|
|
638
|
-
return context.instance.request({
|
|
639
|
-
url: context.endpoint,
|
|
640
|
-
method: 'GET',
|
|
641
|
-
params: params
|
|
642
|
-
});
|
|
643
|
-
case 1:
|
|
644
|
-
response = _context.v;
|
|
645
|
-
rawData = (_ref = (_response$data$d$resu = (_response$data = response.data) == null || (_response$data = _response$data.d) == null ? void 0 : _response$data.results) != null ? _response$data$d$resu : (_response$data2 = response.data) == null ? void 0 : _response$data2.d) != null ? _ref : response.data;
|
|
646
|
-
cols = options == null ? void 0 : options.cols;
|
|
647
|
-
keys = cols ? (Array.isArray(cols) ? cols : [cols]).filter(Boolean) : undefined;
|
|
648
|
-
filterItem = function filterItem(item) {
|
|
649
|
-
if (!keys || !item || typeof item !== 'object') {
|
|
650
|
-
return item;
|
|
651
|
-
}
|
|
652
|
-
return keys.reduce(function (acc, key) {
|
|
653
|
-
if (key in item) {
|
|
654
|
-
acc[key] = item[key];
|
|
655
|
-
}
|
|
656
|
-
return acc;
|
|
657
|
-
}, {});
|
|
658
|
-
};
|
|
659
|
-
data = Array.isArray(rawData) ? rawData.map(filterItem) : filterItem(rawData);
|
|
660
|
-
meta = {
|
|
661
|
-
url: url
|
|
662
|
-
};
|
|
663
|
-
return _context.a(2, {
|
|
664
|
-
data: data,
|
|
665
|
-
meta: meta
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
}, _callee);
|
|
669
|
-
}));
|
|
670
|
-
return _getListItems.apply(this, arguments);
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
function getOnly(_x, _x2, _x3) {
|
|
674
|
-
return _getOnly.apply(this, arguments);
|
|
675
|
-
}
|
|
676
|
-
function _getOnly() {
|
|
677
|
-
_getOnly = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(instance, endpoint, options) {
|
|
678
|
-
var params, _yield$instance$get, data;
|
|
679
|
-
return _regenerator().w(function (_context) {
|
|
680
|
-
while (1) switch (_context.n) {
|
|
681
|
-
case 0:
|
|
682
|
-
params = buildODataParams(options, ',');
|
|
683
|
-
_context.n = 1;
|
|
684
|
-
return instance.get(endpoint, {
|
|
685
|
-
params: params
|
|
686
|
-
});
|
|
687
|
-
case 1:
|
|
688
|
-
_yield$instance$get = _context.v;
|
|
689
|
-
data = _yield$instance$get.data;
|
|
690
|
-
if (!data) {
|
|
691
|
-
_context.n = 2;
|
|
692
|
-
break;
|
|
693
|
-
}
|
|
694
|
-
return _context.a(2, data.d.results ? data.d.results : data.d);
|
|
695
|
-
case 2:
|
|
696
|
-
return _context.a(2);
|
|
697
|
-
}
|
|
698
|
-
}, _callee);
|
|
699
|
-
}));
|
|
700
|
-
return _getOnly.apply(this, arguments);
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
function resolveMetadataType$1(_x) {
|
|
704
|
-
return _resolveMetadataType$1.apply(this, arguments);
|
|
705
|
-
}
|
|
706
|
-
function _resolveMetadataType$1() {
|
|
707
|
-
_resolveMetadataType$1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context) {
|
|
708
|
-
return _regenerator().w(function (_context) {
|
|
709
|
-
while (1) switch (_context.n) {
|
|
710
|
-
case 0:
|
|
711
|
-
if (!context.resolveListItemEntityType) {
|
|
712
|
-
_context.n = 1;
|
|
713
|
-
break;
|
|
714
|
-
}
|
|
715
|
-
return _context.a(2, context.resolveListItemEntityType());
|
|
716
|
-
case 1:
|
|
717
|
-
if (!context.listItemEntityTypeFullName) {
|
|
718
|
-
_context.n = 2;
|
|
719
|
-
break;
|
|
720
|
-
}
|
|
721
|
-
return _context.a(2, context.listItemEntityTypeFullName);
|
|
722
|
-
case 2:
|
|
723
|
-
return _context.a(2, "SP.Data." + context.listName + "ListItem");
|
|
724
|
-
}
|
|
725
|
-
}, _callee);
|
|
726
|
-
}));
|
|
727
|
-
return _resolveMetadataType$1.apply(this, arguments);
|
|
728
|
-
}
|
|
729
|
-
function updateListItem(_x2, _x3, _x4, _x5) {
|
|
730
|
-
return _updateListItem.apply(this, arguments);
|
|
731
|
-
}
|
|
732
|
-
function _updateListItem() {
|
|
733
|
-
_updateListItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(context, id, data, digest) {
|
|
734
|
-
var formDigestValue, metadataType, normalizedData, userMetadata, payload, url, response, _t;
|
|
735
|
-
return _regenerator().w(function (_context2) {
|
|
736
|
-
while (1) switch (_context2.n) {
|
|
737
|
-
case 0:
|
|
738
|
-
_t = digest;
|
|
739
|
-
if (_t) {
|
|
740
|
-
_context2.n = 2;
|
|
741
|
-
break;
|
|
742
|
-
}
|
|
743
|
-
_context2.n = 1;
|
|
744
|
-
return fetchDigest(context.instance, context.baseURL);
|
|
745
|
-
case 1:
|
|
746
|
-
_t = _context2.v;
|
|
747
|
-
case 2:
|
|
748
|
-
formDigestValue = _t;
|
|
749
|
-
_context2.n = 3;
|
|
750
|
-
return resolveMetadataType$1(context);
|
|
751
|
-
case 3:
|
|
752
|
-
metadataType = _context2.v;
|
|
753
|
-
normalizedData = normalizeListPayload(data);
|
|
754
|
-
userMetadata = data.__metadata;
|
|
755
|
-
payload = _extends({}, normalizedData, {
|
|
756
|
-
__metadata: _extends({}, userMetadata && typeof userMetadata === 'object' ? userMetadata : {}, {
|
|
757
|
-
type: metadataType
|
|
758
|
-
})
|
|
759
|
-
});
|
|
760
|
-
url = "_api/lists/getbytitle('" + context.listName + "')/getItemById('" + id + "')";
|
|
761
|
-
_context2.n = 4;
|
|
762
|
-
return context.instance({
|
|
763
|
-
url: url,
|
|
764
|
-
method: 'POST',
|
|
765
|
-
data: JSON.stringify(payload),
|
|
766
|
-
headers: {
|
|
767
|
-
'X-RequestDigest': formDigestValue,
|
|
768
|
-
'IF-MATCH': '*',
|
|
769
|
-
'X-Http-Method': 'PATCH'
|
|
770
|
-
}
|
|
771
|
-
});
|
|
772
|
-
case 4:
|
|
773
|
-
response = _context2.v;
|
|
774
|
-
return _context2.a(2, response);
|
|
775
|
-
}
|
|
776
|
-
}, _callee2);
|
|
777
|
-
}));
|
|
778
|
-
return _updateListItem.apply(this, arguments);
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
var SUPPORTED_VERSION$1 = '2013';
|
|
782
|
-
function uploadFile(_x, _x2) {
|
|
783
|
-
return _uploadFile.apply(this, arguments);
|
|
784
|
-
}
|
|
785
|
-
function _uploadFile() {
|
|
786
|
-
_uploadFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, _ref) {
|
|
787
|
-
var _response$data$d, _response$data, _ref2, _ref3, _listItemFields$Id, _listItemFields$__def;
|
|
788
|
-
var file, folderPath, _ref$overwrite, overwrite, requestUrl, encodedFileName, digest, response, responseData, listItemFields, itemId, _listItemResponse$dat, _listItemResponse$dat2, _listItemResponse$dat3, listItemResponse, deferredId;
|
|
789
|
-
return _regenerator().w(function (_context) {
|
|
790
|
-
while (1) switch (_context.n) {
|
|
791
|
-
case 0:
|
|
792
|
-
file = _ref.file, folderPath = _ref.folderPath, _ref$overwrite = _ref.overwrite, overwrite = _ref$overwrite === void 0 ? true : _ref$overwrite;
|
|
793
|
-
if (!(context.sharepointVersion !== SUPPORTED_VERSION$1)) {
|
|
794
|
-
_context.n = 1;
|
|
795
|
-
break;
|
|
796
|
-
}
|
|
797
|
-
throw new Error('uploadFile is only supported for SharePoint 2013 REST endpoints.');
|
|
798
|
-
case 1:
|
|
799
|
-
if (file != null && file.name) {
|
|
800
|
-
_context.n = 2;
|
|
801
|
-
break;
|
|
802
|
-
}
|
|
803
|
-
throw new Error('A file with a valid name must be provided.');
|
|
804
|
-
case 2:
|
|
805
|
-
requestUrl = "_api/web/lists/getbytitle('" + context.listName + "')/RootFolder";
|
|
806
|
-
requestUrl += buildLibraryPath(folderPath);
|
|
807
|
-
encodedFileName = encodeFileName(file.name);
|
|
808
|
-
requestUrl += "/Files/add(url='" + encodedFileName + "',overwrite=" + (overwrite ? 'true' : 'false') + ")?$expand=ListItemAllFields&$select=ListItemAllFields/Id";
|
|
809
|
-
_context.n = 3;
|
|
810
|
-
return fetchDigest(context.instance, context.baseURL);
|
|
811
|
-
case 3:
|
|
812
|
-
digest = _context.v;
|
|
813
|
-
_context.n = 4;
|
|
814
|
-
return context.instance.post(requestUrl, file, {
|
|
815
|
-
headers: {
|
|
816
|
-
'Content-Type': file.type || 'application/octet-stream',
|
|
817
|
-
'X-RequestDigest': digest
|
|
818
|
-
},
|
|
819
|
-
withCredentials: true
|
|
820
|
-
});
|
|
821
|
-
case 4:
|
|
822
|
-
response = _context.v;
|
|
823
|
-
responseData = (_response$data$d = (_response$data = response.data) == null ? void 0 : _response$data.d) != null ? _response$data$d : response.data;
|
|
824
|
-
listItemFields = responseData == null ? void 0 : responseData.ListItemAllFields;
|
|
825
|
-
itemId = (_ref2 = (_ref3 = (_listItemFields$Id = listItemFields == null ? void 0 : listItemFields.Id) != null ? _listItemFields$Id : listItemFields == null ? void 0 : listItemFields.ID) != null ? _ref3 : responseData == null ? void 0 : responseData.Id) != null ? _ref2 : responseData == null ? void 0 : responseData.ID;
|
|
826
|
-
if (!(typeof itemId !== 'undefined')) {
|
|
827
|
-
_context.n = 5;
|
|
828
|
-
break;
|
|
829
|
-
}
|
|
830
|
-
response.itemId = itemId;
|
|
831
|
-
_context.n = 7;
|
|
832
|
-
break;
|
|
833
|
-
case 5:
|
|
834
|
-
if (!(listItemFields != null && (_listItemFields$__def = listItemFields.__deferred) != null && _listItemFields$__def.uri)) {
|
|
835
|
-
_context.n = 7;
|
|
836
|
-
break;
|
|
837
|
-
}
|
|
838
|
-
_context.n = 6;
|
|
839
|
-
return context.instance.get(listItemFields.__deferred.uri);
|
|
840
|
-
case 6:
|
|
841
|
-
listItemResponse = _context.v;
|
|
842
|
-
deferredId = (_listItemResponse$dat = (_listItemResponse$dat2 = listItemResponse.data) == null || (_listItemResponse$dat2 = _listItemResponse$dat2.d) == null ? void 0 : _listItemResponse$dat2.Id) != null ? _listItemResponse$dat : (_listItemResponse$dat3 = listItemResponse.data) == null ? void 0 : _listItemResponse$dat3.Id;
|
|
843
|
-
if (typeof deferredId !== 'undefined') {
|
|
844
|
-
response.itemId = deferredId;
|
|
845
|
-
}
|
|
846
|
-
case 7:
|
|
847
|
-
return _context.a(2, response);
|
|
848
|
-
}
|
|
849
|
-
}, _callee);
|
|
850
|
-
}));
|
|
851
|
-
return _uploadFile.apply(this, arguments);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
function sendEmail(_x, _x2) {
|
|
855
|
-
return _sendEmail.apply(this, arguments);
|
|
856
|
-
}
|
|
857
|
-
function _sendEmail() {
|
|
858
|
-
_sendEmail = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, _ref) {
|
|
859
|
-
var From, To, Subject, Body, httpRequest, response, _t, _t2, _t3, _t4, _t5;
|
|
860
|
-
return _regenerator().w(function (_context) {
|
|
861
|
-
while (1) switch (_context.n) {
|
|
862
|
-
case 0:
|
|
863
|
-
From = _ref.From, To = _ref.To, Subject = _ref.Subject, Body = _ref.Body;
|
|
864
|
-
httpRequest = '_api/SP.Utilities.Utility.SendEmail';
|
|
865
|
-
_t = context;
|
|
866
|
-
_t2 = httpRequest;
|
|
867
|
-
_context.n = 1;
|
|
868
|
-
return fetchDigest(context.instance, context.baseURL);
|
|
869
|
-
case 1:
|
|
870
|
-
_t3 = _context.v;
|
|
871
|
-
_t4 = {
|
|
872
|
-
'X-RequestDigest': _t3,
|
|
873
|
-
'X-Http-Method': 'POST',
|
|
874
|
-
'Content-Type': 'application/json;odata=verbose'
|
|
875
|
-
};
|
|
876
|
-
_t5 = JSON.stringify({
|
|
877
|
-
properties: {
|
|
878
|
-
__metadata: {
|
|
879
|
-
type: 'SP.Utilities.EmailProperties'
|
|
880
|
-
},
|
|
881
|
-
From: From,
|
|
882
|
-
To: {
|
|
883
|
-
results: Array.isArray(To) ? To : [To]
|
|
884
|
-
},
|
|
885
|
-
Body: Body,
|
|
886
|
-
Subject: Subject
|
|
887
|
-
}
|
|
888
|
-
});
|
|
889
|
-
_context.n = 2;
|
|
890
|
-
return _t.instance.call(_t, {
|
|
891
|
-
url: _t2,
|
|
892
|
-
method: 'POST',
|
|
893
|
-
headers: _t4,
|
|
894
|
-
data: _t5
|
|
895
|
-
});
|
|
896
|
-
case 2:
|
|
897
|
-
response = _context.v;
|
|
898
|
-
return _context.a(2, response);
|
|
899
|
-
}
|
|
900
|
-
}, _callee);
|
|
901
|
-
}));
|
|
902
|
-
return _sendEmail.apply(this, arguments);
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
function typeAhead(_x, _x2, _x3) {
|
|
906
|
-
return _typeAhead.apply(this, arguments);
|
|
907
|
-
}
|
|
908
|
-
function _typeAhead() {
|
|
909
|
-
_typeAhead = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(instance, input, filter) {
|
|
910
|
-
var requestUrl, data, response;
|
|
911
|
-
return _regenerator().w(function (_context) {
|
|
912
|
-
while (1) switch (_context.n) {
|
|
913
|
-
case 0:
|
|
914
|
-
requestUrl = "_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUser";
|
|
915
|
-
data = {
|
|
916
|
-
queryParams: {
|
|
917
|
-
__metadata: {
|
|
918
|
-
type: 'SP.UI.ApplicationPages.ClientPeoplePickerQueryParameters'
|
|
919
|
-
},
|
|
920
|
-
AllowEmailAddresses: true,
|
|
921
|
-
AllowMultipleEntities: false,
|
|
922
|
-
AllUrlZones: false,
|
|
923
|
-
MaximumEntitySuggestions: 10,
|
|
924
|
-
PrincipalSource: 15,
|
|
925
|
-
PrincipalType: 1,
|
|
926
|
-
QueryString: input
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
if (filter) {
|
|
930
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
931
|
-
data.queryParams.RequiredProperties = [filter];
|
|
932
|
-
}
|
|
933
|
-
_context.n = 1;
|
|
934
|
-
return instance.post(requestUrl, JSON.stringify(data), {
|
|
935
|
-
headers: {
|
|
936
|
-
Accept: 'application/json; odata=verbose',
|
|
937
|
-
'Content-Type': 'application/json;odata=verbose'
|
|
938
|
-
}
|
|
939
|
-
});
|
|
940
|
-
case 1:
|
|
941
|
-
response = _context.v;
|
|
942
|
-
return _context.a(2, response.data.d.ClientPeoplePickerSearchUser);
|
|
943
|
-
}
|
|
944
|
-
}, _callee);
|
|
945
|
-
}));
|
|
946
|
-
return _typeAhead.apply(this, arguments);
|
|
947
|
-
}
|
|
948
|
-
function currentUserProperties(_x4) {
|
|
949
|
-
return _currentUserProperties.apply(this, arguments);
|
|
950
|
-
}
|
|
951
|
-
function _currentUserProperties() {
|
|
952
|
-
_currentUserProperties = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(instance) {
|
|
953
|
-
var requestUrl, profile;
|
|
954
|
-
return _regenerator().w(function (_context2) {
|
|
955
|
-
while (1) switch (_context2.n) {
|
|
956
|
-
case 0:
|
|
957
|
-
requestUrl = '_api/sp.userprofiles.peoplemanager/getmyproperties';
|
|
958
|
-
_context2.n = 1;
|
|
959
|
-
return instance.get(requestUrl);
|
|
960
|
-
case 1:
|
|
961
|
-
profile = _context2.v;
|
|
962
|
-
profile = profile.data.d;
|
|
963
|
-
profile.UserProfileProperties.results.forEach(function (prop) {
|
|
964
|
-
if (prop.Key === 'FirstName') {
|
|
965
|
-
profile.FirstName = prop.Value;
|
|
966
|
-
}
|
|
967
|
-
if (prop.Key === 'LastName') {
|
|
968
|
-
profile.LastName = prop.Value;
|
|
969
|
-
}
|
|
970
|
-
if (prop.Key === 'Country') {
|
|
971
|
-
profile.Country = prop.Value;
|
|
972
|
-
}
|
|
973
|
-
if (prop.Key === 'UserName') {
|
|
974
|
-
profile.UserName = prop.Value;
|
|
975
|
-
}
|
|
976
|
-
});
|
|
977
|
-
return _context2.a(2, profile);
|
|
978
|
-
}
|
|
979
|
-
}, _callee2);
|
|
980
|
-
}));
|
|
981
|
-
return _currentUserProperties.apply(this, arguments);
|
|
982
|
-
}
|
|
983
|
-
function getSiteUser(_x5, _x6) {
|
|
984
|
-
return _getSiteUser.apply(this, arguments);
|
|
985
|
-
}
|
|
986
|
-
function _getSiteUser() {
|
|
987
|
-
_getSiteUser = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(instance, searchValue) {
|
|
988
|
-
var requestUrl, response;
|
|
989
|
-
return _regenerator().w(function (_context3) {
|
|
990
|
-
while (1) switch (_context3.n) {
|
|
991
|
-
case 0:
|
|
992
|
-
requestUrl = "_api/web/siteusers?&$filter=substringof('" + searchValue + "', Title) or substringof('" + searchValue + "', LoginName) or substringof('" + searchValue + "', Email)&$top=50&$expand=Groups";
|
|
993
|
-
_context3.n = 1;
|
|
994
|
-
return instance.get(requestUrl);
|
|
995
|
-
case 1:
|
|
996
|
-
response = _context3.v;
|
|
997
|
-
return _context3.a(2, response.data.d);
|
|
998
|
-
}
|
|
999
|
-
}, _callee3);
|
|
1000
|
-
}));
|
|
1001
|
-
return _getSiteUser.apply(this, arguments);
|
|
1002
|
-
}
|
|
1003
|
-
function roleDefinitions(_x7) {
|
|
1004
|
-
return _roleDefinitions.apply(this, arguments);
|
|
1005
|
-
}
|
|
1006
|
-
function _roleDefinitions() {
|
|
1007
|
-
_roleDefinitions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(instance) {
|
|
1008
|
-
var requestUrl, response;
|
|
1009
|
-
return _regenerator().w(function (_context4) {
|
|
1010
|
-
while (1) switch (_context4.n) {
|
|
1011
|
-
case 0:
|
|
1012
|
-
requestUrl = "_api/Web/RoleDefinitions";
|
|
1013
|
-
_context4.n = 1;
|
|
1014
|
-
return instance.get(requestUrl);
|
|
1015
|
-
case 1:
|
|
1016
|
-
response = _context4.v;
|
|
1017
|
-
return _context4.a(2, response.data.d.results);
|
|
1018
|
-
}
|
|
1019
|
-
}, _callee4);
|
|
1020
|
-
}));
|
|
1021
|
-
return _roleDefinitions.apply(this, arguments);
|
|
1022
|
-
}
|
|
1023
|
-
function getEffectiveBasePermissions(_x8) {
|
|
1024
|
-
return _getEffectiveBasePermissions.apply(this, arguments);
|
|
1025
|
-
}
|
|
1026
|
-
function _getEffectiveBasePermissions() {
|
|
1027
|
-
_getEffectiveBasePermissions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(instance) {
|
|
1028
|
-
var requestUrl, response;
|
|
1029
|
-
return _regenerator().w(function (_context5) {
|
|
1030
|
-
while (1) switch (_context5.n) {
|
|
1031
|
-
case 0:
|
|
1032
|
-
requestUrl = "_api/Web/effectiveBasePermissions";
|
|
1033
|
-
_context5.n = 1;
|
|
1034
|
-
return instance.get(requestUrl);
|
|
1035
|
-
case 1:
|
|
1036
|
-
response = _context5.v;
|
|
1037
|
-
return _context5.a(2, response.data.d.EffectiveBasePermissions);
|
|
1038
|
-
}
|
|
1039
|
-
}, _callee5);
|
|
1040
|
-
}));
|
|
1041
|
-
return _getEffectiveBasePermissions.apply(this, arguments);
|
|
1042
|
-
}
|
|
1043
|
-
function currentUserPermissions(_x9) {
|
|
1044
|
-
return _currentUserPermissions.apply(this, arguments);
|
|
1045
|
-
}
|
|
1046
|
-
function _currentUserPermissions() {
|
|
1047
|
-
_currentUserPermissions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(context) {
|
|
1048
|
-
var _yield$getEffectiveBa, High, definitions, result;
|
|
1049
|
-
return _regenerator().w(function (_context6) {
|
|
1050
|
-
while (1) switch (_context6.n) {
|
|
1051
|
-
case 0:
|
|
1052
|
-
_context6.n = 1;
|
|
1053
|
-
return getEffectiveBasePermissions(context.instance);
|
|
1054
|
-
case 1:
|
|
1055
|
-
_yield$getEffectiveBa = _context6.v;
|
|
1056
|
-
High = _yield$getEffectiveBa.High;
|
|
1057
|
-
_context6.n = 2;
|
|
1058
|
-
return roleDefinitions(context.instance);
|
|
1059
|
-
case 2:
|
|
1060
|
-
definitions = _context6.v;
|
|
1061
|
-
result = definitions.find(function (_ref) {
|
|
1062
|
-
var BasePermissions = _ref.BasePermissions;
|
|
1063
|
-
return BasePermissions.High === High;
|
|
1064
|
-
});
|
|
1065
|
-
return _context6.a(2, result);
|
|
1066
|
-
}
|
|
1067
|
-
}, _callee6);
|
|
1068
|
-
}));
|
|
1069
|
-
return _currentUserPermissions.apply(this, arguments);
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
var HTTPSharePointRequests = /*#__PURE__*/function () {
|
|
1073
|
-
function HTTPSharePointRequests(baseURL, config) {
|
|
1074
|
-
var _this = this;
|
|
1075
|
-
this.baseURL = void 0;
|
|
1076
|
-
this.endpoint = void 0;
|
|
1077
|
-
this.listName = void 0;
|
|
1078
|
-
this.instance = void 0;
|
|
1079
|
-
this.sharepointVersion = void 0;
|
|
1080
|
-
this.listItemEntityTypeFullName = void 0;
|
|
1081
|
-
this.lists = {
|
|
1082
|
-
get: function get() {
|
|
1083
|
-
_this.endpoint = '_api/web/lists';
|
|
1084
|
-
_this.sharepointVersion = '2013';
|
|
1085
|
-
return getListItems(_this.getContext());
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
this.folders = {
|
|
1089
|
-
get: function get() {
|
|
1090
|
-
_this.endpoint = '_api/web/folders';
|
|
1091
|
-
_this.sharepointVersion = '2013';
|
|
1092
|
-
getListItems(_this.getContext());
|
|
1093
|
-
}
|
|
1094
|
-
};
|
|
1095
|
-
this.email = {
|
|
1096
|
-
send: function send(props) {
|
|
1097
|
-
_this.sharepointVersion = '2013';
|
|
1098
|
-
return sendEmail(_this.getContext(), props);
|
|
1099
|
-
}
|
|
1100
|
-
};
|
|
1101
|
-
this.user = {
|
|
1102
|
-
properties: function properties() {
|
|
1103
|
-
return {
|
|
1104
|
-
get: function get() {
|
|
1105
|
-
_this.sharepointVersion = '2013';
|
|
1106
|
-
return currentUserProperties(_this.instance);
|
|
1107
|
-
}
|
|
1108
|
-
};
|
|
1109
|
-
},
|
|
1110
|
-
searchSiteUser: function searchSiteUser(searchValue) {
|
|
1111
|
-
_this.sharepointVersion = '2013';
|
|
1112
|
-
return getSiteUser(_this.instance, searchValue);
|
|
1113
|
-
},
|
|
1114
|
-
searchUser: function searchUser(input, filter) {
|
|
1115
|
-
_this.sharepointVersion = '2013';
|
|
1116
|
-
return typeAhead(_this.instance, input, filter);
|
|
1117
|
-
},
|
|
1118
|
-
current: function current() {
|
|
1119
|
-
_this.endpoint = '_api/web/currentUser';
|
|
1120
|
-
_this.sharepointVersion = '2013';
|
|
1121
|
-
return {
|
|
1122
|
-
get: function get() {
|
|
1123
|
-
return getOnly(_this.instance, _this.endpoint);
|
|
1124
|
-
}
|
|
1125
|
-
};
|
|
1126
|
-
},
|
|
1127
|
-
currentPermission: function currentPermission() {
|
|
1128
|
-
return {
|
|
1129
|
-
get: function get() {
|
|
1130
|
-
_this.sharepointVersion = '2013';
|
|
1131
|
-
return currentUserPermissions(_this.getContext());
|
|
1132
|
-
}
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
};
|
|
1136
|
-
this.baseURL = baseURL.endsWith('/') ? baseURL : baseURL + "/";
|
|
1137
|
-
this.endpoint = '/api';
|
|
1138
|
-
this.listName = '';
|
|
1139
|
-
this.instance = instance(this.baseURL, config);
|
|
1140
|
-
this.sharepointVersion = '2013';
|
|
1141
|
-
this.listItemEntityTypeFullName = undefined;
|
|
1142
|
-
}
|
|
1143
|
-
var _proto = HTTPSharePointRequests.prototype;
|
|
1144
|
-
_proto.getContext = function getContext() {
|
|
1145
|
-
return {
|
|
1146
|
-
instance: this.instance,
|
|
1147
|
-
baseURL: this.baseURL,
|
|
1148
|
-
endpoint: this.endpoint,
|
|
1149
|
-
listName: this.listName,
|
|
1150
|
-
sharepointVersion: this.sharepointVersion,
|
|
1151
|
-
listItemEntityTypeFullName: this.listItemEntityTypeFullName,
|
|
1152
|
-
resolveListItemEntityType: this.resolveListItemEntityTypeFullName.bind(this)
|
|
1153
|
-
};
|
|
1154
|
-
};
|
|
1155
|
-
_proto.resolveListItemEntityTypeFullName = /*#__PURE__*/function () {
|
|
1156
|
-
var _resolveListItemEntityTypeFullName = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
1157
|
-
var _response$data$d$List, _response$data, _response$data2;
|
|
1158
|
-
var response, entityType;
|
|
1159
|
-
return _regenerator().w(function (_context) {
|
|
1160
|
-
while (1) switch (_context.n) {
|
|
1161
|
-
case 0:
|
|
1162
|
-
if (!this.listItemEntityTypeFullName) {
|
|
1163
|
-
_context.n = 1;
|
|
1164
|
-
break;
|
|
1165
|
-
}
|
|
1166
|
-
return _context.a(2, this.listItemEntityTypeFullName);
|
|
1167
|
-
case 1:
|
|
1168
|
-
if (this.listName) {
|
|
1169
|
-
_context.n = 2;
|
|
1170
|
-
break;
|
|
1171
|
-
}
|
|
1172
|
-
throw new Error('List name is not set.');
|
|
1173
|
-
case 2:
|
|
1174
|
-
if (!(this.sharepointVersion !== '2013')) {
|
|
1175
|
-
_context.n = 3;
|
|
1176
|
-
break;
|
|
1177
|
-
}
|
|
1178
|
-
this.listItemEntityTypeFullName = "SP.Data." + this.listName + "ListItem";
|
|
1179
|
-
return _context.a(2, this.listItemEntityTypeFullName);
|
|
1180
|
-
case 3:
|
|
1181
|
-
_context.n = 4;
|
|
1182
|
-
return this.instance.get("_api/web/lists/GetByTitle('" + this.listName + "')?$select=ListItemEntityTypeFullName");
|
|
1183
|
-
case 4:
|
|
1184
|
-
response = _context.v;
|
|
1185
|
-
entityType = (_response$data$d$List = (_response$data = response.data) == null || (_response$data = _response$data.d) == null ? void 0 : _response$data.ListItemEntityTypeFullName) != null ? _response$data$d$List : (_response$data2 = response.data) == null ? void 0 : _response$data2.ListItemEntityTypeFullName;
|
|
1186
|
-
if (!(!entityType || typeof entityType !== 'string')) {
|
|
1187
|
-
_context.n = 5;
|
|
1188
|
-
break;
|
|
1189
|
-
}
|
|
1190
|
-
throw new Error("Unable to resolve ListItemEntityTypeFullName for list \"" + this.listName + "\".");
|
|
1191
|
-
case 5:
|
|
1192
|
-
this.listItemEntityTypeFullName = entityType;
|
|
1193
|
-
return _context.a(2, this.listItemEntityTypeFullName);
|
|
1194
|
-
}
|
|
1195
|
-
}, _callee, this);
|
|
1196
|
-
}));
|
|
1197
|
-
function resolveListItemEntityTypeFullName() {
|
|
1198
|
-
return _resolveListItemEntityTypeFullName.apply(this, arguments);
|
|
1199
|
-
}
|
|
1200
|
-
return resolveListItemEntityTypeFullName;
|
|
1201
|
-
}()
|
|
1202
|
-
/**
|
|
1203
|
-
* @deprecated Use `from` instead.
|
|
1204
|
-
*/
|
|
1205
|
-
;
|
|
1206
|
-
_proto.list = function list(listName) {
|
|
1207
|
-
this.listName = listName;
|
|
1208
|
-
this.endpoint = "_vti_bin/ListData.svc/" + listName;
|
|
1209
|
-
this.sharepointVersion = '2010';
|
|
1210
|
-
this.listItemEntityTypeFullName = undefined;
|
|
1211
|
-
return this;
|
|
1212
|
-
};
|
|
1213
|
-
_proto.getDigest = function getDigest() {
|
|
1214
|
-
return fetchDigest(this.instance, this.baseURL);
|
|
1215
|
-
};
|
|
1216
|
-
_proto.from = function from(listName, sharepoint_ver) {
|
|
1217
|
-
var _this2 = this;
|
|
1218
|
-
var version = sharepoint_ver != null ? sharepoint_ver : '2013';
|
|
1219
|
-
this.listName = listName;
|
|
1220
|
-
this.sharepointVersion = version;
|
|
1221
|
-
this.listItemEntityTypeFullName = undefined;
|
|
1222
|
-
this.endpoint = version === '2013' ? "_api/web/lists/GetByTitle('" + this.listName + "')/items" : "_vti_bin/ListData.svc/" + listName;
|
|
1223
|
-
var getContext = function getContext() {
|
|
1224
|
-
return _this2.getContext();
|
|
1225
|
-
};
|
|
1226
|
-
return {
|
|
1227
|
-
create: function create(data) {
|
|
1228
|
-
return createListItem(getContext(), data);
|
|
1229
|
-
},
|
|
1230
|
-
get: function get(options) {
|
|
1231
|
-
return getListItems(getContext(), options);
|
|
1232
|
-
},
|
|
1233
|
-
update: function update(id, data, digest) {
|
|
1234
|
-
return updateListItem(getContext(), id, data, digest);
|
|
1235
|
-
},
|
|
1236
|
-
"delete": function _delete(id) {
|
|
1237
|
-
return deleteItem(getContext(), id);
|
|
1238
|
-
},
|
|
1239
|
-
createFile: function createFile(props) {
|
|
1240
|
-
return createAttachment(getContext(), props);
|
|
1241
|
-
},
|
|
1242
|
-
uploadFile: function uploadFile$1(props) {
|
|
1243
|
-
return uploadFile(getContext(), props);
|
|
1244
|
-
},
|
|
1245
|
-
deleteFile: function deleteFile$1(props) {
|
|
1246
|
-
return deleteFile(getContext(), props);
|
|
1247
|
-
},
|
|
1248
|
-
fields: function fields(options) {
|
|
1249
|
-
_this2.endpoint = !(options != null && options.fieldName) ? "_api/web/lists/GetByTitle('" + _this2.listName + "')/fields" : "_api/web/lists/GetByTitle('" + _this2.listName + "')/fields/getbytitle('" + options.fieldName + "')";
|
|
1250
|
-
return {
|
|
1251
|
-
get: function get() {
|
|
1252
|
-
return getOnly(_this2.instance, _this2.endpoint, options);
|
|
1253
|
-
}
|
|
1254
|
-
};
|
|
1255
|
-
}
|
|
1256
|
-
};
|
|
1257
|
-
};
|
|
1258
|
-
_proto.folder = function folder(folderName) {
|
|
1259
|
-
var _this3 = this;
|
|
1260
|
-
var filePath = ['Shared Documents'];
|
|
1261
|
-
if (folderName) {
|
|
1262
|
-
filePath = Array.isArray(folderName) ? [].concat(filePath, folderName) : [].concat(filePath, [folderName]);
|
|
1263
|
-
}
|
|
1264
|
-
this.endpoint = "_api/web/GetFolderByServerRelativeUrl('" + filePath.join('/') + "')";
|
|
1265
|
-
this.sharepointVersion = '2013';
|
|
1266
|
-
var getContext = function getContext() {
|
|
1267
|
-
return _this3.getContext();
|
|
1268
|
-
};
|
|
1269
|
-
return {
|
|
1270
|
-
get: function get(options) {
|
|
1271
|
-
if (!(options != null && options.type)) {
|
|
1272
|
-
_this3.endpoint += '/Files';
|
|
1273
|
-
} else {
|
|
1274
|
-
_this3.endpoint += "/" + options.type;
|
|
1275
|
-
}
|
|
1276
|
-
return getFiles(getContext(), options);
|
|
1277
|
-
}
|
|
1278
|
-
};
|
|
1279
|
-
};
|
|
1280
|
-
_proto.users = function users(options) {
|
|
1281
|
-
var _this4 = this;
|
|
1282
|
-
this.endpoint = '_api/web/SiteUserInfoList/items';
|
|
1283
|
-
this.sharepointVersion = '2013';
|
|
1284
|
-
return {
|
|
1285
|
-
get: function get() {
|
|
1286
|
-
return getListItems(_this4.getContext(), options);
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
};
|
|
1290
|
-
return HTTPSharePointRequests;
|
|
1291
|
-
}();
|
|
1292
|
-
|
|
1293
|
-
// Load environment variables from .env file
|
|
1294
|
-
function createBase() {
|
|
1295
|
-
function create(_ref) {
|
|
1296
|
-
var baseURL = _ref.baseURL,
|
|
1297
|
-
config = _ref.config;
|
|
1298
|
-
if (!baseURL) {
|
|
1299
|
-
throw new Error('A valid SharePoint URL must be provided.');
|
|
1300
|
-
}
|
|
1301
|
-
return new HTTPSharePointRequests(baseURL, config);
|
|
1302
|
-
}
|
|
1303
|
-
return {
|
|
1304
|
-
/**
|
|
1305
|
-
* @deprecated Use `create` instead.
|
|
1306
|
-
*/
|
|
1307
|
-
baseURL: function baseURL(url, config) {
|
|
1308
|
-
return create({
|
|
1309
|
-
baseURL: url,
|
|
1310
|
-
config: config
|
|
1311
|
-
});
|
|
1312
|
-
},
|
|
1313
|
-
create: create
|
|
1314
|
-
};
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
export default createBase;
|
|
1318
|
-
//# sourceMappingURL=sharepoint_requests.esm.js.map
|