merchi_sdk_js 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. package/dist/address.js +109 -0
  2. package/dist/assignment.js +175 -0
  3. package/dist/automatic_payment_relationship.js +72 -0
  4. package/dist/backup.js +32 -0
  5. package/dist/bank.js +25 -0
  6. package/dist/cart.js +133 -0
  7. package/dist/cart_item.js +71 -0
  8. package/dist/cart_shipment_group.js +23 -0
  9. package/dist/cart_shipment_quote.js +26 -0
  10. package/dist/category.js +68 -0
  11. package/dist/company.js +248 -0
  12. package/dist/company_invitation.js +70 -0
  13. package/dist/component.js +107 -0
  14. package/dist/component_tag.js +60 -0
  15. package/dist/component_version.js +21 -0
  16. package/dist/country_tax.js +93 -0
  17. package/dist/dictionary.js +130 -0
  18. package/dist/discount.js +22 -0
  19. package/dist/discount_group.js +18 -0
  20. package/dist/domain.js +245 -0
  21. package/dist/domain_invitation.js +17 -0
  22. package/dist/domain_tag.js +87 -0
  23. package/dist/domain_types.js +22 -0
  24. package/dist/draft.js +97 -0
  25. package/dist/draft_comment.js +45 -0
  26. package/dist/draft_template.js +39 -0
  27. package/dist/email_address.js +34 -0
  28. package/dist/email_counter.js +47 -0
  29. package/dist/enrolled_domain.js +88 -0
  30. package/dist/exchange_rate.js +66 -0
  31. package/dist/field_types.js +19 -0
  32. package/dist/helpers.js +86 -0
  33. package/dist/internal_tag.js +98 -0
  34. package/dist/inventory.js +100 -0
  35. package/dist/inventory_unit_variation.js +19 -0
  36. package/dist/invoice.js +225 -0
  37. package/dist/invoice_types.js +11 -0
  38. package/dist/item.js +25 -0
  39. package/dist/job.js +536 -0
  40. package/dist/job_comment.js +45 -0
  41. package/dist/job_status.js +47 -0
  42. package/dist/matching_inventory.js +21 -0
  43. package/dist/md5.js +149 -0
  44. package/dist/menu.js +37 -0
  45. package/dist/menu_item.js +24 -0
  46. package/dist/merchi.js +1004 -0
  47. package/dist/merchi_file.js +165 -0
  48. package/dist/model.js +753 -0
  49. package/dist/notification.js +151 -0
  50. package/dist/notification_types.js +199 -0
  51. package/dist/output.cjs.js +31317 -0
  52. package/dist/output.esm.js +31312 -0
  53. package/dist/page.js +41 -0
  54. package/dist/payment.js +32 -0
  55. package/dist/payment_device.js +21 -0
  56. package/dist/payment_types.js +20 -0
  57. package/dist/phone_number.js +37 -0
  58. package/dist/product.js +288 -0
  59. package/dist/product_types.js +32 -0
  60. package/dist/production_comment.js +44 -0
  61. package/dist/quote.js +91 -0
  62. package/dist/quote_item.js +59 -0
  63. package/dist/roles.js +29 -0
  64. package/dist/seo_domain_page.js +42 -0
  65. package/dist/session.js +103 -0
  66. package/dist/set.js +29 -0
  67. package/dist/shipment.js +181 -0
  68. package/dist/shipment_item.js +17 -0
  69. package/dist/shipment_item_fulfillment.js +17 -0
  70. package/dist/shipment_method.js +81 -0
  71. package/dist/shipment_method_variation.js +38 -0
  72. package/dist/subscription_plan.js +75 -0
  73. package/dist/supply_domain.js +65 -0
  74. package/dist/system_role.js +12 -0
  75. package/dist/theme.js +180 -0
  76. package/dist/theme_css_setting.js +61 -0
  77. package/dist/theme_status.js +11 -0
  78. package/dist/user.js +409 -0
  79. package/dist/user_company.js +19 -0
  80. package/dist/user_types.js +23 -0
  81. package/dist/uuid.js +12 -0
  82. package/dist/variation.js +233 -0
  83. package/dist/variation_field.js +233 -0
  84. package/dist/variation_fields_option.js +41 -0
  85. package/dist/variation_option.js +62 -0
  86. package/dist/variations_group.js +43 -0
  87. package/dist/white_label_accessibilities.js +11 -0
  88. package/package.json +30 -0
  89. package/src/address.js +107 -0
  90. package/src/assignment.js +165 -0
  91. package/src/automatic_payment_relationship.js +65 -0
  92. package/src/backup.js +29 -0
  93. package/src/bank.js +21 -0
  94. package/src/cart.js +131 -0
  95. package/src/cart_item.js +71 -0
  96. package/src/cart_shipment_group.js +20 -0
  97. package/src/cart_shipment_quote.js +23 -0
  98. package/src/category.js +62 -0
  99. package/src/company.js +267 -0
  100. package/src/company_invitation.js +63 -0
  101. package/src/component.js +100 -0
  102. package/src/component_tag.js +53 -0
  103. package/src/component_version.js +17 -0
  104. package/src/country_tax.js +89 -0
  105. package/src/dictionary.js +135 -0
  106. package/src/discount.js +19 -0
  107. package/src/discount_group.js +15 -0
  108. package/src/domain.js +254 -0
  109. package/src/domain_invitation.js +13 -0
  110. package/src/domain_tag.js +79 -0
  111. package/src/domain_types.js +18 -0
  112. package/src/draft.js +92 -0
  113. package/src/draft_comment.js +41 -0
  114. package/src/draft_template.js +35 -0
  115. package/src/email_address.js +27 -0
  116. package/src/email_counter.js +42 -0
  117. package/src/enrolled_domain.js +79 -0
  118. package/src/exchange_rate.js +61 -0
  119. package/src/field_types.js +15 -0
  120. package/src/helpers.js +81 -0
  121. package/src/internal_tag.js +90 -0
  122. package/src/inventory.js +99 -0
  123. package/src/inventory_unit_variation.js +18 -0
  124. package/src/invoice.js +224 -0
  125. package/src/invoice_types.js +7 -0
  126. package/src/item.js +22 -0
  127. package/src/job.js +616 -0
  128. package/src/job_comment.js +41 -0
  129. package/src/job_status.js +51 -0
  130. package/src/matching_inventory.js +17 -0
  131. package/src/md5.js +162 -0
  132. package/src/menu.js +32 -0
  133. package/src/menu_item.js +22 -0
  134. package/src/merchi.js +1074 -0
  135. package/src/merchi_file.js +163 -0
  136. package/src/model.js +820 -0
  137. package/src/notification.js +153 -0
  138. package/src/notification_types.js +246 -0
  139. package/src/page.js +38 -0
  140. package/src/payment.js +32 -0
  141. package/src/payment_device.js +17 -0
  142. package/src/payment_types.js +18 -0
  143. package/src/phone_number.js +30 -0
  144. package/src/product.js +309 -0
  145. package/src/product_types.js +28 -0
  146. package/src/production_comment.js +40 -0
  147. package/src/quote.js +89 -0
  148. package/src/quote_item.js +51 -0
  149. package/src/roles.js +27 -0
  150. package/src/seo_domain_page.js +35 -0
  151. package/src/session.js +102 -0
  152. package/src/set.js +28 -0
  153. package/src/shipment.js +191 -0
  154. package/src/shipment_item.js +13 -0
  155. package/src/shipment_item_fulfillment.js +13 -0
  156. package/src/shipment_method.js +73 -0
  157. package/src/shipment_method_variation.js +34 -0
  158. package/src/subscription_plan.js +68 -0
  159. package/src/supply_domain.js +60 -0
  160. package/src/system_role.js +8 -0
  161. package/src/theme.js +188 -0
  162. package/src/theme_css_setting.js +54 -0
  163. package/src/theme_status.js +6 -0
  164. package/src/user.js +442 -0
  165. package/src/user_company.js +15 -0
  166. package/src/user_types.js +19 -0
  167. package/src/uuid.js +3 -0
  168. package/src/variation.js +257 -0
  169. package/src/variation_field.js +261 -0
  170. package/src/variation_fields_option.js +41 -0
  171. package/src/variation_option.js +59 -0
  172. package/src/variations_group.js +43 -0
  173. package/src/white_label_accessibilities.js +6 -0
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.userTypes = void 0;
7
+ var _dictionary = require("./dictionary.js");
8
+ var userTypes = exports.userTypes = new _dictionary.Dictionary();
9
+ userTypes.add("PUBLIC", 0);
10
+ userTypes.add("CLIENT_GUEST", 1);
11
+ userTypes.add("CLIENT_DOMAIN", 2);
12
+ userTypes.add("CLIENT_MULTIPLE_DOMAINS", 3);
13
+ userTypes.add("CLIENT_MERCHI", 4);
14
+ userTypes.add("SELLER_FREE_MERCHI", 5);
15
+ userTypes.add("SELLER_FREE_DOMAIN", 6);
16
+ userTypes.add("SELLER_PAID", 7);
17
+ userTypes.add("SELLER_PAID_MULTIPLE_DOMAINS", 8);
18
+ userTypes.add("SUPPLIER_THIRD_PARTY", 9);
19
+ userTypes.add("SUPPLIER_RESTRICTED", 10);
20
+ userTypes.add("SUPPLIER_MERCHI", 11);
21
+ userTypes.add("UNRESTRICTED", 12);
22
+ userTypes.add("SHOPIFY_REFERENCE", 13);
23
+ userTypes.add("RESERVED_FROM_SOCIAL", 14);
package/dist/uuid.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "generateUUID", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _uuid.v4;
10
+ }
11
+ });
12
+ var _uuid = require("uuid");
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Variation = Variation;
7
+ var _uuid = require("./uuid.js");
8
+ var _field_types = require("./field_types.js");
9
+ var _model = require("./model.js");
10
+ var _helpers = require("./helpers.js");
11
+ var _variation_option = require("./variation_option.js");
12
+ var _variation_field = require("./variation_field.js");
13
+ var _merchi_file = require("./merchi_file.js");
14
+ function Variation() {
15
+ this.resource = '/variation';
16
+ this.json = 'variation';
17
+ this.temporaryId = (0, _uuid.generateUUID)();
18
+ (0, _model.addPropertyTo)(this, 'id');
19
+ (0, _model.addPropertyTo)(this, 'value');
20
+ (0, _model.addPropertyTo)(this, 'quantity');
21
+ (0, _model.addPropertyTo)(this, 'cost');
22
+ (0, _model.addPropertyTo)(this, 'onceOffCost');
23
+ (0, _model.addPropertyTo)(this, 'unitCost');
24
+ (0, _model.addPropertyTo)(this, 'unitCostTotal');
25
+ (0, _model.addPropertyTo)(this, 'selectableOptions', _variation_option.VariationOption);
26
+ (0, _model.addPropertyTo)(this, 'selectedOptions', _variation_option.VariationOption);
27
+ (0, _model.addPropertyTo)(this, 'variationField', _variation_field.VariationField);
28
+ (0, _model.addPropertyTo)(this, 'variationFiles', _merchi_file.MerchiFile);
29
+ this.unitCostAndOnceOffCost = function () {
30
+ var unitCost = this.unitCost() ? this.unitCost() : 0,
31
+ onceOffCost = this.onceOffCost() ? this.onceOffCost() : 0;
32
+ return unitCost + onceOffCost;
33
+ };
34
+ this.unitCostTotalAndOnceOffCost = function () {
35
+ var unitCostTotal = this.unitCostTotal() ? this.unitCostTotal() : 0,
36
+ onceOffCost = this.onceOffCost() ? this.onceOffCost() : 0;
37
+ return unitCostTotal + onceOffCost;
38
+ };
39
+ this.isTextField = function () {
40
+ var field = this.variationField();
41
+ return Boolean(field) && field.isTextType();
42
+ };
43
+ this.isNumberField = function () {
44
+ var field = this.variationField();
45
+ return Boolean(field) && field.isNumberType();
46
+ };
47
+ this.isSelectField = function () {
48
+ var field = this.variationField();
49
+ return Boolean(field) && field.isSelectType();
50
+ };
51
+ this.isCheckBoxField = function () {
52
+ var field = this.variationField();
53
+ return Boolean(field) && field.isCheckboxType();
54
+ };
55
+ this.isRadioField = function () {
56
+ var field = this.variationField();
57
+ return Boolean(field) && field.isRadioType();
58
+ };
59
+ this.isColourSelectField = function () {
60
+ var field = this.variationField();
61
+ return Boolean(field) && field.isColourSelectType();
62
+ };
63
+ this.isImageSelectField = function () {
64
+ var field = this.variationField();
65
+ return Boolean(field) && field.isImageSelectType();
66
+ };
67
+ this.isCheckboxOrRadioField = function () {
68
+ return this.isRadioField() || this.isCheckBoxField();
69
+ };
70
+ this.isSelectableField = function () {
71
+ var field = this.variationField();
72
+ return Boolean(field) && field.isSelectable();
73
+ };
74
+ this.canHaveMultipleSelected = function () {
75
+ var field = this.variationField();
76
+ return Boolean(field) && field.isDefaultMultiSelect();
77
+ };
78
+ this.isTextAreaField = function () {
79
+ var field = this.variationField();
80
+ return Boolean(field) && field.isTextAreaType();
81
+ };
82
+ this.isInstructionsField = function () {
83
+ var field = this.variationField();
84
+ return Boolean(field) && field.isInstructionsType();
85
+ };
86
+ this.isFileUpload = function () {
87
+ var field = this.variationField();
88
+ return Boolean(field) && field.isFileInput();
89
+ };
90
+ this.valueArray = function (updateValueArray) {
91
+ var valuesArray = [],
92
+ i;
93
+ if (!(0, _helpers.isUndefined)(updateValueArray)) {
94
+ this.value(updateValueArray.join(','));
95
+ return updateValueArray;
96
+ }
97
+ if (this.value() === "") {
98
+ return [];
99
+ }
100
+ valuesArray = String(this.value()).split(',');
101
+ for (i = 0; i < valuesArray.length; i++) {
102
+ valuesArray[i] = parseInt(valuesArray[i], 10);
103
+ }
104
+ return valuesArray;
105
+ };
106
+ this.textValue = function () {
107
+ var field = this.variationField(),
108
+ text = "",
109
+ i;
110
+ if (field) {
111
+ if (this.isTextField() || this.isNumberField() || this.isTextAreaField()) {
112
+ return this.value();
113
+ }
114
+ if (this.isSelectableField() && this.selectedOptions()) {
115
+ for (i = 0; i < this.selectedOptions().length; i++) {
116
+ text += this.selectedOptions()[i].value() + " ";
117
+ }
118
+ return text;
119
+ }
120
+ }
121
+ return null;
122
+ };
123
+ this.optionIsSelected = function (id) {
124
+ var selectedIds = this.valueArray();
125
+ return -1 < selectedIds.findIndex(function (_id) {
126
+ return String(_id) === String(id);
127
+ });
128
+ };
129
+ this.selectedSelectableOptions = function () {
130
+ var self = this,
131
+ options = this.selectableOptions() ? this.selectableOptions() : [];
132
+ return options.filter(function (o) {
133
+ return self.optionIsSelected(o.optionId());
134
+ });
135
+ };
136
+ this.selectedFieldOptions = function () {
137
+ var field = this.variationField(),
138
+ options = field.options() ? field.options() : [],
139
+ valueArray = this.valueArray(),
140
+ optionsArray = [],
141
+ selectedId,
142
+ option,
143
+ i,
144
+ z;
145
+ for (i = 0; i < valueArray.length; i++) {
146
+ selectedId = valueArray[i];
147
+ for (z = 0; z < options.length; z++) {
148
+ option = options[z];
149
+ if (selectedId === option.id()) {
150
+ optionsArray.push(option);
151
+ }
152
+ }
153
+ }
154
+ return optionsArray;
155
+ };
156
+ this.findOptionValueIndex = function (optionId) {
157
+ return this.valueArray().indexOf(parseInt(optionId, 10));
158
+ };
159
+ this.optionIsChecked = function (optionId) {
160
+ return this.findOptionValueIndex(optionId) > -1;
161
+ };
162
+ this.addOptionToValueArray = function (optionId) {
163
+ var newValueArray = this.valueArray();
164
+ if (!this.optionIsChecked(optionId)) {
165
+ newValueArray.push(optionId);
166
+ this.valueArray(newValueArray);
167
+ }
168
+ };
169
+ this.removeOptionFromValueArray = function (optionId) {
170
+ var index = this.findOptionValueIndex(optionId),
171
+ newValueArray = this.valueArray();
172
+ newValueArray.splice(index, 1);
173
+ this.valueArray(newValueArray);
174
+ };
175
+ this.fieldName = function () {
176
+ return this.variationField().name();
177
+ };
178
+ this.fieldType = function () {
179
+ return this.variationField().fieldType();
180
+ };
181
+ this.hasOptions = function () {
182
+ return Boolean(this.selectedOptions());
183
+ };
184
+ this.hasMultipleOptions = function () {
185
+ return parseInt(this.fieldType(), 10) === _field_types.fieldTypes.get("CHECKBOX");
186
+ };
187
+ this.isFileUpload = function () {
188
+ return parseInt(this.fieldType(), 10) === _field_types.fieldTypes.get("FILE_UPLOAD");
189
+ };
190
+ this.isColourPicker = function () {
191
+ return parseInt(this.fieldType(), 10) === _field_types.fieldTypes.get("COLOUR_PICKER");
192
+ };
193
+ this.clone = function () {
194
+ var cloneVariation = new Variation();
195
+ cloneVariation.value(this.value());
196
+ cloneVariation.cost(this.cost());
197
+ cloneVariation.variationField(this.variationField());
198
+ cloneVariation.variationFiles(this.variationFiles());
199
+ return cloneVariation;
200
+ };
201
+ this.valueIdArray = function () {
202
+ var value = this.value();
203
+ return value ? value.split(',') : [];
204
+ };
205
+ this.concatinatedSelectedOptionValues = function () {
206
+ var optionIds = this.valueIdArray(),
207
+ optionIdsLength = optionIds.length - 1,
208
+ field = this.variationField(),
209
+ value = '',
210
+ option,
211
+ i;
212
+ for (i = 0; i < optionIds.length; i++) {
213
+ option = field.findOptionById(optionIds[i]);
214
+ value += option.value();
215
+ if (optionIdsLength > i) {
216
+ value += ', ';
217
+ }
218
+ }
219
+ return value;
220
+ };
221
+ this.valueString = function () {
222
+ var field = this.variationField();
223
+ if (field.isSelectable()) {
224
+ return this.concatinatedSelectedOptionValues();
225
+ } else if (this.isFileUpload() && this.variationFiles()) {
226
+ if (this.variationFiles().length > 1) {
227
+ return 'uploaded files';
228
+ }
229
+ return 'uploaded file';
230
+ }
231
+ return this.value();
232
+ };
233
+ }
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VariationField = VariationField;
7
+ var _uuid = require("./uuid.js");
8
+ var _field_types = require("./field_types.js");
9
+ var _model = require("./model.js");
10
+ var _helpers = require("./helpers.js");
11
+ var _discount_group = require("./discount_group.js");
12
+ var _variation_fields_option = require("./variation_fields_option.js");
13
+ var _variation = require("./variation.js");
14
+ var _variation_option = require("./variation_option.js");
15
+ function VariationField() {
16
+ this.resource = '/variationFields';
17
+ this.json = 'variationField';
18
+ this.temporaryId = (0, _uuid.generateUUID)();
19
+ (0, _model.addPropertyTo)(this, 'id');
20
+ (0, _model.addPropertyTo)(this, 'fieldType');
21
+ (0, _model.addPropertyTo)(this, 'name');
22
+ (0, _model.addPropertyTo)(this, 'position');
23
+ (0, _model.addPropertyTo)(this, 'placeholder');
24
+ (0, _model.addPropertyTo)(this, 'defaultValue');
25
+ (0, _model.addPropertyTo)(this, 'required');
26
+ (0, _model.addPropertyTo)(this, 'independent');
27
+ (0, _model.addPropertyTo)(this, 'variationCost');
28
+ (0, _model.addPropertyTo)(this, 'variationCostDiscountGroup', _discount_group.DiscountGroup);
29
+ (0, _model.addPropertyTo)(this, 'variationUnitCost');
30
+ (0, _model.addPropertyTo)(this, 'variationUnitCostDiscountGroup', _discount_group.DiscountGroup);
31
+ (0, _model.addPropertyTo)(this, 'options', _variation_fields_option.VariationFieldsOption);
32
+ (0, _model.addPropertyTo)(this, 'defaultOptions', _variation_fields_option.VariationFieldsOption);
33
+ (0, _model.addPropertyTo)(this, 'multipleSelect');
34
+ (0, _model.addPropertyTo)(this, 'rows');
35
+ (0, _model.addPropertyTo)(this, 'fieldMin');
36
+ (0, _model.addPropertyTo)(this, 'fieldMax');
37
+ (0, _model.addPropertyTo)(this, 'showFilePreview');
38
+ (0, _model.addPropertyTo)(this, 'allowDecimal');
39
+ (0, _model.addPropertyTo)(this, 'allowFileMultiple');
40
+ (0, _model.addPropertyTo)(this, 'allowFileJpeg');
41
+ (0, _model.addPropertyTo)(this, 'allowFileGif');
42
+ (0, _model.addPropertyTo)(this, 'allowFilePdf');
43
+ (0, _model.addPropertyTo)(this, 'allowFilePng');
44
+ (0, _model.addPropertyTo)(this, 'allowFileAi');
45
+ (0, _model.addPropertyTo)(this, 'sellerProductEditable');
46
+ this.isType = function (typeString) {
47
+ return parseInt(this.fieldType(), 10) === _field_types.fieldTypes.get(typeString);
48
+ };
49
+ this.isTextType = function () {
50
+ return this.isType('TEXT_INPUT');
51
+ };
52
+ this.isNumberType = function () {
53
+ return this.isType('NUMBER_INPUT');
54
+ };
55
+ this.isSelectType = function () {
56
+ return this.isType('SELECT');
57
+ };
58
+ this.isDefaultMultiSelect = function () {
59
+ return this.isType('CHECKBOX') || this.isType('IMAGE_SELECT') && this.multipleSelect();
60
+ };
61
+ this.isCheckboxType = function () {
62
+ return this.isType('CHECKBOX');
63
+ };
64
+ this.isRadioType = function () {
65
+ return this.isType('RADIO');
66
+ };
67
+ this.hasOptions = function () {
68
+ return Boolean(this.options());
69
+ };
70
+ this.isCheckboxOrRadio = function () {
71
+ return this.isCheckboxType() || this.isRadioType();
72
+ };
73
+ this.isTextAreaType = function () {
74
+ return this.isType('TEXT_AREA');
75
+ };
76
+ this.isInstructionsType = function () {
77
+ return this.isType('FIELD_INSTRUCTIONS');
78
+ };
79
+ this.isFileInput = function () {
80
+ return this.isType('FILE_UPLOAD');
81
+ };
82
+ this.isColourPickerType = function () {
83
+ return this.isType('COLOUR_PICKER');
84
+ };
85
+ this.isColourSelectType = function () {
86
+ return this.isType('COLOUR_SELECT');
87
+ };
88
+ this.isImageSelectType = function () {
89
+ return this.isType('IMAGE_SELECT');
90
+ };
91
+ this.isSelectable = function () {
92
+ return this.isSelectType() || this.isCheckboxOrRadio() || this.isImageSelectType() || this.isColourSelectType();
93
+ };
94
+ this.canMultiSelect = function () {
95
+ return this.isImageSelectType() || this.isColourSelectType();
96
+ };
97
+ this.fieldInputTypeAttributeValue = function () {
98
+ var inputType = this.fieldType(),
99
+ inputTypeString = null;
100
+ if (inputType === _field_types.fieldTypes.get("TEXT_INPUT")) {
101
+ inputTypeString = 'text';
102
+ } else if (inputType === _field_types.fieldTypes.get('FILE_UPLOAD')) {
103
+ inputTypeString = 'file';
104
+ } else if (inputType === _field_types.fieldTypes.get('NUMBER_INPUT')) {
105
+ inputTypeString = 'number';
106
+ } else if (inputType === _field_types.fieldTypes.get('RADIO')) {
107
+ inputTypeString = 'radio';
108
+ } else if (inputType === _field_types.fieldTypes.get('IMAGE_SELECT')) {
109
+ if (this.multipleSelect()) {
110
+ inputTypeString = 'checkbox';
111
+ } else {
112
+ inputTypeString = 'radio';
113
+ }
114
+ } else if (inputType === _field_types.fieldTypes.get('CHECKBOX')) {
115
+ inputTypeString = 'checkbox';
116
+ } else if (inputType === _field_types.fieldTypes.get('COLOUR_PICKER')) {
117
+ inputTypeString = 'color';
118
+ }
119
+ return inputTypeString;
120
+ };
121
+ this.hasMultipleDefaults = function () {
122
+ return this.optionsDefaults().length > 1;
123
+ };
124
+ this.setSingleOptionDefault = function (index) {
125
+ var i,
126
+ options = this.options();
127
+ for (i = 0; i < options.length; i++) {
128
+ options[i]["default"](false);
129
+ }
130
+ options[index]["default"](true);
131
+ };
132
+ this.optionsDefaults = function () {
133
+ var i,
134
+ defaultsArray = [],
135
+ options = this.options();
136
+ for (i = 0; i < options.length; i++) {
137
+ if (options[i]["default"]()) {
138
+ defaultsArray.push(options[i]);
139
+ }
140
+ }
141
+ return defaultsArray;
142
+ };
143
+ this.findOptionById = function (id) {
144
+ var i = 0,
145
+ options;
146
+ options = this.options();
147
+ for (i = 0; i < options.length; i++) {
148
+ if (parseInt(options[i].id(), 10) === parseInt(id, 10)) {
149
+ return options[i];
150
+ }
151
+ }
152
+ return null;
153
+ };
154
+ this.allowFileJpegString = function () {
155
+ return Boolean(this.allowFileJpeg()) ? ".jpeg, .jpg" : "";
156
+ };
157
+ this.allowFileGifString = function () {
158
+ return Boolean(this.allowFileGif()) ? ".gif" : "";
159
+ };
160
+ this.allowFilePdfString = function () {
161
+ return Boolean(this.allowFilePdf()) ? ".pdf" : "";
162
+ };
163
+ this.allowFilePngString = function () {
164
+ return Boolean(this.allowFilePng()) ? ".png" : "";
165
+ };
166
+ this.allowFileAiString = function () {
167
+ return Boolean(this.allowFileAi()) ? ".ai" : "";
168
+ };
169
+ this.allowedFileTypesString = function () {
170
+ function appendType(fileTypeString) {
171
+ if (fileTypeString !== "") {
172
+ return fileTypeString + ", ";
173
+ }
174
+ return "";
175
+ }
176
+ return appendType(this.allowFileJpegString()) + appendType(this.allowFileGifString()) + appendType(this.allowFilePdfString()) + appendType(this.allowFilePngString()) + appendType(this.allowFileAiString());
177
+ };
178
+ this.allowFileMultipleString = function () {
179
+ if (this.allowFileMultiple()) {
180
+ return "multiple";
181
+ }
182
+ return "";
183
+ };
184
+ this.buildEmptyVariation = function () {
185
+ var variationBuilt = new _variation.Variation(),
186
+ value,
187
+ options,
188
+ i,
189
+ onceOffCost = 0,
190
+ selectableOptions = [],
191
+ sellerProductEditable = this.sellerProductEditable();
192
+ if (this.isSelectable()) {
193
+ options = this.options();
194
+ value = [];
195
+ for (i = 0; i < options.length; i++) {
196
+ var selectableOption = new _variation_option.VariationOption();
197
+ selectableOption.copyFieldOption(options[i]);
198
+ selectableOptions.push(selectableOption);
199
+ if (!sellerProductEditable && options[i]["default"]() || sellerProductEditable && options[i].include()) {
200
+ value.push(options[i].id());
201
+ onceOffCost += options[i].variationCost();
202
+ }
203
+ }
204
+ variationBuilt.value(value.join());
205
+ variationBuilt.onceOffCost(onceOffCost);
206
+ } else {
207
+ variationBuilt.value(this.defaultValue());
208
+ variationBuilt.unitCost(this.variationUnitCost());
209
+ variationBuilt.onceOffCost(this.variationCost());
210
+ }
211
+ variationBuilt.unitCostTotal('0');
212
+ variationBuilt.cost(variationBuilt.onceOffCost());
213
+ variationBuilt.variationField((0, _helpers.clone)(this));
214
+ variationBuilt.selectableOptions(selectableOptions);
215
+ return variationBuilt;
216
+ };
217
+ this.optionsHaveCost = function () {
218
+ var i, options, o;
219
+ function hasCost(cost) {
220
+ return !(0, _helpers.isUndefinedOrNull)(cost);
221
+ }
222
+ if (this.isSelectable()) {
223
+ options = this.options();
224
+ for (i = 0; i < options.length; i++) {
225
+ o = options[i];
226
+ if (hasCost(o.variationCost()) || hasCost(o.variationUnitCost())) {
227
+ return true;
228
+ }
229
+ }
230
+ }
231
+ return false;
232
+ };
233
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VariationFieldsOption = VariationFieldsOption;
7
+ var _uuid = require("./uuid.js");
8
+ var _model = require("./model.js");
9
+ var _discount_group = require("./discount_group.js");
10
+ var _merchi_file = require("./merchi_file.js");
11
+ var _variation_field = require("./variation_field.js");
12
+ function VariationFieldsOption() {
13
+ this.resource = '/variationFieldOptions';
14
+ this.json = 'variationFieldOption';
15
+ this.temporaryId = (0, _uuid.generateUUID)();
16
+ (0, _model.addPropertyTo)(this, 'id');
17
+ (0, _model.addPropertyTo)(this, 'value');
18
+ (0, _model.addPropertyTo)(this, 'position');
19
+ (0, _model.addPropertyTo)(this, 'default');
20
+ (0, _model.addPropertyTo)(this, 'include');
21
+ (0, _model.addPropertyTo)(this, 'colour');
22
+ (0, _model.addPropertyTo)(this, 'variationCost');
23
+ (0, _model.addPropertyTo)(this, 'variationCostDiscountGroup', _discount_group.DiscountGroup);
24
+ (0, _model.addPropertyTo)(this, 'variationUnitCost');
25
+ (0, _model.addPropertyTo)(this, 'variationUnitCostDiscountGroup', _discount_group.DiscountGroup);
26
+ (0, _model.addPropertyTo)(this, 'linkedFile', _merchi_file.MerchiFile);
27
+ (0, _model.addPropertyTo)(this, 'variationField', _variation_field.VariationField);
28
+ this.totalCost = function (quantity) {
29
+ var total = this.variationCost() ? this.variationCost() : 0;
30
+ if (this.variationUnitCost() && quantity) {
31
+ total += quantity * this.variationUnitCost();
32
+ }
33
+ return total;
34
+ };
35
+ this.onceOffCost = function () {
36
+ return this.variationCost();
37
+ };
38
+ this.unitCost = function () {
39
+ return this.variationUnitCost();
40
+ };
41
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VariationOption = VariationOption;
7
+ var _uuid = require("./uuid.js");
8
+ var _model = require("./model.js");
9
+ var _merchi_file = require("./merchi_file.js");
10
+ var _variation = require("./variation.js");
11
+ function VariationOption() {
12
+ this.json = 'variation_option';
13
+ this.temporaryId = (0, _uuid.generateUUID)();
14
+ (0, _model.addPropertyTo)(this, 'optionId');
15
+ (0, _model.addPropertyTo)(this, 'value');
16
+ (0, _model.addPropertyTo)(this, 'available');
17
+ (0, _model.addPropertyTo)(this, 'position');
18
+ (0, _model.addPropertyTo)(this, 'default');
19
+ (0, _model.addPropertyTo)(this, 'include');
20
+ (0, _model.addPropertyTo)(this, 'colour');
21
+ (0, _model.addPropertyTo)(this, 'quantity');
22
+ (0, _model.addPropertyTo)(this, 'onceOffCost');
23
+ (0, _model.addPropertyTo)(this, 'unitCost');
24
+ (0, _model.addPropertyTo)(this, 'unitCostTotal');
25
+ (0, _model.addPropertyTo)(this, 'totalCost');
26
+ (0, _model.addPropertyTo)(this, 'fieldName');
27
+ (0, _model.addPropertyTo)(this, 'linkedFile', _merchi_file.MerchiFile);
28
+ this.copyFieldOption = function (option) {
29
+ this.optionId(option.id());
30
+ this.value(option.value());
31
+ this.colour(option.colour());
32
+ this.position(option.position());
33
+ this["default"](option["default"]());
34
+ this.onceOffCost(option.variationCost());
35
+ this.unitCost(option.variationUnitCost());
36
+ this.linkedFile(option.linkedFile());
37
+ };
38
+
39
+ // a hack around function for job cloneable renderering
40
+ this.covertToVariation = function () {
41
+ var variationConverted = new _variation.Variation(),
42
+ unitCost = this.unitCost(),
43
+ fieldName = this.fieldName(),
44
+ optionValue = this.value();
45
+ variationConverted.value(this.optionId());
46
+ variationConverted.quantity(this.quantity());
47
+ variationConverted.onceOffCost(this.onceOffCost());
48
+ variationConverted.unitCostTotal(this.unitCostTotal());
49
+
50
+ // hack around for variation unit cost
51
+ variationConverted.unitCost = function () {
52
+ return unitCost;
53
+ };
54
+ variationConverted.valueString = function () {
55
+ return optionValue;
56
+ };
57
+ variationConverted.fieldName = function () {
58
+ return fieldName;
59
+ };
60
+ return variationConverted;
61
+ };
62
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VariationsGroup = VariationsGroup;
7
+ var _uuid = require("./uuid.js");
8
+ var _model = require("./model.js");
9
+ var _variation = require("./variation.js");
10
+ function VariationsGroup() {
11
+ this.resource = '/variationsGroups';
12
+ this.json = 'variationsGroup';
13
+ this.temporaryId = (0, _uuid.generateUUID)();
14
+ (0, _model.addPropertyTo)(this, 'id');
15
+ (0, _model.addPropertyTo)(this, 'inventoryCount');
16
+ (0, _model.addPropertyTo)(this, 'inventorySufficient');
17
+ (0, _model.addPropertyTo)(this, 'quantity');
18
+ (0, _model.addPropertyTo)(this, 'groupCost');
19
+ (0, _model.addPropertyTo)(this, 'variations', _variation.Variation);
20
+ this.clone = function () {
21
+ var groupClone = new VariationsGroup(),
22
+ variationsClone = [],
23
+ i;
24
+ groupClone.groupCost(this.groupCost());
25
+ groupClone.quantity(this.quantity());
26
+ for (i = 0; i < this.variations().length; i++) {
27
+ variationsClone.push(this.variations()[i].clone());
28
+ }
29
+ return groupClone.variations(variationsClone);
30
+ };
31
+ this.loopVariationsAndReturnAttributeTotal = function (attribute) {
32
+ var variations = this.variations() ? this.variations() : [],
33
+ total = 0,
34
+ i;
35
+ for (i = 0; i < variations.length; i++) {
36
+ total += variations[i][attribute]();
37
+ }
38
+ return parseFloat(total).toFixed(2);
39
+ };
40
+ this.variationsUnitCostAndOnceOffCost = function () {
41
+ return this.loopVariationsAndReturnAttributeTotal('unitCostAndOnceOffCost');
42
+ };
43
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.whiteLabelAccessibilities = void 0;
7
+ var _dictionary = require("./dictionary.js");
8
+ var whiteLabelAccessibilities = exports.whiteLabelAccessibilities = new _dictionary.Dictionary();
9
+ whiteLabelAccessibilities.add("NOT_REACHABLE", 0);
10
+ whiteLabelAccessibilities.add("NO_CERITICATE", 1);
11
+ whiteLabelAccessibilities.add("FULLY_REACHABLE", 2);
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "merchi_sdk_js",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "dist/output.cjs.js",
6
+ "license": "GPL-3.0-only",
7
+ "module": "dist/output.esm.js",
8
+ "files": [
9
+ "dist/", "src/"
10
+ ],
11
+ "dependencies": {
12
+ "axios": "^0.27.2",
13
+ "browser-or-node": "^2.1.1",
14
+ "eslint": "^8.19.0",
15
+ "eslint-plugin-import": "^2.26.0",
16
+ "form-data": "^4.0.0",
17
+ "moment-timezone": "^0.5.33",
18
+ "uuid": "^8.3.2"
19
+ },
20
+ "devDependencies": {
21
+ "@babel/cli": "^7.23.9",
22
+ "@babel/core": "^7.23.9",
23
+ "@babel/preset-env": "^7.23.9",
24
+ "@rollup/plugin-babel": "^6.0.4",
25
+ "@rollup/plugin-commonjs": "^25.0.7",
26
+ "@rollup/plugin-json": "^6.1.0",
27
+ "@rollup/plugin-node-resolve": "^15.2.3",
28
+ "rollup": "^4.12.0"
29
+ }
30
+ }