rerobe-js-orm 3.0.10 → 3.0.12

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.
@@ -4,7 +4,6 @@ const MerchantFactory_1 = require("./MerchantFactory");
4
4
  const Merchant_1 = require("../../models/Merchant");
5
5
  class MerchantFromFormState extends MerchantFactory_1.default {
6
6
  createMerchant(fs) {
7
- var _a;
8
7
  const MerchantMutableData = {
9
8
  name: fs.fields.name.inputValue,
10
9
  type: fs.fields.type.selectedValue,
@@ -18,7 +17,6 @@ class MerchantFromFormState extends MerchantFactory_1.default {
18
17
  timeZone: fs.fields.timeZone.selectedValue,
19
18
  unitSystem: fs.fields.unitSystem.selectedValue,
20
19
  defaultWeightUnit: fs.fields.defaultWeightUnit.selectedValue,
21
- defaultLocation: (_a = fs.props) === null || _a === void 0 ? void 0 : _a.defaultLocation,
22
20
  webhooks: fs.fields.webhooks.selectedValues,
23
21
  primaryDomain: fs.fields.primaryDomain.inputValue,
24
22
  socialLinks: fs.fields.socialLinks.selectedValue,
@@ -21,4 +21,9 @@ export default class Utilities {
21
21
  firstName: string;
22
22
  lastName: string;
23
23
  };
24
+ formatTimestamp(timestampMillis: number): {
25
+ createdAtDay: string;
26
+ createdAtMonth: string;
27
+ createdAtHour: string;
28
+ };
24
29
  }
@@ -146,5 +146,27 @@ class Utilities {
146
146
  }
147
147
  return res;
148
148
  }
149
+ formatTimestamp(timestampMillis) {
150
+ if (typeof timestampMillis !== 'number' || Number.isNaN(new Date(timestampMillis).valueOf())) {
151
+ return {
152
+ createdAtDay: '',
153
+ createdAtMonth: '',
154
+ createdAtHour: '',
155
+ };
156
+ }
157
+ const dateObj = new Date(timestampMillis);
158
+ const year = dateObj.getUTCFullYear();
159
+ const month = (dateObj.getUTCMonth() + 1).toString().padStart(2, '0'); // Months are 0-indexed in JS
160
+ const day = dateObj.getUTCDate().toString().padStart(2, '0');
161
+ const hour = dateObj.getUTCHours().toString().padStart(2, '0');
162
+ const createdAtDay = `${year}-${month}-${day}`;
163
+ const createdAtMonth = `${year}-${month}`;
164
+ const createdAtHour = `${year}-${month}-${day} ${hour}`;
165
+ return {
166
+ createdAtDay,
167
+ createdAtMonth,
168
+ createdAtHour,
169
+ };
170
+ }
149
171
  }
150
172
  exports.default = Utilities;
@@ -91,7 +91,6 @@ class Merchant extends Base_1.default {
91
91
  timeZone: this.timeZone,
92
92
  unitSystem: this.unitSystem,
93
93
  defaultWeightUnit: this.defaultWeightUnit,
94
- defaultLocation: this.defaultLocation,
95
94
  primaryDomain: this.primaryDomain,
96
95
  webhooks: this.webhooks,
97
96
  socialLinks: this.socialLinks,
@@ -103,11 +103,17 @@ export default class Order extends Base {
103
103
  toObj(): ReRobeOrderObj;
104
104
  generateSchemaForTypesense(name?: string): {
105
105
  default_sorting_field: string;
106
- fields: {
106
+ fields: ({
107
107
  facet: boolean;
108
108
  name: string;
109
109
  type: string;
110
- }[];
110
+ optional?: undefined;
111
+ } | {
112
+ facet: boolean;
113
+ name: string;
114
+ type: string;
115
+ optional: boolean;
116
+ })[];
111
117
  name: string;
112
118
  };
113
119
  toObjForTypesense(): TypesenseOrderObj;
@@ -308,6 +308,24 @@ class Order extends Base_1.default {
308
308
  name: 'merchantId',
309
309
  type: 'string',
310
310
  },
311
+ {
312
+ facet: true,
313
+ name: 'createdAtHour',
314
+ type: 'string',
315
+ optional: true,
316
+ },
317
+ {
318
+ facet: true,
319
+ name: 'createdAtDay',
320
+ type: 'string',
321
+ optional: true,
322
+ },
323
+ {
324
+ facet: true,
325
+ name: 'createdAtMonth',
326
+ type: 'string',
327
+ optional: true,
328
+ },
311
329
  ],
312
330
  name: 'dev_orders_20220809',
313
331
  };
@@ -316,11 +334,16 @@ class Order extends Base_1.default {
316
334
  const image = this.lineItems && this.lineItems[0] && this.lineItems[0].image && this.lineItems[0].image.originalSrc
317
335
  ? this.lineItems[0].image.originalSrc
318
336
  : '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
+ const createdAtTimestamp = this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp);
338
+ const { createdAtHour, createdAtDay, createdAtMonth } = this.utilities.formatTimestamp(createdAtTimestamp);
319
339
  const stagedObj = {
320
340
  id: this.utilities.sanitizeString(this.documentId),
321
341
  documentId: this.utilities.sanitizeString(this.documentId),
322
342
  userId: this.utilities.sanitizeString(this.userId),
323
- createdAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp),
343
+ createdAtTimestamp,
344
+ createdAtHour,
345
+ createdAtDay,
346
+ createdAtMonth,
324
347
  updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
325
348
  merchantId: this.utilities.sanitizeString(this.merchantId),
326
349
  image: this.utilities.sanitizeString(image),
@@ -24,9 +24,9 @@ export default class Product extends Base {
24
24
  optional?: undefined;
25
25
  } | {
26
26
  facet: boolean;
27
- optional: boolean;
28
27
  name: string;
29
28
  type: string;
29
+ optional: boolean;
30
30
  })[];
31
31
  name: string;
32
32
  };
@@ -261,6 +261,8 @@ class Product extends Base_1.default {
261
261
  };
262
262
  }
263
263
  toObjForTypesense() {
264
+ const createdAtTimestamp = this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.createdAtTimestamp);
265
+ const { createdAtHour, createdAtDay, createdAtMonth } = this.utilities.formatTimestamp(createdAtTimestamp);
264
266
  const stagedObj = {
265
267
  brand: this.utilities.sanitizeString(this.filterAttributes.brand),
266
268
  size: this.utilities.sanitizeString(this.filterAttributes.size),
@@ -290,7 +292,10 @@ class Product extends Base_1.default {
290
292
  title: this.utilities.sanitizeString(this.attributes.title),
291
293
  vendorName: this.utilities.sanitizeString(this.attributes.vendorName),
292
294
  vendorId: this.utilities.sanitizeString(this.attributes.vendorId),
293
- createdAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.createdAtTimestamp),
295
+ createdAtTimestamp,
296
+ createdAtHour,
297
+ createdAtDay,
298
+ createdAtMonth,
294
299
  updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.updatedAtTimestamp),
295
300
  sellRequestReviewTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellRequestReviewTimestamp),
296
301
  sellRequestReviewDraftTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellRequestReviewDraftTimestamp),
@@ -463,6 +468,7 @@ class Product extends Base_1.default {
463
468
  facet: true,
464
469
  name: 'size',
465
470
  type: 'string',
471
+ optional: true,
466
472
  },
467
473
  {
468
474
  facet: true,
@@ -510,7 +516,7 @@ class Product extends Base_1.default {
510
516
  },
511
517
  {
512
518
  facet: false,
513
- optional: false,
519
+ optional: true,
514
520
  name: 'merchantId',
515
521
  type: 'string',
516
522
  },
@@ -738,6 +744,24 @@ class Product extends Base_1.default {
738
744
  name: 'materialComposition..*.value',
739
745
  type: 'int32',
740
746
  },
747
+ {
748
+ facet: true,
749
+ name: 'createdAtHour',
750
+ type: 'string',
751
+ optional: true,
752
+ },
753
+ {
754
+ facet: true,
755
+ name: 'createdAtDay',
756
+ type: 'string',
757
+ optional: true,
758
+ },
759
+ {
760
+ facet: true,
761
+ name: 'createdAtMonth',
762
+ type: 'string',
763
+ optional: true,
764
+ },
741
765
  ],
742
766
  name,
743
767
  };
@@ -50,11 +50,17 @@ export default class User extends Base {
50
50
  toCustomerInputObjForRibbn(): RibbnCustomerObj;
51
51
  generateSchemaForTypesense(name?: string): {
52
52
  default_sorting_field: string;
53
- fields: {
53
+ fields: ({
54
54
  facet: boolean;
55
55
  name: string;
56
56
  type: string;
57
- }[];
57
+ optional?: undefined;
58
+ } | {
59
+ facet: boolean;
60
+ name: string;
61
+ type: string;
62
+ optional: boolean;
63
+ })[];
58
64
  name: string;
59
65
  };
60
66
  toObjForTypesense(merchantId: string): TypesenseUserObj;
@@ -295,16 +295,39 @@ class User extends Base_1.default {
295
295
  name: 'registrationSource',
296
296
  type: 'string',
297
297
  },
298
+ {
299
+ facet: true,
300
+ name: 'createdAtHour',
301
+ type: 'string',
302
+ optional: true,
303
+ },
304
+ {
305
+ facet: true,
306
+ name: 'createdAtDay',
307
+ type: 'string',
308
+ optional: true,
309
+ },
310
+ {
311
+ facet: true,
312
+ name: 'createdAtMonth',
313
+ type: 'string',
314
+ optional: true,
315
+ },
298
316
  ],
299
317
  name: 'prod_customers_20220907',
300
318
  };
301
319
  }
302
320
  toObjForTypesense(merchantId) {
321
+ const createdAtTimestamp = this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp);
322
+ const { createdAtHour, createdAtDay, createdAtMonth } = this.utilities.formatTimestamp(createdAtTimestamp);
303
323
  const stagedObj = {
304
324
  id: this.utilities.sanitizeString(this.documentId),
305
325
  documentId: this.utilities.sanitizeString(this.documentId),
306
326
  userId: this.utilities.sanitizeString(this.uid),
307
- createdAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp),
327
+ createdAtTimestamp,
328
+ createdAtHour,
329
+ createdAtDay,
330
+ createdAtMonth,
308
331
  updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
309
332
  merchantId: this.utilities.sanitizeString(merchantId),
310
333
  firstName: this.utilities.sanitizeString(this.firstName),
@@ -19,7 +19,6 @@ declare type MerchantMutableData = {
19
19
  timeZone: string;
20
20
  unitSystem: UnitSystemTypes | string | null;
21
21
  defaultWeightUnit: MetricWeightTypes | ImperialWeightTypes | string | null;
22
- defaultLocation: string;
23
22
  primaryDomain: string;
24
23
  webhooks: MerchantWebHook[];
25
24
  socialLinks: SocialLinksType | null;
@@ -35,6 +34,7 @@ declare type MerchantSystemOnlyMutableData = {
35
34
  sharedSecret: string;
36
35
  ribbnId: string;
37
36
  webshopHomePageId: string;
37
+ defaultLocation: string;
38
38
  };
39
39
  declare type MerchantObj = MerchantMutableData & MerchantSystemOnlyMutableData;
40
40
  declare type MerchantTypes = 'INDIVIDUAL' | 'BUSINESS';
@@ -763,4 +763,7 @@ declare type TypesenseOrderObj = {
763
763
  productBrands: string[];
764
764
  tags: string[];
765
765
  merchantId: string;
766
+ createdAtDay: string;
767
+ createdAtMonth: string;
768
+ createdAtHour: string;
766
769
  };
@@ -299,5 +299,8 @@ declare type TypesenseProductObj = {
299
299
  reservedBy: string[];
300
300
  'inventoryLocations.ids': string[];
301
301
  'materialComposition.names': string[];
302
+ createdAtDay: string;
303
+ createdAtMonth: string;
304
+ createdAtHour: string;
302
305
  [key: string]: any;
303
306
  };
@@ -164,4 +164,7 @@ declare type TypesenseUserObj = {
164
164
  lastOrderTimestamp: number;
165
165
  lastUploadTimestamp: number;
166
166
  registrationSource: string;
167
+ createdAtDay: string;
168
+ createdAtMonth: string;
169
+ createdAtHour: string;
167
170
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.0.10",
3
+ "version": "3.0.12",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",