Skip to content

Feature/improve resource configuration#52

Open
vedrani wants to merge 6 commits intodevelopfrom
feature/improve-resource-configuration
Open

Feature/improve resource configuration#52
vedrani wants to merge 6 commits intodevelopfrom
feature/improve-resource-configuration

Conversation

@vedrani
Copy link
Copy Markdown
Contributor

@vedrani vedrani commented Jul 23, 2018

No description provided.

vedrani added 2 commits July 19, 2018 13:49
  - rename JSON_API_SOURCE into JSON_API_RESOURCE
  - implement rio.registerResourceType
  - improve resource configuration merge and override algorithm
  - refactor JsonApiStandardizer into class
  - fix tests based on changes
Comment thread src/actions/create.js Outdated
const rsaaConfig = buildRSAAConfig(config);
const endpoint = buildEndpoint(rsaaConfig.endpoint, params, options);
const source = _.get(config, 'request.resourceType', JSON_API_SOURCE);
const source = _.get(config, 'request.resourceType', JSON_API_RESOURCE);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Support config.type also.

Comment thread src/actions/find.js Outdated
endpoint,
options,
source: config.request.resourceType || JSON_API_SOURCE,
source: config.request.resourceType || JSON_API_RESOURCE,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same, config.type. Use _.get

Comment thread src/actions/loaded.js
schema,
tag,
source: JSON_API_SOURCE,
source: JSON_API_RESOURCE,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Support for other formats.

const standardizer = rio.getStandardizer(sourceAction.meta.source);
// transforms item into standard model
const transformation = transform(item);
const transformation = standardizer.transform(item);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What if standardizer is null?

Comment thread src/middlewares/apiStateMiddleware.js Outdated

// finds appropriate standardizer for transformation
const transform = rio.getStandardizer(sourceAction.meta.source);
const standardizer = rio.getStandardizer(sourceAction.meta.source);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Extract meta.source

Comment thread src/rio.js
const resourceTypeConfig = this.getResourceType(resourceType);

const resolvedConfig = _.merge({}, resourceTypeConfig, config);
validateResourceConfig(resolvedConfig);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

add comments

Comment thread src/rio.js Outdated

/**
* Register source type for data standardization.
* Register register type for data.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

resource

Comment thread src/rio.js Outdated
this.standardizers[sourceType] = standardizer;
validateResourceTypeConfig(config);
this.resourceTypeConfigs[type] = Object.freeze(config);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

remove line

if (!_.has(object, 'relationships')) {
return {
schema: {},
object: _.cloneDeep(object),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we need to cloneDeep?

relationships,
type: resolveType(object),
},
object: _.cloneDeep(object),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we need to cloneDeep?

vedrani and others added 4 commits July 24, 2018 11:39
 - remove deepClone from code, use Object.freeze
 - resource object with registered actions
 - partially supported actions with dot notation
 - implement execute generic action
 - migrate find, create to execute action
 - implement partial tests for execute
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