Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Ember from 'ember';
import DS from 'ember-data';
var underscore = Ember.String.underscore;
// Allow to have underscore in JSONAPI keys
export default DS.JSONAPISerializer.extend({
keyForAttribute: function(attr) {
return underscore(attr);
},
keyForRelationship: function(rawKey) {
return underscore(rawKey);
}
});
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';
export default DS.JSONAPISerializer.extend({
normalizeSingleResponse(store, primaryModelClass, payload, id/*, requestType*/) {
// Convert plain text response into JSON.
// ID is of the form nodeAddress!containerId!fileName
var splits = Converter.splitForContainerLogs(id);
var convertedPayload = {
id: id,
type: primaryModelClass.modelName,
attributes: {
logs: payload,
containerID: splits[1],
logFileName: splits[2]
}
};
return { data: convertedPayload };
},
});
import DS from 'ember-data';
export default DS.JSONAPISerializer.extend();
import DS from 'ember-data';
export default DS.JSONAPISerializer.extend({
normalizeResponse(_, __, payload) {
return payload;
}
});
registry.register('service:store', DS.Store.extend({
adapter
}));
registry.optionsForType('serializer', { singleton: false });
registry.optionsForType('adapter', { singleton: false });
registry.register('adapter:-default', DS.Adapter);
registry.register('serializer:-default', DS.JSONSerializer);
registry.register('serializer:-rest', DS.RESTSerializer);
registry.register('adapter:-rest', DS.RESTAdapter);
registry.register('adapter:-json-api', DS.JSONAPIAdapter);
registry.register('serializer:-json-api', DS.JSONAPISerializer);
env.restSerializer = container.lookup('serializer:-rest');
env.store = container.lookup('service:store');
env.serializer = env.store.serializerFor('-default');
env.adapter = env.store.get('defaultAdapter');
return env;
}
import DS from 'ember-data';
import DataTableSerializerMixin from 'ember-data-table/mixins/serializer';
export default DS.JSONAPISerializer.extend(DataTableSerializerMixin, {});
import DS from 'ember-data';
export default DS.JSONAPISerializer.extend({
/*
* @summary normalizing the payload from api response with array type ([{},{}..]) to correct json-api format spec. See http://jsonapi.org/
*/
normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) {
//we are kind of doing the job of the this._super(...) here to convert a 'classic JSON' payload into JSON API.
let data = payload.map((resourcePayload) => {
let attributes = {};
primaryModelClass.eachAttribute(key => {
attributes[key] = resourcePayload[key];
});
return {
id: resourcePayload.id,
type: primaryModelClass.modelName,
attributes
};
import DS from 'ember-data';
export default class MilestoneSerializer extends DS.JSONAPISerializer {
attrs = { displayDate2: 'display-date-2' };
}
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';
export default DS.JSONAPISerializer.extend({
internalNormalizeSingleResponse(store, primaryModelClass, payload, id) {
if (payload.app) {
payload = payload.app;
}
var timeoutInSecs = -1;
var appExpiryTime = Converter.timeStampToDate(payload.finishedTime);
if (payload.timeouts && payload.timeouts.timeout && payload.timeouts.timeout[0]) {
timeoutInSecs = payload.timeouts.timeout[0].remainingTimeInSeconds;
if (timeoutInSecs > -1) {
appExpiryTime = Converter.isoDateToDate(payload.timeouts.timeout[0].expiryTime);
}
}
var fixedPayload = {
id: id,