rerobe-js-orm 2.6.91 → 2.6.94

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.
@@ -95,6 +95,8 @@ class OrderFromFormState extends OrderFactory_1.default {
95
95
  totalRefundedPresentment: fs.props.totalRefundedPresentment,
96
96
  totalShippingPricePresentment: fs.props.totalShippingPricePresentment,
97
97
  totalTaxPresentment: fs.props.totalTaxPresentment,
98
+ createdAtTimestamp: 0,
99
+ updatedAtTimestamp: 0,
98
100
  };
99
101
  return new Order_1.default(Object.assign({}, orderAttributes));
100
102
  }
@@ -82,6 +82,10 @@ class Utilities {
82
82
  if (t && typeof t === 'number') {
83
83
  return t;
84
84
  }
85
+ if (t && typeof t === 'string') {
86
+ const result = Date.parse(t);
87
+ return Number.isNaN(result) ? 0 : result;
88
+ }
85
89
  return 0;
86
90
  }
87
91
  }
@@ -111,6 +111,7 @@ class ChatRoom extends Base_1.default {
111
111
  return result;
112
112
  }, []);
113
113
  const stagedObj = {
114
+ id: this.utilities.sanitizeString(this.documentId),
114
115
  documentId: this.utilities.sanitizeString(this.documentId),
115
116
  createdAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp),
116
117
  type: this.utilities.sanitizeString(this.type),
@@ -88,6 +88,18 @@ export default class Order extends Base {
88
88
  totalRefundedPresentment: Money;
89
89
  totalShippingPricePresentment: Money;
90
90
  totalTaxPresentment: Money;
91
+ createdAtTimestamp: number;
92
+ updatedAtTimestamp: number;
91
93
  constructor(props?: any);
92
94
  toObj(): ReRobeOrderObj;
95
+ generateSchemaForTypesense(name?: string): {
96
+ default_sorting_field: string;
97
+ fields: {
98
+ facet: boolean;
99
+ name: string;
100
+ type: string;
101
+ }[];
102
+ name: string;
103
+ };
104
+ toObjForTypesense(): TypesenseOrderObj;
93
105
  }
@@ -124,6 +124,8 @@ class Order extends Base_1.default {
124
124
  this.totalTaxPresentment = (props === null || props === void 0 ? void 0 : props.totalTaxPresentment) || {
125
125
  amount: 0,
126
126
  };
127
+ this.createdAtTimestamp = (props === null || props === void 0 ? void 0 : props.createdAtTimestamp) || 0;
128
+ this.updatedAtTimestamp = (props === null || props === void 0 ? void 0 : props.updatedAtTimestamp) || 0;
127
129
  }
128
130
  toObj() {
129
131
  const orderObj = {
@@ -175,6 +177,8 @@ class Order extends Base_1.default {
175
177
  totalRefundedPresentment: this.totalRefundedPresentment,
176
178
  totalShippingPricePresentment: this.totalShippingPricePresentment,
177
179
  totalTaxPresentment: this.totalTaxPresentment,
180
+ createdAtTimestamp: this.createdAtTimestamp,
181
+ updatedAtTimestamp: this.updatedAtTimestamp,
178
182
  };
179
183
  if (this.paymentType) {
180
184
  orderObj.paymentType = this.paymentType;
@@ -187,6 +191,122 @@ class Order extends Base_1.default {
187
191
  }
188
192
  return orderObj;
189
193
  }
194
+ generateSchemaForTypesense(name = 'prod_orders_20220809') {
195
+ return {
196
+ default_sorting_field: 'createdAtTimestamp',
197
+ fields: [
198
+ {
199
+ facet: false,
200
+ name: 'id',
201
+ type: 'string',
202
+ },
203
+ {
204
+ facet: false,
205
+ name: 'documentId',
206
+ type: 'string',
207
+ },
208
+ {
209
+ facet: true,
210
+ name: 'createdAtTimestamp',
211
+ type: 'int64',
212
+ },
213
+ {
214
+ facet: true,
215
+ name: 'updatedAtTimestamp',
216
+ type: 'int64',
217
+ },
218
+ {
219
+ facet: false,
220
+ name: 'image',
221
+ type: 'string',
222
+ },
223
+ {
224
+ facet: true,
225
+ name: 'orderNumber',
226
+ type: 'int32',
227
+ },
228
+ {
229
+ facet: true,
230
+ name: 'customerName',
231
+ type: 'string',
232
+ },
233
+ {
234
+ facet: true,
235
+ name: 'customerEmail',
236
+ type: 'string',
237
+ },
238
+ {
239
+ facet: true,
240
+ name: 'totalPrice',
241
+ type: 'int32',
242
+ },
243
+ {
244
+ facet: true,
245
+ name: 'state',
246
+ type: 'string',
247
+ },
248
+ {
249
+ facet: true,
250
+ name: 'financialStatus',
251
+ type: 'string',
252
+ },
253
+ {
254
+ facet: true,
255
+ name: 'fulfillmentStatus',
256
+ type: 'string',
257
+ },
258
+ {
259
+ facet: true,
260
+ name: 'salesChannel',
261
+ type: 'string',
262
+ },
263
+ {
264
+ facet: true,
265
+ name: 'productIds',
266
+ type: 'string[]',
267
+ },
268
+ {
269
+ facet: true,
270
+ name: 'productTitles',
271
+ type: 'string[]',
272
+ },
273
+ {
274
+ facet: true,
275
+ name: 'productBrands',
276
+ type: 'string[]',
277
+ },
278
+ {
279
+ facet: true,
280
+ name: 'merchantId',
281
+ type: 'string',
282
+ },
283
+ ],
284
+ name: 'dev_chatRooms_20220725',
285
+ };
286
+ }
287
+ toObjForTypesense() {
288
+ var _a;
289
+ const stagedObj = {
290
+ id: this.utilities.sanitizeString(this.documentId),
291
+ documentId: this.utilities.sanitizeString(this.documentId),
292
+ createdAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp),
293
+ updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
294
+ merchantId: this.utilities.sanitizeString(this.merchantId),
295
+ image: this.utilities.sanitizeString((_a = this.lineItems[0].image) === null || _a === void 0 ? void 0 : _a.originalSrc),
296
+ orderNumber: this.utilities.sanitizeNumber(this.orderNumber),
297
+ customerName: this.utilities.sanitizeString(this.customerName),
298
+ customerEmail: this.utilities.sanitizeString(this.email),
299
+ totalPrice: this.utilities.sanitizeNumber(this.totalPrice.amount),
300
+ state: this.utilities.sanitizeString(this.state),
301
+ financialStatus: this.utilities.sanitizeString(this.financialStatus),
302
+ fulfillmentStatus: this.utilities.sanitizeString(this.fulfillmentStatus),
303
+ salesChannel: this.utilities.sanitizeString(this.salesChannel),
304
+ productIds: this.utilities.sanitzeStringArr(this.lineItems.map((l) => l.productId)),
305
+ productTitles: this.utilities.sanitzeStringArr(this.lineItems.map((l) => l.title)),
306
+ productBrands: this.utilities.sanitzeStringArr(this.lineItems.map((l) => l.brand)),
307
+ };
308
+ return stagedObj;
309
+ }
190
310
  }
191
311
  exports.default = Order;
192
312
  Order.SHIPPING_TYPES = order_constants_1.SHIPPING_TYPES;
@@ -183,6 +183,7 @@ class ProductCollection extends Base_1.default {
183
183
  }
184
184
  toObjForTypesense() {
185
185
  const stagedObj = {
186
+ id: this.utilities.sanitizeString(this.documentId),
186
187
  documentId: this.utilities.sanitizeString(this.documentId),
187
188
  merchantId: this.utilities.sanitizeString(this.merchantId),
188
189
  createdAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp),
@@ -64,6 +64,7 @@ declare type ProductCollectionFormFields = {
64
64
  collectionId: TextInputFormField<string>;
65
65
  };
66
66
  declare type TypesenseProductCollectionObj = {
67
+ id: string;
67
68
  documentId: string;
68
69
  merchantId: string;
69
70
  createdAtTimestamp: number;
@@ -31,6 +31,7 @@ declare type ChatRoomUserInfo = {
31
31
  firstName?: string;
32
32
  };
33
33
  declare type TypesenseChatRoomObj = {
34
+ id: string;
34
35
  documentId: string;
35
36
  createdAtTimestamp: number;
36
37
  type: string;
@@ -69,6 +69,8 @@ declare type ReRobeOrderObj = {
69
69
  totalRefundedPresentment?: Money;
70
70
  totalShippingPricePresentment?: Money;
71
71
  totalTaxPresentment?: Money;
72
+ createdAtTimestamp: number;
73
+ updatedAtTimestamp: number;
72
74
  };
73
75
  declare type OrderWithRefundsAndFulfillmentsInfoObj = {
74
76
  documentId?: string;
@@ -675,3 +677,22 @@ declare type OrderRefundFormFields = {
675
677
  refundLineItems: MultiSelectFormField<RefundLineItem>;
676
678
  note: TextInputFormField<string>;
677
679
  };
680
+ declare type TypesenseOrderObj = {
681
+ id: string;
682
+ documentId: string;
683
+ createdAtTimestamp: number;
684
+ updatedAtTimestamp: number;
685
+ image: string;
686
+ orderNumber: number;
687
+ customerName: string;
688
+ customerEmail: string;
689
+ totalPrice: number;
690
+ state: string;
691
+ financialStatus: string;
692
+ fulfillmentStatus: string;
693
+ salesChannel: string;
694
+ productIds: string[];
695
+ productTitles: string[];
696
+ productBrands: string[];
697
+ merchantId: string;
698
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.6.91",
3
+ "version": "2.6.94",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",