Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [18.x] # Build on Node.js 18
node-version: [22.x] # Build on Node.js 22

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions addon/serializers/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export default class OrderSerializer extends ApplicationSerializer.extend(Embedd
json[key + '_type'] = null;
} else {
let type = belongsTo.modelName;
if (!isBlank(belongsTo.attr(`${key}_type`))) {
type = belongsTo.attr(`${key}_type`);
}
// Strip abstract subtype prefixes so the server receives the bare model type
// e.g. 'facilitator-vendor' -> 'vendor', 'customer-contact' -> 'contact'
if (typeof type === 'string') {
Expand Down
26 changes: 15 additions & 11 deletions addon/serializers/waypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,30 @@ export default class WaypointSerializer extends ApplicationSerializer.extend(Emb
serializePolymorphicType(snapshot, json, relationship) {
let key = relationship.key;
let belongsTo = snapshot.belongsTo(key);
let type = belongsTo.modelName;

// if snapshot already has type filled respect manual input
const isPolymorphicTypeBlank = isBlank(snapshot.attr(key + '_type'));
if (isPolymorphicTypeBlank) {
key = this.keyForAttribute ? this.keyForAttribute(key, 'serialize') : key;

// hotfix polymprohpic model types that do not exists as models like `customer-contact` `customer-vendor` should be `contact` or `vendor`
if (typeof type === 'string') {
if (type.startsWith('customer-')) {
type = type.replace('customer-', '');
}
if (type.startsWith('facilitator-')) {
type = type.replace('facilitator-', '');
}
}

if (!belongsTo) {
json[key + '_type'] = null;
} else {
let type = belongsTo.modelName;
if (!isBlank(belongsTo.attr(`${key}_type`))) {
type = belongsTo.attr(`${key}_type`);
}

// hotfix polymprohpic model types that do not exists as models like `customer-contact` `customer-vendor` should be `contact` or `vendor`
if (typeof type === 'string') {
if (type.startsWith('customer-')) {
type = type.replace('customer-', '');
}
if (type.startsWith('facilitator-')) {
type = type.replace('facilitator-', '');
}
}

json[key + '_type'] = `fleet-ops:${type}`;
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/fleetops-data",
"version": "0.1.31",
"version": "0.1.32",
"description": "Fleetbase Fleet-Ops based models, serializers, transforms, adapters and GeoJson utility functions.",
"keywords": [
"fleetbase-data",
Expand Down
Loading
Loading