@esri/solutions-components 0.6.37 → 0.6.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. package/dist/cjs/calcite-alert_3.cjs.entry.js +1 -1
  2. package/dist/cjs/calcite-combobox_6.cjs.entry.js +1 -1
  3. package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +2 -2
  4. package/dist/cjs/card-manager_3.cjs.entry.js +7 -4
  5. package/dist/cjs/crowdsource-manager.cjs.entry.js +1 -1
  6. package/dist/cjs/{downloadUtils-37d9aaf3.js → downloadUtils-d8e48fbd.js} +55 -12
  7. package/dist/cjs/{index.es-d1d9b140.js → index.es-6159eedc.js} +4 -3
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/map-select-tools_3.cjs.entry.js +4 -3
  10. package/dist/cjs/{mapViewUtils-96172223.js → mapViewUtils-f7bbc35b.js} +5 -2
  11. package/dist/cjs/public-notification.cjs.entry.js +5 -4
  12. package/dist/cjs/{clean-url-d5326abb.js → restHelpersGet-c94617cf.js} +398 -0
  13. package/dist/cjs/solution-configuration.cjs.entry.js +565 -565
  14. package/dist/cjs/solution-contents_3.cjs.entry.js +2 -2
  15. package/dist/cjs/{solution-store-714601a2.js → solution-store-b40c2f46.js} +19 -383
  16. package/dist/cjs/solutions-components.cjs.js +1 -1
  17. package/dist/collection/components/crowdsource-manager/crowdsource-manager.js +10 -4
  18. package/dist/collection/components/map-card/map-card.js +26 -1
  19. package/dist/collection/components/public-notification/public-notification.js +6 -5
  20. package/dist/collection/utils/downloadUtils.js +50 -8
  21. package/dist/collection/utils/downloadUtils.ts +62 -9
  22. package/dist/collection/utils/interfaces.ts +2 -0
  23. package/dist/collection/utils/queryUtils.js +5 -2
  24. package/dist/collection/utils/queryUtils.ts +4 -2
  25. package/dist/components/crowdsource-manager.js +1 -1
  26. package/dist/components/downloadUtils.js +51 -8
  27. package/dist/components/map-card2.js +4 -1
  28. package/dist/components/public-notification.js +2 -2
  29. package/dist/components/queryUtils.js +5 -2
  30. package/dist/components/{clean-url.js → restHelpersGet.js} +392 -1
  31. package/dist/components/solution-configuration.js +552 -552
  32. package/dist/components/solution-store.js +2 -365
  33. package/dist/esm/calcite-alert_3.entry.js +1 -1
  34. package/dist/esm/calcite-combobox_6.entry.js +1 -1
  35. package/dist/esm/calcite-shell-panel_14.entry.js +2 -2
  36. package/dist/esm/card-manager_3.entry.js +7 -4
  37. package/dist/esm/crowdsource-manager.entry.js +1 -1
  38. package/dist/esm/{downloadUtils-76379e4a.js → downloadUtils-d41ecba9.js} +53 -10
  39. package/dist/esm/{index.es-0d134a52.js → index.es-b226bf47.js} +4 -3
  40. package/dist/esm/loader.js +1 -1
  41. package/dist/esm/map-select-tools_3.entry.js +4 -3
  42. package/dist/esm/{mapViewUtils-08f6cfce.js → mapViewUtils-1e2befd7.js} +5 -2
  43. package/dist/esm/public-notification.entry.js +5 -4
  44. package/dist/esm/{clean-url-bce022e6.js → restHelpersGet-a5ec2192.js} +392 -1
  45. package/dist/esm/solution-configuration.entry.js +552 -552
  46. package/dist/esm/solution-contents_3.entry.js +2 -2
  47. package/dist/esm/{solution-store-3ee6c7a3.js → solution-store-17bb0a75.js} +2 -365
  48. package/dist/esm/solutions-components.js +1 -1
  49. package/dist/solutions-components/{p-9800e602.entry.js → p-091120c5.entry.js} +1 -1
  50. package/dist/solutions-components/p-1b14b687.entry.js +6 -0
  51. package/dist/solutions-components/{p-646e983f.entry.js → p-2d143359.entry.js} +1 -1
  52. package/dist/solutions-components/{p-ac7332b3.entry.js → p-40e95e2b.entry.js} +1 -1
  53. package/dist/solutions-components/p-420e1585.entry.js +36 -0
  54. package/dist/solutions-components/p-4807b2a1.js +36 -0
  55. package/dist/solutions-components/p-56a3b81e.entry.js +6 -0
  56. package/dist/solutions-components/p-5856dc4f.js +66 -0
  57. package/dist/solutions-components/p-89b4b401.js +145 -0
  58. package/dist/solutions-components/{p-4ecad91c.entry.js → p-973625f8.entry.js} +1 -1
  59. package/dist/solutions-components/p-99391a15.entry.js +6 -0
  60. package/dist/solutions-components/{p-03130804.js → p-9ecb5d66.js} +1 -1
  61. package/dist/solutions-components/{p-b02eb8f4.js → p-a8661f1f.js} +30 -30
  62. package/dist/solutions-components/p-ba064f24.entry.js +6 -0
  63. package/dist/solutions-components/solutions-components.esm.js +1 -1
  64. package/dist/solutions-components/utils/downloadUtils.ts +62 -9
  65. package/dist/solutions-components/utils/interfaces.ts +2 -0
  66. package/dist/solutions-components/utils/queryUtils.ts +4 -2
  67. package/dist/types/components/crowdsource-manager/crowdsource-manager.d.ts +3 -3
  68. package/dist/types/components/map-card/map-card.d.ts +5 -1
  69. package/dist/types/components/public-notification/public-notification.d.ts +1 -1
  70. package/dist/types/components.d.ts +16 -8
  71. package/dist/types/utils/interfaces.d.ts +1 -0
  72. package/package.json +1 -1
  73. package/dist/solutions-components/p-13b21d19.entry.js +0 -36
  74. package/dist/solutions-components/p-15070568.js +0 -36
  75. package/dist/solutions-components/p-63867402.entry.js +0 -6
  76. package/dist/solutions-components/p-81a0c88f.entry.js +0 -6
  77. package/dist/solutions-components/p-b7804687.entry.js +0 -6
  78. package/dist/solutions-components/p-d0544f24.js +0 -192
  79. package/dist/solutions-components/p-eba875d9.entry.js +0 -6
  80. package/dist/solutions-components/p-ecc95259.js +0 -20
@@ -5,6 +5,8 @@
5
5
  */
6
6
  'use strict';
7
7
 
8
+ require('./solution-resource-f9e3b289.js');
9
+
8
10
  /*! *****************************************************************************
9
11
  Copyright (c) Microsoft Corporation.
10
12
 
@@ -566,8 +568,404 @@ function cleanUrl(url) {
566
568
  return url;
567
569
  }
568
570
 
571
+ /** @license
572
+ * Copyright 2020 Esri
573
+ *
574
+ * Licensed under the Apache License, Version 2.0 (the "License");
575
+ * you may not use this file except in compliance with the License.
576
+ * You may obtain a copy of the License at
577
+ *
578
+ * http://www.apache.org/licenses/LICENSE-2.0
579
+ *
580
+ * Unless required by applicable law or agreed to in writing, software
581
+ * distributed under the License is distributed on an "AS IS" BASIS,
582
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
583
+ * See the License for the specific language governing permissions and
584
+ * limitations under the License.
585
+ */
586
+ /**
587
+ * Supplies the File constructor for Microsoft Legacy Edge.
588
+ *
589
+ * @param fileBits Contents for file
590
+ * @param fileName Name for file
591
+ * @param options Bucket of options, euch as `type` for the MIME type; defaults to empty string for `type`
592
+ * @returns File or, for Microsoft Legacy Edge, Blob
593
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/File/File
594
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob
595
+ */
596
+ function new_File(fileBits, fileName, options) {
597
+ let file;
598
+ try {
599
+ // Modern browser
600
+ file = new File(fileBits, fileName, options);
601
+ }
602
+ catch (error) {
603
+ // Microsoft Legacy Edge
604
+ /* istanbul ignore next */
605
+ file = (function () {
606
+ if (typeof options === "undefined") {
607
+ // Microsoft Legacy Edge fails in karma if options is not defined
608
+ options = {
609
+ type: ""
610
+ };
611
+ }
612
+ const blob = new Blob(fileBits, options);
613
+ blob.lastModified = new Date();
614
+ blob.name = fileName;
615
+ return blob;
616
+ })();
617
+ }
618
+ return file;
619
+ }
620
+
621
+ /** @license
622
+ * Copyright 2018 Esri
623
+ *
624
+ * Licensed under the Apache License, Version 2.0 (the "License");
625
+ * you may not use this file except in compliance with the License.
626
+ * You may obtain a copy of the License at
627
+ *
628
+ * http://www.apache.org/licenses/LICENSE-2.0
629
+ *
630
+ * Unless required by applicable law or agreed to in writing, software
631
+ * distributed under the License is distributed on an "AS IS" BASIS,
632
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
633
+ * See the License for the specific language governing permissions and
634
+ * limitations under the License.
635
+ */
636
+ /**
637
+ * Extracts JSON from a Blob.
638
+ *
639
+ * @param blob Blob to use as source
640
+ * @returns A promise that will resolve with JSON or null
641
+ */
642
+ function blobToJson(blob) {
643
+ return new Promise(resolve => {
644
+ blobToText(blob).then(blobContents => {
645
+ try {
646
+ resolve(JSON.parse(blobContents));
647
+ }
648
+ catch (err) {
649
+ resolve(null);
650
+ }
651
+ }, () => resolve(null));
652
+ });
653
+ }
654
+ /**
655
+ * Converts a Blob to a File.
656
+ *
657
+ * @param blob Blob to use as source
658
+ * @param filename Name to use for file
659
+ * @param mimeType MIME type to override blob's MIME type
660
+ * @returns File created out of Blob and filename
661
+ */
662
+ function blobToFile(blob, filename, mimeType) {
663
+ return blob
664
+ ? new_File([blob], filename ? filename : "", {
665
+ type: mimeType || blob.type
666
+ })
667
+ : null;
668
+ }
669
+ /**
670
+ * Extracts text from a Blob.
671
+ *
672
+ * @param blob Blob to use as source
673
+ * @returns A promise that will resolve with text read from blob
674
+ */
675
+ function blobToText(blob) {
676
+ return new Promise(resolve => {
677
+ const reader = new FileReader();
678
+ reader.onload = function (evt) {
679
+ // Disable needed because Node requires cast
680
+ // tslint:disable-next-line: no-unnecessary-type-assertion
681
+ const blobContents = evt.target.result;
682
+ resolve(blobContents ? blobContents : ""); // not handling ArrayContents variant
683
+ };
684
+ reader.readAsText(blob);
685
+ });
686
+ }
687
+ /**
688
+ * Checks that a URL path ends with a slash.
689
+ *
690
+ * @param url URL to check
691
+ * @returns URL, appended with slash if missing
692
+ */
693
+ function checkUrlPathTermination(url) {
694
+ return url ? (url.endsWith("/") ? url : url + "/") : url;
695
+ }
696
+ /**
697
+ * Gets a property out of a deeply nested object.
698
+ * Does not handle anything but nested object graph
699
+ *
700
+ * @param obj Object to retrieve value from
701
+ * @param path Path into an object, e.g., "data.values.webmap", where "data" is a top-level property
702
+ * in obj
703
+ * @returns Value at end of path
704
+ */
705
+ function getProp(obj, path) {
706
+ return path.split(".").reduce(function (prev, curr) {
707
+ /* istanbul ignore next no need to test undefined scenario */
708
+ return prev ? prev[curr] : undefined;
709
+ }, obj);
710
+ }
711
+ /**
712
+ * Sets a deeply nested property of an object.
713
+ * Creates the full path if it does not exist.
714
+ *
715
+ * @param obj Object to set value of
716
+ * @param path Path into an object, e.g., "data.values.webmap", where "data" is a top-level property in obj
717
+ * @param value The value to set at the end of the path
718
+ */
719
+ function setCreateProp(obj, path, value) {
720
+ const pathParts = path.split(".");
721
+ pathParts.reduce((a, b, c) => {
722
+ if (c === pathParts.length - 1) {
723
+ a[b] = value;
724
+ return value;
725
+ }
726
+ else {
727
+ if (!a[b]) {
728
+ a[b] = {};
729
+ }
730
+ return a[b];
731
+ }
732
+ }, obj);
733
+ }
734
+
735
+ /**
736
+ * Gets a Blob from a web site.
737
+ *
738
+ * @param url Address of Blob
739
+ * @param authentication Credentials for the request
740
+ * @param requestOptions - Options for the request, including parameters relevant to the endpoint.
741
+ * @returns Promise that will resolve with Blob or an AGO-style JSON failure response
742
+ */
743
+ function getBlob(url, authentication, requestOptions = {}) {
744
+ if (!url) {
745
+ return Promise.reject("Url must be provided");
746
+ }
747
+ const blobRequestOptions = {
748
+ authentication: authentication,
749
+ rawResponse: true,
750
+ ...requestOptions
751
+ };
752
+ return request(url, blobRequestOptions).then(response => {
753
+ return response.blob();
754
+ });
755
+ }
756
+
757
+ /** @license
758
+ * Copyright 2018 Esri
759
+ *
760
+ * Licensed under the Apache License, Version 2.0 (the "License");
761
+ * you may not use this file except in compliance with the License.
762
+ * You may obtain a copy of the License at
763
+ *
764
+ * http://www.apache.org/licenses/LICENSE-2.0
765
+ *
766
+ * Unless required by applicable law or agreed to in writing, software
767
+ * distributed under the License is distributed on an "AS IS" BASIS,
768
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
769
+ * See the License for the specific language governing permissions and
770
+ * limitations under the License.
771
+ */
772
+ // ------------------------------------------------------------------------------------------------------------------ //
773
+ const ZIP_FILE_HEADER_SIGNATURE = "PK";
774
+ /**
775
+ * Gets a Blob from a web site and casts it as a file using the supplied name.
776
+ *
777
+ * @param url Address of Blob
778
+ * @param filename Name to use for file
779
+ * @param authentication Credentials for the request
780
+ * @returns Promise that will resolve with a File, undefined if the Blob is null, or an AGO-style JSON failure response
781
+ */
782
+ function getBlobAsFile(url, filename, authentication, ignoreErrors = [], mimeType) {
783
+ return new Promise((resolve, reject) => {
784
+ // Get the blob from the URL
785
+ getBlobCheckForError(url, authentication, ignoreErrors).then(blob => !blob ? resolve(null) : resolve(blobToFile(blob, filename, mimeType)), reject);
786
+ });
787
+ }
788
+ /**
789
+ * Gets a Blob from a web site and checks for a JSON error packet in the Blob.
790
+ *
791
+ * @param url Address of Blob
792
+ * @param authentication Credentials for the request
793
+ * @param ignoreErrors List of HTTP error codes that should be ignored
794
+ * @returns Promise that will resolve with Blob or an AGO-REST JSON failure response
795
+ */
796
+ function getBlobCheckForError(url, authentication, ignoreErrors = []) {
797
+ return new Promise((resolve, reject) => {
798
+ // Get the blob from the URL
799
+ getBlob(url, authentication).then(blob => {
800
+ // Reclassify text/plain blobs as needed
801
+ _fixTextBlobType(blob).then(adjustedBlob => {
802
+ if (adjustedBlob.type === "application/json") {
803
+ // Blob may be an error
804
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
805
+ blobToJson(adjustedBlob).then((json) => {
806
+ // Check for valid JSON with an error
807
+ if (json?.error) {
808
+ const code = json.error.code;
809
+ if (code !== undefined && ignoreErrors.indexOf(code) >= 0) {
810
+ resolve(null); // Error, but ignored
811
+ }
812
+ else {
813
+ reject(json); // Other error; fail with error
814
+ }
815
+ }
816
+ else {
817
+ resolve(adjustedBlob);
818
+ }
819
+ });
820
+ }
821
+ else {
822
+ resolve(adjustedBlob);
823
+ }
824
+ }, reject);
825
+ }, reject);
826
+ });
827
+ }
828
+ /**
829
+ * Gets the data information of an AGO item in its JSON form.
830
+ *
831
+ * @param itemId Id of an item whose data information is sought
832
+ * @param filename Name to use for file
833
+ * @param authentication Credentials for the request to AGO
834
+ * @returns Promise that will resolve with JSON, or an AGO-style JSON failure response
835
+ */
836
+ function getItemDataAsJson(itemId, authentication) {
837
+ return new Promise(resolve => {
838
+ getItemDataBlob(itemId, authentication).then(blob => resolve(blobToJson(blob)), () => resolve(null));
839
+ });
840
+ }
841
+ /**
842
+ * Gets the data information of an AGO item in its raw (Blob) form.
843
+ *
844
+ * @param itemId Id of an item whose data information is sought
845
+ * @param authentication Credentials for the request to AGO
846
+ * @returns A promise that will resolve with the data Blob or null if the item doesn't have a data section
847
+ */
848
+ function getItemDataBlob(itemId, authentication) {
849
+ return new Promise(resolve => {
850
+ const url = getItemDataBlobUrl(itemId, authentication);
851
+ getBlobCheckForError(url, authentication, [400, 500]).then(blob => resolve(_fixTextBlobType(blob)), () => resolve(null));
852
+ });
853
+ }
854
+ /**
855
+ * Gets the URL to the data information of an AGO item in its raw (Blob) form.
856
+ *
857
+ * @param itemId Id of an item whose data information is sought
858
+ * @param authentication Credentials for the request to AGO
859
+ * @returns URL string
860
+ */
861
+ function getItemDataBlobUrl(itemId, authentication) {
862
+ return `${getPortalSharingUrlFromAuth(authentication)}/content/items/${itemId}/data`;
863
+ }
864
+ /**
865
+ * Gets a JSON from a web site.
866
+ *
867
+ * @param url Address of JSON
868
+ * @param authentication Credentials for the request
869
+ * @returns Promise that will resolve with JSON
870
+ */
871
+ function getJson(url, authentication) {
872
+ // Get the blob from the URL
873
+ const requestOptions = { httpMethod: "GET" };
874
+ return getBlob(url, authentication, requestOptions)
875
+ .then(blob => {
876
+ // Reclassify text/plain blobs as needed
877
+ return _fixTextBlobType(blob);
878
+ })
879
+ .then(adjustedBlob => {
880
+ if (adjustedBlob.type === "application/json") {
881
+ // Blob may be an error
882
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
883
+ return blobToJson(adjustedBlob);
884
+ }
885
+ else {
886
+ return Promise.resolve(null);
887
+ }
888
+ });
889
+ }
890
+ /**
891
+ * Extracts the portal sharing url from a supplied authentication.
892
+ *
893
+ * @param authentication Credentials for the request to AGO
894
+ * @returns Portal sharing url to be used in API requests, defaulting to `https://www.arcgis.com/sharing/rest`
895
+ */
896
+ function getPortalSharingUrlFromAuth(authentication) {
897
+ // If auth was passed, use that portal
898
+ return getProp(authentication, "portal") || "https://www.arcgis.com/sharing/rest";
899
+ }
900
+ function getThumbnailFile(url, filename, authentication) {
901
+ return new Promise(resolve => {
902
+ getBlobAsFile(url, filename, authentication, [500]).then(resolve, () => resolve(null));
903
+ });
904
+ }
905
+ // ------------------------------------------------------------------------------------------------------------------ //
906
+ /**
907
+ * Fixes the types of Blobs incorrectly typed as text/plain.
908
+ *
909
+ * @param blob Blob to check
910
+ * @returns Promise resolving to original Blob, unless it's originally typed as text/plain but is
911
+ * really JSON, ZIP, or XML
912
+ * @private
913
+ */
914
+ function _fixTextBlobType(blob) {
915
+ return new Promise((resolve, reject) => {
916
+ if (blob &&
917
+ blob.size > 0 &&
918
+ (blob.type.startsWith("text/plain") ||
919
+ blob.type.startsWith("application/json"))) {
920
+ blobToText(blob).then(blobText => {
921
+ // Convertible to JSON?
922
+ try {
923
+ JSON.parse(blobText);
924
+ // Yes; reclassify as JSON
925
+ resolve(new Blob([blob], { type: "application/json" }));
926
+ }
927
+ catch (ignored) {
928
+ // Nope; test for ZIP file
929
+ if (blobText.length > 4 &&
930
+ blobText.substr(0, 4) === ZIP_FILE_HEADER_SIGNATURE) {
931
+ // Yes; reclassify as ZIP
932
+ resolve(new Blob([blob], { type: "application/zip" }));
933
+ }
934
+ else if (blobText.startsWith("<")) {
935
+ // Reclassify as XML; since the blob started out as text/plain, it's more likely that is
936
+ // meant to be human-readable, so we'll use text/xml instead of application/xml
937
+ resolve(new Blob([blob], { type: "text/xml" }));
938
+ }
939
+ else {
940
+ // Leave as text
941
+ resolve(blob);
942
+ }
943
+ }
944
+ },
945
+ // Faulty blob
946
+ reject);
947
+ }
948
+ else {
949
+ // Empty or not typed as plain text, so simply return
950
+ if (blob) {
951
+ resolve(blob);
952
+ }
953
+ else {
954
+ reject();
955
+ }
956
+ }
957
+ });
958
+ }
959
+
569
960
  exports.ArcGISAuthError = ArcGISAuthError;
570
961
  exports.NODEJS_DEFAULT_REFERER_HEADER = NODEJS_DEFAULT_REFERER_HEADER;
962
+ exports.blobToFile = blobToFile;
963
+ exports.checkUrlPathTermination = checkUrlPathTermination;
571
964
  exports.cleanUrl = cleanUrl;
572
965
  exports.encodeQueryString = encodeQueryString;
966
+ exports.getItemDataAsJson = getItemDataAsJson;
967
+ exports.getJson = getJson;
968
+ exports.getProp = getProp;
969
+ exports.getThumbnailFile = getThumbnailFile;
573
970
  exports.request = request;
971
+ exports.setCreateProp = setCreateProp;