merchi_sdk_js 0.19.0 → 0.20.0
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/company.js +2 -0
- package/src/domain.js +1 -0
- package/src/model.js +7 -0
- package/src/model.serialise.test.js +25 -0
- package/src/product.js +0 -2
package/package.json
CHANGED
package/src/company.js
CHANGED
|
@@ -116,6 +116,8 @@ export function Company() {
|
|
|
116
116
|
addPropertyTo(this, 'internalUseAiContext');
|
|
117
117
|
addPropertyTo(this, 'internalTags', InternalTag);
|
|
118
118
|
addPropertyTo(this, 'reminders', Reminder);
|
|
119
|
+
addPropertyTo(this, 'parentCompany', Company);
|
|
120
|
+
addPropertyTo(this, 'childCompanies', Company);
|
|
119
121
|
|
|
120
122
|
this.create = function (success, error, embed, as_domain) {
|
|
121
123
|
var data = serialise(this),
|
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
|
+
});
|
package/src/product.js
CHANGED
|
@@ -41,7 +41,6 @@ export function Product() {
|
|
|
41
41
|
addPropertyTo(this, 'independent');
|
|
42
42
|
addPropertyTo(this, 'productType');
|
|
43
43
|
addPropertyTo(this, 'description');
|
|
44
|
-
addPropertyTo(this, 'aiContextDrafting');
|
|
45
44
|
addPropertyTo(this, 'notes');
|
|
46
45
|
addPropertyTo(this, 'position');
|
|
47
46
|
addPropertyTo(this, 'spProductId');
|
|
@@ -117,7 +116,6 @@ export function Product() {
|
|
|
117
116
|
addPropertyTo(this, 'draftTemplates', DraftTemplate);
|
|
118
117
|
addPropertyTo(this, 'shipmentMethods', ShipmentMethod);
|
|
119
118
|
addPropertyTo(this, 'aiContext');
|
|
120
|
-
addPropertyTo(this, 'aiContextDrafting');
|
|
121
119
|
addPropertyTo(this, 'internalUseNotes');
|
|
122
120
|
addPropertyTo(this, 'internalUseAiContext');
|
|
123
121
|
addPropertyTo(this, 'groupsFirst');
|