@shushed/helpers 0.0.247-fh-20260130141017 → 0.0.247-main-20260130130323

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.
Files changed (85) hide show
  1. package/dist/cjs/contracts/product.schema.json +1 -1
  2. package/dist/cjs/dist-dereferenced/gift-voucher.js +1 -1
  3. package/dist/cjs/dist-dereferenced/index.js +1 -3
  4. package/dist/cjs/dist-dereferenced/messages/order/delivered.js +1 -1
  5. package/dist/cjs/dist-dereferenced/messages/order/new.js +1 -1
  6. package/dist/cjs/dist-dereferenced/messages/order/processed.js +1 -1
  7. package/dist/cjs/dist-dereferenced/messages/order/return-initiated.js +1 -1
  8. package/dist/cjs/dist-dereferenced/messages/order/returned.js +1 -1
  9. package/dist/cjs/dist-dereferenced/messages/order/shipped.js +1 -1
  10. package/dist/cjs/dist-dereferenced/messages/product-draft.js +1 -1
  11. package/dist/cjs/dist-dereferenced/messages/product.js +1 -1
  12. package/dist/cjs/dist-dereferenced/money.js +1 -1
  13. package/dist/cjs/dist-dereferenced/order/customer.js +1 -1
  14. package/dist/cjs/dist-dereferenced/order/item.js +1 -1
  15. package/dist/cjs/dist-dereferenced/order/orderMain.js +1 -1
  16. package/dist/cjs/dist-dereferenced/order/payment.js +1 -1
  17. package/dist/cjs/dist-dereferenced/order/shipment/pos/outbound.js +1 -1
  18. package/dist/cjs/dist-dereferenced/order/shipment/pos/posMain.js +1 -1
  19. package/dist/cjs/dist-dereferenced/order/shipment/pos/return.js +1 -1
  20. package/dist/cjs/dist-dereferenced/order/shipment/shipmentMain.js +1 -1
  21. package/dist/cjs/dist-dereferenced/order/shipment/shipped/outbound.js +1 -1
  22. package/dist/cjs/dist-dereferenced/order/shipment/shipped/return.js +1 -1
  23. package/dist/cjs/dist-dereferenced/order/shipment/shipped/shippedMain.js +1 -1
  24. package/dist/cjs/dist-dereferenced/product-draft.js +1 -1
  25. package/dist/cjs/dist-dereferenced/product.js +1 -1
  26. package/dist/cjs/dist-dereferenced/purchase-orderline.js +1 -1
  27. package/dist/cjs/dist-dereferenced/stock-movement.js +1 -1
  28. package/dist/cjs/dist-dereferenced/stock.js +1 -1
  29. package/dist/cjs/dist-dereferenced/total.js +1 -1
  30. package/dist/cjs/src-public/airtable.js +17 -7
  31. package/dist/cjs/src-public/env.js +0 -2
  32. package/dist/cjs/src-public/index.js +3 -2
  33. package/dist/cjs/src-public/sitoo.js +349 -0
  34. package/dist/package.json +0 -1
  35. package/dist/types/dist-dereferenced/gift-voucher.d.ts +3 -1
  36. package/dist/types/dist-dereferenced/index.d.ts +0 -1
  37. package/dist/types/dist-dereferenced/messages/order/delivered.d.ts +2903 -253
  38. package/dist/types/dist-dereferenced/messages/order/new.d.ts +2903 -253
  39. package/dist/types/dist-dereferenced/messages/order/processed.d.ts +2903 -253
  40. package/dist/types/dist-dereferenced/messages/order/return-initiated.d.ts +2903 -253
  41. package/dist/types/dist-dereferenced/messages/order/returned.d.ts +2903 -253
  42. package/dist/types/dist-dereferenced/messages/order/shipped.d.ts +2903 -253
  43. package/dist/types/dist-dereferenced/messages/product-draft.d.ts +188 -6
  44. package/dist/types/dist-dereferenced/messages/product.d.ts +109 -12
  45. package/dist/types/dist-dereferenced/money.d.ts +3 -1
  46. package/dist/types/dist-dereferenced/order/customer.d.ts +98 -1
  47. package/dist/types/dist-dereferenced/order/index.d.ts +2903 -253
  48. package/dist/types/dist-dereferenced/order/item.d.ts +221 -7
  49. package/dist/types/dist-dereferenced/order/orderMain.d.ts +2903 -253
  50. package/dist/types/dist-dereferenced/order/payment.d.ts +3 -1
  51. package/dist/types/dist-dereferenced/order/shipment/index.d.ts +125 -5
  52. package/dist/types/dist-dereferenced/order/shipment/pos/index.d.ts +125 -5
  53. package/dist/types/dist-dereferenced/order/shipment/pos/outbound.d.ts +139 -6
  54. package/dist/types/dist-dereferenced/order/shipment/pos/posMain.d.ts +125 -5
  55. package/dist/types/dist-dereferenced/order/shipment/pos/return.d.ts +155 -6
  56. package/dist/types/dist-dereferenced/order/shipment/shipmentMain.d.ts +125 -5
  57. package/dist/types/dist-dereferenced/order/shipment/shipped/index.d.ts +125 -5
  58. package/dist/types/dist-dereferenced/order/shipment/shipped/outbound.d.ts +139 -6
  59. package/dist/types/dist-dereferenced/order/shipment/shipped/return.d.ts +139 -6
  60. package/dist/types/dist-dereferenced/order/shipment/shipped/shippedMain.d.ts +125 -5
  61. package/dist/types/dist-dereferenced/product-draft.d.ts +188 -6
  62. package/dist/types/dist-dereferenced/product.d.ts +109 -12
  63. package/dist/types/dist-dereferenced/purchase-orderline.d.ts +3 -1
  64. package/dist/types/dist-dereferenced/stock-movement.d.ts +3 -1
  65. package/dist/types/dist-dereferenced/stock.d.ts +3 -1
  66. package/dist/types/dist-dereferenced/total.d.ts +111 -4
  67. package/dist/types/dist-types/index.d.ts +0 -1
  68. package/dist/types/dist-types/messages/product.d.ts +1 -1
  69. package/dist/types/dist-types/product.d.ts +1 -1
  70. package/dist/types/src-public/airtable.d.ts +3 -3
  71. package/dist/types/src-public/index.d.ts +1 -1
  72. package/dist/types/src-public/sitoo.d.ts +254 -0
  73. package/package.json +1 -2
  74. package/dist/cjs/dist-dereferenced/category-tree.js +0 -4
  75. package/dist/cjs/dist-types/category-tree.js +0 -2
  76. package/dist/cjs/src-public/fredhopper/fredhopper.base.js +0 -497
  77. package/dist/cjs/src-public/fredhopper/fredhopper.js +0 -105
  78. package/dist/cjs/src-public/fredhopper/fredhopper.types.js +0 -10
  79. package/dist/cjs/src-public/fredhopper/index.js +0 -10
  80. package/dist/types/dist-dereferenced/category-tree.d.ts +0 -53
  81. package/dist/types/dist-types/category-tree.d.ts +0 -12
  82. package/dist/types/src-public/fredhopper/fredhopper.base.d.ts +0 -59
  83. package/dist/types/src-public/fredhopper/fredhopper.d.ts +0 -21
  84. package/dist/types/src-public/fredhopper/fredhopper.types.d.ts +0 -70
  85. package/dist/types/src-public/fredhopper/index.d.ts +0 -2
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Total", "type": "object", "properties": { "amount_net": { "title": "Amount Net", "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "value": { "type": "integer", "minimum": 0 }, "decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 }, "currency": { "title": "Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_value": { "type": "integer", "minimum": 0 }, "lcy_currency": { "$ref": "#/properties/amount_net/properties/currency", "title": "LCY Currency" }, "lcy_decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 } }, "required": ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"] }, "amount_gross": { "$ref": "#/properties/amount_net", "title": "Amount gross" }, "discount_amount_net": { "$ref": "#/properties/amount_net", "title": "Discount Amount Net" }, "discount_amount_gross": { "$ref": "#/properties/amount_net", "title": "Discount Amount Gross" }, "discount_amount_percent": { "type": "number", "title": "Discount Amount Percent", "minimum": 0, "maximum": 100 } }, "required": ["amount_net", "amount_gross", "discount_amount_net", "discount_amount_gross", "discount_amount_percent"], "$id": "https://shushed.example.com/total.schema.json" };
3
+ const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Total", "type": "object", "properties": { "amount_net": { "title": "Amount Net", "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "value": { "type": "integer", "minimum": 0 }, "decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 }, "currency": { "title": "Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_value": { "type": "integer", "minimum": 0 }, "lcy_currency": { "title": "LCY Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 } }, "required": ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"] }, "amount_gross": { "title": "Amount gross", "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "value": { "type": "integer", "minimum": 0 }, "decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 }, "currency": { "title": "Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_value": { "type": "integer", "minimum": 0 }, "lcy_currency": { "title": "LCY Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 } }, "required": ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"] }, "discount_amount_net": { "title": "Discount Amount Net", "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "value": { "type": "integer", "minimum": 0 }, "decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 }, "currency": { "title": "Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_value": { "type": "integer", "minimum": 0 }, "lcy_currency": { "title": "LCY Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 } }, "required": ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"] }, "discount_amount_gross": { "title": "Discount Amount Gross", "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "value": { "type": "integer", "minimum": 0 }, "decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 }, "currency": { "title": "Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_value": { "type": "integer", "minimum": 0 }, "lcy_currency": { "title": "LCY Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 } }, "required": ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"] }, "discount_amount_percent": { "type": "number", "title": "Discount Amount Percent", "minimum": 0, "maximum": 100 } }, "required": ["amount_net", "amount_gross", "discount_amount_net", "discount_amount_gross", "discount_amount_percent"], "$id": "https://shushed.example.com/total.schema.json" };
4
4
  exports.default = schema;
@@ -13,6 +13,7 @@ class AirtableHelper extends runtime_1.default {
13
13
  dictionary;
14
14
  primaryKeyFieldName;
15
15
  primaryKeyWritable = true;
16
+ viewId;
16
17
  constructor(opts, airtableOpts) {
17
18
  super(opts);
18
19
  this.baseId = airtableOpts.baseId;
@@ -23,6 +24,9 @@ class AirtableHelper extends runtime_1.default {
23
24
  if (typeof airtableOpts.primaryKeyWritable !== 'undefined') {
24
25
  this.primaryKeyWritable = airtableOpts.primaryKeyWritable;
25
26
  }
27
+ if (typeof airtableOpts.viewId !== 'undefined') {
28
+ this.viewId = airtableOpts.viewId;
29
+ }
26
30
  }
27
31
  static translateFields(dictionary, y) {
28
32
  const nextFields = {};
@@ -419,12 +423,15 @@ class AirtableHelper extends runtime_1.default {
419
423
  if (!unprocessedResult) {
420
424
  const res = (await resp.json());
421
425
  nextCursor = res.cursor;
422
- this.logging.log(`Received ${res.payloads.length} records from the table: ${this.tableId}.`);
426
+ const scope = this.viewId ? `view: ${this.viewId}` : `table: ${this.tableId}`;
427
+ this.logging.log(`Received ${res.payloads.length} records from the ${scope}.`);
423
428
  for (const payload of res.payloads) {
424
- const changes = payload.changedTablesById[this.tableId];
429
+ const changes = this.viewId
430
+ ? payload.changedViewsById?.[this.viewId]
431
+ : payload.changedTablesById?.[this.tableId];
425
432
  const airtableCreated = Object.entries(changes?.createdRecordsById || {}).map(([k, v]) => ({
426
433
  id: k,
427
- fields: AirtableHelper.translateFields(this.dictionary, { fields: (v.cellValuesByFieldId || {}) }).fields,
434
+ fields: AirtableHelper.translateFields(this.dictionary, { fields: v.cellValuesByFieldId || {} }).fields,
428
435
  created_at: v.createdTime || payload.timestamp,
429
436
  last_modified_at: v.createdTime || payload.timestamp,
430
437
  previous_fields: null
@@ -541,7 +548,8 @@ class AirtableHelper extends runtime_1.default {
541
548
  return null;
542
549
  }
543
550
  createNotificationUrl() {
544
- return `${this.runtimeUrl}/executeWorkflow/${this.workflowId}/${this.triggerId}?request-from-airtable=1&baseId=${this.baseId}&tableId=${this.tableId}`;
551
+ const baseUrl = `${this.runtimeUrl}/executeWorkflow/${this.workflowId}/${this.triggerId}?request-from-airtable=1&baseId=${this.baseId}&tableId=${this.tableId}`;
552
+ return this.viewId ? `${baseUrl}&viewId=${this.viewId}` : baseUrl;
545
553
  }
546
554
  async isValidSignature(secret, payload, signature) {
547
555
  const macSecretDecoded = Buffer.from(secret, 'base64');
@@ -579,7 +587,8 @@ class AirtableHelper extends runtime_1.default {
579
587
  async webhookHasChanged() {
580
588
  const existingWebhook = await this.getWebhook();
581
589
  const fieldIds = Object.values(this.dictionary).filter((x, idx, arr) => arr.indexOf(x) === idx);
582
- if (existingWebhook?.specification.options.filters.recordChangeScope === this.tableId
590
+ const expectedScope = this.viewId || this.tableId;
591
+ if (existingWebhook?.specification.options.filters.recordChangeScope === expectedScope
583
592
  && (0, lodash_isequal_1.default)(existingWebhook?.specification.options.filters.watchDataInFieldIds, fieldIds)
584
593
  && (0, lodash_isequal_1.default)(existingWebhook?.specification.options.includes?.includeCellValuesInFieldIds, fieldIds)
585
594
  && existingWebhook.specification.options.includes?.includePreviousCellValues) {
@@ -590,7 +599,8 @@ class AirtableHelper extends runtime_1.default {
590
599
  async updateOrCreateWebhook() {
591
600
  const existingWebhook = await this.getWebhook();
592
601
  const fieldIds = Object.values(this.dictionary).filter((x, idx, arr) => arr.indexOf(x) === idx);
593
- if (existingWebhook?.specification.options.filters.recordChangeScope === this.tableId
602
+ const recordChangeScope = this.viewId || this.tableId;
603
+ if (existingWebhook?.specification.options.filters.recordChangeScope === recordChangeScope
594
604
  && (0, lodash_isequal_1.default)(existingWebhook?.specification.options.filters.watchDataInFieldIds, fieldIds)
595
605
  && (0, lodash_isequal_1.default)(existingWebhook?.specification.options.includes?.includeCellValuesInFieldIds, fieldIds)
596
606
  && existingWebhook.specification.options.includes?.includePreviousCellValues) {
@@ -607,7 +617,7 @@ class AirtableHelper extends runtime_1.default {
607
617
  options: {
608
618
  filters: {
609
619
  dataTypes: ["tableData"],
610
- recordChangeScope: this.tableId,
620
+ recordChangeScope,
611
621
  watchDataInFieldIds: fieldIds,
612
622
  },
613
623
  includes: {
@@ -579,9 +579,7 @@ class EnvEngine extends runtime_1.default {
579
579
  if (!pubSubProjectId) {
580
580
  throw new Error('PubSub Project ID is not set. Please set the ' + ENV_NAME_PUBSUB_PROJECT_ID + ' environment variable.');
581
581
  }
582
- console.log(JSON.stringify({ rnPartialConfig }));
583
582
  const rnConfig = this.getRespectfulNudgeConfig(subscriptionName, rnPartialConfig);
584
- console.log(JSON.stringify({ rnConfig }));
585
583
  const subscriptionQualifiedName = `projects/${rnConfig.pubSubProjectId}/subscriptions/${subscriptionName}`;
586
584
  return this.withGoogleIdentityToken({
587
585
  workflowId: workflowTriggerId.split('/')[0],
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.RedisConnectionError = exports.RateLimit = exports.setHeaders = exports.BCOrderHelper = exports.DatoHelper = exports.AirtableHelper = exports.CentraHelper = exports.BigQueryHelper = exports.JWKSHelper = exports.CloudTasksHelper = exports.Secrets = exports.SchedulerHelper = exports.Logging = exports.Runtime = exports.PubSubHelper = exports.EnvEngine = exports.validate = void 0;
20
+ exports.SitooHelper = exports.RedisConnectionError = exports.RateLimit = exports.setHeaders = exports.BCOrderHelper = exports.DatoHelper = exports.AirtableHelper = exports.CentraHelper = exports.BigQueryHelper = exports.JWKSHelper = exports.CloudTasksHelper = exports.Secrets = exports.SchedulerHelper = exports.Logging = exports.Runtime = exports.PubSubHelper = exports.EnvEngine = exports.validate = void 0;
21
21
  var validate_1 = require("./validate");
22
22
  Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return __importDefault(validate_1).default; } });
23
23
  __exportStar(require("./sanitize"), exports);
@@ -52,4 +52,5 @@ Object.defineProperty(exports, "setHeaders", { enumerable: true, get: function (
52
52
  var rateLimit_1 = require("./rateLimit");
53
53
  Object.defineProperty(exports, "RateLimit", { enumerable: true, get: function () { return __importDefault(rateLimit_1).default; } });
54
54
  Object.defineProperty(exports, "RedisConnectionError", { enumerable: true, get: function () { return rateLimit_1.RedisConnectionError; } });
55
- __exportStar(require("./fredhopper"), exports);
55
+ var sitoo_1 = require("./sitoo");
56
+ Object.defineProperty(exports, "SitooHelper", { enumerable: true, get: function () { return __importDefault(sitoo_1).default; } });
@@ -0,0 +1,349 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SitooOrderItemType = exports.SitooPaymentState = exports.SitooOrderType = exports.SitooOrderState = void 0;
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ const lodash_groupby_1 = __importDefault(require("lodash.groupby"));
9
+ const env_1 = __importDefault(require("./env"));
10
+ const SITOO_TR_TYPE_MANUAL_IN = 10;
11
+ const SITOO_TR_TYPE_MANUAL_OUT = 20;
12
+ var SitooOrderState;
13
+ (function (SitooOrderState) {
14
+ SitooOrderState[SitooOrderState["Abandoned"] = -1] = "Abandoned";
15
+ SitooOrderState[SitooOrderState["Open"] = 0] = "Open";
16
+ SitooOrderState[SitooOrderState["Closed"] = 10] = "Closed";
17
+ SitooOrderState[SitooOrderState["Cancelled"] = 20] = "Cancelled";
18
+ })(SitooOrderState || (exports.SitooOrderState = SitooOrderState = {}));
19
+ var SitooOrderType;
20
+ (function (SitooOrderType) {
21
+ SitooOrderType[SitooOrderType["Order"] = 10] = "Order";
22
+ SitooOrderType[SitooOrderType["Booking"] = 100] = "Booking";
23
+ SitooOrderType[SitooOrderType["POSParked"] = 110] = "POSParked";
24
+ })(SitooOrderType || (exports.SitooOrderType = SitooOrderType = {}));
25
+ var SitooPaymentState;
26
+ (function (SitooPaymentState) {
27
+ SitooPaymentState[SitooPaymentState["None"] = 0] = "None";
28
+ SitooPaymentState[SitooPaymentState["Pending"] = 10] = "Pending";
29
+ SitooPaymentState[SitooPaymentState["Reserved"] = 15] = "Reserved";
30
+ SitooPaymentState[SitooPaymentState["Successful"] = 20] = "Successful";
31
+ SitooPaymentState[SitooPaymentState["Cancelled"] = 30] = "Cancelled";
32
+ SitooPaymentState[SitooPaymentState["Failed"] = 40] = "Failed";
33
+ })(SitooPaymentState || (exports.SitooPaymentState = SitooPaymentState = {}));
34
+ var SitooOrderItemType;
35
+ (function (SitooOrderItemType) {
36
+ SitooOrderItemType[SitooOrderItemType["Product"] = 10] = "Product";
37
+ SitooOrderItemType[SitooOrderItemType["Discount"] = 20] = "Discount";
38
+ })(SitooOrderItemType || (exports.SitooOrderItemType = SitooOrderItemType = {}));
39
+ const BATCH_SIZE = 900;
40
+ class SitooHelper extends env_1.default {
41
+ opts;
42
+ shaToken;
43
+ baseUrl;
44
+ siteId;
45
+ constructor(options, opts) {
46
+ super(options);
47
+ this.opts = opts;
48
+ this.shaToken = crypto_1.default.createHash('sha256').update(opts.accessToken).digest('hex').slice(0, 8);
49
+ this.baseUrl = opts.sitooBaseUrl.replace(/\/$/, '');
50
+ this.siteId = opts.sitooSiteId;
51
+ }
52
+ async getAllOrders(options) {
53
+ const allOrders = [];
54
+ const pageSize = 100;
55
+ let start = 0;
56
+ let hasMore = true;
57
+ while (hasMore) {
58
+ const queryParams = new URLSearchParams();
59
+ queryParams.set('num', pageSize.toString());
60
+ queryParams.set('start', start.toString());
61
+ queryParams.set('sort', 'orderid');
62
+ if (options?.fromTimestamp !== undefined) {
63
+ queryParams.set('orderdatefrom', options.fromTimestamp.toString());
64
+ }
65
+ if (options?.untilTimestamp !== undefined) {
66
+ queryParams.set('orderdateto', options.untilTimestamp.toString());
67
+ }
68
+ if (options?.filterByState !== undefined) {
69
+ queryParams.set('orderstate', options.filterByState.toString());
70
+ }
71
+ const url = `${this.baseUrl}/sites/${this.siteId}/orders.json?${queryParams.toString()}`;
72
+ const response = await fetch(url, {
73
+ method: 'GET',
74
+ headers: {
75
+ 'Authorization': `Basic ${this.opts.accessToken}`,
76
+ 'Content-Type': 'application/json',
77
+ },
78
+ });
79
+ if (!response.ok) {
80
+ const errorText = await response.text().catch(() => 'Unknown error');
81
+ throw new Error(`Sitoo API error: ${response.status} ${response.statusText} - ${errorText}`);
82
+ }
83
+ const envelope = await response.json();
84
+ allOrders.push(...envelope.items);
85
+ if (envelope.items.length < pageSize) {
86
+ hasMore = false;
87
+ }
88
+ else {
89
+ start += envelope.items.length;
90
+ }
91
+ }
92
+ return allOrders;
93
+ }
94
+ async getSitooWarehouses() {
95
+ const url = `${this.baseUrl}/sites/${this.siteId}/warehouses.json`;
96
+ const response = await fetch(url, {
97
+ method: 'GET',
98
+ headers: {
99
+ 'Authorization': `Basic ${this.opts.accessToken}`,
100
+ 'Content-Type': 'application/json',
101
+ },
102
+ });
103
+ if (!response.ok) {
104
+ const errorText = await response.text().catch(() => 'Unknown error');
105
+ throw new Error(`Sitoo API error: ${response.status} ${response.statusText} - ${errorText}`);
106
+ }
107
+ const data = await response.json();
108
+ const nameToId = {};
109
+ const warehouses = {};
110
+ for (const warehouse of data.items) {
111
+ nameToId[warehouse.name] = warehouse.warehouseid;
112
+ warehouses[warehouse.warehouseid] = warehouse;
113
+ }
114
+ return { nameToId, warehouses };
115
+ }
116
+ async fetchWarehouseTransactionsWithFilter(params) {
117
+ const queryParams = new URLSearchParams();
118
+ queryParams.set('num', (params.num || 100).toString());
119
+ if (params.transactiontype !== undefined) {
120
+ queryParams.set('transactiontype', params.transactiontype.toString());
121
+ }
122
+ if (params.datecreatedfrom !== undefined) {
123
+ queryParams.set('datecreatedfrom', params.datecreatedfrom.toString());
124
+ }
125
+ if (params.start !== undefined) {
126
+ queryParams.set('start', params.start.toString());
127
+ }
128
+ queryParams.set('sort', params.ascending ? 'warehousetransactionid' : '-warehousetransactionid');
129
+ const url = `${this.baseUrl}/sites/${this.siteId}/warehouses/${params.warehouseid}/warehousetransactions.json?${queryParams.toString()}`;
130
+ const response = await fetch(url, {
131
+ method: 'GET',
132
+ headers: {
133
+ 'Authorization': `Basic ${this.opts.accessToken}`,
134
+ 'Content-Type': 'application/json',
135
+ },
136
+ });
137
+ if (!response.ok) {
138
+ const errorText = await response.text().catch(() => 'Unknown error');
139
+ throw new Error(`Sitoo API error: ${response.status} ${response.statusText} - ${errorText}`);
140
+ }
141
+ return await response.json();
142
+ }
143
+ async searchTransactionsInApi(warehouseId, entryNosToFind, transactionType, datecreatedfrom) {
144
+ const found = new Map();
145
+ let lowestTransactionId = undefined;
146
+ if (entryNosToFind.size === 0) {
147
+ return { found, lowestTransactionId };
148
+ }
149
+ let hasMore = true;
150
+ const pageSize = 100;
151
+ const currentDateFrom = datecreatedfrom;
152
+ let currentStart = 0;
153
+ while (hasMore && found.size < entryNosToFind.size) {
154
+ const envelope = await this.fetchWarehouseTransactionsWithFilter({
155
+ warehouseid: warehouseId,
156
+ datecreatedfrom: currentDateFrom,
157
+ transactiontype: transactionType,
158
+ ascending: false,
159
+ num: pageSize,
160
+ start: currentStart,
161
+ });
162
+ const transactions = envelope.items;
163
+ if (transactions.length === 0) {
164
+ hasMore = false;
165
+ break;
166
+ }
167
+ for (const transaction of transactions) {
168
+ if (lowestTransactionId === undefined || transaction.warehousetransactionid < lowestTransactionId) {
169
+ lowestTransactionId = transaction.warehousetransactionid;
170
+ }
171
+ if (transaction.description) {
172
+ for (const entryNo of entryNosToFind) {
173
+ if (!found.has(entryNo) && transaction.description.includes(`'${entryNo}'`)) {
174
+ found.set(entryNo, transaction);
175
+ }
176
+ }
177
+ }
178
+ if (found.size === entryNosToFind.size) {
179
+ break;
180
+ }
181
+ }
182
+ currentStart = currentStart ? currentStart + transactions.length : transactions.length;
183
+ if (transactions.length < pageSize) {
184
+ hasMore = false;
185
+ }
186
+ }
187
+ return { found, lowestTransactionId };
188
+ }
189
+ async batchAddWarehouseTransactions(transactions) {
190
+ if (transactions.length === 0)
191
+ return [];
192
+ if (transactions.length > BATCH_SIZE) {
193
+ throw new Error(`Batch size exceeds maximum of ${BATCH_SIZE}. Got ${transactions.length}`);
194
+ }
195
+ const url = `${this.baseUrl}/sites/${this.siteId}/warehousetransactions.json`;
196
+ const response = await fetch(url, {
197
+ method: 'POST',
198
+ headers: {
199
+ 'Authorization': `Basic ${this.opts.accessToken}`,
200
+ 'Content-Type': 'application/json',
201
+ },
202
+ body: JSON.stringify(transactions),
203
+ });
204
+ if (!response.ok) {
205
+ const errorText = await response.text().catch(() => 'Unknown error');
206
+ throw new Error(`Sitoo API error: ${response.status} ${response.statusText} - ${errorText}`);
207
+ }
208
+ const result = await response.json();
209
+ return result;
210
+ }
211
+ async syncWarehouseTransactions(items, options) {
212
+ if (items.length === 0) {
213
+ return [];
214
+ }
215
+ const locationCodeToWarehouse = (await this.getSitooWarehouses()).nameToId;
216
+ const foundEntryNos = new Map();
217
+ const results = {};
218
+ const entryNoToIdx = {};
219
+ const entriesByWarehouseAndTransactionType = new Map();
220
+ for (let i = 0; i < items.length; i++) {
221
+ const entry = items[i];
222
+ const warehouseId = locationCodeToWarehouse[entry.location_code];
223
+ const transactionType = entry.type === 'transfer' ? (entry.quantity > 0 ? SITOO_TR_TYPE_MANUAL_IN : SITOO_TR_TYPE_MANUAL_OUT) : undefined;
224
+ entryNoToIdx[entry.entry_no] = i;
225
+ if (transactionType === undefined) {
226
+ results[i] = {
227
+ error: false,
228
+ message: `Not supported transaction type: ${entry.type}`,
229
+ };
230
+ continue;
231
+ }
232
+ if (warehouseId === undefined) {
233
+ results[i] = {
234
+ error: false,
235
+ message: `Not supported warehouse in Sitoo: ${entry.location_code}`,
236
+ };
237
+ continue;
238
+ }
239
+ const key = `${warehouseId}-${transactionType}`;
240
+ if (!entriesByWarehouseAndTransactionType.has(key)) {
241
+ entriesByWarehouseAndTransactionType.set(key, []);
242
+ }
243
+ entriesByWarehouseAndTransactionType.get(key).push(entry);
244
+ }
245
+ for (const [_, warehouseEntries] of entriesByWarehouseAndTransactionType) {
246
+ if (warehouseEntries.length > 0) {
247
+ let datecreatedfrom = undefined;
248
+ for (const entry of warehouseEntries) {
249
+ const entryCreatedAt = Math.floor(new Date(entry.created_at).getTime() / 1000);
250
+ if (datecreatedfrom === undefined || entryCreatedAt < datecreatedfrom) {
251
+ datecreatedfrom = entryCreatedAt;
252
+ }
253
+ }
254
+ const { found: apiFound } = await this.searchTransactionsInApi(locationCodeToWarehouse[warehouseEntries[0].location_code], new Set(warehouseEntries.map(e => e.entry_no.toString())), warehouseEntries[0].quantity > 0 ? SITOO_TR_TYPE_MANUAL_IN : SITOO_TR_TYPE_MANUAL_OUT, datecreatedfrom);
255
+ for (const [entryNo, transaction] of apiFound) {
256
+ foundEntryNos.set(entryNo, transaction.warehousetransactionid);
257
+ }
258
+ }
259
+ }
260
+ for (const [entryNo, transactionId] of foundEntryNos) {
261
+ const idx = entryNoToIdx[entryNo];
262
+ results[idx] = {
263
+ error: false,
264
+ message: `Found transaction in Sitoo: ${transactionId} for the entry ${entryNo}`,
265
+ };
266
+ }
267
+ const batches = [[]];
268
+ for (const [_, warehouseEntries] of entriesByWarehouseAndTransactionType) {
269
+ for (let i = 0; i < warehouseEntries.length; i += 1) {
270
+ if (!foundEntryNos.has(warehouseEntries[i].entry_no)) {
271
+ if ((batches[batches.length - 1].length + 1) >= BATCH_SIZE) {
272
+ batches.push([]);
273
+ }
274
+ batches[batches.length - 1].push(warehouseEntries[i]);
275
+ }
276
+ }
277
+ }
278
+ const hasMissingEntries = batches[0].length > 0;
279
+ if (!options?.preview && hasMissingEntries) {
280
+ for (let i = 0; i < batches.length; i++) {
281
+ const warehouseEntities = (0, lodash_groupby_1.default)(batches[i], e => `${locationCodeToWarehouse[e.location_code]}-${e.quantity > 0 ? 'positive' : 'negative'}`);
282
+ const entryNosInBatches = {};
283
+ const transactionsToCreate = [];
284
+ for (const k in warehouseEntities) {
285
+ const entriesToCreate = warehouseEntities[k];
286
+ const warehouseId = locationCodeToWarehouse[entriesToCreate[0].location_code];
287
+ const entryType = entriesToCreate[0].quantity > 0 ? SITOO_TR_TYPE_MANUAL_IN : SITOO_TR_TYPE_MANUAL_OUT;
288
+ entryNosInBatches[transactionsToCreate.length] = entriesToCreate.map(e => e.entry_no);
289
+ transactionsToCreate.push({
290
+ warehouseid: warehouseId,
291
+ transactiontype: entryType,
292
+ description: entriesToCreate.map(e => `'${e.entry_no}'`).join(', '),
293
+ items: entriesToCreate.map(e => ({
294
+ sku: [e.style_id, e.colour_id, e.size_code].filter(Boolean).join('-'),
295
+ decimalquantity: `${e.quantity.toFixed(3)}`,
296
+ moneypricein: (((e.unit_cost?.value ?? 0) / 100) * e.quantity).toFixed(2),
297
+ })),
298
+ });
299
+ }
300
+ try {
301
+ const createdIds = await this.batchAddWarehouseTransactions(transactionsToCreate);
302
+ for (let j = 0; j < transactionsToCreate.length; j++) {
303
+ const transactionId = createdIds[j];
304
+ for (let k = 0; k < entryNosInBatches[j].length; k += 1) {
305
+ const entryNo = entryNosInBatches[j][k];
306
+ const idx = entryNoToIdx[entryNo];
307
+ results[idx] = {
308
+ entryNo: entryNo,
309
+ transactionId: transactionId,
310
+ };
311
+ }
312
+ }
313
+ }
314
+ catch (error) {
315
+ for (const entry of batches[i]) {
316
+ const idx = entryNoToIdx[entry.entry_no];
317
+ results[idx] = error;
318
+ }
319
+ }
320
+ }
321
+ }
322
+ else {
323
+ for (let i = 0; i < batches.length; i++) {
324
+ for (let j = 0; j < batches[i].length; j += 1) {
325
+ const entry = batches[i][j];
326
+ const idx = entryNoToIdx[entry.entry_no];
327
+ const warehouseId = locationCodeToWarehouse[entry.location_code];
328
+ const transactionType = entry.quantity > 0 ? SITOO_TR_TYPE_MANUAL_IN : SITOO_TR_TYPE_MANUAL_OUT;
329
+ results[idx] = {
330
+ error: false,
331
+ message: `In Preview Mode. ${entry.entry_no} scheduled to be created as transction type: ${transactionType} in the warehouse: ${warehouseId}. Batch: ${i}`
332
+ };
333
+ }
334
+ }
335
+ }
336
+ const resultsAsArray = [];
337
+ for (let i = 0; i < items.length; i += 1) {
338
+ const result = results[i];
339
+ if (!result) {
340
+ resultsAsArray.push(new Error(`${items[i].entry_no} got missed in processing`));
341
+ }
342
+ else {
343
+ resultsAsArray.push(result);
344
+ }
345
+ }
346
+ return resultsAsArray;
347
+ }
348
+ }
349
+ exports.default = SitooHelper;
package/dist/package.json CHANGED
@@ -9,7 +9,6 @@
9
9
  "@hackylabs/deep-redact": "^2.2.1",
10
10
  "ajv": "^8.17.1",
11
11
  "ajv-formats": "^3.0.1",
12
- "archiver": "^7.0.1",
13
12
  "co-body": "^6.2.0",
14
13
  "jose": "^6.0.11",
15
14
  "lodash.chunk": "^4.2.0",
@@ -54,8 +54,10 @@ declare const schema: {
54
54
  readonly minimum: 0;
55
55
  };
56
56
  readonly lcy_currency: {
57
- readonly $ref: "#/properties/balance/properties/currency";
58
57
  readonly title: "LCY Currency";
58
+ readonly $schema: "http://json-schema.org/draft-07/schema#";
59
+ readonly type: "string";
60
+ readonly enum: readonly ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"];
59
61
  };
60
62
  readonly lcy_decimal_places: {
61
63
  readonly type: "integer";
@@ -1,5 +1,4 @@
1
1
  export { default as Asset } from './asset';
2
- export { default as CategoryTree } from './category-tree';
3
2
  export { default as Category } from './category';
4
3
  export { default as Country } from './country';
5
4
  export { default as Currency } from './currency';