rerobe-js-orm 3.0.12 → 3.0.14
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/lib/factories/ProductCollection/ProductCollectionFromFormState.js +1 -0
- package/lib/form-states/ProductCollection/ProductCollectionFormState.js +9 -0
- package/lib/helpers/Utilities.d.ts +2 -1
- package/lib/helpers/Utilities.js +6 -3
- package/lib/models/Order.js +8 -1
- package/lib/models/Product.js +8 -1
- package/lib/models/ProductCollection.d.ts +1 -0
- package/lib/models/ProductCollection.js +9 -0
- package/lib/models/User.js +8 -1
- package/lib/types/product-collection-types.d.ts +3 -0
- package/lib/types/rerobe-order-types.d.ts +1 -0
- package/lib/types/rerobe-product-types.d.ts +1 -0
- package/lib/types/rerobe-user-types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ class ProductCollectionFromFormState extends ProductCollectionFactory_1.default
|
|
|
19
19
|
description: fs.fields.description.inputValue || '',
|
|
20
20
|
type: fs.fields.type.selectedValue || '',
|
|
21
21
|
imgUrl: fs.fields.imgUrl.inputValue || '',
|
|
22
|
+
imageUrls: fs.fields.imageUrls.selectedValues || [],
|
|
22
23
|
refinements: fs.fields.refinements.selectedValue || {},
|
|
23
24
|
tags: fs.fields.tags.selectedValues || [],
|
|
24
25
|
collectionId,
|
|
@@ -16,6 +16,7 @@ class ProductCollectionFormState extends FormState_1.default {
|
|
|
16
16
|
this.fields.description = this.fieldFactory('textInput', 'description');
|
|
17
17
|
this.fields.type = this.fieldFactory('singleSelect', 'type');
|
|
18
18
|
this.fields.imgUrl = this.fieldFactory('textInput', 'imgUrl');
|
|
19
|
+
this.fields.imageUrls = this.fieldFactory('multiSelect', 'imageUrls', []);
|
|
19
20
|
this.fields.refinements = this.fieldFactory('singleSelect', 'refinements');
|
|
20
21
|
this.fields.tags = this.fieldFactory('multiSelect', 'tags', []);
|
|
21
22
|
this.fields.collectionId = this.fieldFactory('textInput', 'collectionId');
|
|
@@ -65,6 +66,14 @@ class ProductCollectionFormState extends FormState_1.default {
|
|
|
65
66
|
}
|
|
66
67
|
valid = true;
|
|
67
68
|
}
|
|
69
|
+
if (fieldKey === 'imageUrls') {
|
|
70
|
+
if (this.props.imageUrls) {
|
|
71
|
+
if (Array.isArray(this.props.imageUrls)) {
|
|
72
|
+
selectedValues = this.props.imageUrls;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
valid = true;
|
|
76
|
+
}
|
|
68
77
|
return {
|
|
69
78
|
options,
|
|
70
79
|
selectedValues,
|
package/lib/helpers/Utilities.js
CHANGED
|
@@ -149,9 +149,10 @@ class Utilities {
|
|
|
149
149
|
formatTimestamp(timestampMillis) {
|
|
150
150
|
if (typeof timestampMillis !== 'number' || Number.isNaN(new Date(timestampMillis).valueOf())) {
|
|
151
151
|
return {
|
|
152
|
+
createdAtHour: '',
|
|
152
153
|
createdAtDay: '',
|
|
153
154
|
createdAtMonth: '',
|
|
154
|
-
|
|
155
|
+
createdAtYear: '',
|
|
155
156
|
};
|
|
156
157
|
}
|
|
157
158
|
const dateObj = new Date(timestampMillis);
|
|
@@ -159,13 +160,15 @@ class Utilities {
|
|
|
159
160
|
const month = (dateObj.getUTCMonth() + 1).toString().padStart(2, '0'); // Months are 0-indexed in JS
|
|
160
161
|
const day = dateObj.getUTCDate().toString().padStart(2, '0');
|
|
161
162
|
const hour = dateObj.getUTCHours().toString().padStart(2, '0');
|
|
163
|
+
const createdAtHour = `${year}-${month}-${day} ${hour}`;
|
|
162
164
|
const createdAtDay = `${year}-${month}-${day}`;
|
|
163
165
|
const createdAtMonth = `${year}-${month}`;
|
|
164
|
-
const
|
|
166
|
+
const createdAtYear = `${year}`;
|
|
165
167
|
return {
|
|
168
|
+
createdAtHour,
|
|
166
169
|
createdAtDay,
|
|
167
170
|
createdAtMonth,
|
|
168
|
-
|
|
171
|
+
createdAtYear,
|
|
169
172
|
};
|
|
170
173
|
}
|
|
171
174
|
}
|
package/lib/models/Order.js
CHANGED
|
@@ -326,6 +326,12 @@ class Order extends Base_1.default {
|
|
|
326
326
|
type: 'string',
|
|
327
327
|
optional: true,
|
|
328
328
|
},
|
|
329
|
+
{
|
|
330
|
+
facet: true,
|
|
331
|
+
name: 'createdAtYear',
|
|
332
|
+
type: 'string',
|
|
333
|
+
optional: true,
|
|
334
|
+
},
|
|
329
335
|
],
|
|
330
336
|
name: 'dev_orders_20220809',
|
|
331
337
|
};
|
|
@@ -335,7 +341,7 @@ class Order extends Base_1.default {
|
|
|
335
341
|
? this.lineItems[0].image.originalSrc
|
|
336
342
|
: 'https://res.cloudinary.com/ribbn/image/fetch/e_blur:1000,o_20,q_50/https://cdn.shopify.com/s/files/1/0261/9686/9172/products/7AC16810-F519-4665-8891-7163EB29FBB7_1000x1000.jpg%3Fv%3D1634827512';
|
|
337
343
|
const createdAtTimestamp = this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp);
|
|
338
|
-
const { createdAtHour, createdAtDay, createdAtMonth } = this.utilities.formatTimestamp(createdAtTimestamp);
|
|
344
|
+
const { createdAtHour, createdAtDay, createdAtMonth, createdAtYear } = this.utilities.formatTimestamp(createdAtTimestamp);
|
|
339
345
|
const stagedObj = {
|
|
340
346
|
id: this.utilities.sanitizeString(this.documentId),
|
|
341
347
|
documentId: this.utilities.sanitizeString(this.documentId),
|
|
@@ -344,6 +350,7 @@ class Order extends Base_1.default {
|
|
|
344
350
|
createdAtHour,
|
|
345
351
|
createdAtDay,
|
|
346
352
|
createdAtMonth,
|
|
353
|
+
createdAtYear,
|
|
347
354
|
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
|
|
348
355
|
merchantId: this.utilities.sanitizeString(this.merchantId),
|
|
349
356
|
image: this.utilities.sanitizeString(image),
|
package/lib/models/Product.js
CHANGED
|
@@ -262,7 +262,7 @@ class Product extends Base_1.default {
|
|
|
262
262
|
}
|
|
263
263
|
toObjForTypesense() {
|
|
264
264
|
const createdAtTimestamp = this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.createdAtTimestamp);
|
|
265
|
-
const { createdAtHour, createdAtDay, createdAtMonth } = this.utilities.formatTimestamp(createdAtTimestamp);
|
|
265
|
+
const { createdAtHour, createdAtDay, createdAtMonth, createdAtYear } = this.utilities.formatTimestamp(createdAtTimestamp);
|
|
266
266
|
const stagedObj = {
|
|
267
267
|
brand: this.utilities.sanitizeString(this.filterAttributes.brand),
|
|
268
268
|
size: this.utilities.sanitizeString(this.filterAttributes.size),
|
|
@@ -296,6 +296,7 @@ class Product extends Base_1.default {
|
|
|
296
296
|
createdAtHour,
|
|
297
297
|
createdAtDay,
|
|
298
298
|
createdAtMonth,
|
|
299
|
+
createdAtYear,
|
|
299
300
|
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.updatedAtTimestamp),
|
|
300
301
|
sellRequestReviewTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellRequestReviewTimestamp),
|
|
301
302
|
sellRequestReviewDraftTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellRequestReviewDraftTimestamp),
|
|
@@ -762,6 +763,12 @@ class Product extends Base_1.default {
|
|
|
762
763
|
type: 'string',
|
|
763
764
|
optional: true,
|
|
764
765
|
},
|
|
766
|
+
{
|
|
767
|
+
facet: true,
|
|
768
|
+
name: 'createdAtYear',
|
|
769
|
+
type: 'string',
|
|
770
|
+
optional: true,
|
|
771
|
+
},
|
|
765
772
|
],
|
|
766
773
|
name,
|
|
767
774
|
};
|
|
@@ -16,6 +16,7 @@ class ProductCollection extends Base_1.default {
|
|
|
16
16
|
this.refinements = (props === null || props === void 0 ? void 0 : props.refinements) || {};
|
|
17
17
|
this.tags = (props === null || props === void 0 ? void 0 : props.tags) || [];
|
|
18
18
|
this.collectionId = (props === null || props === void 0 ? void 0 : props.collectionId) || '';
|
|
19
|
+
this.imageUrls = (props === null || props === void 0 ? void 0 : props.imageUrls) || [];
|
|
19
20
|
}
|
|
20
21
|
toObj() {
|
|
21
22
|
const productCollectionObj = {
|
|
@@ -31,6 +32,7 @@ class ProductCollection extends Base_1.default {
|
|
|
31
32
|
refinements: this.refinements,
|
|
32
33
|
tags: this.tags,
|
|
33
34
|
collectionId: this.collectionId,
|
|
35
|
+
imageUrls: this.imageUrls,
|
|
34
36
|
};
|
|
35
37
|
return productCollectionObj;
|
|
36
38
|
}
|
|
@@ -79,10 +81,16 @@ class ProductCollection extends Base_1.default {
|
|
|
79
81
|
type: 'string',
|
|
80
82
|
},
|
|
81
83
|
{
|
|
84
|
+
// deprecate soon, will be migrated into imageUrls
|
|
82
85
|
facet: false,
|
|
83
86
|
name: 'imgUrl',
|
|
84
87
|
type: 'string',
|
|
85
88
|
},
|
|
89
|
+
{
|
|
90
|
+
facet: false,
|
|
91
|
+
name: 'imageUrls',
|
|
92
|
+
type: 'string[]',
|
|
93
|
+
},
|
|
86
94
|
{
|
|
87
95
|
facet: true,
|
|
88
96
|
optional: true,
|
|
@@ -208,6 +216,7 @@ class ProductCollection extends Base_1.default {
|
|
|
208
216
|
'refinements.statusRefinement': this.utilities.sanitzeStringArr(this.refinements.statusRefinement),
|
|
209
217
|
'refinements.salesChannelRefinement': this.utilities.sanitzeStringArr(this.refinements.salesChannelRefinement),
|
|
210
218
|
tags: this.utilities.sanitzeStringArr(this.tags),
|
|
219
|
+
imageUrls: this.utilities.sanitzeStringArr(this.imageUrls),
|
|
211
220
|
collectionId: this.utilities.sanitizeString(this.collectionId),
|
|
212
221
|
};
|
|
213
222
|
return stagedObj;
|
package/lib/models/User.js
CHANGED
|
@@ -313,13 +313,19 @@ class User extends Base_1.default {
|
|
|
313
313
|
type: 'string',
|
|
314
314
|
optional: true,
|
|
315
315
|
},
|
|
316
|
+
{
|
|
317
|
+
facet: true,
|
|
318
|
+
name: 'createdAtYear',
|
|
319
|
+
type: 'string',
|
|
320
|
+
optional: true,
|
|
321
|
+
},
|
|
316
322
|
],
|
|
317
323
|
name: 'prod_customers_20220907',
|
|
318
324
|
};
|
|
319
325
|
}
|
|
320
326
|
toObjForTypesense(merchantId) {
|
|
321
327
|
const createdAtTimestamp = this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp);
|
|
322
|
-
const { createdAtHour, createdAtDay, createdAtMonth } = this.utilities.formatTimestamp(createdAtTimestamp);
|
|
328
|
+
const { createdAtHour, createdAtDay, createdAtMonth, createdAtYear } = this.utilities.formatTimestamp(createdAtTimestamp);
|
|
323
329
|
const stagedObj = {
|
|
324
330
|
id: this.utilities.sanitizeString(this.documentId),
|
|
325
331
|
documentId: this.utilities.sanitizeString(this.documentId),
|
|
@@ -328,6 +334,7 @@ class User extends Base_1.default {
|
|
|
328
334
|
createdAtHour,
|
|
329
335
|
createdAtDay,
|
|
330
336
|
createdAtMonth,
|
|
337
|
+
createdAtYear,
|
|
331
338
|
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
|
|
332
339
|
merchantId: this.utilities.sanitizeString(merchantId),
|
|
333
340
|
firstName: this.utilities.sanitizeString(this.firstName),
|
|
@@ -48,6 +48,7 @@ declare type ProductCollectionType = {
|
|
|
48
48
|
refinements: ProductRefinements;
|
|
49
49
|
tags: string[];
|
|
50
50
|
collectionId: string;
|
|
51
|
+
imageUrls: string[];
|
|
51
52
|
};
|
|
52
53
|
declare type CompleteProductCollection = ProductCollectionType & {
|
|
53
54
|
[key: string]: any;
|
|
@@ -61,6 +62,7 @@ declare type ProductCollectionFormFields = {
|
|
|
61
62
|
imgUrl: TextInputFormField<string>;
|
|
62
63
|
refinements: SingleSelectFormField<ProductRefinements>;
|
|
63
64
|
tags: MultiSelectFormField<string>;
|
|
65
|
+
imageUrls: MultiSelectFormField<string>;
|
|
64
66
|
collectionId: TextInputFormField<string>;
|
|
65
67
|
};
|
|
66
68
|
declare type TypesenseProductCollectionObj = {
|
|
@@ -89,5 +91,6 @@ declare type TypesenseProductCollectionObj = {
|
|
|
89
91
|
'refinements.statusRefinement': string[];
|
|
90
92
|
'refinements.salesChannelRefinement': string[];
|
|
91
93
|
tags: string[];
|
|
94
|
+
imageUrls: string[];
|
|
92
95
|
collectionId: string;
|
|
93
96
|
};
|
|
@@ -164,7 +164,8 @@ declare type TypesenseUserObj = {
|
|
|
164
164
|
lastOrderTimestamp: number;
|
|
165
165
|
lastUploadTimestamp: number;
|
|
166
166
|
registrationSource: string;
|
|
167
|
+
createdAtHour: string;
|
|
167
168
|
createdAtDay: string;
|
|
168
169
|
createdAtMonth: string;
|
|
169
|
-
|
|
170
|
+
createdAtYear: string;
|
|
170
171
|
};
|