pollination-react-io 1.13.2 → 1.14.0

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.
@@ -6,6 +6,7 @@ declare type CloudFileMeta = FileMeta & {
6
6
  export interface SelectCloudArtifactsProps {
7
7
  projectOwner?: string;
8
8
  projectName?: string;
9
+ jobId?: string;
9
10
  fileNameMatch?: string;
10
11
  onChange?: (artifact: CloudFileMeta) => void;
11
12
  client?: APIClient;
@@ -7,7 +7,6 @@ export declare enum Action {
7
7
  }
8
8
  interface GeometryOptions {
9
9
  units?: 'Meters' | 'Millimeters' | 'Feet' | 'Inches' | 'Centimeters';
10
- layer?: string;
11
10
  }
12
11
  export interface SendGeometryProps {
13
12
  geometry?: string[];
@@ -6,6 +6,9 @@ export declare enum Action {
6
6
  clear = "clear",
7
7
  subscribePreview = "subscribe-preview"
8
8
  }
9
+ interface ResultsOptions {
10
+ units?: 'Meters' | 'Millimeters' | 'Feet' | 'Inches' | 'Centimeters';
11
+ }
9
12
  export interface SendResultsProps {
10
13
  results?: XOR<object, (args?: any) => Promise<object>>;
11
14
  defaultAction?: Action;
@@ -14,4 +17,6 @@ export interface SendResultsProps {
14
17
  [index in Action]: boolean;
15
18
  };
16
19
  buttonLabel?: string;
20
+ geometryOptions?: ResultsOptions;
17
21
  }
22
+ export {};
@@ -2,7 +2,7 @@ import { FileMeta } from '@pollination-solutions/pollination-sdk';
2
2
  import { FileWithPath } from 'react-dropzone';
3
3
  import { APIClient } from './useAPIClient';
4
4
  export declare const useArtifacts: (owner: string, name: string, client: APIClient) => {
5
- listArtifacts: (path?: string[]) => Promise<FileMeta[]>;
5
+ listArtifacts: (path?: string[], jobId?: string) => Promise<FileMeta[]>;
6
6
  deleteArtifact: (path: string) => Promise<void>;
7
7
  downloadArtifact: (path: string) => Promise<any>;
8
8
  uploadArtifact: (folderRoot: FileMeta | undefined, file: FileWithPath) => Promise<import("@pollination-solutions/pollination-sdk").S3UploadRequest>;
@@ -21684,16 +21684,29 @@ function getHost(key, defaultValue) {
21684
21684
  }
21685
21685
 
21686
21686
  var useArtifacts = function (owner, name, client) {
21687
- var listArtifacts = useCallback(function (path) {
21687
+ var listArtifacts = useCallback(function (path, jobId) {
21688
21688
  if (!client || !client.artifacts)
21689
21689
  return new Promise(function (resolve) { return resolve([]); });
21690
- return client.artifacts.listArtifacts({
21691
- owner: owner,
21692
- name: name,
21693
- page: 1,
21694
- perPage: 50,
21695
- path: path
21696
- }).then(function (r) { return r.data; });
21690
+ // any string val except ''
21691
+ if (jobId) {
21692
+ return client.jobs.searchJobFolder({
21693
+ owner: owner,
21694
+ name: name,
21695
+ jobId: jobId,
21696
+ page: 1,
21697
+ perPage: 50,
21698
+ path: path
21699
+ }).then(function (r) { return r.data; });
21700
+ }
21701
+ else {
21702
+ return client.artifacts.listArtifacts({
21703
+ owner: owner,
21704
+ name: name,
21705
+ page: 1,
21706
+ perPage: 50,
21707
+ path: path
21708
+ }).then(function (r) { return r.data; });
21709
+ }
21697
21710
  }, [client, owner, name]);
21698
21711
  var downloadArtifact = useCallback(function (path) {
21699
21712
  if (!client)
@@ -39788,7 +39801,7 @@ var getFileIcon$1 = function (type, disabled) {
39788
39801
 
39789
39802
  var SelectCloudArtifacts = function (_a) {
39790
39803
  var _b, _c;
39791
- var projectOwner = _a.projectOwner, projectName = _a.projectName, _d = _a.fileNameMatch, fileNameMatch = _d === void 0 ? '.*' : _d, onChange = _a.onChange, client = _a.client;
39804
+ var projectOwner = _a.projectOwner, projectName = _a.projectName, jobId = _a.jobId, _d = _a.fileNameMatch, fileNameMatch = _d === void 0 ? '.*' : _d, onChange = _a.onChange, client = _a.client;
39792
39805
  var host = getHost();
39793
39806
  var listArtifacts = useArtifacts(projectOwner, projectName, client).listArtifacts;
39794
39807
  var _e = useState(false), loading = _e[0], setLoading = _e[1];
@@ -39797,14 +39810,14 @@ var SelectCloudArtifacts = function (_a) {
39797
39810
  var _h = useState(), selArtifact = _h[0], setSelArtifact = _h[1];
39798
39811
  useEffect(function () {
39799
39812
  setLoading(true);
39800
- listArtifacts(path)
39813
+ listArtifacts(path, jobId)
39801
39814
  .then(function (facts) {
39802
39815
  var folders = facts.filter(function (f) { return f.file_type === 'folder'; });
39803
39816
  var files = facts.filter(function (f) { return f.file_type === 'file'; });
39804
39817
  setArtifacts({ folders: folders, files: files });
39805
39818
  })
39806
39819
  .finally(function () { return setLoading(false); });
39807
- }, [client, fileNameMatch, host, listArtifacts, path]);
39820
+ }, [client, fileNameMatch, host, jobId, listArtifacts, path]);
39808
39821
  useEffect(function () {
39809
39822
  if (!selArtifact || selArtifact.file_type !== 'folder')
39810
39823
  return;
@@ -39836,7 +39849,7 @@ var SelectCloudArtifacts = function (_a) {
39836
39849
  var items = useMemo(function () {
39837
39850
  return __spreadArray(__spreadArray([], artifacts.folders, true), artifacts.files, true).map(function (a) {
39838
39851
  var match = a.file_name.match(fileMatchRegex);
39839
- var disabled = a.file_type === 'folder' || (match && match.length) > 1 ? false : true;
39852
+ var disabled = a.file_type === 'folder' || (match && match.length > 0) ? false : true;
39840
39853
  return (__assign(__assign({}, a), { name: a.file_name, id: a.key, disabled: disabled }));
39841
39854
  })
39842
39855
  .sort(function (a, b) { return a.file_type === 'folder' ? -1 : 1; });
@@ -41272,7 +41285,7 @@ var getAction = function (key) {
41272
41285
  }
41273
41286
  };
41274
41287
  var SendResults = function (_a) {
41275
- var results = _a.results, defaultAction = _a.defaultAction, defaultKey = _a.defaultKey, optionsConfig = _a.optionsConfig, _b = _a.buttonLabel, buttonLabel = _b === void 0 ? 'Send Results' : _b;
41288
+ var results = _a.results, defaultAction = _a.defaultAction, defaultKey = _a.defaultKey, optionsConfig = _a.optionsConfig, _b = _a.buttonLabel, buttonLabel = _b === void 0 ? 'Send Results' : _b, geometryOptions = _a.geometryOptions;
41276
41289
  var _c = useState(defaultAction !== null && defaultAction !== void 0 ? defaultAction : Action.preview), selOpt = _c[0], setSelOpt = _c[1];
41277
41290
  var _d = useState(defaultKey !== null && defaultKey !== void 0 ? defaultKey : performance.now().toString()), key = _d[0], setKey = _d[1];
41278
41291
  var sendMessage = useSendMessage().sendMessage;
@@ -41288,32 +41301,23 @@ var SendResults = function (_a) {
41288
41301
  sendMessage('SubscribePreviewResults', {
41289
41302
  data: results,
41290
41303
  uniqueId: key,
41291
- options: {
41292
- layer: 'StreamlitLayer',
41293
- units: 'Meters',
41294
- },
41304
+ options: geometryOptions,
41295
41305
  });
41296
41306
  return function () {
41297
41307
  sendMessage('ClearResults', {
41298
41308
  data: results,
41299
41309
  uniqueId: key,
41300
- options: {
41301
- layer: 'StreamlitLayer',
41302
- units: 'Meters',
41303
- },
41310
+ options: geometryOptions,
41304
41311
  });
41305
41312
  };
41306
- }, [key, results, selOpt, sendMessage]);
41313
+ }, [geometryOptions, key, results, selOpt, sendMessage]);
41307
41314
  return (React__default.createElement(SettingsButton, { disabled: !sendMessage, onClick: function () {
41308
41315
  if (!sendMessage)
41309
41316
  return;
41310
41317
  sendMessage(getAction(selOpt), {
41311
41318
  data: results,
41312
41319
  uniqueId: key,
41313
- options: {
41314
- layer: 'StreamlitLayer',
41315
- units: 'Meters',
41316
- },
41320
+ options: geometryOptions,
41317
41321
  });
41318
41322
  }, options: [{
41319
41323
  type: 'radio',