merchi_sdk_ts 0.0.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/.babelrc +13 -0
- package/.eslintrc.cjs +43 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/jest.config.js +17 -0
- package/package.json +44 -0
- package/src/constants/auto_assign_production_on_actions.ts +6 -0
- package/src/constants/call_to_actions.test.ts +5 -0
- package/src/constants/call_to_actions.ts +14 -0
- package/src/constants/discount_types.test.ts +5 -0
- package/src/constants/discount_types.ts +3 -0
- package/src/constants/domain_types.test.ts +5 -0
- package/src/constants/domain_types.ts +12 -0
- package/src/constants/errors.ts +32 -0
- package/src/constants/event_types.test.ts +5 -0
- package/src/constants/event_types.ts +5 -0
- package/src/constants/field_types.test.ts +5 -0
- package/src/constants/field_types.ts +13 -0
- package/src/constants/input_types.test.ts +5 -0
- package/src/constants/input_types.ts +13 -0
- package/src/constants/inventory_status.test.ts +5 -0
- package/src/constants/inventory_statuses.ts +6 -0
- package/src/constants/invoice_types.test.ts +5 -0
- package/src/constants/invoice_types.ts +5 -0
- package/src/constants/item_types.test.ts +5 -0
- package/src/constants/item_types.ts +5 -0
- package/src/constants/job/drafting_status.test.ts +5 -0
- package/src/constants/job/drafting_status.ts +7 -0
- package/src/constants/job/payment_status.test.ts +5 -0
- package/src/constants/job/payment_status.ts +7 -0
- package/src/constants/job/production_status.test.ts +5 -0
- package/src/constants/job/production_status.ts +12 -0
- package/src/constants/job/shipment_status.test.ts +5 -0
- package/src/constants/job/shipment_status.ts +11 -0
- package/src/constants/job/supply_chain_request_status.test.ts +5 -0
- package/src/constants/job/supply_chain_request_status.ts +6 -0
- package/src/constants/job_priorities.test.ts +5 -0
- package/src/constants/job_priorities.ts +6 -0
- package/src/constants/job_status.test.ts +5 -0
- package/src/constants/job_status.ts +49 -0
- package/src/constants/job_types.test.ts +5 -0
- package/src/constants/job_types.ts +15 -0
- package/src/constants/notification_sections.test.ts +5 -0
- package/src/constants/notification_sections.ts +13 -0
- package/src/constants/notification_types.test.ts +5 -0
- package/src/constants/notification_types.ts +97 -0
- package/src/constants/notification_urgencies.test.ts +5 -0
- package/src/constants/notification_urgencies.ts +7 -0
- package/src/constants/payment_types.test.ts +5 -0
- package/src/constants/payment_types.ts +10 -0
- package/src/constants/platform.test.ts +15 -0
- package/src/constants/platform.ts +6 -0
- package/src/constants/product_types.test.ts +6 -0
- package/src/constants/product_types.ts +25 -0
- package/src/constants/rights.test.ts +5 -0
- package/src/constants/rights.ts +5 -0
- package/src/constants/robots_meta_directives.test.ts +5 -0
- package/src/constants/robots_meta_directives.ts +11 -0
- package/src/constants/roles.test.ts +5 -0
- package/src/constants/roles.ts +38 -0
- package/src/constants/shipment_companies.test.ts +5 -0
- package/src/constants/shipment_companies.ts +18 -0
- package/src/constants/shipment_services.test.ts +5 -0
- package/src/constants/shipment_services.ts +3 -0
- package/src/constants/system_roles.test.ts +5 -0
- package/src/constants/system_roles.ts +3 -0
- package/src/constants/theme_foundations.test.ts +5 -0
- package/src/constants/theme_foundations.ts +6 -0
- package/src/constants/theme_status.test.ts +5 -0
- package/src/constants/theme_status.ts +5 -0
- package/src/constants/user_types.test.ts +5 -0
- package/src/constants/user_types.ts +17 -0
- package/src/constants/white_label_accessibilities.test.ts +5 -0
- package/src/constants/white_label_accessibilities.ts +6 -0
- package/src/cookie.test.ts +11 -0
- package/src/cookie.ts +16 -0
- package/src/entities/address.test.ts +7 -0
- package/src/entities/address.ts +65 -0
- package/src/entities/assignment.test.ts +39 -0
- package/src/entities/assignment.ts +92 -0
- package/src/entities/automatic_payment_relationship.test.ts +8 -0
- package/src/entities/automatic_payment_relationship.ts +26 -0
- package/src/entities/backup.test.ts +7 -0
- package/src/entities/backup.ts +14 -0
- package/src/entities/bank.test.ts +7 -0
- package/src/entities/bank.ts +45 -0
- package/src/entities/cart.test.ts +50 -0
- package/src/entities/cart.ts +89 -0
- package/src/entities/cart_item.test.ts +33 -0
- package/src/entities/cart_item.ts +77 -0
- package/src/entities/cart_shipment_group.ts +21 -0
- package/src/entities/cart_shipment_quote.ts +33 -0
- package/src/entities/category.test.ts +57 -0
- package/src/entities/category.ts +37 -0
- package/src/entities/company.test.ts +7 -0
- package/src/entities/company.ts +275 -0
- package/src/entities/company_invitation.test.ts +7 -0
- package/src/entities/company_invitation.ts +33 -0
- package/src/entities/component.test.ts +14 -0
- package/src/entities/component.ts +92 -0
- package/src/entities/component_tag.test.ts +7 -0
- package/src/entities/component_tag.ts +17 -0
- package/src/entities/component_version.test.ts +7 -0
- package/src/entities/component_version.ts +30 -0
- package/src/entities/country_tax.test.ts +13 -0
- package/src/entities/country_tax.ts +46 -0
- package/src/entities/discount.test.ts +18 -0
- package/src/entities/discount.ts +34 -0
- package/src/entities/discount_group.test.ts +7 -0
- package/src/entities/discount_group.ts +28 -0
- package/src/entities/domain.test.ts +79 -0
- package/src/entities/domain.ts +246 -0
- package/src/entities/domain_invitation.test.ts +7 -0
- package/src/entities/domain_invitation.ts +36 -0
- package/src/entities/domain_tag.test.ts +7 -0
- package/src/entities/domain_tag.ts +42 -0
- package/src/entities/draft.test.ts +43 -0
- package/src/entities/draft.ts +88 -0
- package/src/entities/draft_comment.test.ts +7 -0
- package/src/entities/draft_comment.ts +54 -0
- package/src/entities/draft_template.test.ts +7 -0
- package/src/entities/draft_template.ts +40 -0
- package/src/entities/email_address.test.ts +7 -0
- package/src/entities/email_address.ts +24 -0
- package/src/entities/email_counter.test.ts +7 -0
- package/src/entities/email_counter.ts +20 -0
- package/src/entities/enrolled_domain.test.ts +7 -0
- package/src/entities/enrolled_domain.ts +40 -0
- package/src/entities/exchange_rate.test.ts +7 -0
- package/src/entities/exchange_rate.ts +22 -0
- package/src/entities/file.test.ts +43 -0
- package/src/entities/file.ts +172 -0
- package/src/entities/internal_tag.test.ts +7 -0
- package/src/entities/internal_tag.ts +51 -0
- package/src/entities/inventory.test.ts +28 -0
- package/src/entities/inventory.ts +56 -0
- package/src/entities/inventory_unit_variation.test.ts +7 -0
- package/src/entities/inventory_unit_variation.ts +29 -0
- package/src/entities/invoice.test.ts +43 -0
- package/src/entities/invoice.ts +179 -0
- package/src/entities/item.test.ts +19 -0
- package/src/entities/item.ts +44 -0
- package/src/entities/job.test.ts +95 -0
- package/src/entities/job.ts +349 -0
- package/src/entities/job_comment.test.ts +7 -0
- package/src/entities/job_comment.ts +50 -0
- package/src/entities/matching_inventory.ts +29 -0
- package/src/entities/menu.test.ts +7 -0
- package/src/entities/menu.ts +30 -0
- package/src/entities/menu_item.test.ts +7 -0
- package/src/entities/menu_item.ts +29 -0
- package/src/entities/notification.test.ts +7 -0
- package/src/entities/notification.ts +99 -0
- package/src/entities/page.test.ts +7 -0
- package/src/entities/page.ts +32 -0
- package/src/entities/payment.test.ts +19 -0
- package/src/entities/payment.ts +65 -0
- package/src/entities/payment_device.test.ts +7 -0
- package/src/entities/payment_device.ts +30 -0
- package/src/entities/phone_number.test.ts +7 -0
- package/src/entities/phone_number.ts +36 -0
- package/src/entities/product.test.ts +750 -0
- package/src/entities/product.ts +427 -0
- package/src/entities/production_comment.test.ts +7 -0
- package/src/entities/production_comment.ts +50 -0
- package/src/entities/quote.test.ts +98 -0
- package/src/entities/quote.ts +140 -0
- package/src/entities/quote_item.test.ts +50 -0
- package/src/entities/quote_item.ts +71 -0
- package/src/entities/seo_domain_page.test.ts +7 -0
- package/src/entities/seo_domain_page.ts +33 -0
- package/src/entities/session.test.ts +7 -0
- package/src/entities/session.ts +28 -0
- package/src/entities/shipment.test.ts +24 -0
- package/src/entities/shipment.ts +185 -0
- package/src/entities/shipment_item.test.ts +7 -0
- package/src/entities/shipment_item.ts +15 -0
- package/src/entities/shipment_item_fulfillment.test.ts +8 -0
- package/src/entities/shipment_item_fulfillment.ts +15 -0
- package/src/entities/shipment_method.test.ts +7 -0
- package/src/entities/shipment_method.ts +61 -0
- package/src/entities/shipment_method_variation.test.ts +7 -0
- package/src/entities/shipment_method_variation.ts +39 -0
- package/src/entities/short_url.test.ts +7 -0
- package/src/entities/short_url.ts +36 -0
- package/src/entities/subscription_plan.test.ts +7 -0
- package/src/entities/subscription_plan.ts +73 -0
- package/src/entities/supply_domain.test.ts +7 -0
- package/src/entities/supply_domain.ts +27 -0
- package/src/entities/system_role.test.ts +7 -0
- package/src/entities/system_role.ts +17 -0
- package/src/entities/theme.test.ts +38 -0
- package/src/entities/theme.ts +267 -0
- package/src/entities/theme_css_setting.test.ts +7 -0
- package/src/entities/theme_css_setting.ts +23 -0
- package/src/entities/user.test.ts +154 -0
- package/src/entities/user.ts +394 -0
- package/src/entities/user_company.test.ts +7 -0
- package/src/entities/user_company.ts +27 -0
- package/src/entities/variation.test.ts +7 -0
- package/src/entities/variation.ts +61 -0
- package/src/entities/variation_field.test.ts +76 -0
- package/src/entities/variation_field.ts +169 -0
- package/src/entities/variation_fields_option.test.ts +46 -0
- package/src/entities/variation_fields_option.ts +95 -0
- package/src/entities/variation_option.test.ts +7 -0
- package/src/entities/variation_option.ts +52 -0
- package/src/entities/variations_group.test.ts +7 -0
- package/src/entities/variations_group.ts +41 -0
- package/src/entity.ts +1002 -0
- package/src/merchi.test.ts +25 -0
- package/src/merchi.ts +379 -0
- package/src/request.test.ts +43 -0
- package/src/request.ts +124 -0
- package/src/test_util.ts +18 -0
- package/src/toasts.test.ts +38 -0
- package/src/toasts.ts +34 -0
- package/src/util/float.ts +12 -0
- package/src/util/query_string.test.ts +7 -0
- package/src/util/query_string.ts +11 -0
- package/src/util/validation.test.ts +16 -0
- package/src/util/validation.ts +2 -0
- package/src/uuid.test.ts +15 -0
- package/src/uuid.ts +8 -0
- package/tsconfig.json +23 -0
- package/webpack.config.cjs +27 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Domain } from './domain';
|
|
2
|
+
import { Entity } from '../entity';
|
|
3
|
+
import { User } from './user';
|
|
4
|
+
|
|
5
|
+
export class DomainInvitation extends Entity {
|
|
6
|
+
protected static resourceName = 'domain_invitations';
|
|
7
|
+
protected static singularName = 'domainInvitation';
|
|
8
|
+
protected static pluralName = 'domainInvitations';
|
|
9
|
+
|
|
10
|
+
@DomainInvitation.property({type: Date})
|
|
11
|
+
public archived?: Date | null;
|
|
12
|
+
|
|
13
|
+
@DomainInvitation.property()
|
|
14
|
+
public id?: number;
|
|
15
|
+
|
|
16
|
+
@DomainInvitation.property()
|
|
17
|
+
public userName?: string;
|
|
18
|
+
|
|
19
|
+
@DomainInvitation.property()
|
|
20
|
+
public userEmail?: string;
|
|
21
|
+
|
|
22
|
+
@DomainInvitation.property()
|
|
23
|
+
public role?: number;
|
|
24
|
+
|
|
25
|
+
@DomainInvitation.property()
|
|
26
|
+
public token?: string;
|
|
27
|
+
|
|
28
|
+
@DomainInvitation.property()
|
|
29
|
+
public domain?: Domain;
|
|
30
|
+
|
|
31
|
+
@DomainInvitation.property()
|
|
32
|
+
public sender?: User;
|
|
33
|
+
|
|
34
|
+
@DomainInvitation.property({type: Date})
|
|
35
|
+
public user?: User | null;
|
|
36
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Domain } from './domain';
|
|
2
|
+
import { Entity } from '../entity';
|
|
3
|
+
import { Invoice } from './invoice';
|
|
4
|
+
import { Job } from './job';
|
|
5
|
+
import { Product } from './product';
|
|
6
|
+
import { Shipment } from './shipment';
|
|
7
|
+
|
|
8
|
+
export class DomainTag extends Entity {
|
|
9
|
+
protected static resourceName = 'domain_tags';
|
|
10
|
+
protected static singularName = 'domainTag';
|
|
11
|
+
protected static pluralName = 'domainTags';
|
|
12
|
+
|
|
13
|
+
@DomainTag.property()
|
|
14
|
+
public id?: number;
|
|
15
|
+
|
|
16
|
+
@DomainTag.property()
|
|
17
|
+
public colour?: number;
|
|
18
|
+
|
|
19
|
+
@DomainTag.property()
|
|
20
|
+
public name?: string;
|
|
21
|
+
|
|
22
|
+
@DomainTag.property()
|
|
23
|
+
public description?: string;
|
|
24
|
+
|
|
25
|
+
@DomainTag.property()
|
|
26
|
+
public showPublic?: boolean;
|
|
27
|
+
|
|
28
|
+
@DomainTag.property()
|
|
29
|
+
public domain?: Domain;
|
|
30
|
+
|
|
31
|
+
@DomainTag.property({arrayType: 'Job'})
|
|
32
|
+
public jobs?: Job[];
|
|
33
|
+
|
|
34
|
+
@DomainTag.property({arrayType: 'Product'})
|
|
35
|
+
public products?: Product[];
|
|
36
|
+
|
|
37
|
+
@DomainTag.property({arrayType: 'Invoice'})
|
|
38
|
+
public invoices?: Invoice[];
|
|
39
|
+
|
|
40
|
+
@DomainTag.property({arrayType: 'Shipment'})
|
|
41
|
+
public shipments?: Shipment[];
|
|
42
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Merchi } from '../merchi';
|
|
2
|
+
|
|
3
|
+
test('can make Draft', () => {
|
|
4
|
+
const merchi = new Merchi();
|
|
5
|
+
const draft = new merchi.Draft();
|
|
6
|
+
expect(draft).toBeTruthy();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('wereChangesRequested', () => {
|
|
10
|
+
const merchi = new Merchi();
|
|
11
|
+
const draft = new merchi.Draft();
|
|
12
|
+
expect(draft.wereChangesRequested).toThrow();
|
|
13
|
+
draft.comments = [];
|
|
14
|
+
expect(draft.wereChangesRequested()).toBe(false);
|
|
15
|
+
draft.comments = [new merchi.DraftComment()];
|
|
16
|
+
expect(draft.wereChangesRequested).toThrow();
|
|
17
|
+
draft.comments[0].changeRequest = false;
|
|
18
|
+
expect(draft.wereChangesRequested()).toBe(false);
|
|
19
|
+
draft.comments[0].changeRequest = true;
|
|
20
|
+
expect(draft.wereChangesRequested()).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('commentsYoungestToEldest', () => {
|
|
24
|
+
const merchi = new Merchi();
|
|
25
|
+
const draft = new merchi.Draft();
|
|
26
|
+
expect(draft.commentsYoungestToEldest).toThrow();
|
|
27
|
+
draft.comments = [];
|
|
28
|
+
expect(draft.commentsYoungestToEldest()).toEqual([]);
|
|
29
|
+
draft.comments = [new merchi.DraftComment(), new merchi.DraftComment()];
|
|
30
|
+
expect(draft.commentsYoungestToEldest).toThrow();
|
|
31
|
+
draft.comments[0].id = 2;
|
|
32
|
+
draft.comments[1].id = 1;
|
|
33
|
+
expect(draft.commentsYoungestToEldest()[0].id).toEqual(1);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('draft accepted serialised to milliseconds', () => {
|
|
37
|
+
const merchi = new Merchi();
|
|
38
|
+
const draft = new merchi.Draft();
|
|
39
|
+
draft.accepted = new Date('Feb 28 2013 19:00:00 GMT-0500');
|
|
40
|
+
const correct = [['accepted', '1362096000']];
|
|
41
|
+
const backData = Array.from((draft.toFormData() as any).entries());
|
|
42
|
+
expect(backData).toEqual(correct);
|
|
43
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { DraftComment } from './draft_comment';
|
|
2
|
+
import { Entity } from '../entity';
|
|
3
|
+
import { MerchiFile } from './file';
|
|
4
|
+
import { Job } from './job';
|
|
5
|
+
import { Notification } from './notification';
|
|
6
|
+
import { User } from './user';
|
|
7
|
+
|
|
8
|
+
export class Draft extends Entity {
|
|
9
|
+
protected static resourceName = 'drafts';
|
|
10
|
+
protected static singularName = 'draft';
|
|
11
|
+
protected static pluralName = 'drafts';
|
|
12
|
+
|
|
13
|
+
@Draft.property({type: Date})
|
|
14
|
+
public archived?: Date | null;
|
|
15
|
+
|
|
16
|
+
@Draft.property()
|
|
17
|
+
public id?: number;
|
|
18
|
+
|
|
19
|
+
@Draft.property({type: Date})
|
|
20
|
+
public date?: Date | null;
|
|
21
|
+
|
|
22
|
+
@Draft.property({type: Date})
|
|
23
|
+
public accepted?: Date | null;
|
|
24
|
+
|
|
25
|
+
@Draft.property({type: Date})
|
|
26
|
+
public resendDate?: Date | null;
|
|
27
|
+
|
|
28
|
+
@Draft.property()
|
|
29
|
+
public viewed?: boolean;
|
|
30
|
+
|
|
31
|
+
@Draft.property()
|
|
32
|
+
public sendSms?: boolean;
|
|
33
|
+
|
|
34
|
+
@Draft.property()
|
|
35
|
+
public sendEmail?: boolean;
|
|
36
|
+
|
|
37
|
+
@Draft.property({arrayType: 'DraftComment'})
|
|
38
|
+
public comments?: DraftComment[];
|
|
39
|
+
|
|
40
|
+
@Draft.property()
|
|
41
|
+
public commentsCount?: number;
|
|
42
|
+
|
|
43
|
+
@Draft.property()
|
|
44
|
+
public changesRequested?: boolean;
|
|
45
|
+
|
|
46
|
+
@Draft.property()
|
|
47
|
+
public designer?: User;
|
|
48
|
+
|
|
49
|
+
@Draft.property({arrayType: 'MerchiFile'})
|
|
50
|
+
public images?: MerchiFile[];
|
|
51
|
+
|
|
52
|
+
@Draft.property({arrayType: 'Notification'})
|
|
53
|
+
public notification?: Notification[];
|
|
54
|
+
|
|
55
|
+
@Draft.property()
|
|
56
|
+
public job?: Job;
|
|
57
|
+
|
|
58
|
+
@Draft.property()
|
|
59
|
+
public sharedWithJob?: Job;
|
|
60
|
+
|
|
61
|
+
public wereChangesRequested = () => {
|
|
62
|
+
/* true if any comment is/was a change request comment. */
|
|
63
|
+
if (this.comments === undefined) {
|
|
64
|
+
throw 'comments is undefined. did you forget to embed it?';
|
|
65
|
+
}
|
|
66
|
+
for (const comment of this.comments) {
|
|
67
|
+
if (comment.changeRequest === undefined) {
|
|
68
|
+
throw 'changeRequest is undefined.';
|
|
69
|
+
}
|
|
70
|
+
if (comment.changeRequest) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
public commentsYoungestToEldest = () => {
|
|
78
|
+
if (this.comments === undefined) {
|
|
79
|
+
throw 'comments is undefined. did you forget to embed it?';
|
|
80
|
+
}
|
|
81
|
+
return this.comments.sort((a, b) => {
|
|
82
|
+
if (a.id === undefined || b.id === undefined) {
|
|
83
|
+
throw 'comment id is undefined. did you forget to embed it?';
|
|
84
|
+
}
|
|
85
|
+
return a.id - b.id;
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Draft } from './draft';
|
|
2
|
+
import { Entity } from '../entity';
|
|
3
|
+
import { MerchiFile } from './file';
|
|
4
|
+
import { Job } from './job';
|
|
5
|
+
import { Notification } from './notification';
|
|
6
|
+
import { User } from './user';
|
|
7
|
+
|
|
8
|
+
export class DraftComment extends Entity {
|
|
9
|
+
protected static resourceName = 'draft_comments';
|
|
10
|
+
protected static singularName = 'draftComment';
|
|
11
|
+
protected static pluralName = 'draftComments';
|
|
12
|
+
|
|
13
|
+
@DraftComment.property({type: Date})
|
|
14
|
+
public archived?: Date | null;
|
|
15
|
+
|
|
16
|
+
@DraftComment.property()
|
|
17
|
+
public id?: number;
|
|
18
|
+
|
|
19
|
+
@DraftComment.property({type: Date})
|
|
20
|
+
public date?: Date | null;
|
|
21
|
+
|
|
22
|
+
@DraftComment.property()
|
|
23
|
+
public urgency?: number;
|
|
24
|
+
|
|
25
|
+
@DraftComment.property()
|
|
26
|
+
public text?: string;
|
|
27
|
+
|
|
28
|
+
@DraftComment.property()
|
|
29
|
+
public changeRequest?: boolean;
|
|
30
|
+
|
|
31
|
+
@DraftComment.property()
|
|
32
|
+
public sendSms?: boolean;
|
|
33
|
+
|
|
34
|
+
@DraftComment.property()
|
|
35
|
+
public sendEmail?: boolean;
|
|
36
|
+
|
|
37
|
+
@DraftComment.property()
|
|
38
|
+
public user?: User;
|
|
39
|
+
|
|
40
|
+
@DraftComment.property({arrayType: "MerchiFile"})
|
|
41
|
+
public files?: MerchiFile[];
|
|
42
|
+
|
|
43
|
+
@DraftComment.property({arrayType: 'User'})
|
|
44
|
+
public forwards?: User[];
|
|
45
|
+
|
|
46
|
+
@DraftComment.property({arrayType: 'Notification'})
|
|
47
|
+
public notifications?: Notification[];
|
|
48
|
+
|
|
49
|
+
@DraftComment.property({type: Draft})
|
|
50
|
+
public draft?: Draft | null;
|
|
51
|
+
|
|
52
|
+
@DraftComment.property({type: Job})
|
|
53
|
+
public job?: Job | null;
|
|
54
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Entity } from '../entity';
|
|
2
|
+
import { MerchiFile } from './file';
|
|
3
|
+
import { Job } from './job';
|
|
4
|
+
import { Product } from './product';
|
|
5
|
+
|
|
6
|
+
export class DraftTemplate extends Entity {
|
|
7
|
+
protected static resourceName = 'draft_templates';
|
|
8
|
+
protected static singularName = 'draftTemplate';
|
|
9
|
+
protected static pluralName = 'draftTemplates';
|
|
10
|
+
|
|
11
|
+
@DraftTemplate.property({type: Date})
|
|
12
|
+
public archived?: Date | null;
|
|
13
|
+
|
|
14
|
+
@DraftTemplate.property()
|
|
15
|
+
public id?: number;
|
|
16
|
+
|
|
17
|
+
@DraftTemplate.property({type: Date})
|
|
18
|
+
public date?: Date | null;
|
|
19
|
+
|
|
20
|
+
@DraftTemplate.property()
|
|
21
|
+
public description?: string;
|
|
22
|
+
|
|
23
|
+
@DraftTemplate.property()
|
|
24
|
+
public name?: string;
|
|
25
|
+
|
|
26
|
+
@DraftTemplate.property()
|
|
27
|
+
public height?: number;
|
|
28
|
+
|
|
29
|
+
@DraftTemplate.property()
|
|
30
|
+
public width?: number;
|
|
31
|
+
|
|
32
|
+
@DraftTemplate.property({type: MerchiFile})
|
|
33
|
+
public file?: MerchiFile;
|
|
34
|
+
|
|
35
|
+
@DraftTemplate.property({type: Product})
|
|
36
|
+
public product?: Product | null;
|
|
37
|
+
|
|
38
|
+
@DraftTemplate.property({type: Job})
|
|
39
|
+
public job?: Job | null;
|
|
40
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Company } from './company';
|
|
2
|
+
import { Entity } from '../entity';
|
|
3
|
+
import { User } from './user';
|
|
4
|
+
|
|
5
|
+
export class EmailAddress extends Entity {
|
|
6
|
+
protected static resourceName = 'email_addresses';
|
|
7
|
+
protected static singularName = 'emailAddress';
|
|
8
|
+
protected static pluralName = 'emailAddresses';
|
|
9
|
+
|
|
10
|
+
@EmailAddress.property({type: Date})
|
|
11
|
+
public archived?: Date | null;
|
|
12
|
+
|
|
13
|
+
@EmailAddress.property()
|
|
14
|
+
public id?: number;
|
|
15
|
+
|
|
16
|
+
@EmailAddress.property()
|
|
17
|
+
public emailAddress?: string;
|
|
18
|
+
|
|
19
|
+
@EmailAddress.property({arrayType: 'User'})
|
|
20
|
+
public users?: User[];
|
|
21
|
+
|
|
22
|
+
@EmailAddress.property({arrayType: 'Company'})
|
|
23
|
+
public companies?: Company[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Entity } from '../entity';
|
|
2
|
+
|
|
3
|
+
export class EmailCounter extends Entity {
|
|
4
|
+
protected static resourceName = 'email_counters';
|
|
5
|
+
protected static singularName = 'emailCounter';
|
|
6
|
+
protected static pluralName = 'emailCounters';
|
|
7
|
+
protected static primaryKey = 'emailAddress';
|
|
8
|
+
|
|
9
|
+
@EmailCounter.property()
|
|
10
|
+
public emailAddress?: string;
|
|
11
|
+
|
|
12
|
+
@EmailCounter.property()
|
|
13
|
+
public unsubscribed?: boolean;
|
|
14
|
+
|
|
15
|
+
@EmailCounter.property()
|
|
16
|
+
public silenced?: boolean;
|
|
17
|
+
|
|
18
|
+
@EmailCounter.property()
|
|
19
|
+
public tokens?: number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Domain } from './domain';
|
|
2
|
+
import { Entity } from '../entity';
|
|
3
|
+
import { User } from './user';
|
|
4
|
+
import { Role } from '../constants/roles';
|
|
5
|
+
import { DomainType } from '../constants/domain_types';
|
|
6
|
+
|
|
7
|
+
export class EnrolledDomain extends Entity {
|
|
8
|
+
protected static resourceName = 'enrolled_domains';
|
|
9
|
+
protected static singularName = 'enrolledDomain';
|
|
10
|
+
protected static pluralName = 'enrolledDomains';
|
|
11
|
+
|
|
12
|
+
@EnrolledDomain.property({type: Date})
|
|
13
|
+
public archived?: Date | null;
|
|
14
|
+
|
|
15
|
+
@EnrolledDomain.property()
|
|
16
|
+
public id?: number;
|
|
17
|
+
|
|
18
|
+
@EnrolledDomain.property()
|
|
19
|
+
public isJobsAssignee?: boolean;
|
|
20
|
+
|
|
21
|
+
@EnrolledDomain.property()
|
|
22
|
+
public role?: Role;
|
|
23
|
+
|
|
24
|
+
@EnrolledDomain.property()
|
|
25
|
+
public user?: User;
|
|
26
|
+
|
|
27
|
+
@EnrolledDomain.property()
|
|
28
|
+
public domain?: Domain;
|
|
29
|
+
|
|
30
|
+
public getRole(): Role {
|
|
31
|
+
if (this.domain === undefined) {
|
|
32
|
+
const err = 'domain is undefined, did you forget to embed it?';
|
|
33
|
+
throw new Error(err);
|
|
34
|
+
}
|
|
35
|
+
if (this.domain.domainType === DomainType.DOMAIN_SUPPLIER) {
|
|
36
|
+
return Role.SUPPLIER;
|
|
37
|
+
}
|
|
38
|
+
return this.role ? this.role : Role.PUBLIC;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Entity } from '../entity';
|
|
2
|
+
|
|
3
|
+
export class ExchangeRate extends Entity {
|
|
4
|
+
protected static resourceName = 'exchange_rates';
|
|
5
|
+
protected static singularName = 'exchangeRate';
|
|
6
|
+
protected static pluralName = 'exchangeRates';
|
|
7
|
+
|
|
8
|
+
@ExchangeRate.property()
|
|
9
|
+
public id?: number;
|
|
10
|
+
|
|
11
|
+
@ExchangeRate.property()
|
|
12
|
+
public fromCurrency?: string;
|
|
13
|
+
|
|
14
|
+
@ExchangeRate.property()
|
|
15
|
+
public toCurrency?: string;
|
|
16
|
+
|
|
17
|
+
@ExchangeRate.property()
|
|
18
|
+
public rate?: number;
|
|
19
|
+
|
|
20
|
+
@ExchangeRate.property()
|
|
21
|
+
public lastUpdated?: Date;
|
|
22
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Merchi } from '../merchi';
|
|
2
|
+
import { setup, mockFetch } from '../test_util';
|
|
3
|
+
|
|
4
|
+
setup();
|
|
5
|
+
|
|
6
|
+
test('can make file', () => {
|
|
7
|
+
const merchi = new Merchi();
|
|
8
|
+
const file = new merchi.MerchiFile();
|
|
9
|
+
expect(file).toBeTruthy();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('can get and set id', () => {
|
|
13
|
+
const merchi = new Merchi();
|
|
14
|
+
const file = new merchi.MerchiFile();
|
|
15
|
+
file.id = 2;
|
|
16
|
+
expect(file.id).toBe(2);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('can upload file', () => {
|
|
20
|
+
const merchi = new Merchi();
|
|
21
|
+
const file = new merchi.MerchiFile();
|
|
22
|
+
const jsFile = new File([''], 'name');
|
|
23
|
+
file.fromFormFile(jsFile);
|
|
24
|
+
const fetch = mockFetch(true, {}, 200);
|
|
25
|
+
file.create();
|
|
26
|
+
const sentToServer = fetch.mock.calls[0][1];
|
|
27
|
+
expect(sentToServer.method).toBe('POST');
|
|
28
|
+
const data: any = Array.from(sentToServer.body.entries());
|
|
29
|
+
expect(data[0][1]).toBe(jsFile);
|
|
30
|
+
expect(data[1]).toEqual(['fileDataIndex', '0']);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('isImage', () => {
|
|
34
|
+
const merchi = new Merchi();
|
|
35
|
+
const file = new merchi.MerchiFile();
|
|
36
|
+
expect(file.isImage).toThrow();
|
|
37
|
+
file.mimetype = null;
|
|
38
|
+
expect(file.isImage()).toEqual(false);
|
|
39
|
+
file.mimetype = 'application/pdf';
|
|
40
|
+
expect(file.isImage()).toEqual(false);
|
|
41
|
+
file.mimetype = 'image/png';
|
|
42
|
+
expect(file.isImage()).toEqual(true);
|
|
43
|
+
});
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Backup } from './backup';
|
|
2
|
+
import { Company } from './company';
|
|
3
|
+
import { Component } from './component';
|
|
4
|
+
import { Domain } from './domain';
|
|
5
|
+
import { Draft } from './draft';
|
|
6
|
+
import { DraftComment } from './draft_comment';
|
|
7
|
+
import { Entity } from '../entity';
|
|
8
|
+
import { Invoice } from './invoice';
|
|
9
|
+
import { Job } from './job';
|
|
10
|
+
import { JobComment } from './job_comment';
|
|
11
|
+
import { Notification } from './notification';
|
|
12
|
+
import { Product } from './product';
|
|
13
|
+
import { ProductionComment } from './production_comment';
|
|
14
|
+
import { Theme } from './theme';
|
|
15
|
+
import { User } from './user';
|
|
16
|
+
import { Variation } from './variation';
|
|
17
|
+
import { VariationFieldsOption } from './variation_fields_option';
|
|
18
|
+
|
|
19
|
+
export class MerchiFile extends Entity {
|
|
20
|
+
protected static resourceName = 'files';
|
|
21
|
+
protected static singularName = 'file';
|
|
22
|
+
protected static pluralName = 'files';
|
|
23
|
+
|
|
24
|
+
public fileData?: File;
|
|
25
|
+
|
|
26
|
+
public fromFormFile = (file: File) => {
|
|
27
|
+
this.fileData = file;
|
|
28
|
+
this.mimetype = file.type || 'application/octet-stream';
|
|
29
|
+
this.name = file.name;
|
|
30
|
+
this.size = file.size;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
@MerchiFile.property({type: Date})
|
|
34
|
+
public archived?: Date | null;
|
|
35
|
+
|
|
36
|
+
@MerchiFile.property()
|
|
37
|
+
public id?: number;
|
|
38
|
+
|
|
39
|
+
@MerchiFile.property()
|
|
40
|
+
public uploadId?: string;
|
|
41
|
+
|
|
42
|
+
@MerchiFile.property({type: String})
|
|
43
|
+
public name?: string | null;
|
|
44
|
+
|
|
45
|
+
@MerchiFile.property({type: String})
|
|
46
|
+
public mimetype?: string | null;
|
|
47
|
+
|
|
48
|
+
@MerchiFile.property()
|
|
49
|
+
public size?: number;
|
|
50
|
+
|
|
51
|
+
@MerchiFile.property({type: Date})
|
|
52
|
+
public creationDate?: Date | null;
|
|
53
|
+
|
|
54
|
+
@MerchiFile.property({type: String})
|
|
55
|
+
public cachedViewUrl?: string | null;
|
|
56
|
+
|
|
57
|
+
@MerchiFile.property({type: Date})
|
|
58
|
+
public viewUrlExpires?: Date | null;
|
|
59
|
+
|
|
60
|
+
@MerchiFile.property({type: String})
|
|
61
|
+
public cachedDownloadUrl?: string | null;
|
|
62
|
+
|
|
63
|
+
@MerchiFile.property({type: Date})
|
|
64
|
+
public downloadUrlExpires?: Date | null;
|
|
65
|
+
|
|
66
|
+
@MerchiFile.property({type: User})
|
|
67
|
+
public uploader?: User | null;
|
|
68
|
+
|
|
69
|
+
@MerchiFile.property()
|
|
70
|
+
public viewUrl?: string;
|
|
71
|
+
|
|
72
|
+
@MerchiFile.property()
|
|
73
|
+
public downloadUrl?: string;
|
|
74
|
+
|
|
75
|
+
@MerchiFile.property({arrayType: 'Component'})
|
|
76
|
+
public components?: Component[];
|
|
77
|
+
|
|
78
|
+
@MerchiFile.property({arrayType: 'Component'})
|
|
79
|
+
public componentFeatureImages?: Component[];
|
|
80
|
+
|
|
81
|
+
@MerchiFile.property({arrayType: 'DraftComment'})
|
|
82
|
+
public draftComments?: DraftComment[];
|
|
83
|
+
|
|
84
|
+
@MerchiFile.property({arrayType: 'Variation'})
|
|
85
|
+
public variations?: Variation[];
|
|
86
|
+
|
|
87
|
+
@MerchiFile.property({arrayType: 'Backup'})
|
|
88
|
+
public backups?: Backup[];
|
|
89
|
+
|
|
90
|
+
@MerchiFile.property({arrayType: 'Notification'})
|
|
91
|
+
public notification?: Notification[];
|
|
92
|
+
|
|
93
|
+
@MerchiFile.property({arrayType: 'Company'})
|
|
94
|
+
public companyLogos?: Company[];
|
|
95
|
+
|
|
96
|
+
@MerchiFile.property({arrayType: 'Product'})
|
|
97
|
+
public products?: Product[];
|
|
98
|
+
|
|
99
|
+
@MerchiFile.property({arrayType: 'Product'})
|
|
100
|
+
public featuredProducts?: Product[];
|
|
101
|
+
|
|
102
|
+
@MerchiFile.property({arrayType: 'Draft'})
|
|
103
|
+
public drafts?: Draft[];
|
|
104
|
+
|
|
105
|
+
@MerchiFile.property({arrayType: 'VariationFieldsOption'})
|
|
106
|
+
public options?: VariationFieldsOption[];
|
|
107
|
+
|
|
108
|
+
@MerchiFile.property({arrayType: 'JobComment'})
|
|
109
|
+
public jobComments?: JobComment[];
|
|
110
|
+
|
|
111
|
+
@MerchiFile.property({arrayType: 'Job'})
|
|
112
|
+
public jobs?: Job[];
|
|
113
|
+
|
|
114
|
+
@MerchiFile.property({arrayType: 'Job'})
|
|
115
|
+
public clientJobs?: Job[];
|
|
116
|
+
|
|
117
|
+
@MerchiFile.property({arrayType: 'Domain'})
|
|
118
|
+
public domainLogos?: Domain[];
|
|
119
|
+
|
|
120
|
+
@MerchiFile.property({arrayType: 'Domain'})
|
|
121
|
+
public domainFavicons?: Domain[];
|
|
122
|
+
|
|
123
|
+
@MerchiFile.property({arrayType: 'User'})
|
|
124
|
+
public userProfilePictures?: User[];
|
|
125
|
+
|
|
126
|
+
@MerchiFile.property({arrayType: 'Invoice'})
|
|
127
|
+
public invoices?: Invoice[];
|
|
128
|
+
|
|
129
|
+
@MerchiFile.property({arrayType: 'Invoice'})
|
|
130
|
+
public invoicesPaid?: Invoice[];
|
|
131
|
+
|
|
132
|
+
@MerchiFile.property({arrayType: 'Theme'})
|
|
133
|
+
public themeMainCss?: Theme[];
|
|
134
|
+
|
|
135
|
+
@MerchiFile.property({arrayType: 'Theme'})
|
|
136
|
+
public themeMainCssUsing?: Theme[];
|
|
137
|
+
|
|
138
|
+
@MerchiFile.property({arrayType: 'Theme'})
|
|
139
|
+
public themeMainCssEditing?: Theme[];
|
|
140
|
+
|
|
141
|
+
@MerchiFile.property({arrayType: 'Theme'})
|
|
142
|
+
public themeEmailCss?: Theme[];
|
|
143
|
+
|
|
144
|
+
@MerchiFile.property({arrayType: 'Theme'})
|
|
145
|
+
public themeEmailCssUsing?: Theme[];
|
|
146
|
+
|
|
147
|
+
@MerchiFile.property({arrayType: 'Theme'})
|
|
148
|
+
public themeEmailCssEditing?: Theme[];
|
|
149
|
+
|
|
150
|
+
@MerchiFile.property({arrayType: 'Theme'})
|
|
151
|
+
public themes?: Theme[];
|
|
152
|
+
|
|
153
|
+
@MerchiFile.property({arrayType: 'Theme'})
|
|
154
|
+
public themeFeatureImages?: Theme[];
|
|
155
|
+
|
|
156
|
+
@MerchiFile.property({arrayType: 'Theme'})
|
|
157
|
+
public themeImages?: Theme[];
|
|
158
|
+
|
|
159
|
+
@MerchiFile.property({arrayType: 'ProductionComment'})
|
|
160
|
+
public productionComments?: ProductionComment[];
|
|
161
|
+
|
|
162
|
+
public isImage = () => {
|
|
163
|
+
if (this.mimetype === undefined) {
|
|
164
|
+
const err = 'mimetype is undefined, did you forget to embed it?';
|
|
165
|
+
throw new Error(err);
|
|
166
|
+
}
|
|
167
|
+
if (this.mimetype === null) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
return this.mimetype.split('/')[0] === 'image';
|
|
171
|
+
};
|
|
172
|
+
}
|