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

Content family and org #545

Merged
merged 7 commits into from
Jun 15, 2021
Merged

Content family and org #545

merged 7 commits into from
Jun 15, 2021

Conversation

tomwayson
Copy link
Member

@tomwayson tomwayson commented Jun 15, 2021

This PR gets closer to resolving #322. In essence, everything we need should be there if the content was fetched from the Hub API. If the content is coming from portal, we still have to add logic to enrichContent() to fetch additional enrichments such as server, layers, recordCount, etc.

This PR also makes a few fixes to the way itemToContent and datasetToContent were handling hubId and isPortal. TLDR: we should only set hubId if we are fairy confident that it is in the index. Also, isPortal is not returned by the API, we'll need to set it (and the proxied url) in enrichContent() before calling fetchEnrichments().

In service of those, the PR also moves several low level utils from the Hub app to Hub.js (getFamily, getItemHubId, etc), and it also re-orders how properties are set in datasetToConent() to logically group them (common, server, layer). So it may seem like a lot of 🧀 was moved.

…ontent()

affects: @esri/hub-common, @esri/hub-content, @esri/hub-search

ISSUES CLOSED: #355
affects: @esri/hub-common, @esri/hub-content
… not returned by the API

affects: @esri/hub-content
affects: @esri/hub-content

always set content.item.modified to the item's modified date
content.modified should prefer the
enriched date and fall back to item.modified
…ments

affects: @esri/hub-content

also enrichContent is now tolerant of content not having errors
@tomwayson tomwayson changed the title F/content family and identifier Content family and org Jun 15, 2021
@@ -319,11 +348,25 @@ export interface IHubContent extends IHubResource, IItem {
data?: {
[propName: string]: any;
};
// service types: Feature Service, Map Service
/** service information (currentVersion, capabilities, maxRecordCount etc) */
server?: Partial<IFeatureServiceDefinition>;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be service? vs server?

Copy link
Member Author

Choose a reason for hiding this comment

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

the Hub API returns server, so we rollin' w/ that.

@codecov
Copy link

codecov bot commented Jun 15, 2021

Codecov Report

Merging #545 (02d08c6) into master (655cca6) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #545   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          430       430           
  Lines         5929      5982   +53     
  Branches       912       935   +23     
=========================================
+ Hits          5929      5982   +53     
Impacted Files Coverage Δ
packages/common/src/collections.ts 100.00% <100.00%> (ø)
packages/common/src/content.ts 100.00% <100.00%> (ø)
packages/content/src/content.ts 100.00% <100.00%> (ø)
packages/content/src/enrichments.ts 100.00% <100.00%> (ø)
packages/content/src/hub.ts 100.00% <100.00%> (ø)
packages/content/src/portal.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 655cca6...02d08c6. Read the comment docs.

layers?: Array<Partial<ILayerDefinition>>;
// layer types: Feature Layers, Raster Layers
/** layer information (geometryType, fields, etc) */
layer?: Partial<ILayerDefinition>;
Copy link
Member

Choose a reason for hiding this comment

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

Thoughts on just using layers and if there is only one entry... treating it like a layer?

Copy link
Member Author

Choose a reason for hiding this comment

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

so, layer represents the one layer out of all the ones on the server that you are currently looking at. If this we an instance of a class, we'd have a layerId property and a layer getter like this.layers.filter(layer => layer.id === this.layerId).

// layer types: Feature Layers, Raster Layers
/** layer information (geometryType, fields, etc) */
layer?: Partial<ILayerDefinition>;
recordCount?: number;
Copy link
Member

Choose a reason for hiding this comment

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

how does recordCount work w/ layers?

Copy link
Member Author

Choose a reason for hiding this comment

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

recordCount only refers the the "current" layer (see #545 (comment)). and is not returned for service types (Feature Service, Map Service), only for the Feature Layer pseudo type.

Copy link
Member Author

Choose a reason for hiding this comment

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

i.e it must be re-fetched if you switch layers

@@ -269,8 +297,13 @@ export function datasetToItem(dataset: DatasetResource): IItem {
id: itemId,
owner: owner as string,
orgId,
created: (created || createdAt) as number,
modified: (modified || updatedAt) as number,
created: created as number,
Copy link
Member

Choose a reason for hiding this comment

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

I sorta thought createdAt came from the hub api but i don't see it. Are we sure we will never have createdAt?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm thinking more about this, i guess created at was from our composer service.

Copy link
Member Author

@tomwayson tomwayson Jun 15, 2021

Choose a reason for hiding this comment

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

it comes from the model serializer adapter (or composer). I've tested this locally sending models that come out of composer in the app's datasetModelToContent() and it does the right thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have a massive spreadsheet that maps all the attributes returned from the API for various content types and maps them to the dataset model, which is a superset w/ CPs, and such.

Copy link
Member

@dbouwman dbouwman left a comment

Choose a reason for hiding this comment

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

Not sure I quite follow all of that, but seems legit :)

Copy link
Contributor

@rweber-esri rweber-esri left a comment

Choose a reason for hiding this comment

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

Looks good to me, only minor comments.


/**
* return the layerId if we can tell that item is a single layer service
* @param {*} item from AGO
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, comment formatting. Outside scope of this PR, but have we ever explored adding eslint-plugin-jsdoc or similar for enforcing consistent commenting/docing styles?

Copy link
Member Author

Choose a reason for hiding this comment

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

so you are saying that the doc comments shouldn't have types, right? b/c that is taken care of by typedoc?

Copy link
Contributor

Choose a reason for hiding this comment

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

I hadn't considered that. I guess it'd just be nice if our inline comments were aligned w/ the docs generated by typedoc.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what's out of alignment, either specifically w/ this comment (other than I think it should not have the types), or in general, but if there are improvements w/ can make w/ eslint-plugin-jsdoc I say open an issue.

packages/content/src/hub.ts Show resolved Hide resolved
@tomwayson tomwayson merged commit c41b183 into master Jun 15, 2021
@tomwayson tomwayson deleted the f/content-family-and-identifier branch June 15, 2021 18:14
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.

4 participants