merchi_sdk_js 0.19.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/domain.js +1 -0
- package/src/model.js +7 -0
- package/src/model.serialise.test.js +25 -0
package/package.json
CHANGED
package/src/domain.js
CHANGED
|
@@ -72,6 +72,7 @@ export function Domain() {
|
|
|
72
72
|
addPropertyTo(this, 'showDomainToAccessibleEntitiesOnly')
|
|
73
73
|
addPropertyTo(this, 'enableNotifications');
|
|
74
74
|
addPropertyTo(this, 'assignToAgent');
|
|
75
|
+
addPropertyTo(this, 'jobAgentPolicy');
|
|
75
76
|
addPropertyTo(this, 'merchiAgentUser', User);
|
|
76
77
|
addPropertyTo(this, 'enableEmailNotifications');
|
|
77
78
|
addPropertyTo(this, 'enableSmsNotifications');
|
package/src/model.js
CHANGED
|
@@ -676,6 +676,13 @@ export function serialise(obj, existing, prefix, files, options) {
|
|
|
676
676
|
property !== 'id') {
|
|
677
677
|
return;
|
|
678
678
|
}
|
|
679
|
+
// JSON/JSONB columns (e.g. Domain.jobAgentPolicy) are plain objects.
|
|
680
|
+
// FormData stringifies objects as "[object Object]" unless we encode.
|
|
681
|
+
if (value !== null &&
|
|
682
|
+
typeof value === 'object' &&
|
|
683
|
+
!(typeof Blob !== 'undefined' && value instanceof Blob)) {
|
|
684
|
+
value = JSON.stringify(value);
|
|
685
|
+
}
|
|
679
686
|
appendData(property, value);
|
|
680
687
|
}
|
|
681
688
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { Domain } from './domain.js';
|
|
4
|
+
import { serialise } from './model.js';
|
|
5
|
+
|
|
6
|
+
test('serialise encodes jobAgentPolicy JSON for form data', () => {
|
|
7
|
+
const domain = new Domain();
|
|
8
|
+
domain.id(7);
|
|
9
|
+
domain.jobAgentPolicy({
|
|
10
|
+
playbooks: { drafting: false, invoice: true },
|
|
11
|
+
outreach: { sendEmail: true },
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const [data] = serialise(domain);
|
|
15
|
+
const encoded = data.get('jobAgentPolicy');
|
|
16
|
+
|
|
17
|
+
assert.equal(
|
|
18
|
+
encoded,
|
|
19
|
+
JSON.stringify({
|
|
20
|
+
playbooks: { drafting: false, invoice: true },
|
|
21
|
+
outreach: { sendEmail: true },
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
assert.notEqual(encoded, '[object Object]');
|
|
25
|
+
});
|