@storecraft/database-sql-base 1.0.23 → 1.2.5

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.
@@ -8,7 +8,7 @@ import { count_regular, delete_me, delete_media_of, delete_search_of,
8
8
  insert_tags_of, regular_upsert_me, where_id_or_handle_table,
9
9
  with_media, with_search, with_tags} from './con.shared.js'
10
10
  import { sanitize, sanitize_array } from './utils.funcs.js'
11
- import { query_to_eb, query_to_sort } from './utils.query.js'
11
+ import { query_to_eb, withQuery, withSort } from './utils.query.js'
12
12
 
13
13
  export const table_name = 'customers'
14
14
 
@@ -130,23 +130,18 @@ export const remove = (driver) => {
130
130
  const list = (driver) => {
131
131
  return async (query) => {
132
132
 
133
- const items = await driver.client
133
+ const items = await withQuery(
134
+ driver.client
134
135
  .selectFrom(table_name)
135
136
  .selectAll()
136
137
  .select(eb => [
137
138
  with_media(eb, eb.ref('customers.id'), driver.dialectType),
138
139
  with_tags(eb, eb.ref('customers.id'), driver.dialectType),
139
140
  with_search(eb, eb.ref('customers.id'), driver.dialectType),
140
- ].filter(Boolean))
141
- .where(
142
- (eb) => {
143
- return query_to_eb(eb, query, table_name);
144
- }
145
- )
146
- .orderBy(query_to_sort(query, table_name))
147
- .limit(query.limitToLast ?? query.limit ?? 10)
148
- .execute();
149
-
141
+ ].filter(Boolean)),
142
+ query, table_name
143
+ ).execute();
144
+
150
145
  if(query.limitToLast) items.reverse();
151
146
 
152
147
  return sanitize_array(items);
@@ -160,7 +155,8 @@ const list = (driver) => {
160
155
  const list_customer_orders = (driver) => {
161
156
  return async (id, query) => {
162
157
 
163
- const items = await driver.client
158
+ const items = await withSort(
159
+ driver.client
164
160
  .selectFrom('orders')
165
161
  .selectAll()
166
162
  .select(eb => [
@@ -180,11 +176,12 @@ const list_customer_orders = (driver) => {
180
176
  ].filter(Boolean)
181
177
  )
182
178
  )
183
- .orderBy(query_to_sort(query, 'orders'))
184
- .limit(query.limitToLast ?? query.limit ?? 10)
185
- .execute();
179
+ .limit(query.limitToLast ?? query.limit ?? 10),
180
+ query, 'orders'
181
+ ).execute();
186
182
 
187
- if(query.limitToLast) items.reverse();
183
+ if(query.limitToLast)
184
+ items.reverse();
188
185
 
189
186
  return sanitize_array(items);
190
187
  }
@@ -7,7 +7,7 @@ import {
7
7
  helper_compute_product_extra_tags_because_of_discount_side_effect_for_db
8
8
  } from '@storecraft/core/database'
9
9
  import { SQL } from '../index.js'
10
- import { discount_to_conjunctions } from './con.discounts.utils.js'
10
+ import { discount_to_conjunctions, is_order_discount } from './con.discounts.utils.js'
11
11
  import {
12
12
  delete_entity_values_by_value_or_reporter_and_context,
13
13
  delete_me, delete_media_of, delete_search_of,
@@ -16,7 +16,7 @@ import {
16
16
  with_media, with_tags, count_regular, with_search,
17
17
  } from './con.shared.js'
18
18
  import { sanitize, sanitize_array } from './utils.funcs.js'
19
- import { query_to_eb, query_to_sort } from './utils.query.js'
19
+ import { query_to_eb, withQuery, withSort } from './utils.query.js'
20
20
  import { report_document_media } from './con.images.js'
21
21
 
22
22
  export const table_name = 'discounts'
@@ -59,23 +59,30 @@ const upsert = (driver) => {
59
59
  trx, extra_tag);
60
60
  }
61
61
 
62
- if(item.active && item.application.id===enums.DiscountApplicationEnum.Auto.id) {
62
+ // make connections into `products_to_discounts`, only applicable for
63
+ // `product` discounts and automatic discounts
64
+ if(
65
+ item.active &&
66
+ item.application.id===enums.DiscountApplicationEnum.Auto.id &&
67
+ !is_order_discount(item)
68
+ ) {
63
69
  // make connections
64
70
  await trx
65
71
  .insertInto('products_to_discounts')
66
72
  .columns(['entity_handle', 'entity_id', 'value', 'reporter'])
67
73
  .expression(eb =>
68
74
  eb.selectFrom('products')
69
- .select(eb => [
70
- 'handle as entity_handle',
71
- 'id as entity_id',
72
- eb.val(item.id).as('value'),
73
- eb.val(item.handle).as('reporter')
74
- ]
75
- )
76
- .where(
77
- eb => eb.and(discount_to_conjunctions(eb, item))
78
- )
75
+ .select(
76
+ eb => [
77
+ 'handle as entity_handle',
78
+ 'id as entity_id',
79
+ eb.val(item.id).as('value'),
80
+ eb.val(item.handle).as('reporter')
81
+ ]
82
+ )
83
+ .where(
84
+ eb => eb.and(discount_to_conjunctions(eb, item))
85
+ )
79
86
  ).execute();
80
87
 
81
88
  for(const extra_search of extra_search_for_products) {
@@ -243,24 +250,20 @@ const remove = (driver) => {
243
250
  const list = (driver) => {
244
251
  return async (query) => {
245
252
 
246
- const items = await driver.client
253
+ const items = await withQuery(
254
+ driver.client
247
255
  .selectFrom(table_name)
248
256
  .selectAll()
249
257
  .select(eb => [
250
258
  with_media(eb, eb.ref('discounts.id'), driver.dialectType),
251
259
  with_tags(eb, eb.ref('discounts.id'), driver.dialectType),
252
260
  with_search(eb, eb.ref('discounts.id'), driver.dialectType),
253
- ].filter(Boolean))
254
- .where(
255
- (eb) => {
256
- return query_to_eb(eb, query, table_name);
257
- }
258
- )
259
- .orderBy(query_to_sort(query, table_name))
260
- .limit(query.limitToLast ?? query.limit ?? 10)
261
- .execute();
261
+ ].filter(Boolean)),
262
+ query, table_name
263
+ ).execute();
262
264
 
263
- if(query.limitToLast) items.reverse();
265
+ if(query.limitToLast)
266
+ items.reverse();
264
267
 
265
268
  return sanitize_array(items);
266
269
  }
@@ -273,7 +276,8 @@ const list = (driver) => {
273
276
  const list_discount_products = (driver) => {
274
277
  return async (handle_or_id, query={}) => {
275
278
 
276
- const items = await driver.client
279
+ const items = await withSort(
280
+ driver.client
277
281
  .selectFrom('products')
278
282
  .innerJoin(
279
283
  'products_to_discounts',
@@ -298,11 +302,12 @@ const list_discount_products = (driver) => {
298
302
  ].filter(Boolean)
299
303
  )
300
304
  )
301
- .orderBy(query_to_sort(query, 'products'))
302
- .limit(query.limitToLast ?? query.limit ?? 10)
303
- .execute();
305
+ .limit(query.limitToLast ?? query.limit ?? 10),
306
+ query, 'products'
307
+ ).execute();
304
308
 
305
- if(query.limitToLast) items.reverse();
309
+ if(query.limitToLast)
310
+ items.reverse();
306
311
 
307
312
  return sanitize_array(items);
308
313
  }
@@ -8,9 +8,10 @@
8
8
  * @import { ExpressionBuilder, BinaryOperator } from 'kysely'
9
9
  */
10
10
  import { enums } from "@storecraft/core/api";
11
+ import { assert } from "console";
11
12
 
12
13
  /** @param {DiscountType} d */
13
- const is_order_discount = d => {
14
+ export const is_order_discount = d => {
14
15
  return (
15
16
  (d.info.details.type===enums.DiscountMetaEnum.order.type) ||
16
17
  // @ts-ignore
@@ -19,7 +20,7 @@ const is_order_discount = d => {
19
20
  }
20
21
 
21
22
  /** @param {DiscountType} d */
22
- const is_automatic_discount = d => {
23
+ export const is_automatic_discount = d => {
23
24
  return (d.application.id===enums.DiscountApplicationEnum.Auto.id);
24
25
  }
25
26
 
@@ -53,7 +54,7 @@ const eb_in = (eb, table, value) => {
53
54
  }
54
55
 
55
56
  /**
56
- * create a mongodb conjunctions clauses from discount, intended
57
+ * @description create a filter conjunctions clauses from discount
57
58
  * for filtering.
58
59
  * @param {ExpressionBuilder<Database, 'products'>} eb
59
60
  * @param {DiscountType} d
@@ -65,7 +66,10 @@ export const discount_to_conjunctions = (eb, d) => {
65
66
  d.active && d?.info?.filters?.length
66
67
  );
67
68
 
68
- if(!is_good) return [];
69
+ assert(
70
+ is_good,
71
+ `discount_to_conjunctions: discount is not a product discount`
72
+ );
69
73
 
70
74
  const conjunctions = [];
71
75
  const filters = d.info.filters;
package/src/con.images.js CHANGED
@@ -9,7 +9,7 @@ import { count_regular, delete_me, delete_search_of,
9
9
  insert_search_of, regular_upsert_me, where_id_or_handle_table
10
10
  } from './con.shared.js'
11
11
  import { sanitize, sanitize_array } from './utils.funcs.js'
12
- import { query_to_eb, query_to_sort } from './utils.query.js'
12
+ import { withQuery } from './utils.query.js'
13
13
  import { Transaction } from 'kysely'
14
14
  import { ID } from '@storecraft/core/api/utils.func.js'
15
15
  import {
@@ -196,19 +196,15 @@ export const report_document_media = (driver) => {
196
196
  */
197
197
  const list = (driver) => {
198
198
  return async (query) => {
199
- const items = await driver.client
199
+ const items = await withQuery(
200
+ driver.client
200
201
  .selectFrom(table_name)
201
- .selectAll()
202
- .where(
203
- (eb) => {
204
- return query_to_eb(eb, query, table_name);
205
- }
206
- )
207
- .orderBy(query_to_sort(query, 'images')) // ts complains because `usage` field is absent
208
- .limit(query.limitToLast ?? query.limit ?? 10)
209
- .execute();
202
+ .selectAll(),
203
+ query, table_name
204
+ ).execute()
210
205
 
211
- if(query.limitToLast) items.reverse();
206
+ if(query.limitToLast)
207
+ items.reverse();
212
208
 
213
209
  return sanitize_array(items);
214
210
  }
@@ -8,7 +8,7 @@ import {
8
8
  with_search
9
9
  } from './con.shared.js'
10
10
  import { sanitize_array } from './utils.funcs.js'
11
- import { query_to_eb, query_to_sort } from './utils.query.js'
11
+ import { withQuery } from './utils.query.js'
12
12
 
13
13
  export const table_name = 'notifications'
14
14
 
@@ -117,22 +117,20 @@ const remove = (driver) => {
117
117
  const list = (driver) => {
118
118
  return async (query) => {
119
119
 
120
- const items = await driver.client
120
+ const items = await withQuery(
121
+ driver.client
121
122
  .selectFrom(table_name)
122
123
  .selectAll()
123
- .select(eb => [
124
- with_search(eb, eb.ref('notifications.id'), driver.dialectType),
125
- ].filter(Boolean))
126
- .where(
127
- (eb) => {
128
- return query_to_eb(eb, query, table_name);
129
- }
130
- )
131
- .orderBy(query_to_sort(query, 'notifications'))
132
- .limit(query.limitToLast ?? query.limit ?? 10)
133
- .execute();
134
-
135
- if(query.limitToLast) items.reverse();
124
+ .select(
125
+ eb => [
126
+ with_search(eb, eb.ref('notifications.id'), driver.dialectType),
127
+ ].filter(Boolean)
128
+ ),
129
+ query, table_name
130
+ ).execute();
131
+
132
+ if(query.limitToLast)
133
+ items.reverse();
136
134
 
137
135
  return sanitize_array(items);
138
136
  }
package/src/con.orders.js CHANGED
@@ -9,7 +9,7 @@ import { count_regular, delete_me, delete_media_of, delete_search_of,
9
9
  insert_tags_of, regular_upsert_me, where_id_or_handle_table,
10
10
  with_media, with_search, with_tags} from './con.shared.js'
11
11
  import { sanitize, sanitize_array } from './utils.funcs.js'
12
- import { query_to_eb, query_to_sort } from './utils.query.js'
12
+ import { withQuery } from './utils.query.js'
13
13
 
14
14
  export const table_name = 'orders'
15
15
 
@@ -129,31 +129,29 @@ const remove = (driver) => {
129
129
  const list = (driver) => {
130
130
  return async (query) => {
131
131
 
132
- const items = await driver.client
132
+ const items = await withQuery(
133
+ driver.client
133
134
  .selectFrom(table_name)
134
135
  // .selectAll()
135
136
  .select(
136
137
  [
137
138
  'active', 'address', 'attributes', 'contact', 'coupons', 'created_at',
138
139
  'updated_at', 'description', 'handle', 'id', 'line_items', 'notes',
139
- 'payment_gateway', 'pricing', 'shipping_method', 'status', 'validation'
140
+ 'payment_gateway', 'pricing', 'shipping_method', 'status', 'validation',
140
141
  ]
141
142
  )
142
- .select(eb => [
143
- with_media(eb, eb.ref('orders.id'), driver.dialectType),
144
- with_tags(eb, eb.ref('orders.id'), driver.dialectType),
145
- with_search(eb, eb.ref('orders.id'), driver.dialectType),
146
- ].filter(Boolean))
147
- .where(
148
- (eb) => {
149
- return query_to_eb(eb, query, table_name);
150
- }
151
- )
152
- .orderBy(query_to_sort(query, table_name))
153
- .limit(query.limitToLast ?? query.limit ?? 10)
154
- .execute();
155
-
156
- if(query.limitToLast) items.reverse();
143
+ .select(
144
+ eb => [
145
+ with_media(eb, eb.ref('orders.id'), driver.dialectType),
146
+ with_tags(eb, eb.ref('orders.id'), driver.dialectType),
147
+ with_search(eb, eb.ref('orders.id'), driver.dialectType),
148
+ ].filter(Boolean)
149
+ ),
150
+ query, table_name
151
+ ).execute();
152
+
153
+ if(query.limitToLast)
154
+ items.reverse();
157
155
 
158
156
  return sanitize_array(items);
159
157
  }
package/src/con.posts.js CHANGED
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * @import { db_posts as db_col } from '@storecraft/core/database'
3
3
  */
4
-
5
4
  import { SQL } from '../index.js'
6
- import { stringArrayFrom } from './con.helpers.json.js'
7
5
  import { report_document_media } from './con.images.js'
8
- import { count_regular, delete_entity_values_by_value_or_reporter_and_context,
6
+ import {
7
+ count_regular, delete_entity_values_by_value_or_reporter_and_context,
9
8
  delete_me, delete_media_of, delete_search_of, delete_tags_of,
10
9
  insert_media_of, insert_search_of, insert_tags_of,
11
10
  regular_upsert_me, where_id_or_handle_table,
12
- with_media, with_search, with_tags} from './con.shared.js'
11
+ with_media, with_search, with_tags
12
+ } from './con.shared.js'
13
13
  import { sanitize, sanitize_array } from './utils.funcs.js'
14
- import { query_to_eb, query_to_sort } from './utils.query.js'
14
+ import { withQuery, withSort } from './utils.query.js'
15
15
 
16
16
  export const table_name = 'posts'
17
17
 
@@ -60,12 +60,13 @@ const get = (driver) => {
60
60
  const result = await driver.client
61
61
  .selectFrom(table_name)
62
62
  .selectAll()
63
- .select(eb => [
64
- with_media(eb, id_or_handle, driver.dialectType),
65
- with_tags(eb, id_or_handle, driver.dialectType),
66
- with_search(eb, id_or_handle, driver.dialectType),
67
- ]
68
- .filter(Boolean))
63
+ .select(
64
+ eb => [
65
+ with_media(eb, id_or_handle, driver.dialectType),
66
+ with_tags(eb, id_or_handle, driver.dialectType),
67
+ with_search(eb, id_or_handle, driver.dialectType),
68
+ ].filter(Boolean)
69
+ )
69
70
  .where(where_id_or_handle_table(id_or_handle))
70
71
  .executeTakeFirst();
71
72
 
@@ -113,25 +114,24 @@ const remove = (driver) => {
113
114
  const list = (driver) => {
114
115
  return async (query) => {
115
116
 
116
- const items = await driver.client
117
+ const items = await withQuery(
118
+ driver.client
117
119
  .selectFrom(table_name)
118
120
  .selectAll()
119
- .select(eb => [
120
- with_media(eb, eb.ref('posts.id'), driver.dialectType),
121
- with_tags(eb, eb.ref('posts.id'), driver.dialectType),
122
- with_search(eb, eb.ref('posts.id'), driver.dialectType),
123
- ].filter(Boolean))
124
- .where(
125
- (eb) => {
126
- return query_to_eb(eb, query, table_name);
127
- }
128
- )
129
- .orderBy(query_to_sort(query, 'posts'))
130
- // .orderBy()
131
- .limit(query.limitToLast ?? query.limit ?? 10)
132
- .execute();
133
-
134
- if(query.limitToLast) items.reverse();
121
+ .select(
122
+ eb => [
123
+ with_media(eb, eb.ref('posts.id'), driver.dialectType),
124
+ with_tags(eb, eb.ref('posts.id'), driver.dialectType),
125
+ with_search(eb, eb.ref('posts.id'), driver.dialectType),
126
+ ].filter(Boolean)
127
+ ),
128
+ query, table_name
129
+ )
130
+ .execute();
131
+ // console.log({items})
132
+
133
+ if(query.limitToLast)
134
+ items.reverse();
135
135
 
136
136
  return sanitize_array(items);
137
137
  }
@@ -21,7 +21,7 @@ import {
21
21
  products_with_related_products,
22
22
  with_search} from './con.shared.js'
23
23
  import { sanitize, sanitize_array } from './utils.funcs.js'
24
- import { query_to_eb, query_to_sort } from './utils.query.js'
24
+ import { withQuery } from './utils.query.js'
25
25
  import { Transaction } from 'kysely'
26
26
  import { report_document_media } from './con.images.js'
27
27
  import { union } from '@storecraft/core/api/utils.func.js'
@@ -34,12 +34,18 @@ import {
34
34
  export const table_name = 'products'
35
35
 
36
36
  /**
37
- *
38
37
  * @param {db_col["$type_upsert"]} item
39
38
  */
40
39
  const is_variant = item => {
41
- if(item && ('variant_hint' in item) && ('parent_handle' in item)&& ('parent_id' in item)) {
42
- return item.parent_handle && item.parent_id && item.variant_hint;
40
+ if(
41
+ item &&
42
+ ('variant_hint' in item) &&
43
+ ('parent_handle' in item) &&
44
+ ('parent_id' in item)
45
+ ) {
46
+ return item.parent_handle &&
47
+ item.parent_id &&
48
+ item.variant_hint;
43
49
  }
44
50
 
45
51
  return false;
@@ -47,8 +53,6 @@ const is_variant = item => {
47
53
 
48
54
  /**
49
55
  * @param {SQL} driver
50
- *
51
- *
52
56
  * @returns {db_col["upsert"]}
53
57
  */
54
58
  const upsert = (driver) => {
@@ -383,40 +387,42 @@ const list = (driver) => {
383
387
  const expand_variants = expand.includes('*') || expand.includes('variants');
384
388
  const expand_related_products = expand.includes('*') || expand.includes('related_products');
385
389
 
386
- const items = await driver.client
387
- .selectFrom(table_name)
388
- .selectAll()
389
- .select(
390
- eb => [
391
- with_tags(eb, eb.ref('products.id'), driver.dialectType),
392
- with_media(eb, eb.ref('products.id'), driver.dialectType),
393
- with_search(eb, eb.ref('products.id'), driver.dialectType),
394
-
395
- expand_collections &&
396
- products_with_collections(eb, eb.ref('products.id'), driver.dialectType),
390
+ const items = await withQuery(
391
+ driver.client
392
+ .selectFrom(table_name)
393
+ .selectAll()
394
+ .select(
395
+ eb => [
396
+ with_tags(eb, eb.ref('products.id'), driver.dialectType),
397
+ with_media(eb, eb.ref('products.id'), driver.dialectType),
398
+ with_search(eb, eb.ref('products.id'), driver.dialectType),
399
+
400
+ expand_collections &&
401
+ products_with_collections(
402
+ eb, eb.ref('products.id'), driver.dialectType
403
+ ),
397
404
 
398
- expand_discounts &&
399
- products_with_discounts(eb, eb.ref('products.id'), driver.dialectType),
405
+ expand_discounts &&
406
+ products_with_discounts(
407
+ eb, eb.ref('products.id'), driver.dialectType
408
+ ),
400
409
 
401
- expand_variants &&
402
- products_with_variants(eb, eb.ref('products.id'), driver.dialectType),
410
+ expand_variants &&
411
+ products_with_variants(
412
+ eb, eb.ref('products.id'), driver.dialectType
413
+ ),
403
414
 
404
- expand_related_products &&
405
- products_with_related_products(eb, eb.ref('products.id'), driver.dialectType),
406
- ].filter(Boolean)
407
- )
408
- .where(
409
- (eb) => {
410
- return query_to_eb(eb, query, table_name);
411
- }
412
- )
413
- .orderBy(query_to_sort(query, table_name))
414
- .limit(query.limitToLast ?? query.limit ?? 10)
415
- .execute();
415
+ expand_related_products &&
416
+ products_with_related_products(
417
+ eb, eb.ref('products.id'), driver.dialectType
418
+ ),
419
+ ].filter(Boolean)
420
+ ),
421
+ query, table_name
422
+ ).execute();
416
423
 
417
- if(query.limitToLast) items.reverse();
418
- // .compile();
419
- // console.log(items)
424
+ if(query.limitToLast)
425
+ items.reverse();
420
426
 
421
427
  return sanitize_array(items);
422
428
  }
package/src/con.search.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { SQL } from '../index.js'
7
7
  import { jsonArrayFrom } from './con.helpers.json.js';
8
- import { query_to_eb, query_to_sort } from './utils.query.js';
8
+ import { withQuery } from './utils.query.js';
9
9
 
10
10
  /**
11
11
  * @type {(keyof db_driver["resources"])[]}
@@ -22,7 +22,8 @@ const tables = [
22
22
  'notifications',
23
23
  'discounts',
24
24
  'orders',
25
- 'templates'
25
+ 'templates',
26
+ 'chats'
26
27
  ]
27
28
 
28
29
  /**
@@ -42,7 +43,7 @@ const prefix_to_resource = {
42
43
  'tag': 'tags',
43
44
  'template': 'templates',
44
45
  'post': 'posts',
45
-
46
+ 'chat': 'chats',
46
47
  }
47
48
 
48
49
  const resource_to_props = {
@@ -58,6 +59,7 @@ const resource_to_props = {
58
59
  'tags': ['id', 'handle'],
59
60
  'templates': ['id', 'handle', 'title'],
60
61
  'posts': ['id', 'handle', 'title'],
62
+ 'chats': ['id', 'customer_email', 'customer_id'],
61
63
  }
62
64
 
63
65
  /**
@@ -85,6 +87,7 @@ export const quicksearch = (driver) => {
85
87
  const db = driver.client;
86
88
  const expand = query.expand ?? ['*'];
87
89
  const all = expand.includes('*');
90
+ query.limit ??= 5;
88
91
 
89
92
  const sts = db
90
93
  .selectNoFrom(
@@ -99,16 +102,12 @@ export const quicksearch = (driver) => {
99
102
  // console.log(table_name, props)
100
103
  props
101
104
  return jsonArrayFrom(
102
- eb
103
- .selectFrom(table_name)
104
- .select(props)
105
- .where(
106
- (eb) => {
107
- return query_to_eb(eb, query, table_name);
108
- }
109
- )
110
- .orderBy(query_to_sort(query, table_name))
111
- .limit(query.limit ?? 5),
105
+ withQuery(
106
+ eb
107
+ .selectFrom(table_name)
108
+ .select(props),
109
+ query, table_name
110
+ ),
112
111
  driver.dialectType
113
112
  ).as(table_name)
114
113
  }
@@ -120,12 +119,15 @@ export const quicksearch = (driver) => {
120
119
  await sts.executeTakeFirst())
121
120
  );
122
121
 
122
+
123
123
  const sanitized = Object.fromEntries(
124
124
  Object.entries(items).filter(
125
125
  ([key, value]) => Boolean(value?.length)
126
126
  )
127
127
  );
128
-
128
+
129
+ // console.log('items', JSON.stringify(items, null, 2))
130
+
129
131
  // console.log('sanitized', JSON.stringify(sanitized, null, 2))
130
132
 
131
133
  return sanitized;