merchi_sdk_js 0.31.5 → 0.31.6
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/category.js +4 -0
- package/src/category.test.js +44 -0
- package/src/domain_tag.js +2 -0
- package/src/user.js +2 -0
package/package.json
CHANGED
package/src/category.js
CHANGED
|
@@ -2,7 +2,9 @@ import { generateUUID } from './uuid.js';
|
|
|
2
2
|
import { addPropertyTo, fromJson, serialise, create, enumerateFiles,
|
|
3
3
|
getOne, deleteOne, fromJsonList, getList } from './model.js';
|
|
4
4
|
import { Domain } from './domain.js';
|
|
5
|
+
import { DomainTag } from './domain_tag.js';
|
|
5
6
|
import { MerchiFile } from './merchi_file.js';
|
|
7
|
+
import { User } from './user.js';
|
|
6
8
|
|
|
7
9
|
export function Category() {
|
|
8
10
|
this.resource = '/categories';
|
|
@@ -22,6 +24,8 @@ export function Category() {
|
|
|
22
24
|
addPropertyTo(this, 'domain', Domain);
|
|
23
25
|
addPropertyTo(this, 'subcategories', Category);
|
|
24
26
|
addPropertyTo(this, 'parent', Category);
|
|
27
|
+
addPropertyTo(this, 'tags', DomainTag);
|
|
28
|
+
addPropertyTo(this, 'assigned', User);
|
|
25
29
|
|
|
26
30
|
this.create = function (success, error, embed, domainId) {
|
|
27
31
|
var data = serialise(this),
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { Category } from './category.js';
|
|
4
|
+
import { DomainTag } from './domain_tag.js';
|
|
5
|
+
import { User } from './user.js';
|
|
6
|
+
import { fromJson, serialise } from './model.js';
|
|
7
|
+
|
|
8
|
+
test('category reads and serialises tags and assigned team members', () => {
|
|
9
|
+
const category = new Category();
|
|
10
|
+
fromJson(category, {
|
|
11
|
+
id: 1,
|
|
12
|
+
tags: [{id: 4, name: 'rush'}],
|
|
13
|
+
assigned: [{id: 9, name: 'Ada'}],
|
|
14
|
+
}, {makesDirty: false});
|
|
15
|
+
|
|
16
|
+
assert.equal(category.tags()[0].id(), 4);
|
|
17
|
+
assert.equal(category.tags()[0].name(), 'rush');
|
|
18
|
+
assert.equal(category.assigned()[0].id(), 9);
|
|
19
|
+
assert.equal(category.assigned()[0].name(), 'Ada');
|
|
20
|
+
assert.equal(category.tags()[0].categories(), undefined);
|
|
21
|
+
|
|
22
|
+
const tag = new DomainTag();
|
|
23
|
+
tag.id(4);
|
|
24
|
+
const user = new User();
|
|
25
|
+
user.id(9);
|
|
26
|
+
const replacement = new Category();
|
|
27
|
+
replacement.tags([tag]);
|
|
28
|
+
replacement.assigned([user]);
|
|
29
|
+
const [data] = serialise(replacement);
|
|
30
|
+
assert.equal(data.get('tags-count'), 1);
|
|
31
|
+
assert.equal(data.get('tags-0-id'), 4);
|
|
32
|
+
assert.equal(data.get('assigned-count'), 1);
|
|
33
|
+
assert.equal(data.get('assigned-0-id'), 9);
|
|
34
|
+
|
|
35
|
+
const linked = new DomainTag();
|
|
36
|
+
const linkedCategory = new Category();
|
|
37
|
+
linkedCategory.id(3);
|
|
38
|
+
linked.categories([linkedCategory]);
|
|
39
|
+
assert.equal(linked.categories()[0].id(), 3);
|
|
40
|
+
|
|
41
|
+
const assignee = new User();
|
|
42
|
+
assignee.assignedCategories([linkedCategory]);
|
|
43
|
+
assert.equal(assignee.assignedCategories()[0].id(), 3);
|
|
44
|
+
});
|
package/src/domain_tag.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { generateUUID } from './uuid.js';
|
|
2
2
|
import { addPropertyTo, serialise, create, fromJson, patchOne, deleteOne,
|
|
3
3
|
fromJsonList, getList, enumerateFiles, getOne } from './model.js';
|
|
4
|
+
import { Category } from './category.js';
|
|
4
5
|
import { Domain } from './domain.js';
|
|
5
6
|
import { Product } from './product.js';
|
|
6
7
|
|
|
@@ -16,6 +17,7 @@ export function DomainTag() {
|
|
|
16
17
|
addPropertyTo(this, 'showPublic');
|
|
17
18
|
addPropertyTo(this, 'domain', Domain);
|
|
18
19
|
addPropertyTo(this, 'products', Product);
|
|
20
|
+
addPropertyTo(this, 'categories', Category);
|
|
19
21
|
|
|
20
22
|
this.create = function (success, error, embed, domainId) {
|
|
21
23
|
var data = serialise(this),
|
package/src/user.js
CHANGED
|
@@ -10,6 +10,7 @@ import { Address } from './address.js';
|
|
|
10
10
|
import { EmailAddress } from './email_address.js';
|
|
11
11
|
import { EnrolledDomain } from './enrolled_domain.js';
|
|
12
12
|
import { PhoneNumber } from './phone_number.js';
|
|
13
|
+
import { Category } from './category.js';
|
|
13
14
|
import { Product } from './product.js';
|
|
14
15
|
import { Domain } from './domain.js';
|
|
15
16
|
import { MerchiFile } from './merchi_file.js';
|
|
@@ -61,6 +62,7 @@ export function User() {
|
|
|
61
62
|
addPropertyTo(this, 'aiContext');
|
|
62
63
|
addPropertyTo(this, 'internalUseNotes');
|
|
63
64
|
addPropertyTo(this, 'internalUseAiContext');
|
|
65
|
+
addPropertyTo(this, 'assignedCategories', Category);
|
|
64
66
|
addPropertyTo(this, 'tags', DomainTag);
|
|
65
67
|
addPropertyTo(this, 'internalTags', InternalTag);
|
|
66
68
|
addPropertyTo(this, 'reminders', Reminder);
|