2020-09-18 10:14:06 +00:00
|
|
|
import attr from 'ember-data/attr';
|
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import { or } from '@ember/object/computed';
|
|
|
|
|
|
|
|
import Fragment from 'ember-data-model-fragments/fragment';
|
|
|
|
import { fragmentArray, array } from 'ember-data-model-fragments/attributes';
|
|
|
|
|
2020-09-30 11:33:01 +00:00
|
|
|
export const schema = {
|
|
|
|
PathType: {
|
|
|
|
allowedValues: ['PathPrefix', 'PathExact', 'PathRegex'],
|
|
|
|
},
|
|
|
|
Methods: {
|
|
|
|
allowedValues: ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-09-18 10:14:06 +00:00
|
|
|
export default Fragment.extend({
|
|
|
|
PathExact: attr('string'),
|
|
|
|
PathPrefix: attr('string'),
|
|
|
|
PathRegex: attr('string'),
|
|
|
|
|
|
|
|
Header: fragmentArray('intention-permission-http-header'),
|
|
|
|
Methods: array('string'),
|
|
|
|
|
2020-09-30 11:33:01 +00:00
|
|
|
Path: or(...schema.PathType.allowedValues),
|
|
|
|
PathType: computed(...schema.PathType.allowedValues, function() {
|
|
|
|
return schema.PathType.allowedValues.find(prop => typeof this[prop] === 'string');
|
2020-09-18 10:14:06 +00:00
|
|
|
}),
|
|
|
|
});
|