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.
@@ -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,
@@ -22,8 +22,9 @@ export default class Utilities {
22
22
  lastName: string;
23
23
  };
24
24
  formatTimestamp(timestampMillis: number): {
25
+ createdAtHour: string;
25
26
  createdAtDay: string;
26
27
  createdAtMonth: string;
27
- createdAtHour: string;
28
+ createdAtYear: string;
28
29
  };
29
30
  }
@@ -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
- createdAtHour: '',
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 createdAtHour = `${year}-${month}-${day} ${hour}`;
166
+ const createdAtYear = `${year}`;
165
167
  return {
168
+ createdAtHour,
166
169
  createdAtDay,
167
170
  createdAtMonth,
168
- createdAtHour,
171
+ createdAtYear,
169
172
  };
170
173
  }
171
174
  }
@@ -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),
@@ -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
  };
@@ -9,6 +9,7 @@ export default class ProductCollection extends Base {
9
9
  description: string;
10
10
  type: CollectionType;
11
11
  imgUrl: string;
12
+ imageUrls: string[];
12
13
  refinements: ProductRefinements;
13
14
  tags: string[];
14
15
  collectionId: string;
@@ -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;
@@ -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
  };
@@ -766,4 +766,5 @@ declare type TypesenseOrderObj = {
766
766
  createdAtDay: string;
767
767
  createdAtMonth: string;
768
768
  createdAtHour: string;
769
+ createdAtYear: string;
769
770
  };
@@ -302,5 +302,6 @@ declare type TypesenseProductObj = {
302
302
  createdAtDay: string;
303
303
  createdAtMonth: string;
304
304
  createdAtHour: string;
305
+ createdAtYear: string;
305
306
  [key: string]: any;
306
307
  };
@@ -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
- createdAtHour: string;
170
+ createdAtYear: string;
170
171
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.0.12",
3
+ "version": "3.0.14",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",