@shushed/helpers 0.0.229 → 0.0.230-fix-erp-780-20260109153401
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.
- package/dist/cjs/contracts/index.js +1 -5
- package/dist/cjs/contracts/product-draft.schema.json +5 -159
- package/dist/cjs/dist-dereferenced/index.js +1 -5
- package/dist/cjs/dist-dereferenced/messages/product-draft.js +1 -1
- package/dist/cjs/dist-dereferenced/product-draft.js +1 -1
- package/dist/cjs/src-public/airtable.js +59 -96
- package/dist/cjs/src-public/bcOrder.js +6 -2
- package/dist/cjs/src-public/centra.js +5 -56
- package/dist/cjs/src-public/env.js +1 -1
- package/dist/cjs/src-public/index.js +1 -3
- package/dist/cjs/src-public/pubsub.js +10 -36
- package/dist/cjs/src-public/runtime.js +9 -48
- package/dist/cjs/src-public/utils.js +0 -3
- package/dist/package.json +2 -3
- package/dist/types/contracts/index.d.ts +0 -2
- package/dist/types/dist-dereferenced/index.d.ts +0 -2
- package/dist/types/dist-dereferenced/messages/product-draft.d.ts +1 -148
- package/dist/types/dist-dereferenced/product-draft.d.ts +1 -148
- package/dist/types/dist-types/index.d.ts +0 -2
- package/dist/types/dist-types/messages/product-draft.d.ts +4 -23
- package/dist/types/dist-types/product-draft.d.ts +4 -23
- package/dist/types/src-public/airtable.d.ts +9 -0
- package/dist/types/src-public/centra.d.ts +0 -3
- package/dist/types/src-public/env.d.ts +1 -1
- package/dist/types/src-public/index.d.ts +0 -1
- package/dist/types/src-public/pubsub.d.ts +1 -4
- package/dist/types/src-public/runtime.d.ts +4 -17
- package/dist/types/src-public/types.d.ts +0 -6
- package/dist/types/src-public/utils.d.ts +1 -1
- package/package.json +3 -4
- package/dist/cjs/contracts/purchase-orderline.schema.json +0 -135
- package/dist/cjs/contracts/stock-movement.schema.json +0 -144
- package/dist/cjs/dist-dereferenced/purchase-orderline.js +0 -4
- package/dist/cjs/dist-dereferenced/stock-movement.js +0 -4
- package/dist/cjs/dist-types/purchase-orderline.js +0 -2
- package/dist/cjs/dist-types/stock-movement.js +0 -2
- package/dist/cjs/src-public/sitoo.js +0 -349
- package/dist/types/dist-dereferenced/purchase-orderline.d.ts +0 -114
- package/dist/types/dist-dereferenced/stock-movement.d.ts +0 -110
- package/dist/types/dist-types/purchase-orderline.d.ts +0 -31
- package/dist/types/dist-types/stock-movement.d.ts +0 -30
- package/dist/types/src-public/sitoo.d.ts +0 -254
|
@@ -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": "ProductDraft", "type": "object", "additionalProperties": false, "properties": { "development_colourway_id": { "type": "string", "pattern": "^[A-Z]{2}\\d{2}[A-Z]+?-\\d{6}-\\d{4}$" }, "development_style_id": { "type": "string", "pattern": "^[A-Z]{2}\\d{2}[A-Z]+?-\\d{6}$" }, "centric_id": { "type": ["string"] }, "style_centric_id": { "type": ["string"] }, "product_id": { "type": ["string"] }, "created_at": { "type": "string", "format": "date-time" }, "erp_settings": { "type": ["string", "null"] }, "erp_created_at": { "type": ["string", "null"], "format": "date-time" }, "erp_export_settings": { "type": "array", "items": { "type": "string", "enum": ["Exportable to Website", "Exportable to Next", "Available to sell"] } }, "is_colourway_approved": { "type": "boolean" }, "product_name": { "type": ["string", "null"] }, "erp_name": { "type": ["string", "null"] }, "colour_id": { "type": "string" }, "colour_label": { "type": ["string", "null"] }, "style_id": { "type": ["string"] }, "season_id": { "type": "string" }, "size_curves": { "type": "array", "items": { "type": "object", "properties": { "channel": { "type": "string" }, "name": { "type": "string" } } } }, "plm_buying_quantities": { "type": "array", "items": { "type": "object", "properties": { "channel": { "type": "string" }, "round": { "type": "number", "minimum": 0 } }, "is_approved": { "type": "boolean" }, "quantity": { "type": "number" } } }, "store_grade": { "type": ["string", "null"] }, "drops": { "type": "array", "items": { "type": "object", "properties": { "channel": { "type": "string" }, "drop_name": { "type": "string" } } } }, "direct_stock_buffer": { "type": ["number", "null"] }, "qa_completed": { "type": ["boolean", "null"] }, "warehouse_instructions": { "type": ["string", "null"] }, "available_to_sell_from": { "type": ["string", "null"], "format": "date-time" }, "processing_time_warehouse": { "type": ["number", "null"] }, "stock_type": { "type": ["string", "null"] }, "block": { "type": ["string", "null"] }, "packing_method": { "type": ["string", "null"] }, "packaging_code": { "type": ["string", "null"] }, "is_bought_in_product": { "type": ["boolean", "null"] }, "reprocess_method": { "type": ["string", "null"] }, "is_carry_over": { "type": ["boolean", "null"] }, "image_url": { "type": ["string", "null"], "format": "uri" }, "attributes": { "type": "object", "additionalProperties": false, "properties": { "product_type": { "type": ["string", "null"] }, "product_category": { "type": ["string", "null"] }, "product_subcategory": { "type": ["string", "null"] }, "division": { "type": ["string", "null"] }, "care_instructions": { "type": "array", "items": { "type": "string" } }, "embelishment": { "type": ["string", "null"] }, "lining": { "type": ["string", "null"] }, "rise": { "type": ["string", "null"] }, "sleeve": { "type": ["string", "null"] }, "shape": { "type": ["string", "null"] }, "straps": { "type": ["string", "null"] }, "designer": { "type": ["string", "null"] }, "sustainability_callout": { "type": ["string", "null"] }, "certificate": { "anyOf": [{ "type": "object", "additionalProperties": false, "properties": { "type": { "type": ["string"] }, "file": { "type": ["string"] } } }, { "type": "null" }] }, "bias_cut": { "anyOf": [{ "type": "object", "additionalProperties": false, "properties": { "type": { "type": ["string"] }, "statement": { "type": ["string"] } } }, { "type": "null" }] }, "design": { "anyOf": [{ "type": "object", "additionalProperties": false, "properties": { "type": { "type": ["string"] }, "statement": { "type": ["string"] } } }, { "type": "null" }] }, "fabric": { "anyOf": [{ "type": "object", "additionalProperties": false, "properties": { "type": { "type": ["string"] }, "statement": { "type": ["string"] } } }, { "type": "null" }] }, "fit": { "anyOf": [{ "type": "object", "additionalProperties": false, "properties": { "type": { "type": ["string"] }, "statement": { "type": ["string"] } } }, { "type": "null" }] }, "pockets": { "type": ["string", "null"] }, "pleatsGathers": { "type": ["string", "null"] }, "lining_statement": { "type": ["string", "null"] }, "range": { "type": ["string", "null"] }, "main_fibre": { "type": ["string", "null"] }, "main_fibre_composition": { "type": ["string", "null"] }, "size_range": { "type": ["string", "null"] }, "sizes": { "type": ["string", "null"] }, "occasion": { "type": ["string", "null"] }, "strategy_type": { "type": ["string", "null"] }, "pattern_name": { "type": ["string", "null"] }, "neckline": { "type": ["string", "null"] }, "sleeve_length": { "type": ["string", "null"] }, "leg_length": { "type": ["string", "null"] }, "heel_height": { "type": ["string", "null"] }, "heel_shape": { "type": ["string", "null"] }, "toe_shape": { "type": ["string", "null"] }, "handle_straps": { "type": ["string", "null"] }, "fastening": { "anyOf": [{ "type": ["array", "null"], "items": { "type": "string" } }, { "type": "null" }] }, "sole_code": { "type": ["string", "null"] }, "fashionability": { "type": ["string", "null"] }, "fashion_type": { "type": ["string", "null"] }, "development_type": { "type": ["string", "null"] }, "weight_statement": { "type": ["string", "null"] }, "weight": { "type": ["number", "null"], "minimum": 0 }, "extra_selling_points": { "type": "array", "items": { "type": "string" } }, "length_measurement": { "type": ["string", "null"] }, "fabric_composition": { "type": ["string", "null"] } } }, "preorder_options": { "type": ["string", "null"], "enum": ["Never", "Default", "Weeks", null] }, "preorder_num_period": { "type": ["string", "null"] }, "vat_posting_group_code": { "type": ["string", "null"] }, "retail_price": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "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"] }, { "type": "null" }] }, "cost": { "type": "object", "additionalProperties": false, "properties": { "current_cost": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "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"] }, { "type": "null" }] }, "finishing_cost": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "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"] }, { "type": "null" }] }, "other_costs": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "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"] }, { "type": "null" }] }, "commission_rate": { "type": ["number", "null"] }, "freight_rate": { "type": ["number", "null"] }, "duty_rate": { "type": ["number", "null"] }, "unit_cost": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "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"] }, { "type": "null" }] }, "last_direct_cost": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "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"] }, { "type": "null" }] } } }, "duty": { "material": { "type": ["string", "null"] }, "category": { "type": ["string", "null"] }, "commodity_code": { "type": ["string", "null"] }, "tariff_no": { "type": ["string", "null"] } }, "payment_terms": { "type": "object", "additionalProperties": false, "properties": { "supplier_payment_terms": { "type": ["string", "null"] }, "supplier_inco_terms": { "type": ["string", "null"] } } }, "supplier_data": { "type": "object", "additionalProperties": false, "properties": { "country_of_origin": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Country", "type": "string", "enum": ["AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "CV", "KH", "CM", "CA", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CD", "CG", "CK", "CR", "CI", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "SZ", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MK", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN", "LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SX", "SK", "SI", "SB", "SO", "ZA", "GS", "SS", "ES", "LK", "SD", "SR", "SJ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "UM", "US", "UY", "UZ", "VU", "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW"] }, { "type": "null" }] }, "port_of_origin": { "type": ["string", "null"] }, "moq": { "type": ["number", "null"], "minimum": 0 }, "supplier_id": { "type": ["string", "null"] }, "erp_supplier_id": { "type": ["string", "null"] }, "supplier_name": { "type": ["string", "null"] }, "factory_id": { "type": ["string", "null"] } } } }, "required": ["product_id", "colour_id", "style_id"], "$id": "https://shushed.example.com/product-draft.schema.json" };
|
|
3
|
+
const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "ProductDraft", "type": "object", "additionalProperties": false, "properties": { "development_colourway_id": { "type": "string", "pattern": "^[A-Z]{2}\\d{2}[A-Z]+?-\\d{6}-\\d{4}$" }, "development_style_id": { "type": "string", "pattern": "^[A-Z]{2}\\d{2}[A-Z]+?-\\d{6}$" }, "product_id": { "type": ["string"] }, "created_at": { "type": "string", "format": "date-time" }, "is_colourway_approved": { "type": "boolean" }, "product_name": { "type": ["string", "null"] }, "colour_id": { "type": "string" }, "colour_label": { "type": ["string", "null"] }, "style_id": { "type": ["string"] }, "season_id": { "type": "string" }, "size_curves": { "type": "array", "items": { "type": "object", "properties": { "channel": { "type": "string" }, "name": { "type": "string" } } } }, "plm_buying_quantities": { "type": "array", "items": { "type": "object", "properties": { "channel": { "type": "string" }, "round": { "type": "number", "minimum": 0 } }, "is_approved": { "type": "boolean" }, "quantity": { "type": "number" } } }, "drops": { "type": "array", "items": { "type": "object", "properties": { "channel": { "type": "string" }, "drop_name": { "type": "string" } } } }, "stock_type": { "type": ["string", "null"] }, "block": { "type": ["string", "null"] }, "packing_method": { "type": ["string", "null"] }, "is_bought_in_product": { "type": ["boolean", "null"] }, "reprocess_method": { "type": ["string", "null"] }, "is_carry_over": { "type": ["boolean", "null"] }, "image_url": { "type": ["string", "null"], "format": "uri" }, "attributes": { "type": "object", "additionalProperties": false, "properties": { "product_type": { "type": ["string", "null"] }, "product_category": { "type": ["string", "null"] }, "product_subcategory": { "type": ["string", "null"] }, "division": { "type": ["string", "null"] }, "care_instructions": { "type": "array", "items": { "type": "string" } }, "embelishment": { "type": ["string", "null"] }, "lining": { "type": ["string", "null"] }, "rise": { "type": ["string", "null"] }, "sleeve": { "type": ["string", "null"] }, "shape": { "type": ["string", "null"] }, "straps": { "type": ["string", "null"] }, "designer": { "type": ["string", "null"] }, "sustainability_callout": { "type": ["string", "null"] }, "certificate": { "anyOf": [{ "type": "object", "additionalProperties": false, "properties": { "type": { "type": ["string"] }, "file": { "type": ["string"] } } }, { "type": "null" }] }, "bias_cut": { "anyOf": [{ "type": "object", "additionalProperties": false, "properties": { "type": { "type": ["string"] }, "statement": { "type": ["string"] } } }, { "type": "null" }] }, "design": { "anyOf": [{ "type": "object", "additionalProperties": false, "properties": { "type": { "type": ["string"] }, "statement": { "type": ["string"] } } }, { "type": "null" }] }, "fabric": { "anyOf": [{ "type": "object", "additionalProperties": false, "properties": { "type": { "type": ["string"] }, "statement": { "type": ["string"] } } }, { "type": "null" }] }, "fit": { "anyOf": [{ "type": "object", "additionalProperties": false, "properties": { "type": { "type": ["string"] }, "statement": { "type": ["string"] } } }, { "type": "null" }] }, "pockets": { "type": ["string", "null"] }, "pleatsGathers": { "type": ["string", "null"] }, "lining_statement": { "type": ["string", "null"] }, "range": { "type": ["string", "null"] }, "main_fibre": { "type": ["string", "null"] }, "main_fibre_composition": { "type": ["string", "null"] }, "size_range": { "type": ["string", "null"] }, "sizes": { "type": ["string", "null"] }, "occasion": { "type": ["string", "null"] }, "strategy_type": { "type": ["string", "null"] }, "pattern_name": { "type": ["string", "null"] }, "neckline": { "type": ["string", "null"] }, "sleeve_length": { "type": ["string", "null"] }, "leg_length": { "type": ["string", "null"] }, "heel_height": { "type": ["string", "null"] }, "heel_shape": { "type": ["string", "null"] }, "toe_shape": { "type": ["string", "null"] }, "handle_straps": { "type": ["string", "null"] }, "fastening": { "anyOf": [{ "type": ["array", "null"], "items": { "type": "string" } }, { "type": "null" }] }, "sole_code": { "type": ["string", "null"] }, "fashionability": { "type": ["string", "null"] }, "fashion_type": { "type": ["string", "null"] }, "development_type": { "type": ["string", "null"] }, "weight_statement": { "type": ["string", "null"] }, "weight": { "type": ["number", "null"], "minimum": 0 }, "extra_selling_points": { "type": "array", "items": { "type": "string" } }, "length_measurement": { "type": ["string", "null"] }, "fabric_composition": { "type": ["string", "null"] } } }, "retail_price": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "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"] }, { "type": "null" }] }, "cost": { "type": "object", "additionalProperties": false, "properties": { "current_cost": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "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"] }, { "type": "null" }] }, "finishing_cost": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "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"] }, { "type": "null" }] }, "other_costs": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "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"] }, { "type": "null" }] }, "commission_rate": { "type": ["number", "null"] }, "freight_rate": { "type": ["number", "null"] }, "duty_rate": { "type": ["number", "null"] } } }, "duty": { "material": { "type": ["string", "null"] }, "category": { "type": ["string", "null"] }, "commodity_code": { "type": ["string", "null"] } }, "payment_terms": { "type": "object", "additionalProperties": false, "properties": { "supplier_payment_terms": { "type": ["string", "null"] }, "supplier_inco_terms": { "type": ["string", "null"] } } }, "supplier_data": { "type": "object", "additionalProperties": false, "properties": { "country_of_origin": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Country", "type": "string", "enum": ["AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "CV", "KH", "CM", "CA", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CD", "CG", "CK", "CR", "CI", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "SZ", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MK", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN", "LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SX", "SK", "SI", "SB", "SO", "ZA", "GS", "SS", "ES", "LK", "SD", "SR", "SJ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "UM", "US", "UY", "UZ", "VU", "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW"] }, { "type": "null" }] }, "port_of_origin": { "type": ["string", "null"] }, "moq": { "type": ["number", "null"], "minimum": 0 }, "supplier_id": { "type": ["string", "null"] }, "supplier_name": { "type": ["string", "null"] }, "factory_id": { "type": ["string", "null"] } } } }, "required": ["development_colourway_id", "development_style_id", "product_id", "colour_id", "style_id", "created_at", "season_id"], "$id": "https://shushed.example.com/product-draft.schema.json" };
|
|
4
4
|
exports.default = schema;
|
|
@@ -42,107 +42,71 @@ class AirtableHelper extends runtime_1.default {
|
|
|
42
42
|
}
|
|
43
43
|
return existingRecord;
|
|
44
44
|
}
|
|
45
|
-
async updateMultiple(payload, options = {}
|
|
45
|
+
async updateMultiple(payload, options = {}, callIdx = 0, collectedResult = {
|
|
46
|
+
updatedRecords: [],
|
|
47
|
+
createdRecords: [],
|
|
48
|
+
records: []
|
|
49
|
+
}) {
|
|
46
50
|
let response = null;
|
|
47
51
|
const tableUrl = `https://api.airtable.com/v0/${this.baseId}/${this.tableId}`;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
while (callIdx < maxCallIdx) {
|
|
60
|
-
const currentBatch = payloadDeduplicated.slice(callIdx * batchSize, (callIdx + 1) * batchSize);
|
|
61
|
-
const recordsInBatch = currentBatch.map(x => {
|
|
62
|
-
const recordId = x.$recordId;
|
|
63
|
-
const fieldsWithoutRecordId = { ...x };
|
|
64
|
-
delete fieldsWithoutRecordId.$recordId;
|
|
65
|
-
const record = {
|
|
66
|
-
fields: AirtableHelper.convertToDictionary(this.dictionary, this.primaryKeyWritable === false
|
|
67
|
-
? AirtableHelper.removePrimaryKey(fieldsWithoutRecordId, this.primaryKeyFieldName)
|
|
68
|
-
: fieldsWithoutRecordId),
|
|
69
|
-
};
|
|
70
|
-
if (recordId) {
|
|
71
|
-
record.id = recordId;
|
|
72
|
-
}
|
|
73
|
-
return record;
|
|
74
|
-
});
|
|
75
|
-
try {
|
|
76
|
-
response = await fetch(`${tableUrl}`, {
|
|
77
|
-
method: "PATCH",
|
|
78
|
-
headers: {
|
|
79
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
80
|
-
"Content-Type": "application/json",
|
|
52
|
+
const currentBatch = payload.slice(callIdx * 10, (callIdx + 1) * 10);
|
|
53
|
+
try {
|
|
54
|
+
response = await fetch(`${tableUrl}`, {
|
|
55
|
+
method: "PATCH",
|
|
56
|
+
headers: {
|
|
57
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
},
|
|
60
|
+
body: JSON.stringify({
|
|
61
|
+
performUpsert: {
|
|
62
|
+
fieldsToMergeOn: (options.fieldsToMergeOn ?? [this.primaryKeyFieldName]).map(x => this.dictionary[x] || x),
|
|
81
63
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const errorMessage = `Failed to update records in ${this.tableId} table (baseId: ${this.baseId}). Status: ${response?.status || 'unknown'}. Error: ${err.message}`;
|
|
104
|
-
const batchErrors = currentBatch.map(() => new Error(errorMessage));
|
|
105
|
-
collectedResult = {
|
|
106
|
-
updatedRecords: collectedResult.updatedRecords,
|
|
107
|
-
createdRecords: collectedResult.createdRecords,
|
|
108
|
-
records: collectedResult.records.concat(batchErrors)
|
|
109
|
-
};
|
|
64
|
+
returnFieldsByFieldId: true,
|
|
65
|
+
typecast: options.typecast || false,
|
|
66
|
+
records: currentBatch.map(x => {
|
|
67
|
+
const recordId = x.$recordId;
|
|
68
|
+
const fieldsWithoutRecordId = { ...x };
|
|
69
|
+
delete fieldsWithoutRecordId.$recordId;
|
|
70
|
+
const record = {
|
|
71
|
+
fields: AirtableHelper.convertToDictionary(this.dictionary, this.primaryKeyWritable === false
|
|
72
|
+
? AirtableHelper.removePrimaryKey(fieldsWithoutRecordId, this.primaryKeyFieldName)
|
|
73
|
+
: fieldsWithoutRecordId),
|
|
74
|
+
};
|
|
75
|
+
if (recordId) {
|
|
76
|
+
record.id = recordId;
|
|
77
|
+
}
|
|
78
|
+
return record;
|
|
79
|
+
})
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
if (!response.ok && response) {
|
|
83
|
+
const text = await response.text().catch(() => `${response?.status || 'unknown'}`);
|
|
84
|
+
throw new Error(text);
|
|
110
85
|
}
|
|
111
|
-
|
|
112
|
-
|
|
86
|
+
const resp = (await response.json());
|
|
87
|
+
const nextCollectedResult = {
|
|
88
|
+
updatedRecords: collectedResult.updatedRecords.concat(resp.updatedRecords),
|
|
89
|
+
createdRecords: collectedResult.createdRecords.concat(resp.createdRecords),
|
|
90
|
+
records: collectedResult.records.concat(resp.records.map(x => AirtableHelper.translateFields(this.dictionary, x)))
|
|
91
|
+
};
|
|
92
|
+
if (payload.length > (callIdx + 1) * 10) {
|
|
93
|
+
return this.updateMultiple(payload, options, callIdx + 1, nextCollectedResult);
|
|
113
94
|
}
|
|
95
|
+
return nextCollectedResult;
|
|
114
96
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
isMatching = false;
|
|
126
|
-
}
|
|
127
|
-
k += 1;
|
|
128
|
-
}
|
|
129
|
-
if (isMatching) {
|
|
130
|
-
foundMatchingRecord = j;
|
|
131
|
-
}
|
|
132
|
-
j += 1;
|
|
133
|
-
}
|
|
134
|
-
if (foundMatchingRecord !== null) {
|
|
135
|
-
resultInOrder.push(collectedResult.records[foundMatchingRecord]);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
resultInOrder.push(new Error(`Record ${payload[i][this.primaryKeyFieldName]} does not match any record in the response`));
|
|
97
|
+
catch (err) {
|
|
98
|
+
const errorMessage = `Failed to update records in ${this.tableId} table (baseId: ${this.baseId}). Status: ${response?.status || 'unknown'}. Error: ${err.message}`;
|
|
99
|
+
const batchErrors = currentBatch.map(() => new Error(errorMessage));
|
|
100
|
+
const nextCollectedResult = {
|
|
101
|
+
updatedRecords: collectedResult.updatedRecords,
|
|
102
|
+
createdRecords: collectedResult.createdRecords,
|
|
103
|
+
records: collectedResult.records.concat(batchErrors)
|
|
104
|
+
};
|
|
105
|
+
if (payload.length > (callIdx + 1) * 10) {
|
|
106
|
+
return this.updateMultiple(payload, options, callIdx + 1, nextCollectedResult);
|
|
139
107
|
}
|
|
108
|
+
return nextCollectedResult;
|
|
140
109
|
}
|
|
141
|
-
return {
|
|
142
|
-
updatedRecords: collectedResult.updatedRecords,
|
|
143
|
-
createdRecords: collectedResult.createdRecords,
|
|
144
|
-
records: resultInOrder
|
|
145
|
-
};
|
|
146
110
|
}
|
|
147
111
|
async upsert(payload) {
|
|
148
112
|
const existingRecord = await this.getExistingRecord(payload);
|
|
@@ -294,10 +258,9 @@ class AirtableHelper extends runtime_1.default {
|
|
|
294
258
|
const escapeFormulaValue = (value) => {
|
|
295
259
|
return value.replace(/"/g, '\\"');
|
|
296
260
|
};
|
|
297
|
-
const dedupedKeys = keys.filter((x, idx, self) => self.indexOf(x) === idx);
|
|
298
261
|
const batchSize = 50;
|
|
299
|
-
for (let i = 0; i <
|
|
300
|
-
const batch =
|
|
262
|
+
for (let i = 0; i < keys.length; i += batchSize) {
|
|
263
|
+
const batch = keys.slice(i, i + batchSize);
|
|
301
264
|
const orConditions = batch.map(key => `${this.dictionary[this.primaryKeyFieldName]} = "${escapeFormulaValue(key)}"`).join(', ');
|
|
302
265
|
const formula = `OR(${orConditions})`;
|
|
303
266
|
const records = await this.getExistingRecords(formula);
|
|
@@ -630,7 +630,11 @@ function transformMasterOrder(payload) {
|
|
|
630
630
|
const shipments = (mappedShipments.length || returnShipments.length)
|
|
631
631
|
? [...mappedShipments, ...returnShipments]
|
|
632
632
|
: [];
|
|
633
|
-
const shipping_method = (payload.shipments?.[0]?.
|
|
633
|
+
const shipping_method = (payload.shipments?.[0]?.shipping_agent_service_code) ||
|
|
634
|
+
(payload.shipments?.[0]?.shipping_agent_code) ||
|
|
635
|
+
(sale0?.shipping_agent_service_code) ||
|
|
636
|
+
(sale0?.shipping_agent_code) ||
|
|
637
|
+
null;
|
|
634
638
|
const merchReturnGrossFromCreditMemos = (payload.credit_memos || []).reduce((acc, cm) => {
|
|
635
639
|
const lines = cm?.credit_memo_lines || [];
|
|
636
640
|
let hasQualifying = false;
|
|
@@ -853,7 +857,7 @@ function transformMasterOrder(payload) {
|
|
|
853
857
|
};
|
|
854
858
|
const cardPays = (payload.card_payments || []).map((c) => ({
|
|
855
859
|
created_at: c.created_at,
|
|
856
|
-
amount: c.
|
|
860
|
+
amount: c.amount,
|
|
857
861
|
type: c.type || 'Payment',
|
|
858
862
|
payment_method_code: String(c.service_type || ''),
|
|
859
863
|
transaction_id: c.transaction_id,
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const crypto_1 = __importDefault(require("crypto"));
|
|
7
7
|
const env_1 = __importDefault(require("./env"));
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
|
-
const CACHE_EXPIRATION_MS = 1000 * 60 *
|
|
9
|
+
const CACHE_EXPIRATION_MS = 1000 * 60 * 60 * 3;
|
|
10
10
|
class CentraHelper extends env_1.default {
|
|
11
11
|
opts;
|
|
12
12
|
shaToken;
|
|
@@ -99,12 +99,6 @@ class CentraHelper extends env_1.default {
|
|
|
99
99
|
getCacheKeyForMarket(marketExternalId) {
|
|
100
100
|
return `${this.getCacheKeyForMarkets()}_${marketExternalId}`;
|
|
101
101
|
}
|
|
102
|
-
getCacheKeyForCampaigns() {
|
|
103
|
-
return `centra_${this.shaToken}_campaign_name`;
|
|
104
|
-
}
|
|
105
|
-
getCacheKeyForCampaign(campaignName) {
|
|
106
|
-
return `${this.getCacheKeyForCampaigns()}_${campaignName}`;
|
|
107
|
-
}
|
|
108
102
|
getCacheKeyForSizeCharts() {
|
|
109
103
|
return `centra_${this.shaToken}_size_chart_external_id`;
|
|
110
104
|
}
|
|
@@ -136,7 +130,7 @@ class CentraHelper extends env_1.default {
|
|
|
136
130
|
return `${this.getCacheKeyForCentraWarehouses()}_${warehouseExternalId}`;
|
|
137
131
|
}
|
|
138
132
|
getCacheKeyForCentraPricelists() {
|
|
139
|
-
return `centra_${this.shaToken}
|
|
133
|
+
return `centra_${this.shaToken}_pricelist_external_id`;
|
|
140
134
|
}
|
|
141
135
|
getCacheKeyForCentraPricelist(pricelistExternalId) {
|
|
142
136
|
return `${this.getCacheKeyForCentraPricelists()}_${pricelistExternalId}`;
|
|
@@ -224,7 +218,7 @@ class CentraHelper extends env_1.default {
|
|
|
224
218
|
return result;
|
|
225
219
|
}
|
|
226
220
|
async fetchCentraCampaigns(names) {
|
|
227
|
-
const limit =
|
|
221
|
+
const limit = (names?.length || 0) > 200 ? 200 : (names?.length || 0);
|
|
228
222
|
let nextCursor = null;
|
|
229
223
|
const result = {};
|
|
230
224
|
do {
|
|
@@ -276,7 +270,7 @@ class CentraHelper extends env_1.default {
|
|
|
276
270
|
nextCursor = null;
|
|
277
271
|
}
|
|
278
272
|
if (campaignConnection && campaignConnection.edges?.length) {
|
|
279
|
-
for (let i =
|
|
273
|
+
for (let i = campaignConnection.edges.length; i < (names?.length || 0); i++) {
|
|
280
274
|
const { node } = campaignConnection.edges[i];
|
|
281
275
|
result[node.name] = node;
|
|
282
276
|
}
|
|
@@ -727,9 +721,7 @@ class CentraHelper extends env_1.default {
|
|
|
727
721
|
}
|
|
728
722
|
else {
|
|
729
723
|
for (const warehouse of warehouses) {
|
|
730
|
-
|
|
731
|
-
warehouseToSet[warehouse.externalId] = warehouse;
|
|
732
|
-
}
|
|
724
|
+
warehouseToSet[warehouse.externalId] = warehouse;
|
|
733
725
|
}
|
|
734
726
|
await this.set(Object.entries(warehouseToSet).filter(([_, value]) => !(value instanceof Error)).map(([key, value]) => ({ name: this.getCacheKeyForCentraWarehouse(key), value: JSON.stringify(value) })), 'env', {
|
|
735
727
|
ephemeralMs: CACHE_EXPIRATION_MS,
|
|
@@ -805,49 +797,6 @@ class CentraHelper extends env_1.default {
|
|
|
805
797
|
}
|
|
806
798
|
return Object.assign({}, pricelistInCache, pricelistToSet);
|
|
807
799
|
}
|
|
808
|
-
async getCentraCampaigns(alwaysFetch = false) {
|
|
809
|
-
let campaignInCache = {};
|
|
810
|
-
let dedupedCampaignNamesInCache = [];
|
|
811
|
-
let campaignsToFetch = null;
|
|
812
|
-
if (!alwaysFetch) {
|
|
813
|
-
const campaignNamesInCache = await (this.get(this.getCacheKeyForCampaigns(), 'env', {
|
|
814
|
-
isEphemeral: true,
|
|
815
|
-
encrypted: false,
|
|
816
|
-
}).then(x => x ? JSON.parse(x) : null));
|
|
817
|
-
if (campaignNamesInCache) {
|
|
818
|
-
dedupedCampaignNamesInCache = campaignNamesInCache.filter((x, index, self) => self.indexOf(x) === index);
|
|
819
|
-
campaignInCache = Object.fromEntries(Object.entries(await this.get(dedupedCampaignNamesInCache.map((x) => this.getCacheKeyForCampaign(x)), 'env', {
|
|
820
|
-
isEphemeral: true,
|
|
821
|
-
encrypted: false,
|
|
822
|
-
})).map(([key, value]) => [key, value ? JSON.parse(value || 'null') : undefined]).filter(([_, value]) => value));
|
|
823
|
-
campaignsToFetch = dedupedCampaignNamesInCache.filter(x => !campaignInCache[x]);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
const campaignToSet = {};
|
|
827
|
-
if (!campaignsToFetch || campaignsToFetch.length) {
|
|
828
|
-
const campaigns = await this.fetchCentraCampaigns();
|
|
829
|
-
if (CentraHelper.isCentraErrors(campaigns)) {
|
|
830
|
-
return new Error(`Failed to fetch campaigns: ${campaigns.errors.map((x) => x.message).join(', ')}`);
|
|
831
|
-
}
|
|
832
|
-
else {
|
|
833
|
-
for (const campaign of Object.values(campaigns)) {
|
|
834
|
-
campaignToSet[campaign.name] = campaign;
|
|
835
|
-
}
|
|
836
|
-
await this.set(Object.entries(campaignToSet).filter(([_, value]) => !(value instanceof Error)).map(([key, value]) => ({ name: this.getCacheKeyForCampaign(key), value: JSON.stringify(value) })), 'env', {
|
|
837
|
-
ephemeralMs: CACHE_EXPIRATION_MS,
|
|
838
|
-
encrypted: false,
|
|
839
|
-
});
|
|
840
|
-
await this.set([{
|
|
841
|
-
name: this.getCacheKeyForCampaigns(),
|
|
842
|
-
value: JSON.stringify(Object.keys(campaignToSet)),
|
|
843
|
-
}], 'env', {
|
|
844
|
-
ephemeralMs: CACHE_EXPIRATION_MS,
|
|
845
|
-
encrypted: false,
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
return Object.assign({}, campaignInCache, campaignToSet);
|
|
850
|
-
}
|
|
851
800
|
async getCentraMarkets(alwaysFetch = false) {
|
|
852
801
|
let marketInCache = {};
|
|
853
802
|
let dedupedMarketNamesInCache = [];
|
|
@@ -567,7 +567,7 @@ class EnvEngine extends runtime_1.default {
|
|
|
567
567
|
batchSize: 1,
|
|
568
568
|
subscriptionFilter: null,
|
|
569
569
|
batchWindowSeconds: 10,
|
|
570
|
-
}, Object.fromEntries(Object.entries(rnPartialConfig).filter(
|
|
570
|
+
}, Object.fromEntries(Object.entries(rnPartialConfig).filter(x => !(x === null || x === undefined))));
|
|
571
571
|
return rnConfig;
|
|
572
572
|
}
|
|
573
573
|
createOrUpdateRespectfulNudge(subscriptionName, rnPartialConfig) {
|
|
@@ -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.
|
|
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;
|
|
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,5 +52,3 @@ 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
|
-
var sitoo_1 = require("./sitoo");
|
|
56
|
-
Object.defineProperty(exports, "SitooHelper", { enumerable: true, get: function () { return __importDefault(sitoo_1).default; } });
|