Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the csv distribution when dataset is a proxied csv #20

Merged
merged 2 commits into from
Feb 22, 2022

Conversation

sonofflynn89
Copy link
Collaborator

Part of https://devtopia.esri.com/dc/hub/issues/2408

Imports proxied csv detection logic from hub.js
Also added @esri/arcgis-rest-feature-layer as a dev and peer dependency to fix typescript errors when running npm run dev

@@ -11,6 +11,7 @@
"url": "git@github.com:koopjs/koop-output-dcat-us-11.git"
},
"devDependencies": {
"@esri/arcgis-rest-feature-layer": "^3.2.1",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drspacemanphd this is what I was talking about. This package is declared as a dependency in the example app, but when I run npm run dev the script chokes on a typescript error, saying that an interface from this package is not defined. Adding it as a dev and a peer dependency solves the issue and shouldn't affect consumers.

Comment on lines +62 to +68
const item = datasetToItem({
id: dataset.id,
attributes: dataset
} as DatasetResource);
const requestOptions: IHubRequestOptions = { isPortal: false };

return !!getProxyUrl(item, requestOptions);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking out loud...

This set of conversions is clever, but squishy. We're basically taking a V3 API response, making it look sorta like a dataset, then making that sorta look like an item, then throwing it into the getProxyUrl method which expects a full item.

We can do this because we happen to know about the internals of getProxyUrl enough to know that this will work.

That said, if it works—great. A regression here would be low-impact and you have a test to validate it anyways.

One question though—why not just use isProxiedCSV instead of getProxyUrl?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay—I see now that isProxiedCSV isn't part of the Hub.js public API. I'm not sure why—but you probably had a reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewctate thanks for the review!

Okay—I see now that isProxiedCSV isn't part of the Hub.js public API. I'm not sure why—but you probably had a reason.

That was my original plan, but Tom is really trying to minimize hub.js' public footprint. I discussed it with him, but ultimately he asked for us to do it this way 🤷‍♂️

This set of conversions is clever, but squishy.

I know it's not ideal. Tom is doing a massive refactor for getting IHubContents that we'll probably use in the near future. The result of that refactor will already have the proxied csv stuff baked in 🙌

Copy link
Contributor

@drewdaemon drewdaemon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@sonofflynn89
Copy link
Collaborator Author

Thanks @andrewctate!

@sonofflynn89 sonofflynn89 merged commit 9f7e760 into main Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants