chunk-UILPRJKY.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import {
  2. U
  3. } from "./chunk-VNFRAYHO.js";
  4. import {
  5. G,
  6. kt
  7. } from "./chunk-VBRY5KJM.js";
  8. import {
  9. s3 as s
  10. } from "./chunk-EMJ4ZSM2.js";
  11. import {
  12. m,
  13. r,
  14. t
  15. } from "./chunk-GZT4BVFP.js";
  16. // node_modules/@arcgis/core/portal/support/resourceUtils.js
  17. async function c(e, t2 = {}, a) {
  18. await e.load(a);
  19. const o = G(e.itemUrl, "resources"), { start: n = 1, num: c2 = 10, sortOrder: u2 = "asc", sortField: i2 = "created" } = t2, l2 = { query: { start: n, num: c2, sortOrder: u2, sortField: i2, token: e.apiKey }, signal: m(a, "signal") }, p2 = await e.portal._request(o, l2);
  20. return { total: p2.total, nextStart: p2.nextStart, resources: p2.resources.map(({ created: t3, size: r2, resource: a2 }) => ({ created: new Date(t3), size: r2, resource: e.resourceFromPath(a2) })) };
  21. }
  22. async function u(e, o, n, c2) {
  23. if (!e.hasPath())
  24. throw new s(`portal-item-resource-${o}:invalid-path`, "Resource does not have a valid path");
  25. const u2 = e.portalItem;
  26. await u2.load(c2);
  27. const i2 = G(u2.userItemUrl, o === "add" ? "addResources" : "updateResources"), [l2, d2] = p(e.path), m3 = await h(n), f2 = new FormData();
  28. return l2 && l2 !== "." && f2.append("resourcesPrefix", l2), f2.append("fileName", d2), f2.append("file", m3, d2), f2.append("f", "json"), r(c2) && c2.access && f2.append("access", c2.access), await u2.portal._request(i2, { method: "post", body: f2, signal: m(c2, "signal") }), e;
  29. }
  30. async function i(e, a, o) {
  31. if (!a.hasPath())
  32. throw new s("portal-item-resources-remove:invalid-path", "Resource does not have a valid path");
  33. await e.load(o);
  34. const n = G(e.userItemUrl, "removeResources");
  35. await e.portal._request(n, { method: "post", query: { resource: a.path }, signal: m(o, "signal") }), a.portalItem = null;
  36. }
  37. async function l(e, t2) {
  38. await e.load(t2);
  39. const a = G(e.userItemUrl, "removeResources");
  40. return e.portal._request(a, { method: "post", query: { deleteAll: true }, signal: m(t2, "signal") });
  41. }
  42. function p(e) {
  43. const t2 = e.lastIndexOf("/");
  44. return t2 === -1 ? [".", e] : [e.slice(0, t2), e.slice(t2 + 1)];
  45. }
  46. function d(e) {
  47. const [t2, r2] = m2(e), [a, o] = p(t2);
  48. return [a, o, r2];
  49. }
  50. function m2(e) {
  51. const t2 = kt(e);
  52. return t(t2) ? [e, ""] : [e.slice(0, e.length - t2.length - 1), `.${t2}`];
  53. }
  54. async function h(t2) {
  55. if (t2 instanceof Blob)
  56. return t2;
  57. return (await U(t2.url, { responseType: "blob" })).data;
  58. }
  59. function f(e, t2) {
  60. if (!e.hasPath())
  61. return null;
  62. const [r2, , a] = d(e.path);
  63. return e.portalItem.resourceFromPath(G(r2, t2 + a));
  64. }
  65. function w(e, t2) {
  66. if (!e.hasPath())
  67. return null;
  68. const [r2, , a] = d(e.path);
  69. return e.portalItem.resourceFromPath(G(r2, t2 + a));
  70. }
  71. export {
  72. c,
  73. u,
  74. i,
  75. l,
  76. d,
  77. h,
  78. f,
  79. w
  80. };
  81. //# sourceMappingURL=chunk-UILPRJKY.js.map