diff --git a/utilities/logistics-b2b/log-verification-utility/.gitignore b/utilities/logistics-b2b/log-verification-utility/.gitignore index 5b4e0ec..3a79b99 100644 --- a/utilities/logistics-b2b/log-verification-utility/.gitignore +++ b/utilities/logistics-b2b/log-verification-utility/.gitignore @@ -3,6 +3,7 @@ package-lock.json *.env .vscode /public/logs/* +/public/server/* verification-logs /utils/*.json /utils/*.txt @@ -12,4 +13,4 @@ test.js !LICENSE.md logFlow*.json .DS_Store -log_report.json \ No newline at end of file +log_report.md \ No newline at end of file diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/keywords/onInit.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/keywords/onInit.js index d9a2b1d..b31f2e2 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/keywords/onInit.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/keywords/onInit.js @@ -1,11 +1,14 @@ module.exports = { isQuoteMatching: (data) => { - const quotePrice = parseFloat(data?.price?.value); + let quotePrice = parseFloat(data?.price?.value); const breakupArr = data.breakup; let totalBreakup = 0; breakupArr.forEach((breakup) => { totalBreakup += parseFloat(breakup?.price?.value); + }); + totalBreakup= parseFloat(totalBreakup).toFixed(2) + quotePrice=quotePrice.toFixed(2) if (quotePrice != totalBreakup) return false; else return true; }, diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/schemaValidator.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/schemaValidator.js index 43fb234..66aa4f1 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/schemaValidator.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/schemaValidator.js @@ -1,16 +1,4 @@ -const onConfirmSchema = require("./on_confirm"); -const onInitSchema = require("./on_init"); -const onSearchSchema = require("./on_search"); -const selectSchema = require("./select"); -const onSelectSchema = require("./on_select"); -const onUpdateSchema = require("./on_update"); -const searchSchema = require("./search"); -const initSchema = require("./init"); -const masterSchema = require("./master"); -const confirmSchema = require("./confirm"); -const statusSchema = require("./status"); -const updateSchema = require("./update"); -const onStatusSchema = require("./on_status"); + const { isLengthValid } = require("./keywords/init"); const { isQuoteMatching } = require("./keywords/onInit"); const { isFutureDated } = require("./keywords/confirm"); @@ -42,7 +30,33 @@ const formatted_error = (errors) => { return error_json; }; -const validate_schema = (data, schema) => { +const loadSchema = (schemaType, version) => { + try { + return require(`./${version}/${schemaType}.js`); + } catch (error) { + console.log("Error Occurred while importing", error); + } +}; + +const validate_schema = (data, schema,version) => { + const searchSchema = loadSchema("search", version); + const onSearchSchema = loadSchema("on_search", version); + + const selectSchema = loadSchema("select", version); + const onSelectSchema = loadSchema("on_select", version); + + const initSchema = loadSchema("init", version); + const onInitSchema = loadSchema("on_init", version); + + const confirmSchema = loadSchema("confirm", version); + const onConfirmSchema = loadSchema("on_confirm", version); + + const updateSchema = loadSchema("update", version); + const onUpdateSchema = loadSchema("on_update", version); + + const statusSchema = loadSchema("status", version); + const onStatusSchema = loadSchema("on_status", version); + const Ajv = require("ajv"); const ajv = new Ajv({ allErrors: true, @@ -96,8 +110,9 @@ const validate_schema = (data, schema) => { return error_list; }; -const validate_schema_b2b_master = (data) => { - error_list = validate_schema(data, masterSchema); +const validate_schema_b2b_master = (data,version) => { + const masterSchema = loadSchema("master", version); + error_list = validate_schema(data, masterSchema,version); return formatted_error(error_list); }; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/confirm.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/confirm.js similarity index 100% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/confirm.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/confirm.js diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/init.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/init.js similarity index 100% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/init.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/init.js diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/master.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/master.js similarity index 100% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/master.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/master.js diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_confirm.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_confirm.js similarity index 99% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_confirm.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_confirm.js index 201216f..d6fef76 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_confirm.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_confirm.js @@ -628,8 +628,6 @@ module.exports = { }, }, isQuoteMatching: true, - errorMessage: - "price is not matching with the total breakup price", required: ["price", "breakup", "ttl"], }, payments: { diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_init.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_init.js similarity index 99% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_init.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_init.js index 5de61bb..c145f38 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_init.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_init.js @@ -549,8 +549,7 @@ module.exports = { }, }, isQuoteMatching: true, - errorMessage: - "price is not matching with the total breakup price", + required: ["price", "breakup", "ttl"], }, payments: { diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_search.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_search.js similarity index 100% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_search.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_search.js diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_select.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_select.js similarity index 98% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_select.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_select.js index 3a97ae2..f2fe7b0 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_select.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_select.js @@ -220,7 +220,7 @@ module.exports = { }, "@ondc/org/title_type": { type: "string", - enum: ["item", "discount", "Packing charges", "delivery ", "tax", "misc"] + enum: ["item", "discount", "packing", "delivery ", "tax", "misc"] }, price: { type: "object", @@ -321,8 +321,7 @@ module.exports = { }, }, isQuoteMatching: true, - errorMessage: - "price is not matching with the total breakup price", + required: ["price", "breakup", "ttl"], }, }, diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_status.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_status.js similarity index 99% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_status.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_status.js index c687d03..4d202a2 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_status.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_status.js @@ -568,8 +568,7 @@ module.exports = { }, }, isQuoteMatching: true, - errorMessage: - "price is not matching with the total breakup price", + required: ["price", "breakup", "ttl"], }, payments: { diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_update.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_update.js similarity index 99% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_update.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_update.js index d87b56d..8abb301 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/on_update.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/on_update.js @@ -7,7 +7,6 @@ module.exports = { properties: { domain: { type: "string", - const: "ONDC:RET10", }, location: { type: "object", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/search.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/search.js similarity index 99% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/search.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/search.js index 9c8f6af..5c45d70 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/search.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/search.js @@ -7,7 +7,6 @@ module.exports = { properties: { domain: { type: "string", - const: "ONDC:RET10", }, location: { type: "object", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/select.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/select.js similarity index 98% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/select.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/select.js index 9a4649c..8e18120 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/select.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/select.js @@ -177,7 +177,8 @@ module.exports = { type: "object", properties: { code: { - type: "string" + type: "string", + enum: ["BUYER_TERMS"], }, }, required: ["code"], @@ -191,7 +192,8 @@ module.exports = { type: "object", properties: { code: { - type: "string" + type: "string", + enum: ["ITEM_REQ", "PACKAGING_REQ"], }, }, required: ["code"], diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/status.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/status.js similarity index 98% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/status.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/status.js index 45afe99..c6bcf70 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/status.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/status.js @@ -7,7 +7,6 @@ module.exports = { properties: { domain: { type: "string", - const: "ONDC:RET10", }, location: { type: "object", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/update.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/update.js similarity index 99% rename from utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/update.js rename to utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/update.js index 62e1bd1..24e08c0 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/update.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v1/update.js @@ -7,7 +7,6 @@ module.exports = { properties: { domain: { type: "string", - const: "ONDC:RET10", }, location: { type: "object", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/confirm.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/confirm.js new file mode 100644 index 0000000..5adfe0d --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/confirm.js @@ -0,0 +1,769 @@ +module.exports = { + $id: "http://example.com/schema/confirmSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "confirm", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/select/0/context/transaction_id" }, + errorMessage: + "Transaction ID should be same across the transaction: ${/search/0/context/transaction_id}", + }, + message_id: { + type: "string", + allOf: [ + { + not: { + const: { $data: "1/transaction_id" }, + }, + errorMessage: + "Message ID should not be equal to transaction_id: ${1/transaction_id}", + }, + ] + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + const: "PT30S", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order: { + type: "object", + properties: { + id: { + type: "string", + }, + state: { + type: "string", + enum: ["Created"], + }, + provider: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/init/0/message/order/provider/id" }, + }, + locations: { + type: "array", + const: { $data: "/init/0/message/order/provider/locations" }, + errorMessage:"mismatch from /init", + items: { + type: "object", + properties: { + id: { + type: "string", + + }, + }, + required: ["id"], + }, + }, + }, + required: ["id", "locations"], + }, + items: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + fulfillment_ids: { + type: "array", + items: { + type: "string", + }, + }, + quantity: { + type: "object", + properties: { + selected: { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + }, + required: ["selected"], + }, + "add-ons": { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["BUYER_TERMS"], + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["ITEM_REQ", "PACKAGING_REQ"], + }, + }, + required: ["code"], + }, + value: { + type: "string", + anyOf: [ + { + const: { $data: "/init/0/message/order/items/0/tags/0/list/0/value" }, + }, + { + const: { $data: "/init/0/message/order/items/0/tags/0/list/1/value" }, + } + ] + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: ["id", "fulfillment_ids", "quantity"], + }, + }, + billing: { + type: "object", + properties: { + name: { + type: "string", + const: { $data: "/init/0/message/order/billing/name" }, + }, + address: { + type: "string", + const: { $data: "/init/0/message/order/billing/address" }, + }, + state: { + type: "object", + properties: { + name: { + type: "string", + const: { + $data: "/init/0/message/order/billing/state/name", + }, + }, + }, + required: ["name"], + }, + city: { + type: "object", + properties: { + name: { + type: "string", + const: { + $data: "/init/0/message/order/billing/city/name", + }, + }, + }, + required: ["name"], + }, + tax_id: { + type: "string", + const: { $data: "/init/0/message/order/billing/tax_id" }, + }, + email: { + type: "string", + const: { $data: "/init/0/message/order/billing/email" }, + }, + phone: { + type: "string", + const: { $data: "/init/0/message/order/billing/phone" }, + }, + }, + + required: ["name", "address", "state", "city", "tax_id", "phone"], + }, + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + type: { + type: "string", + }, + tracking: { + type: "boolean", + }, + stops: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + enum: ["start", "end"], + }, + location: { + type: "object", + properties: { + gps: { + type: "string", + pattern: "^(-?[0-9]{1,3}(?:.[0-9]{6,15})?),( )*?(-?[0-9]{1,3}(?:.[0-9]{6,15})?)$", + errorMessage: "Incorrect gps value", + }, + address: { + type: "string", + }, + city: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + area_code: { + type: "string", + }, + state: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + }, + required: [ + "gps", + "address", + "city", + "country", + "area_code", + "state", + ], + }, + contact: { + type: "object", + properties: { + phone: { + type: "string", + }, + email: { + type: "string", + }, + }, + required: ["phone"], + }, + customer: { + type: "object", + properties: { + person: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + }, + required: ["person"], + }, + }, + required: ["type", "location", "contact"], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["DELIVERY_TERMS"], + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: [ + "INCOTERMS", + "NAMED_PLACE_OF_DELIVERY", + ], + }, + }, + required: ["code"], + }, + value: { + type: "string", + anyOf: [ + { + const: { $data: "/init/0/message/order/fulfillments/0/tags/0/list/0/value" }, + }, + { + const: { $data: "/init/0/message/order/fulfillments/0/tags/0/list/1/value" }, + } + ] + }, + }, + if: { + properties: { + descriptor: { + properties: { code: { const: "INCOTERMS" } }, + }, + }, + }, + then: { + properties: { + value: { + enum: [ + "DPU", + "CIF", + "EXW", + "FOB", + "DAP", + "DDP", + ], + }, + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: ["id", "type", "stops"], + }, + }, + quote: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + const: { + $data: "/on_init/0/message/order/quote/price/value", + }, + }, + }, + required: ["currency", "value"], + }, + breakup: { + type: "array", + items: { + type: "object", + properties: { + "@ondc/org/item_id": { + type: "string", + }, + "@ondc/org/item_quantity": { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + title: { + type: "string", + }, + "@ondc/org/title_type": { + type: "string", + enum: ["item", "discount", "packing", "delivery", "tax", "misc"] + }, + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + item: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + }, + required: ["price"], + }, + }, + if: { + properties: { + "@ondc/org/title_type": { + const: "item", + }, + }, + }, + then: { + required: [ + "@ondc/org/item_id", + "@ondc/org/item_quantity", + "title", + "@ondc/org/title_type", + "price", + "item", + ], + }, + else: { + properties: { + "@ondc/org/title_type": { + enum: [ + "delivery", + "packing", + "tax", + "discount", + "misc", + ], + }, + }, + required: [ + "@ondc/org/item_id", + "title", + "@ondc/org/title_type", + "price", + ], + }, + }, + }, + ttl: { + type: "string", + }, + }, + required: ["price", "breakup", "ttl"], + }, + payments: { + type: "array", + items: { + type: "object", + properties: { + params: { + type: "object", + properties: { + currency: { + type: "string", + }, + transaction_id: { + type: "string", + }, + amount: { + type: "string", + }, + }, + required: ["currency", "amount"], + }, + status: { + type: "string", + enum: ["PAID", "NOT-PAID"], + }, + type: { + type: "string", + enum: [ + "PRE-FULFILLMENT", + "ON-FULFILLMENT", + "POST-FULFILLMENT", + ], + }, + collected_by: { + type: "string", + }, + "@ondc/org/buyer_app_finder_fee_type": { + type: "string", + }, + "@ondc/org/buyer_app_finder_fee_amount": { + type: "string", + }, + "@ondc/org/settlement_details": { + type: "array", + items: { + type: "object", + properties: { + settlement_counterparty: { + type: "string", + enum: ["seller-app", "buyer-app"], + }, + settlement_phase: { + type: "string", + }, + settlement_type: { + type: "string", + enum: ["upi", "neft", "rtgs"], + }, + upi_address: { + type: "string", + }, + settlement_bank_account_no: { + type: "string", + }, + settlement_ifsc_code: { + type: "string", + }, + beneficiary_name: { + type: "string", + }, + bank_name: { + type: "string", + }, + branch_name: { + type: "string", + }, + }, + allOf: [ + { + if: { + properties: { + settlement_type: { + const: "upi", + }, + }, + }, + then: { + required: ["upi_address"], + }, + }, + { + if: { + properties: { + settlement_type: { + const: ["neft", "rtgs"], + }, + }, + }, + then: { + required: [ + "settlement_ifsc_code", + "settlement_bank_account_no", + ], + }, + }, + ], + required: ["settlement_counterparty", "settlement_type"], + }, + }, + }, + required: [ + "params", + "status", + "type", + "collected_by", + "@ondc/org/buyer_app_finder_fee_type", + "@ondc/org/buyer_app_finder_fee_amount", + ], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: ["buyer_id"], + }, + }, + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: ["buyer_id_code", "buyer_id_no"], + }, + }, + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + created_at: { + type: "string", + const: { $data: "3/context/timestamp" }, + errorMessage: + "created_at does not match context timestamp - ${3/context/timestamp}", + }, + updated_at: { + type: "string", + const: { $data: "3/context/timestamp" }, + errorMessage: + "updated_at does not match context timestamp - ${3/context/timestamp}", + }, + }, + additionalProperties:false, + required: [ + "id", + "state", + "provider", + "items", + "billing", + "fulfillments", + "quote", + "payments", + "created_at", + "updated_at", + ], + }, + }, + required: ["order"], + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/init.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/init.js new file mode 100644 index 0000000..9b9db05 --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/init.js @@ -0,0 +1,531 @@ +module.exports = { + $id: "http://example.com/schema/initSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "init", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/select/0/context/transaction_id" }, + errorMessage: + "Transaction ID should be same across the transaction: ${/search/0/context/transaction_id}", + }, + message_id: { + type: "string", + allOf: [ + { + not: { + const: { $data: "1/transaction_id" }, + }, + errorMessage: + "Message ID should not be equal to transaction_id: ${1/transaction_id}", + }, + ], + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + const: "PT30S" + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order: { + type: "object", + properties: { + provider: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/select/0/message/order/provider/id" }, + }, + locations: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + const: { + $data: + "/select/0/message/order/provider/locations/0/id", + }, + }, + }, + required: ["id"], + }, + } + }, + required: ["id", "locations"], + }, + items: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + fulfillment_ids: { + type: "array", + items: { + type: "string", + }, + }, + quantity: { + type: "object", + properties: { + selected: { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + }, + required: ["selected"], + }, + "add-ons": { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["BUYER_TERMS"], + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["ITEM_REQ", "PACKAGING_REQ"], + }, + }, + required: ["code"], + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: ["id", "quantity"], + }, + }, + billing: { + type: "object", + properties: { + name: { + type: "string", + minLength: 3, + }, + address: { + type: "string", + }, + state: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + city: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + tax_id: { + type: "string", + }, + email: { + type: "string", + }, + phone: { + type: "string", + }, + created_at: { + type: "string", + }, + updated_at: { + type: "string", + }, + }, + additionalProperties: false, + required: ["name", "address", "state", "city", "tax_id", "phone"], + }, + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + type: { + type: "string", + }, + stops: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + }, + location: { + type: "object", + properties: { + gps: { + type: "string", + pattern: + "^(-?[0-9]{1,3}(?:.[0-9]{6,15})?),( )*?(-?[0-9]{1,3}(?:.[0-9]{6,15})?)$", + errorMessage: "Incorrect gps value", + }, + address: { + type: "string", + }, + city: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + area_code: { + type: "string", + }, + state: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + }, + required: [ + "gps", + "address", + "city", + "country", + "area_code", + "state", + ], + }, + contact: { + type: "object", + properties: { + phone: { + type: "string", + }, + }, + required: ["phone"], + }, + }, + required: ["type", "location", "contact"], + }, + }, + customer: { + type: "object", + properties: { + person: { + type: "object", + properties: { + creds: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + type: { + type: "string", + enum: [ + "License", + "Badge", + "Permit", + "Certificate", + ], + }, + desc: { + type: "string", + }, + icon: { + type: "string", + }, + url: { + type: "string", + pattern: + "^https://[\\w.-]+(\\.[a-zA-Z]{2,})?(:[0-9]+)?(/\\S*)?$", + }, + }, + required: ["id", "type", "desc", "icon", "url"], + }, + }, + }, + required: ["creds"], + }, + }, + required: ["person"], + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["DELIVERY_TERMS"], + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: [ + "INCOTERMS", + "NAMED_PLACE_OF_DELIVERY", + ], + }, + }, + required: ["code"], + }, + value: { + type: "string", + }, + }, + if: { + properties: { + descriptor: { + properties: { code: { const: "INCOTERMS" } }, + }, + }, + }, + then: { + properties: { + value: { + enum: [ + "DPU", + "CIF", + "EXW", + "FOB", + "DAP", + "DDP", + ], + }, + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: ["id", "type", "stops"], + }, + }, + payments: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + enum: [ + "PRE-FULFILLMENT", + "ON-FULFILLMENT", + "POST-FULFILLMENT", + ], + }, + }, + required: ["type"], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: ["buyer_id"], + }, + }, + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: ["buyer_id_code", "buyer_id_no"], + }, + }, + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + additionalProperties: false, + required: [ + "provider", + "items", + "billing", + "fulfillments", + "payments", + "tags", + ], + }, + }, + required: ["order"], + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/master.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/master.js new file mode 100644 index 0000000..d01fe98 --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/master.js @@ -0,0 +1,78 @@ +module.exports = { + $id: "http://example.com/schema/masterSchema", + type: "object", + properties: { + search: { + type: "array", + items: { + $ref: "searchSchema#", + }, + }, + on_search: { + type: "array", + items: { + $ref: "onSearchSchema#", + }, + }, + select: { + type: "array", + items: { + $ref: "selectSchema#", + }, + }, + on_select: { + type: "array", + items: { + $ref: "onSelectSchema#", + }, + }, + init: { + type: "array", + items: { + $ref: "initSchema#", + }, + }, + on_init: { + type: "array", + items: { + $ref: "onInitSchema#", + }, + }, + confirm: { + type: "array", + items: { + $ref: "confirmSchema#", + }, + }, + on_confirm: { + type: "array", + items: { + $ref: "onConfirmSchema#", + }, + }, + update: { + type: "array", + items: { + $ref: "updateSchema#", + }, + }, + on_update: { + type: "array", + items: { + $ref: "onUpdateSchema#", + }, + }, + status: { + type: "array", + items: { + $ref: "statusSchema#", + }, + }, + on_status: { + type: "array", + items: { + $ref: "onStatusSchema#", + }, + } + }, +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_confirm.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_confirm.js new file mode 100644 index 0000000..3e87a93 --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_confirm.js @@ -0,0 +1,833 @@ +module.exports = { + $id: "http://example.com/schema/onConfirmSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "on_confirm", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/select/0/context/transaction_id" }, + errorMessage: + "Transaction ID should be same across the transaction: ${/select/0/context/transaction_id}", + }, + message_id: { + type: "string", + allOf: [ + { + const: { $data: "/confirm/0/context/message_id" }, + errorMessage: + "Message ID for on_action API should be same as action API: ${/init/0/context/message_id}", + }, + { + not: { + const: { $data: "1/transaction_id" }, + }, + errorMessage: + "Message ID should not be equal to transaction_id: ${1/transaction_id}", + }, + ] + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/confirm/0/message/order/id" }, + }, + state: { + type: "string", + enum: ["Created", "Accepted", "Cancelled"], + }, + provider: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/confirm/0/message/order/provider/id" }, + }, + locations: { + type: "array", + const: { $data: "/confirm/0/message/order/provider/locations" }, + items: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + rateable: { + type: "boolean", + }, + }, + required: ["id", "locations"], + }, + items: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + fulfillment_ids: { + type: "array", + items: { + type: "string", + }, + }, + quantity: { + type: "object", + properties: { + selected: { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + }, + required: ["selected"], + }, + "add-ons": { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["BUYER_TERMS"], + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["ITEM_REQ", "PACKAGING_REQ"], + }, + }, + required: ["code"], + }, + value: { + type: "string", + anyOf: [ + { + const: { $data: "/init/0/message/order/items/0/tags/0/list/0/value" }, + }, + { + const: { $data: "/init/0/message/order/items/0/tags/0/list/1/value" }, + } + ] + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: ["id", "fulfillment_ids", "quantity"], + }, + }, + billing: { + type: "object", + properties: { + name: { + type: "string", + const: { $data: "/init/0/message/order/billing/name" }, + }, + address: { + type: "string", + const: { $data: "/init/0/message/order/billing/address" }, + }, + state: { + type: "object", + properties: { + name: { + type: "string", + const: { + $data: "/init/0/message/order/billing/state/name", + }, + }, + }, + required: ["name"], + }, + city: { + type: "object", + properties: { + name: { + type: "string", + const: { + $data: "/init/0/message/order/billing/city/name", + }, + }, + }, + required: ["name"], + }, + tax_id: { + type: "string", + const: { $data: "/init/0/message/order/billing/tax_id" }, + }, + email: { + type: "string", + const: { $data: "/init/0/message/order/billing/email" }, + }, + phone: { + type: "string", + const: { $data: "/init/0/message/order/billing/phone" }, + }, + }, + + required: ["name", "address", "state", "city", "tax_id", "phone"], + }, + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + "@ondc/org/provider_name": { + type: "string", + }, + state: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + }, + required: ["descriptor"], + }, + type: { + type: "string", + }, + tracking: { + type: "boolean", + }, + stops: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + enum: ["start", "end"], + }, + location: { + type: "object", + properties: { + id: { + type: "string", + }, + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + gps: { + type: "string", + pattern: "^(-?[0-9]{1,3}(?:.[0-9]{6,15})?),( )*?(-?[0-9]{1,3}(?:.[0-9]{6,15})?)$", + errorMessage: "Incorrect gps value", + }, + address: { + type: "string", + }, + city: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + area_code: { + type: "string", + }, + state: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + }, + }, + time: { + type: "object", + properties: { + range: { + type: "object", + properties: { + start: { + type: "string", + }, + end: { + type: "string", + }, + }, + required: ["start", "end"], + }, + }, + required: ["range"], + }, + instructions: { + type: "object", + properties: { + name: { + type: "string", + }, + short_desc: { + type: "string", + }, + }, + required: ["name", "short_desc"], + }, + contact: { + type: "object", + properties: { + phone: { + type: "string", + }, + email: { + type: "string", + }, + }, + required: ["phone"], + }, + }, + required: ["type", "location", "time", "contact"], + }, + }, + rateable: { + type: "boolean", + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["DELIVERY_TERMS"], + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: [ + "INCOTERMS", + "NAMED_PLACE_OF_DELIVERY", + ], + }, + }, + required: ["code"], + }, + value: { + type: "string", + anyOf: [ + { + const: { $data: "/init/0/message/order/fulfillments/0/tags/0/list/0/value" }, + }, + { + const: { $data: "/init/0/message/order/fulfillments/0/tags/0/list/1/value" }, + } + ] + }, + }, + if: { + properties: { + descriptor: { + properties: { code: { const: "INCOTERMS" } }, + }, + }, + }, + then: { + properties: { + value: { + enum: [ + "DPU", + "CIF", + "EXW", + "FOB", + "DAP", + "DDP", + ], + }, + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: [ + "id", + "@ondc/org/provider_name", + "state", + "type", + "stops", + ], + }, + }, + quote: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + const: { + $data: "/on_init/0/message/order/quote/price/value", + }, + }, + }, + required: ["currency", "value"], + }, + breakup: { + type: "array", + items: { + type: "object", + properties: { + "@ondc/org/item_id": { + type: "string", + }, + "@ondc/org/item_quantity": { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + title: { + type: "string", + }, + "@ondc/org/title_type": { + type: "string", + }, + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + item: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + }, + required: ["price"], + }, + }, + if: { + properties: { + "@ondc/org/title_type": { + const: "item", + }, + }, + }, + then: { + required: [ + "@ondc/org/item_id", + "@ondc/org/item_quantity", + "title", + "@ondc/org/title_type", + "price", + "item", + ], + }, + else: { + properties: { + "@ondc/org/title_type": { + enum: [ + "delivery", + "packing", + "tax", + "discount", + "misc", + ], + }, + }, + required: [ + "@ondc/org/item_id", + "title", + "@ondc/org/title_type", + "price", + ], + }, + }, + }, + ttl: { + type: "string", + }, + }, + isQuoteMatching: true, + required: ["price", "breakup", "ttl"], + }, + payments: { + type: "array", + items: { + type: "object", + properties: { + params: { + type: "object", + properties: { + currency: { + type: "string", + }, + transaction_id: { + type: "string", + }, + amount: { + type: "string", + }, + }, + required: ["currency", "amount"], + }, + status: { + type: "string", + enum: ["PAID", "NOT-PAID"], + }, + type: { + type: "string", + enum: [ + "PRE-FULFILLMENT", + "ON-FULFILLMENT", + "POST-FULFILLMENT", + ], + }, + collected_by: { + type: "string", + enum: ["BAP", "BPP"], + }, + "@ondc/org/buyer_app_finder_fee_type": { + type: "string", + }, + "@ondc/org/buyer_app_finder_fee_amount": { + type: "string", + }, + "@ondc/org/settlement_details": { + type: "array", + items: { + type: "object", + properties: { + settlement_counterparty: { + type: "string", + enum: ["seller-app", "buyer-app"], + }, + settlement_phase: { + type: "string", + }, + settlement_type: { + type: "string", + enum: ["upi", "neft", "rtgs"], + }, + beneficiary_name: { + type: "string", + }, + upi_address: { + type: "string", + }, + settlement_bank_account_no: { + type: "string", + }, + settlement_ifsc_code: { + type: "string", + }, + bank_name: { + type: "string", + }, + branch_name: { + type: "string", + }, + }, + allOf: [ + { + if: { + properties: { + settlement_type: { + const: "upi", + }, + }, + }, + then: { + required: ["upi_address"], + }, + }, + { + if: { + properties: { + settlement_type: { + const: ["neft", "rtgs"], + }, + }, + }, + then: { + required: [ + "settlement_ifsc_code", + "settlement_bank_account_no", + ], + }, + }, + ], + required: ["settlement_counterparty", "settlement_type"], + }, + }, + }, + if: { properties: { type: { const: "ON-FULFILLMENT" } } }, + then: { + properties: { + collected_by: { + const: "BPP", + }, + }, + }, + required: [ + "params", + "status", + "type", + "collected_by", + "@ondc/org/buyer_app_finder_fee_type", + "@ondc/org/buyer_app_finder_fee_amount", + ], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: ["buyer_id"], + }, + }, + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: ["buyer_id_code", "buyer_id_no"], + }, + }, + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + created_at: { + type: "string", + format: "date-time", + const: { $data: "/confirm/0/message/order/created_at" }, + errorMessage: + "should remain same as in /confirm - ${/confirm/0/message/order/created_at}", + }, + updated_at: { + type: "string", + format: "date-time", + const: { $data: "3/context/timestamp" }, + errorMessage: + " should be updated as per context/timestamp - ${3/context/timestamp}", + }, + }, + additionalProperties: false, + required: [ + "id", + "state", + "provider", + "items", + "billing", + "fulfillments", + "quote", + "payments", + "tags", + "created_at", + "updated_at", + ], + }, + }, + required: ["order"], + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_init.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_init.js new file mode 100644 index 0000000..d47c1fe --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_init.js @@ -0,0 +1,694 @@ +module.exports = { + $id: "http://example.com/schema/onInitSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "on_init", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/select/0/context/transaction_id" }, + errorMessage: + "Transaction ID should be same across the transaction: ${/select/0/context/transaction_id}", + }, + message_id: { + type: "string", + allOf: [ + { + const: { $data: "/init/0/context/message_id" }, + errorMessage: + "Message ID for on_action API should be same as action API: ${/init/0/context/message_id}", + }, + { + not: { + const: { $data: "1/transaction_id" }, + }, + errorMessage: + "Message ID should not be equal to transaction_id: ${1/transaction_id}", + }, + ] + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + format: "duration" + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order: { + type: "object", + properties: { + provider: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/init/0/message/order/provider/id" }, + }, + }, + required: ["id"], + }, + provider_location: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/init/0/message/order/provider/locations/0/id"} + }, + }, + required: ["id"], + }, + items: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + fulfillment_ids: { + type: "array", + items: { + type: "string", + }, + }, + quantity: { + type: "object", + properties: { + selected: { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + }, + required: ["selected"], + }, + "add-ons": { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum:["BUYER_TERMS"] + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum:["ITEM_REQ","PACKAGING_REQ"] + }, + }, + required: ["code"], + }, + value: { + type: "string", + anyOf: [ + { + const: { $data: "/init/0/message/order/items/0/tags/0/list/0/value" }, + }, + { + const: { $data: "/init/0/message/order/items/0/tags/0/list/1/value" }, + } + ] + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: ["id", "fulfillment_ids", "quantity"], + }, + }, + billing: { + type: "object", + properties: { + name: { + type: "string", + const: { $data: "/init/0/message/order/billing/name" }, + }, + address: { + type: "string", + const: { $data: "/init/0/message/order/billing/address" }, + }, + state: { + type: "object", + properties: { + name: { + type: "string", + const: { + $data: "/init/0/message/order/billing/state/name", + }, + }, + }, + required: ["name"], + }, + city: { + type: "object", + properties: { + name: { + type: "string", + const: { + $data: "/init/0/message/order/billing/city/name", + }, + }, + }, + required: ["name"], + }, + tax_id: { + type: "string", + const: { $data: "/init/0/message/order/billing/tax_id" }, + }, + email: { + type: "string", + const: { $data: "/init/0/message/order/billing/email" }, + }, + phone: { + type: "string", + const: { $data: "/init/0/message/order/billing/phone" }, + }, + }, + + required: ["name", "address", "state", "city", "tax_id", "phone"], + }, + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + type: { + type: "string", + }, + tracking: { + type: "boolean", + }, + stops: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + enum: ["start", "end"], + }, + location: { + type: "object", + properties: { + gps: { + type: "string", + pattern: "^(-?[0-9]{1,3}(?:.[0-9]{6,15})?),( )*?(-?[0-9]{1,3}(?:.[0-9]{6,15})?)$", + errorMessage: "Incorrect gps value", + }, + address: { + type: "string", + }, + city: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + area_code: { + type: "string", + }, + state: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + }, + required: [ + "gps", + "address", + "city", + "country", + "area_code", + "state", + ], + }, + contact: { + type: "object", + properties: { + phone: { + type: "string", + }, + }, + required: ["phone"], + }, + }, + required: ["type", "location", "contact"], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["DELIVERY_TERMS"], + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: [ + "INCOTERMS", + "NAMED_PLACE_OF_DELIVERY", + ], + }, + }, + required: ["code"], + }, + value: { + type: "string", + anyOf: [ + { + const: { $data: "/init/0/message/order/fulfillments/0/tags/0/list/0/value" }, + }, + { + const: { $data: "/init/0/message/order/fulfillments/0/tags/0/list/1/value" }, + } + ] + }, + }, + if: { + properties: { + descriptor: { + properties: { code: { const: "INCOTERMS" } }, + }, + }, + }, + then: { + properties: { + value: { + enum: [ + "DPU", + "CIF", + "EXW", + "FOB", + "DAP", + "DDP", + ], + }, + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: ["id", "type", "tracking", "stops"], + }, + }, + quote: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + breakup: { + type: "array", + items: { + type: "object", + properties: { + "@ondc/org/item_id": { + type: "string", + }, + "@ondc/org/item_quantity": { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + title: { + type: "string", + }, + "@ondc/org/title_type": { + type: "string", + enum: ["item", "discount", "packing", "delivery", "tax", "misc"] + }, + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + item: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + }, + required: ["price"], + }, + }, + if: { + properties: { + "@ondc/org/title_type": { + const: "item", + }, + }, + }, + then: { + required: [ + "@ondc/org/item_id", + "@ondc/org/item_quantity", + "title", + "@ondc/org/title_type", + "price", + "item", + ], + }, + else: { + properties: { + "@ondc/org/title_type": { + enum: [ + "delivery", + "packing", + "tax", + "discount", + "misc", + ], + }, + }, + required: [ + "@ondc/org/item_id", + "title", + "@ondc/org/title_type", + "price", + ], + }, + }, + }, + ttl: { + type: "string", + }, + }, + isQuoteMatching: true, + + required: ["price", "breakup", "ttl"], + }, + payments: { + type: "array", + items: { + type: "object", + properties: { + "@ondc/org/buyer_app_finder_fee_type": { + type: "string", + }, + "@ondc/org/buyer_app_finder_fee_amount": { + type: "string", + }, + "@ondc/org/settlement_details": { + type: "array", + items: { + type: "object", + properties: { + settlement_counterparty: { + type: "string", + enum: ["seller-app", "buyer-app"], + }, + settlement_phase: { + type: "string", + }, + settlement_type: { + type: "string", + enum: ["upi", "neft", "rtgs"], + }, + beneficiary_name: { + type: "string", + }, + upi_address: { + type: "string", + }, + settlement_bank_account_no: { + type: "string", + }, + settlement_ifsc_code: { + type: "string", + }, + bank_name: { + type: "string", + }, + branch_name: { + type: "string", + }, + }, + allOf: [ + { + if: { + properties: { + settlement_type: { + const: "upi", + }, + }, + }, + then: { + required: ["upi_address"], + }, + }, + { + if: { + properties: { + settlement_type: { + const: ["neft", "rtgs"], + }, + }, + }, + then: { + required: [ + "settlement_ifsc_code", + "settlement_bank_account_no", + ], + }, + }, + ], + required: ["settlement_counterparty", "settlement_type"], + }, + }, + }, + required: [ + "@ondc/org/buyer_app_finder_fee_type", + "@ondc/org/buyer_app_finder_fee_amount", + ], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: ["buyer_id"], + }, + }, + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: ["buyer_id_code", "buyer_id_no"], + }, + }, + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + additionalProperties:false, + required: [ + "provider", + "provider_location", + "items", + "billing", + "fulfillments", + "quote", + "payments", + ], + }, + }, + required: ["order"], + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_search.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_search.js new file mode 100644 index 0000000..13d05ca --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_search.js @@ -0,0 +1,966 @@ +module.exports = { + $id: "http://example.com/schema/onSearchSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "on_search", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/search/0/context/transaction_id" }, + errorMessage: + "Transaction ID should be same across the transaction: ${/search/0/context/transaction_id}", + }, + message_id: { + type: "string", + allOf: [ + { + const: { $data: "/search/0/context/message_id" }, + errorMessage: + "Message ID for on_action API should be same as action API: ${/search/0/context/message_id}", + }, + { + not: { + const: { $data: "1/transaction_id" }, + }, + errorMessage: + "Message ID should not be equal to transaction_id: ${1/transaction_id}", + }, + ], + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + catalog: { + type: "object", + properties: { + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + type: { + type: "string", + enum: ["Delivery", "Self-Pickup"], + }, + }, + required: ["id", "type"], + }, + }, + payments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + type: { + type: "string", + enum: [ + "PRE-FULFILLMENT", + "ON-FULFILLMENT", + "POST-FULFILLMENT", + ], + }, + }, + required: ["id", "type"], + }, + }, + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + short_desc: { + type: "string", + }, + long_desc: { + type: "string", + }, + images: { + type: "array", + items: { + type: "object", + properties: { + url: { + type: "string", + }, + }, + required: ["url"], + }, + }, + }, + required: ["name", "short_desc", "long_desc", "images"], + }, + providers: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + code: { + type: "string", + }, + short_desc: { + type: "string", + }, + long_desc: { + type: "string", + }, + additional_desc: { + type: "object", + properties: { + url: { + type: "string", + }, + content_type: { + type: "string", + }, + }, + required: ["url", "content_type"], + }, + images: { + type: "array", + items: { + type: "object", + properties: { + url: { + type: "string", + }, + }, + required: ["url"], + }, + }, + }, + required: ["name", "code"], + }, + rating: { + type: "string", + }, + ttl: { + type: "string", + format: "duration", + }, + locations: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + gps: { + type: "string", + pattern: + "^(-?[0-9]{1,3}(?:.[0-9]{6,15})?),( )*?(-?[0-9]{1,3}(?:.[0-9]{6,15})?)$", + errorMessage: "Incorrect gps value", + }, + address: { + type: "string", + }, + city: { + type: "object", + properties: { + code: { + type: "string", + }, + name: { + type: "string", + }, + }, + required: ["code", "name"], + }, + state: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + area_code: { + type: "string", + }, + }, + additionalProperties: false, + required: [ + "id", + "gps", + "address", + "city", + "state", + "country", + "area_code", + ], + }, + }, + creds: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + type: { + type: "string", + enum: ["License", "Badge", "Permit", "Certificate"], + }, + desc: { + type: "string", + }, + url: { + type: "string", + format: "uri", + }, + }, + required: ["id", "type", "desc", "url"], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + }, + }, + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + }, + }, + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + items: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + parent_item_id: { + type: "string", + }, + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + code: { + type: "string", + }, + short_desc: { + type: "string", + }, + long_desc: { + type: "string", + }, + images: { + type: "array", + items: { + type: "object", + properties: { + url: { + type: "string", + }, + }, + required: ["url"], + }, + }, + media: { + type: "array", + items: { + type: "object", + properties: { + mimetype: { + type: "string", + }, + url: { + type: "string", + }, + }, + required: ["mimetype", "url"], + }, + }, + }, + required: [ + "name", + "code", + "short_desc", + "long_desc", + "images", + ], + }, + creator: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + contact: { + type: "object", + properties: { + name: { + type: "string", + }, + address: { + type: "object", + properties: { + full: { + type: "string", + }, + }, + required: ["full"], + }, + phone: { + type: "string", + }, + email: { + type: "string", + }, + }, + required: ["address", "phone"], + }, + }, + required: ["name", "contact"], + }, + }, + required: ["descriptor"], + }, + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + offered_value: { + type: "string", + }, + maximum_value: { + type: "string", + }, + }, + required: ["currency", "value", "maximum_value"], + }, + quantity: { + type: "object", + properties: { + unitized: { + type: "object", + properties: { + measure: { + type: "object", + properties: { + unit: { + type: "string", + enum: [ + "unit", + "dozen", + "gram", + "kilogram", + "tonne", + "litre", + "millilitre", + ], + }, + value: { + type: "string", + }, + }, + required: ["unit", "value"], + }, + }, + required: ["measure"], + }, + available: { + type: "object", + properties: { + measure: { + type: "object", + properties: { + unit: { + type: "string", + enum: [ + "unit", + "dozen", + "gram", + "kilogram", + "tonne", + "litre", + "millilitre", + ], + }, + value: { + type: "string", + }, + }, + required: ["unit", "value"], + }, + count: { + type: "string", + }, + }, + required: ["measure", "count"], + }, + maximum: { + type: "object", + properties: { + measure: { + type: "object", + properties: { + unit: { + type: "string", + enum: [ + "unit", + "dozen", + "gram", + "kilogram", + "tonne", + "litre", + "millilitre", + ], + }, + value: { + type: "string", + }, + }, + required: ["unit", "value"], + }, + count: { + type: "string", + }, + }, + required: ["measure", "count"], + }, + }, + required: ["unitized", "available", "maximum"], + }, + category_ids: { + type: "array", + items: { + type: "string", + }, + }, + fulfillment_ids: { + type: "array", + items: { + type: "string", + }, + }, + location_ids: { + type: "array", + items: { + type: "string", + }, + }, + payment_ids: { + type: "array", + items: { + type: "string", + }, + }, + "add-ons": { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + short_desc: { + type: "string", + }, + long_desc: { + type: "string", + }, + images: { + type: "array", + items: { + type: "object", + properties: { + url: { + type: "string", + }, + }, + required: ["url"], + }, + }, + }, + required: [ + "name", + "short_desc", + "long_desc", + "images", + ], + }, + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + offered_value: { + type: "string", + }, + maximum_value: { + type: "string", + }, + }, + required: [ + "currency", + "value", + "offered_value", + "maximum_value", + ], + }, + }, + required: ["id", "descriptor", "price"], + }, + }, + cancellation_terms: { + type: "array", + items: { + type: "object", + properties: { + fulfillment_state: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + }, + required: ["descriptor"], + }, + refund_eligible: { + type: "string", + }, + return_policy: { + type: "object", + properties: { + return_eligible: { + type: "string", + }, + return_within: { + type: "string", + }, + fulfillment_managed_by: { + type: "string", + }, + return_location: { + type: "object", + properties: { + address: { + type: "string", + }, + gps: { + type: "string", + }, + }, + required: ["address", "gps"], + }, + }, + required: [ + "return_eligible", + "return_within", + "fulfillment_managed_by", + "return_location", + ], + }, + }, + if: { + properties: { + fulfillment_state: { + properties: { + descriptor: { + properties: { + code: { + const: "Order-delivered", + }, + }, + }, + }, + }, + }, + }, + then: { + required: ["fulfillment_state", "return_policy"], + }, + else: { + required: [ + "fulfillment_state", + "refund_eligible", + ], + }, + }, + }, + replacement_terms: { + type: "array", + items: { + type: "object", + properties: { + replace_within: { + type: "string", + }, + }, + required: ["replace_within"], + }, + }, + time: { + type: "object", + properties: { + label: { + type: "string", + }, + range: { + type: "object", + properties: { + start: { + type: "string", + }, + end: { + type: "string", + }, + }, + required: ["start", "end"], + }, + }, + required: ["label", "range"], + }, + matched: { + type: "string", + }, + recommended: { + type: "string", + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + }, + }, + }, + + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + }, + }, + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: [ + "id", + + "descriptor", + "creator", + "price", + "quantity", + "category_ids", + "fulfillment_ids", + "location_ids", + "payment_ids", + "cancellation_terms", + "replacement_terms", + + "matched", + "recommended", + ], + }, + }, + offers: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + code: { + type: "string", + }, + short_desc: { + type: "string", + }, + long_desc: { + type: "string", + }, + images: { + type: "array", + items: { + type: "object", + properties: { + url: { + type: "string", + }, + }, + required: ["url"], + }, + }, + }, + required: [ + "name", + "code", + "short_desc", + "long_desc", + "images", + ], + }, + location_ids: { + type: "array", + items: {}, + }, + category_ids: { + type: "array", + items: {}, + }, + item_ids: { + type: "array", + items: {}, + }, + time: { + type: "object", + properties: { + label: { + type: "string", + }, + range: { + type: "object", + properties: { + start: { + type: "string", + }, + end: { + type: "string", + }, + }, + required: ["start", "end"], + }, + }, + required: ["label", "range"], + }, + }, + required: [ + "id", + "descriptor", + "location_ids", + "category_ids", + "item_ids", + "time", + ], + }, + }, + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + contact: { + type: "object", + properties: { + phone: { + type: "string", + }, + email: { + type: "string", + }, + }, + required: ["phone", "email"], + }, + }, + required: ["contact"], + }, + }, + }, + required: [ + "id", + "descriptor", + "ttl", + "locations", + "tags", + "items", + "fulfillments", + ], + }, + }, + }, + additionalProperties: false, + required: ["fulfillments", "payments", "descriptor", "providers"], + }, + }, + required: ["catalog"], + }, + search: { + type: "array", + items: { + $ref: "searchSchema#", + }, + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_select.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_select.js new file mode 100644 index 0000000..8e8591b --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_select.js @@ -0,0 +1,335 @@ +module.exports = { + $id: "http://example.com/schema/onSelectSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "on_select", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/select/0/context/transaction_id" }, + errorMessage: + "Transaction ID should be same across the transaction: ${/select/0/context/transaction_id}", + }, + message_id: { + type: "string", + allOf: [ + { + const: { $data: "/select/0/context/message_id" }, + errorMessage: + "Message ID for on_action API should be same as action API: ${/select/0/context/message_id}", + }, + { + not: { + const: { $data: "1/transaction_id" }, + }, + errorMessage: + "Message ID should not be equal to transaction_id: ${1/transaction_id}", + }, + ] + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string" + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order: { + type: "object", + properties: { + provider: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/select/0/message/order/provider/id" }, + + }, + }, + required: ["id"], + }, + items: { + type: "array", + items: { + type: "object", + properties: { + fulfillment_ids: { + type: "array", + items: { + type: "string", + }, + }, + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + "@ondc/org/provider_name": { + type: "string", + }, + tracking: { + type: "boolean", + }, + "@ondc/org/category": { + type: "string", + }, + "@ondc/org/TAT": { + type: "string", + format: "duration" + }, + state: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["Serviceable", "Non-Serviceable"], + }, + }, + required: ["code"], + }, + }, + required: ["descriptor"], + }, + }, + required: [ + "id", + "@ondc/org/provider_name", + "tracking", + "@ondc/org/category", + "@ondc/org/TAT", + "state", + ], + }, + }, + quote: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + breakup: { + type: "array", + items: { + type: "object", + properties: { + "@ondc/org/item_id": { + type: "string", + }, + "@ondc/org/item_quantity": { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + title: { + type: "string", + }, + "@ondc/org/title_type": { + type: "string", + enum: ["item", "discount", "packing", "delivery ", "tax", "misc"] + }, + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + item: { + type: "object", + properties: { + quantity: { + type: "object", + properties: { + available: { + type: "object", + properties: { + count: { + type: "string", + }, + }, + required: ["count"], + }, + maximum: { + type: "object", + properties: { + count: { + type: "string", + }, + }, + required: ["count"], + }, + }, + required: ["available", "maximum"], + }, + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + }, + required: ["quantity", "price"], + }, + }, + if: { + properties: { + "@ondc/org/title_type": { + const: "item", + }, + }, + }, + then: { + required: [ + "@ondc/org/item_id", + "@ondc/org/item_quantity", + "title", + "@ondc/org/title_type", + "price", + "item", + ], + }, + else: { + properties: { + "@ondc/org/title_type": { + enum: [ + "delivery", + "packing", + "tax", + "discount", + "misc", + ], + }, + }, + required: [ + "@ondc/org/item_id", + "title", + "@ondc/org/title_type", + "price", + ], + }, + }, + }, + ttl: { + type: "string", + format: "duration" + }, + }, + isQuoteMatching: true, + + required: ["price", "breakup", "ttl"], + }, + }, + required: ["provider", "items", "quote"], + }, + }, + required: ["order"], + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_status.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_status.js new file mode 100644 index 0000000..ecaf332 --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_status.js @@ -0,0 +1,765 @@ +module.exports = { + $id: "http://example.com/schema/onStatusSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "on_status", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/select/0/context/transaction_id" }, + errorMessage: + "Transaction ID should be same across the transaction: ${/select/0/context/transaction_id}", + }, + message_id: { + type: "string", + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/confirm/0/message/order/id" }, + }, + state: { + type: "string", + enum: [ + "Created", + "Accepted", + "In-progress", + "Cancelled", + "Completed", + ], + }, + provider: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/select/0/message/order/provider/id" }, + }, + locations: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + }, + required: ["id", "locations"], + }, + items: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + fulfillment_ids: { + type: "array", + items: { + type: "string", + }, + }, + quantity: { + type: "object", + properties: { + selected: { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + }, + additionalProperties: false, + required: ["selected"], + }, + }, + required: ["id", "fulfillment_ids", "quantity"], + }, + }, + billing: { + type: "object", + properties: { + name: { + type: "string", + const: { $data: "/init/0/message/order/billing/name" }, + }, + address: { + type: "string", + const: { $data: "/init/0/message/order/billing/address" }, + }, + state: { + type: "object", + properties: { + name: { + type: "string", + const: { + $data: "/init/0/message/order/billing/state/name", + }, + }, + }, + required: ["name"], + }, + city: { + type: "object", + properties: { + name: { + type: "string", + }, + const: { + $data: "/init/0/message/order/billing/city/name", + }, + }, + required: ["name"], + }, + email: { + type: "string", + const: { $data: "/init/0/message/order/billing/email" }, + }, + phone: { + type: "string", + const: { $data: "/init/0/message/order/billing/phone" }, + }, + }, + required: ["name", "address", "state", "city", "phone"], + }, + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + "@ondc/org/provider_name": { + type: "string", + }, + type: { + type: "string", + }, + tracking: { + type: "boolean", + }, + state: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: [ + "Pending", + "Out-for-pickup", + "Order-picked-up", + "In-transit", + "At-destination-hub", + "Out-for-delivery", + "Order-delivered", + ], + }, + }, + required: ["code"], + }, + }, + required: ["descriptor"], + }, + stops: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + enum: ["start", "end"], + }, + location: { + type: "object", + properties: { + id: { + type: "string", + }, + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + images: { + type: "array", + items: { + type: "string", + }, + }, + }, + required: ["name"], + }, + gps: { + type: "string", + pattern: + "^(-?[0-9]{1,3}(?:.[0-9]{6,15})?),( )*?(-?[0-9]{1,3}(?:.[0-9]{6,15})?)$", + errorMessage: "Incorrect gps value", + }, + address: { + type: "string", + }, + city: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + area_code: { + type: "string", + }, + state: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + }, + }, + time: { + type: "object", + properties: { + range: { + type: "object", + properties: { + start: { + type: "string", + pattern: + "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", + errorMessage: + "should be in RFC 3339 (YYYY-MM-DDTHH:MN:SS.MSSZ) Format", + }, + end: { + type: "string", + pattern: + "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", + errorMessage: + "should be in RFC 3339 (YYYY-MM-DDTHH:MN:SS.MSSZ) Format", + }, + }, + required: ["start", "end"], + }, + timestamp: { + type: "string", + pattern: + "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", + errorMessage: + "should be in RFC 3339 (YYYY-MM-DDTHH:MN:SS.MSSZ) Format", + }, + }, + required: ["range"], + }, + instructions: { + type: "object", + properties: { + name: { + type: "string", + }, + short_desc: { + type: "string", + }, + long_desc: { + type: "string", + }, + images: { + type: "array", + items: { + type: "string", + }, + }, + }, + required: [ + "name", + "short_desc", + "long_desc", + "images", + ], + }, + contact: { + type: "object", + properties: { + phone: { + type: "string", + }, + email: { + type: "string", + }, + }, + required: ["phone"], + }, + agent: { + type: "object", + properties: { + person: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + contact: { + type: "object", + properties: { + phone: { + type: "string", + }, + }, + required: ["phone"], + }, + }, + required: ["person", "contact"], + }, + }, + if: { properties: { type: { const: "start" } } }, + then: { + properties: { + location: { required: ["id", "descriptor", "gps"] }, + }, + }, + else: { + properties: { + location: { required: ["address", "gps"] }, + }, + }, + required: ["type", "location", "time", "contact"], + }, + }, + }, + required: [ + "id", + "@ondc/org/provider_name", + "type", + "tracking", + "state", + "stops", + ], + anyof: [ + { + properties: { + state: { + const: "Order-picked-up", + }, + stops: { + type: "array", + items: { + properties: { + type: { + const: "start", + }, + time: { + required: ["range", "timestamp"], + }, + }, + }, + }, + }, + }, + ], + }, + }, + quote: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + breakup: { + type: "array", + items: { + type: "object", + properties: { + "@ondc/org/item_id": { + type: "string", + }, + "@ondc/org/item_quantity": { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + title: { + type: "string", + }, + "@ondc/org/title_type": { + type: "string", + }, + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + item: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + }, + required: ["price"], + }, + }, + if: { + properties: { + "@ondc/org/title_type": { + const: "item", + }, + }, + }, + then: { + required: [ + "@ondc/org/item_id", + "@ondc/org/item_quantity", + "title", + "@ondc/org/title_type", + "price", + "item", + ], + }, + else: { + properties: { + "@ondc/org/title_type": { + enum: [ + "delivery", + "packing", + "tax", + "discount", + "misc", + ], + }, + }, + required: [ + "@ondc/org/item_id", + "title", + "@ondc/org/title_type", + "price", + ], + }, + }, + }, + ttl: { + type: "string", + }, + }, + isQuoteMatching: true, + + required: ["price", "breakup", "ttl"], + }, + payments: { + type: "array", + items: { + type: "object", + properties: { + params: { + type: "object", + properties: { + currency: { + type: "string", + }, + transaction_id: { + type: "string", + }, + amount: { + type: "string", + }, + }, + required: ["currency", "amount"], + }, + status: { + type: "string", + enum: ["PAID", "NOT-PAID"], + }, + type: { + type: "string", + const: { + $data: "/on_confirm/0/message/order/payments/0/type", + }, + enum: [ + "PRE-FULFILLMENT", + "ON-FULFILLMENT", + "POST-FULFILLMENT", + ], + }, + collected_by: { + type: "string", + const: { + $data: + "/on_confirm/0/message/order/payments/0/collected_by", + }, + enum: ["BAP", "BPP"], + }, + "@ondc/org/buyer_app_finder_fee_type": { + type: "string", + }, + "@ondc/org/buyer_app_finder_fee_amount": { + type: "string", + }, + "@ondc/org/settlement_details": { + type: "array", + items: { + type: "object", + properties: { + settlement_counterparty: { + type: "string", + enum: ["seller-app", "buyer-app"], + }, + settlement_phase: { + type: "string", + }, + settlement_type: { + type: "string", + enum: ["upi", "neft", "rtgs"], + }, + beneficiary_name: { + type: "string", + }, + upi_address: { + type: "string", + }, + settlement_bank_account_no: { + type: "string", + }, + settlement_ifsc_code: { + type: "string", + }, + bank_name: { + type: "string", + }, + branch_name: { + type: "string", + }, + }, + allOf: [ + { + if: { + properties: { + settlement_type: { + const: "upi", + }, + }, + }, + then: { + required: ["upi_address"], + }, + }, + { + if: { + properties: { + settlement_type: { + const: ["neft", "rtgs"], + }, + }, + }, + then: { + required: [ + "settlement_ifsc_code", + "settlement_bank_account_no", + ], + }, + }, + ], + required: ["settlement_counterparty", "settlement_type"], + }, + }, + }, + if: { properties: { type: { const: "ON-FULFILLMENT" } } }, + then: { + properties: { + collected_by: { + const: "BPP", + }, + }, + }, + required: [ + "params", + "status", + "type", + "collected_by", + "@ondc/org/buyer_app_finder_fee_type", + "@ondc/org/buyer_app_finder_fee_amount", + ], + }, + }, + + documents: { + type: "array", + items: { + type: "object", + properties: { + url: { + type: "string", + }, + label: { + type: "string", + }, + }, + required: ["url", "label"], + }, + }, + created_at: { + type: "string", + format: "date-time", + const: { $data: "/confirm/0/message/order/created_at" }, + errorMessage: + "order/created_at should remain same as in /confirm - ${/confirm/0/message/order/created_at}", + }, + updated_at: { + type: "string", + format: "date-time", + }, + }, + additionalProperties: false, + required: [ + "id", + "state", + "provider", + "items", + "billing", + "fulfillments", + "quote", + "payments", + "documents", + "created_at", + "updated_at", + ], + }, + }, + required: ["order"], + }, + }, + + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_update.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_update.js new file mode 100644 index 0000000..1301497 --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_update.js @@ -0,0 +1,543 @@ +module.exports = { + $id: "http://example.com/schema/onUpdateSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "on_update", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/select/0/context/transaction_id" }, + }, + message_id: { + type: "string", + const: { $data: "/update/0/context/message_id" }, + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/confirm/0/message/order/id" }, + }, + state: { + type: "string", + enum: ["Created", "Accepted", "In-progress"], + }, + provider: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/init/0/message/order/provider/id" }, + }, + }, + required: ["id"], + }, + items: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + quantity: { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + fulfillment_ids: { + type: "array", + items: { + type: "string", + }, + }, + }, + required: ["id", "quantity", "fulfillment_ids"], + }, + }, + payment: { + type: "object", + properties: { + uri: { + type: "string", + }, + tl_method: { + type: "string", + }, + params: { + type: "object", + properties: { + currency: { + type: "string", + }, + transaction_id: { + type: "string", + }, + amount: { + type: "string", + }, + }, + required: ["currency", "amount"], + }, + status: { + type: "string", + enum: ["PAID", "NOT-PAID"], + }, + type: { + type: "string", + enum: [ + "PRE-FULFILLMENT", + "ON-FULFILLMENT", + "POST-FULFILLMENT", + ], + }, + collected_by: { + type: "string", + enum: ["BAP", "BPP"], + }, + "@ondc/org/buyer_app_finder_fee_type": { + type: "string", + }, + "@ondc/org/buyer_app_finder_fee_amount": { + type: "string", + }, + "@ondc/org/settlement_details": { + type: "array", + items: { + type: "object", + properties: { + settlement_counterparty: { + type: "string", + enum: ["seller-app", "buyer-app"], + }, + settlement_phase: { + type: "string", + }, + settlement_type: { + type: "string", + enum: ["upi", "neft", "rtgs"], + }, + beneficiary_name: { + type: "string", + }, + upi_address: { + type: "string", + }, + settlement_bank_account_no: { + type: "string", + }, + settlement_ifsc_code: { + type: "string", + }, + bank_name: { + type: "string", + }, + branch_name: { + type: "string", + }, + }, + allOf: [ + { + if: { + properties: { + settlement_type: { + const: "upi", + }, + }, + }, + then: { + required: ["upi_address"], + }, + }, + { + if: { + properties: { + settlement_type: { + const: ["neft", "rtgs"], + }, + }, + }, + then: { + required: [ + "settlement_ifsc_code", + "settlement_bank_account_no", + ], + }, + }, + ], + required: ["settlement_counterparty", "settlement_type"], + }, + }, + }, + if: { properties: { type: { const: "ON-FULFILLMENT" } } }, + then: { + properties: { + collected_by: { + const: "BPP", + }, + }, + }, + required: [ + "params", + "status", + "type", + "collected_by", + "@ondc/org/buyer_app_finder_fee_type", + "@ondc/org/buyer_app_finder_fee_amount", + ], + }, + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + "@ondc/org/provider_name": { + type: "string", + }, + state: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: [ + "Pending", + "Out-for-pickup", + "Order-picked-up", + "In-transit", + "At-destination-hub", + "Out-for-delivery", + "Order-delivered", + ], + }, + }, + required: ["code"], + }, + }, + required: ["descriptor"], + }, + type: { + type: "string", + }, + tracking: { + type: "boolean", + }, + stops: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + }, + location: { + type: "object", + properties: { + id: { + type: "string", + }, + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + gps: { + type: "string", + }, + address: { + type: "string", + }, + city: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + area_code: { + type: "string", + }, + state: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + }, + required: [], + }, + time: { + type: "object", + properties: { + range: { + type: "object", + properties: { + start: { + type: "string", + pattern: + "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", + errorMessage: + "should be in RFC 3339 (YYYY-MM-DDTHH:MN:SS.MSSZ) Format", + }, + end: { + type: "string", + pattern: + "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", + errorMessage: + "should be in RFC 3339 (YYYY-MM-DDTHH:MN:SS.MSSZ) Format", + }, + }, + required: ["start", "end"], + }, + }, + required: ["range"], + }, + instructions: { + type: "object", + properties: { + name: { + type: "string", + }, + short_desc: { + type: "string", + }, + }, + required: ["name", "short_desc"], + }, + contact: { + type: "object", + properties: { + phone: { + type: "string", + }, + email: { + type: "string", + }, + }, + required: ["phone", "email"], + }, + }, + required: [ + "type", + "location", + "time", + "instructions", + "contact", + ], + }, + }, + rateable: { + type: "boolean", + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["ITEM_DETAILS"], + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: [ + "ITEM_ID", + "COUNT", + "MEASURE_UNIT", + "MEASURE_VALUE", + ], + }, + }, + required: ["code"], + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: [ + "id", + "@ondc/org/provider_name", + "state", + "type", + "stops", + ], + }, + }, + }, + + required: ["id", "state", "provider", "items"], + }, + }, + required: ["order"], + }, + search: { + type: "array", + items: { + $ref: "searchSchema#", + }, + }, + on_search: { + type: "array", + items: { + $ref: "onSearchSchema#", + }, + }, + init: { + type: "array", + items: { + $ref: "initSchema#", + }, + }, + on_init: { + type: "array", + items: { + $ref: "onInitSchema#", + }, + }, + confirm: { + type: "array", + items: { + $ref: "confirmSchema#", + }, + }, + on_confirm: { + type: "array", + items: { + $ref: "onConfirmSchema#", + }, + }, + update: { + type: "array", + items: { + $ref: "updateSchema#", + }, + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/search.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/search.js new file mode 100644 index 0000000..a10ad82 --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/search.js @@ -0,0 +1,262 @@ +module.exports = { + $id: "http://example.com/schema/searchSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "search", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + transaction_id: { + type: "string", + }, + message_id: { + type: "string", + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + const: "PT30S", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + intent: { + type: "object", + properties: { + item: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + category: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + }, + fulfillment: { + type: "object", + properties: { + type: { + type: "string", + enum: ["Delivery", "Self-Pickup", "Delivery and Self-Pickup"], + }, + stops: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + }, + location: { + type: "object", + properties: { + gps: { + type: "string", + }, + area_code: { + type: "string", + }, + }, + required: ["gps", "area_code"], + }, + }, + required: ["type", "location"], + }, + }, + }, + required: ["type", "stops"], + }, + payment: { + type: "object", + properties: { + type: { + type: "string", + enum: [ + "PRE-FULFILLMENT", + "ON-FULFILLMENT", + "POST-FULFILLMENT", + ], + }, + }, + required: ["type"], + }, + tags: { + type: "array", + minItems: 2, + uniqueItems: true, + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: ["bap_terms", "buyer_id"], + }, + }, + required:["code"] + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + }, + }, + required:["code"] + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + minItems: 2, + }, + }, + required: ["descriptor", "list"], + if: { + properties: { + descriptor: { + properties: { code: { const: "bap_terms" } }, + }, + }, + }, + then: { + properties: { + list: { + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + enum: ["finder_fee_type", "finder_fee_amount"], + }, + }, + }, + }, + required: ["descriptor"], + }, + }, + }, + errorMessage: + "For 'bap_terms', the 'list' must contain either 'finder_fee_type' or 'finder_fee_amount'.", + }, + else: { + if: { + properties: { + descriptor: { + properties: { code: { const: "buyer_id" } }, + }, + }, + }, + then: { + properties: { + list: { + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + enum: ["buyer_id_code", "buyer_id_no"], + }, + }, + }, + }, + required: ["descriptor"], + }, + }, + }, + errorMessage: + "For 'buyer_id', the 'list' must contain either 'buyer_id_code' or 'buyer_id_no'.", + }, + }, + }, + }, + }, + additionalProperties:false, + required: ["item", "fulfillment", "payment", "tags"], + }, + }, + required: ["intent"], + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/select.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/select.js new file mode 100644 index 0000000..444749f --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/select.js @@ -0,0 +1,432 @@ +module.exports = { + $id: "http://example.com/schema/selectSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "select", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/search/0/context/transaction_id" }, + errorMessage: + "Transaction ID should be same across the transaction: ${/search/0/context/transaction_id}", + }, + message_id: { + type: "string", + allOf: [ + { + not: { + const: { $data: "1/transaction_id" }, + }, + errorMessage: + "Message ID should not be equal to transaction_id: ${1/transaction_id}", + }, + ], + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + const: { $data: "2/message/order/provider/ttl" }, + errorMessage: + "should match provider ttl - ${2/message/order/provider/ttl}", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order: { + type: "object", + properties: { + provider: { + type: "object", + properties: { + id: { + type: "string", + }, + locations: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + ttl: { + type: "string", + format: "duration", + }, + }, + required: ["id", "locations"], + }, + items: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + location_ids: { + type: "array", + items: { + type: "string", + }, + }, + quantity: { + type: "object", + properties: { + selected: { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + }, + required: ["selected"], + }, + "add-ons": { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["BUYER_TERMS"], + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["ITEM_REQ", "PACKAGING_REQ"], + }, + }, + required: ["code"], + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: ["id", "location_ids", "quantity"], + }, + }, + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + stops: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + }, + location: { + type: "object", + properties: { + gps: { + type: "string", + pattern: + "^(-?[0-9]{1,3}(?:.[0-9]{6,15})?),( )*?(-?[0-9]{1,3}(?:.[0-9]{6,15})?)$", + errorMessage: "Incorrect gps value", + }, + area_code: { + type: "string", + }, + }, + required: ["gps", "area_code"], + }, + }, + required: ["type", "location"], + }, + }, + customer: { + type: "object", + properties: { + person: { + type: "object", + properties: { + creds: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + type: { + type: "string", + enum: [ + "License", + "Badge", + "Permit", + "Certificate", + ], + }, + desc: { + type: "string", + }, + icon: { + type: "string", + }, + url: { + type: "string", + pattern: + "^https://[\\w.-]+(\\.[a-zA-Z]{2,})?(:[0-9]+)?(/\\S*)?$", + }, + }, + required: ["id", "type", "desc", "url"], + }, + }, + }, + required: ["creds"], + }, + }, + required: ["person"], + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["DELIVERY_TERMS"], + }, + }, + required: ["code"], + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: [ + "INCOTERMS", + "NAMED_PLACE_OF_DELIVERY", + ], + }, + }, + required: ["code"], + }, + value: { + type: "string", + }, + }, + if: { + properties: { + descriptor: { + properties: { code: { const: "INCOTERMS" } }, + }, + }, + }, + then: { + properties: { + value: { + enum: [ + "DPU", + "CIF", + "EXW", + "FOB", + "DAP", + "DDP", + ], + }, + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + required: ["stops"], + }, + }, + payments: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + enum: [ + "PRE-FULFILLMENT", + "ON-FULFILLMENT", + "POST-FULFILLMENT", + ], + }, + }, + required: ["type"], + }, + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: ["buyer_id", "COMM_CHANNEL"], + }, + }, + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: [ + "buyer_id_code", + "buyer_id_no", + "chat_url", + ], + }, + }, + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + additionalProperties: false, + required: ["provider", "items", "fulfillments", "payments", "tags"], + }, + }, + required: ["order"], + additionalProperties: false, + }, + }, + required: ["context", "message"], + additionalProperties: false, +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/status.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/status.js new file mode 100644 index 0000000..387a6fe --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/status.js @@ -0,0 +1,107 @@ +module.exports = { + $id: "http://example.com/schema/statusSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/on_confirm/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/on_confirm/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "status", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/on_confirm/0/context/transaction_id" }, + }, + message_id: { + type: "string", + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + const: "PT30S", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order_id: { + type: "string", + const: { $data: "/on_confirm/0/message/order/id" }, + }, + }, + additionalProperties:false, + required: ["order_id"], + }, + on_confirm: { + type: "array", + items: { + $ref: "onConfirmSchema#", + }, + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/update.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/update.js new file mode 100644 index 0000000..2067cf4 --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/update.js @@ -0,0 +1,333 @@ +module.exports = { + $id: "http://example.com/schema/updateSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "update", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/select/0/context/transaction_id" }, + }, + message_id: { + type: "string", + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + const: "PT30S", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + update_target: { + type: "string", + enum:["fulfillment","item"] + }, + order: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/confirm/0/message/order/id" }, + }, + state: { + type: "string", + }, + provider: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/select/0/message/order/provider/id" }, + }, + }, + required: ["id"], + }, + items: { + type: "array", + items: + { + type: "object", + properties: { + id: { + type: "string", + }, + quantity: { + type: "object", + properties: { + selected: { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + }, + required: ["selected"], + }, + }, + required: ["id", "quantity"], + }, + + }, + payments: { + type: "array", + items: + { + type: "object", + properties: { + uri: { + type: "string", + }, + tl_method: { + type: "string", + }, + params: { + type: "object", + properties: { + currency: { + type: "string", + }, + transaction_id: { + type: "string", + }, + amount: { + type: "string", + }, + }, + required: ["currency", "amount"], + }, + status: { + type: "string", + enum: ["PAID", "NOT-PAID"], + }, + type: { + type: "string", + enum: [ + "PRE-FULFILLMENT", + "ON-FULFILLMENT", + "POST-FULFILLMENT", + ], + }, + collected_by: { + type: "string", + }, + "@ondc/org/buyer_app_finder_fee_type": { + type: "string", + }, + "@ondc/org/buyer_app_finder_fee_amount": { + type: "string", + }, + "@ondc/org/settlement_details": { + type: "array", + items: + { + type: "object", + properties: { + settlement_counterparty: { + type: "string", + }, + settlement_phase: { + type: "string", + }, + settlement_type: { + type: "string", + }, + upi_address: { + type: "string", + }, + settlement_bank_account_no: { + type: "string", + }, + settlement_ifsc_code: { + type: "string", + }, + beneficiary_name: { + type: "string", + }, + bank_name: { + type: "string", + }, + branch_name: { + type: "string", + }, + }, + allOf: [ + { + if: { + properties: { + settlement_type: { + const: "upi", + }, + }, + }, + then: { + required: ["upi_address"], + }, + }, + { + if: { + properties: { + settlement_type: { + const: ["neft", "rtgs"], + }, + }, + }, + then: { + required: [ + "settlement_ifsc_code", + "settlement_bank_account_no", + ], + }, + }, + ], + required: [ + "settlement_counterparty", + "settlement_type", + ], + }, + + }, + }, + required: [ + "uri", + "tl_method", + "params", + "status", + "type", + "collected_by", + "@ondc/org/buyer_app_finder_fee_type", + "@ondc/org/buyer_app_finder_fee_amount", + ], + }, + + }, + }, + additionalProperties:false, + required: ["id", "state", "provider", "items", "payments"], + }, + }, + required: ["update_target", "order"], + }, + search: { + type: "array", + items: { + $ref: "searchSchema#", + }, + }, + on_search: { + type: "array", + items: { + $ref: "onSearchSchema#", + }, + }, + select: { + type: "array", + items: { + $ref: "selectSchema#", + }, + }, + on_select: { + type: "array", + items: { + $ref: "onSelectSchema#", + }, + }, + init: { + type: "array", + items: { + $ref: "initSchema#", + }, + }, + on_init: { + type: "array", + items: { + $ref: "onInitSchema#", + }, + }, + confirm: { + type: "array", + items: { + $ref: "confirmSchema#", + }, + }, + on_confirm: { + type: "array", + items: { + $ref: "onConfirmSchema#", + }, + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/confirmSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/confirmSchema.js index 55f5a4c..5700fdc 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/confirmSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/confirmSchema.js @@ -87,6 +87,15 @@ module.exports = { properties: { id: { type: "string", + allOf: [ + { + not: { + const: { $data: "3/context/transaction_id" }, + }, + errorMessage: + "should be unique and not be equal to transaction_id: ${3/context/transaction_id}", + }, + ], }, state: { type: "string", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/initSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/initSchema.js index 51e46f8..6844f48 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/initSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/initSchema.js @@ -335,7 +335,6 @@ module.exports = { }, additionalProperties: false, isLengthValid:true, - errorMessage:"name + building + locality < 190 chars", required: [ "name", "building", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/onStatusSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/onStatusSchema.js index fb38da1..d9c2783 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/onStatusSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/onStatusSchema.js @@ -202,8 +202,7 @@ module.exports = { }, }, isQuoteMatching: true, - errorMessage: - "price is not matching with the total breakup price", + required: ["price", "breakup"], }, fulfillments: { @@ -394,7 +393,7 @@ module.exports = { }, }, if: { properties: { type: { const: "Prepaid" } } }, - then: { required: ["type", "state", "tracking"] }, + then: { required: ["type", "state", "tracking","start","end"] }, else: { required: ["type", "state"], }, diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/searchSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/searchSchema.js index fd47ce2..e1a8a1b 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/searchSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.1/searchSchema.js @@ -139,7 +139,6 @@ module.exports = { }, }, isEndTimeGreater: true, - errorMessage: 'The "end" time must be greater than the "start" time. Ref footnote 12 of v1.1 .', required: ["start", "end"], }, }, @@ -243,7 +242,7 @@ module.exports = { type: "string", }, }, - required: ["@ondc/org/collection_amount"], + required: [], }, "@ondc/org/payload_details": { type: "object", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/common/commonSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/common/commonSchema.js index 9a9ed5a..2d0b76e 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/common/commonSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/common/commonSchema.js @@ -55,7 +55,6 @@ module.exports = { }, }, isLengthValid: true, - errorMessage: "name + building + locality < 190 chars", }, }, required: ["gps", "address"], diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/confirmSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/confirmSchema.js index 5f77fae..c2ac4e6 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/confirmSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/confirmSchema.js @@ -88,6 +88,15 @@ module.exports = { properties: { id: { type: "string", + allOf: [ + { + not: { + const: { $data: "3/context/transaction_id" }, + }, + errorMessage: + "should be unique and not be equal to transaction_id: ${3/context/transaction_id}", + }, + ], }, state: { type: "string", @@ -303,7 +312,7 @@ module.exports = { }, duration: { type: "string", - format: "duration" + format: "duration", }, location: { type: "object", @@ -583,7 +592,7 @@ module.exports = { "both 'state' and 'rto_action' tags are required", }, }, - + additionalProperties: false, required: ["id", "type", "start", "end", "tags"], }, }, @@ -1021,8 +1030,40 @@ module.exports = { type: "string", format: "date-time", }, - }, + tags: { + type: "array", + items: { + type: "object", + properties: { + code: { + type: "string", + enum: constants.TERMS, + + }, + list: { + type: "array", + items: { + type: "object", + properties: { + code: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["code", "value"], + }, + }, + }, + required: ["code", "list"], + }, + minItems: 2, + errorMessage: "both 'bpp_terms' and 'bap_terms' tags are required (logistics buyer NP must accept LSP terms. If not accepted, LSP can NACK /confirm with error code 65002)", + }, + }, + additionalProperties: false, required: [ "id", "state", @@ -1042,7 +1083,6 @@ module.exports = { }, }, // isFutureDated: true, - // errorMessage: - // "order/created_at or order/updated_at cannot be future dated w.r.t context/timestamp", + required: ["context", "message"], }; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/initSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/initSchema.js index 7ac6ff0..0721b13 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/initSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/initSchema.js @@ -197,7 +197,7 @@ module.exports = { }, }, isLengthValid:true, - errorMessage:"name + building + locality < 190 chars", + required: [ "name", "building", @@ -275,7 +275,7 @@ module.exports = { }, }, isLengthValid:true, - errorMessage:"name + building + locality < 190 chars", + required: [ "name", "building", @@ -346,7 +346,6 @@ module.exports = { }, }, isLengthValid: true, - errorMessage: "name + building + locality < 190 chars", additionalProperties: false, required: [ "name", @@ -460,6 +459,7 @@ module.exports = { errorMessage:"should be same as in /search - ${/search/0/message/intent/payment/type}" }, }, + additionalProperties:false, required: ["type"], }, }, diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/keywords/onInit.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/keywords/onInit.js index 172c10e..af5d333 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/keywords/onInit.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/keywords/onInit.js @@ -1,12 +1,14 @@ module.exports = { isQuoteMatching: (data) => { - const quotePrice = parseFloat(data?.price?.value); + let quotePrice = parseFloat(data?.price?.value); const breakupArr = data.breakup; let totalBreakup = 0; breakupArr.forEach((breakup) => { totalBreakup += parseFloat(breakup?.price?.value); }); // console.log(quotePrice,totalBreakup); + totalBreakup= parseFloat(totalBreakup).toFixed(2) + quotePrice=quotePrice.toFixed(2) if (quotePrice != totalBreakup) return false; else return true; }, diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onCancelSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onCancelSchema.js index 860fa2d..79705df 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onCancelSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onCancelSchema.js @@ -195,8 +195,7 @@ module.exports = { }, required: ["price", "breakup"], isQuoteMatching: true, - errorMessage: - "price is not matching with the total breakup price", + }, fulfillments: { @@ -340,8 +339,7 @@ module.exports = { }, }, isLengthValid: true, - errorMessage: - "name + building + locality < 190 chars", + }, }, required: ["gps", "address"], @@ -462,8 +460,7 @@ module.exports = { }, }, isLengthValid: true, - errorMessage: - "name + building + locality < 190 chars", + }, }, required: ["gps", "address"], @@ -541,14 +538,14 @@ module.exports = { properties: { time: { required: ["range"] }, }, - required: ["time", "person", "location", "contact"], + required: [ "person", "location", "contact"], }, end: { properties: { time: { required: ["range"] }, }, - required: ["time", "person", "location", "contact"], + required: ["person", "location", "contact"], }, }, required: ["id", "type", "state", "start", "end", "tracking"], @@ -717,6 +714,6 @@ module.exports = { }, }, // isFutureDated: true, - // errorMessage: "order/created_at or order/updated_at cannot be future dated w.r.t context/timestamp", + required: ["context", "message"], }; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onInitSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onInitSchema.js index a372264..7b1e2fc 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onInitSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onInitSchema.js @@ -187,8 +187,7 @@ module.exports = { }, required: ["price", "breakup", "ttl"], isQuoteMatching: true, - errorMessage: - "price is not matching with the total breakup price", + }, fulfillments: { type: "array", @@ -356,6 +355,8 @@ module.exports = { type: { type: "string", enum: constants.PAYMENT_TYPE, + const: { $data: "/search/0/message/intent/payment/type" }, + errorMessage:"does not match the intended payment type by the logistics buyer" }, collected_by: { type: "string", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onSearchSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onSearchSchema.js index 203bb8c..71dd9a7 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onSearchSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onSearchSchema.js @@ -301,6 +301,7 @@ module.exports = { required: ["label", "duration", "timestamp"], }, }, + additionalProperties:false, required: [ "id", "category_id", @@ -322,7 +323,53 @@ module.exports = { type: "string", enum: constants.FULFILLMENT_TYPE, }, + start: { + type: "object", + properties: { + time: { + type: "object", + properties: { + duration: { + type: "string", + }, + }, + required: ["duration"], + }, + }, + required: ["time"], + }, + tags: { + type: "array", + items: { + type: "object", + properties: { + code: { + type: "string", + enum: ["distance"] + }, + list: { + type: "array", + items: { + type: "object", + properties: { + code: { + type: "string", + enum: ["motorable_distance_type","motorable_distance"] + }, + value: { + type: "string", + }, + }, + required: ["code", "value"], + }, + }, + }, + + required: ["code", "list"], + }, + }, }, + additionalProperties:false, required: ["id", "type"], }, }, diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onStatusSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onStatusSchema.js index 348df28..0b7fbf5 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onStatusSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onStatusSchema.js @@ -199,8 +199,7 @@ module.exports = { }, required: ["price", "breakup"], isQuoteMatching: true, - errorMessage: - "price is not matching with the total breakup price", + }, fulfillments: { type: "array", @@ -340,8 +339,7 @@ module.exports = { }, }, isLengthValid: true, - errorMessage: - "name + building + locality < 190 chars", + }, }, required: ["gps", "address"], @@ -467,8 +465,7 @@ module.exports = { }, }, isLengthValid: true, - errorMessage: - "name + building + locality < 190 chars", + }, }, required: ["gps", "address"], diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onUpdateSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onUpdateSchema.js index aad1d92..ab0a17a 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onUpdateSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onUpdateSchema.js @@ -259,7 +259,7 @@ module.exports = { }, }, - required: ["code", "short_desc"], + required: [], allOf: [ { if: { properties: { code: { const: "1" } } }, diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/searchSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/searchSchema.js index 3c7def9..a750922 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/searchSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/searchSchema.js @@ -122,8 +122,6 @@ module.exports = { }, }, isEndTimeGreater: true, - errorMessage: - 'The "end" time must be greater than the "start" time', required: ["start", "end"], }, }, diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/updateSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/updateSchema.js index 34098a6..209fc5f 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/updateSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/updateSchema.js @@ -326,13 +326,12 @@ module.exports = { format: "date-time", }, }, - + additionalProperties:false, required: ["id", "items", "fulfillments", "updated_at"], }, }, required: ["update_target", "order"], }, }, - required: ["context", "message"], }; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/main.js b/utilities/logistics-b2b/log-verification-utility/schema/main.js index 3abb175..cc7470e 100755 --- a/utilities/logistics-b2b/log-verification-utility/schema/main.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/main.js @@ -9,13 +9,15 @@ const { const fs = require("fs"); const validate_schema_for_domain_json = (vertical, data, version) => { - version = getVersion(data); + version = getVersion(data,vertical); switch (vertical) { case "logistics": + res = validate_schema_master(data, version); return res; case "b2b": - res = validate_schema_b2b_master(data); + + res = validate_schema_b2b_master(data,version); return res; default: console.log("Invalid Domain!!"); diff --git a/utilities/logistics-b2b/log-verification-utility/utils/ContextVal.js b/utilities/logistics-b2b/log-verification-utility/utils/ContextVal.js index 7d0ceb7..11175d7 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/ContextVal.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/ContextVal.js @@ -14,9 +14,8 @@ const checkContextVal = (payload, msgIdSet, i) => { let Obj = {}; let data = payload.context; let domain = payload.context.domain; - let maxTimeDiff = 0; - if (domain === "ONDC:RET10") { - maxTimeDiff = 5000; + let maxTimeDiff = 5000; + if (domain === "ONDC:RET10" && payload?.context?.version === "2.0.1") { if (action === "init") { maxTimeDiff = utils.iso8601DurationToSeconds(payload.context.ttl); dao.setValue("maxTimeDiff", maxTimeDiff); @@ -25,6 +24,16 @@ const checkContextVal = (payload, msgIdSet, i) => { } } else if (domain === "nic2004:60232") { maxTimeDiff = 1000; + } else if ( + domain === "ONDC:RET10" && + payload?.context?.version === "2.0.2" + ) { + if (action === "select") { + maxTimeDiff = utils.iso8601DurationToSeconds(payload.context.ttl); + dao.setValue("maxTimeDiff", maxTimeDiff); + } else if (action === "on_select") { + maxTimeDiff = dao.getValue("maxTimeDiff"); + } } console.log("time difference", maxTimeDiff); @@ -88,6 +97,7 @@ const checkContextVal = (payload, msgIdSet, i) => { } else { if ( action === "on_search" || + action === "on_select" || action === "on_init" || action === "on_confirm" || action === "on_update" diff --git a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bInit.js b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bInit.js index d63e0cb..b7cc0ce 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bInit.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bInit.js @@ -36,11 +36,14 @@ const checkInit = (data, msgIdSet) => { if (providerLocArr) { providerLocArr.forEach((location, i) => { - providerObj[0]?.locations?.forEach((element) => { - console.log(location.id, element.id); + if (providerObj) { + providerObj[0]?.locations?.forEach((element) => { + console.log(location.id, element.id); + + if (location.id === element.id) providerLocExists = true; + }); + } - if (location.id === element.id) providerLocExists = true; - }); if (!providerLocExists) { let itemkey = `providerLocErr${i}`; initObj[ @@ -66,10 +69,12 @@ const checkInit = (data, msgIdSet) => { let itemExists = false; itemsArr.forEach((item, i) => { - onSearchitemsArr.forEach((element) => { - if (item.id === element.id) itemExists = true; - console.log(item.id, element.id); - }); + if (onSearchitemsArr) { + onSearchitemsArr.forEach((element) => { + if (item.id === element.id) itemExists = true; + }); + } + if (!itemExists) { let itemkey = `itemErr${i}`; initObj[itemkey] = `Item Id '${item.id}' does not exist in /on_search`; diff --git a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSearch.js b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSearch.js index a4dd00b..32ee952 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSearch.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSearch.js @@ -7,6 +7,7 @@ const { reverseGeoCodingCheck } = require("../reverseGeoCoding"); const checkOnSearch = async (data, msgIdSet) => { const onSrchObj = {}; let onSearch = data; + let domain = onSearch.context.domain; onSearch = onSearch.message.catalog; try { @@ -49,6 +50,38 @@ const checkOnSearch = async (data, msgIdSet) => { } } } + + //checking mandatory attributes for fashion and electronics + + provider.items.forEach((item) => { + let itemTags = item?.tags; + let mandatoryAttr; + + if (domain === "ONDC:RET12") { + mandatoryAttr = constants.FASHION_ATTRIBUTES; + } + if (domain === "ONDC:RET14") { + mandatoryAttr = constants.ELECTRONICS_ATTRIBUTES; + } + itemTags.map(({ descriptor, list }, index) => { + switch (descriptor.code) { + case "attribute": + const encounteredAttr = []; + list.map(({ descriptor, value }) => { + encounteredAttr.push(descriptor.code); + }); + + // Check if all mandatory attributes are encountered + const missingAttr = mandatoryAttr.filter( + (code) => !encounteredAttr.includes(code) + ); + if (missingAttr.length > 0) { + onSrchObj.mssngAttrErr = `'${missingAttr}' attribute/s required in items/tags for ${domain} domain`; + } + break; + } + }); + }); } } diff --git a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnStatus.js b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnStatus.js index 6facef2..30585b6 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnStatus.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnStatus.js @@ -107,12 +107,12 @@ const checkOnStatus = (data, msgIdSet) => { fulfillment.stops.forEach((stop) => { if (stop.type === "start") { pickupTime = stop?.time?.timestamp; - dao.setValue("pickupTime", pickupTime); + if (!pickupTime) { onStatusObj.pickupTimeErr = `Pickup timestamp (fulfillments/start/time/timestamp) is required for fulfillment state - ${ffState}`; } else if ( dao.getValue("pickupTime") && - fulfillment?.start?.time?.timestamp !== + pickupTime !== dao.getValue("pickupTime") ) { onStatusObj.pickupTimeErr = `Pickup timestamp (fulfillments/start/time/timestamp) cannot change for fulfillment state - ${ffState}`; @@ -135,12 +135,11 @@ const checkOnStatus = (data, msgIdSet) => { fulfillment.stops.forEach((stop) => { if (stop.type === "start") { pickupTime = stop?.time?.timestamp; - dao.setValue("pickupTime", pickupTime); if (!pickupTime) { onStatusObj.pickupTimeErr = `Pickup timestamp (fulfillments/start/time/timestamp) is required for fulfillment state - ${ffState}`; } else if ( dao.getValue("pickupTime") && - fulfillment?.start?.time?.timestamp !== + pickupTime !== dao.getValue("pickupTime") ) { onStatusObj.pickupTimeErr = `Pickup timestamp (fulfillments/start/time/timestamp) cannot change for fulfillment state - ${ffState}`; diff --git a/utilities/logistics-b2b/log-verification-utility/utils/constants.js b/utilities/logistics-b2b/log-verification-utility/utils/constants.js index 5e039d0..56c887f 100755 --- a/utilities/logistics-b2b/log-verification-utility/utils/constants.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/constants.js @@ -133,6 +133,7 @@ module.exports = Object.freeze({ "004", "005", "006", + "007", "008", "009", "010", @@ -167,5 +168,8 @@ module.exports = Object.freeze({ "RTO-Disposed", "Cancelled", ], - CANCELLATION_TAGS_LIST:["retry_count","rto_id","cancellation_reason_id","sub_reason_id","cancelled_by"] + CANCELLATION_TAGS_LIST:["retry_count","rto_id","cancellation_reason_id","sub_reason_id","cancelled_by"], + FASHION_ATTRIBUTES : ["brand","colour","size","gender","material"], + ELECTRONICS_ATTRIBUTES: ["brand","model"], + TERMS:["bap_terms","bpp_terms"] }); diff --git a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logConfirm.js b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logConfirm.js index 72d9b7f..5b91a63 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logConfirm.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logConfirm.js @@ -72,10 +72,10 @@ const checkConfirm = (data, msgIdSet) => { let p2h2p = dao.getValue("p2h2p"); fulfillments.forEach((fulfillment) => { - let avgPickupTime= fulfillment.start.time.duration; + let avgPickupTime= fulfillment?.start?.time?.duration; - if(avgPickupTime!==dao.getValue("avgPickupTime")){ - cnfrmObj.avgPckupErr=`Average Pickup Time mismatches from the one provided in /on_search` + if(avgPickupTime && avgPickupTime!==dao.getValue("avgPickupTime")){ + cnfrmObj.avgPckupErr=`Average Pickup Time (fulfillments/start/time/duration) mismatches from the one provided in /on_search` } if (fulfillment["@ondc/org/awb_no"] && p2h2p) awbNo = true; if (rts === "yes" && !fulfillment?.start?.instructions?.short_desc) { diff --git a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logInit.js b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logInit.js index 4907554..93cdc26 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logInit.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logInit.js @@ -77,7 +77,6 @@ const checkInit = (data, msgIdSet) => { } onSearchitemsArr?.forEach((element) => { if (item.id === element.id) itemExists = true; - console.log(item.id, element.id); }); if (!itemExists) { let itemkey = `itemErr${i}`; @@ -86,7 +85,10 @@ const checkInit = (data, msgIdSet) => { let itemObj = onSearchitemsArr.filter( (element) => item.id === element.id ); + itemObj = itemObj[0]; + dao.setValue("selectedItem",itemObj.id) + console.log(itemObj.id); if (item.category_id != itemObj.category_id) { let itemkey = `catIdErr${i}`; initObj[ diff --git a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnCancel.js b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnCancel.js index 731db03..1dbeee1 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnCancel.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnCancel.js @@ -9,8 +9,10 @@ const checkOnCancel = (data, msgIdSet) => { let contextTime = on_cancel.context.timestamp; let version = on_cancel.context.core_version; let messageId = on_cancel.context.message_id; + const providerId = on_cancel.message?.provider?.id; on_cancel = on_cancel.message.order; + let onSearchItemsArr = dao.getValue(`${on_cancel?.provider?.id}itemsArr`); let ffState; let orderState = on_cancel.state; let items = on_cancel.items; @@ -42,6 +44,13 @@ const checkOnCancel = (data, msgIdSet) => { } catch (error) { console.log(error); } + if (onSearchItemsArr) { + let selectedItem = onSearchItemsArr.filter( + (element) => element.parent_item_id === dao.getValue("selectedItem") + ); + selectedItem = selectedItem[0]; + } + try { fulfillments.forEach((fulfillment) => { ffState = fulfillment?.state?.descriptor?.code; @@ -63,9 +72,7 @@ const checkOnCancel = (data, msgIdSet) => { onCancelObj.msngPickupTimeErr = `Pickup timestamp (fulfillments/start/time/timestamp) is missing for fulfillment state - ${ffState}`; } } - if(fulfillment.tracking===true){ - onStatusObj.trackErr=`fulfillment tracking can be disabled (false) after the fulfillment is 'Cancelled` - } + if (fulfillment.start.time.timestamp && dao.getValue("pickupTime")) { if ( !_.isEqual( @@ -76,9 +83,17 @@ const checkOnCancel = (data, msgIdSet) => { onCancelObj.pickupTimeErr = `Pickup timestamp (fulfillments/start/time/timestamp) cannot change for fulfillment state - ${ffState}`; } } - console.log('comparing RTO fulfillment id with /on_search'); + console.log("comparing RTO fulfillment id with /on_search"); //checking RTO id matching with /on_search if (version === "1.2.0") { + if (dao.getValue("rts") === "yes") { + if (!fulfillment?.start?.time) { + onCancelObj.msngStrtTime = `Pickup time range (fulfillments/start/time) is missing`; + } + if (!fulfillment?.end?.time) { + onCancelObj.msngDlvryTime = `Delivery time range (fulfillments/end/time) is missing`; + } + } let fulTags = fulfillment?.tags; let rtoID; fulTags.forEach((tag) => { @@ -87,8 +102,9 @@ const checkOnCancel = (data, msgIdSet) => { lists.forEach((list) => { if (list.code === "rto_id") { rtoID = list.value; - if (rtoID !== dao.getValue("rtoID")) { - onCancelObj.rtoIdTagsErr = `rto_id '${rtoID}' in fulfillments/tags does not match with the one provided in on_search '${dao.getValue("rtoID")}' in /fulfillments`; + + if (rtoID !== selectedItem.fulfillment_id) { + onCancelObj.rtoIdTagsErr = `rto_id '${rtoID}' in fulfillments/tags does not match with the one provided in on_search '${selectedItem.fulfillment_id}' in /fulfillments`; } } }); @@ -100,9 +116,9 @@ const checkOnCancel = (data, msgIdSet) => { if (orderState !== "Cancelled") { onCancelObj.ordrStatErr = `Order state should be 'Cancelled' for fulfillment state - ${ffState}`; } - console.log(fulfillment.id,dao.getValue("rtoID")); - if(fulfillment.id!==dao.getValue("rtoID")){ - onCancelObj.rtoIdErr = `RTO id - '${fulfillment.id}' of fulfillment type 'RTO' does not match with the one provided in on_search '${dao.getValue("rtoID")}' in /fulfillments`; + console.log(fulfillment.id, selectedItem?.fulfillment_id); + if (fulfillment.id !== selectedItem.fulfillment_id) { + onCancelObj.rtoIdErr = `RTO id - '${fulfillment.id}' of fulfillment type 'RTO' does not match with the one provided in on_search '${selectedItem.fulfillment_id}' in /fulfillments`; } if (ffState === "RTO-Initiated") { RtoPickupTime = fulfillment?.start?.time?.timestamp; diff --git a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnStatus.js b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnStatus.js index abda338..7ec4271 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnStatus.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnStatus.js @@ -62,7 +62,7 @@ const checkOnStatus = (data, msgIdSet) => { ) { if ( categoryId === "Immediate Delivery" && - fulfillment.tracking !== true + fulfillment.tracking !== true && ffState!=='Cancelled' ) { onStatusObj.trckErr = `tracking should be enabled (true) for hyperlocal (Immediate Delivery)`; } @@ -74,6 +74,12 @@ const checkOnStatus = (data, msgIdSet) => { onStatusObj.deliveryTimeErr = `Delivery timestamp (fulfillments/end/time/timestamp) cannot be provided for fulfillment state - ${ffState}`; } } + + if (ffState === "Agent-assigned" || ffState === "Searching-for-Agent") { + if (orderState !== "In-progress") { + onStatusObj.ordrStatErr = `Order state should be 'In-progress' for fulfillment state - ${ffState}`; + } + } if (ffState === "Order-picked-up") { if (orderState !== "In-progress") { onStatusObj.ordrStatErr = `Order state should be 'In-progress' for fulfillment state - ${ffState}`; @@ -142,15 +148,11 @@ const checkOnStatus = (data, msgIdSet) => { onStatusObj.ordrStatErr = `Order state should be 'Cancelled' for fulfillment state - ${ffState}`; } if (fulfillments.length > 1) { - if (!dao.getValue("pickupTime")) { - onStatusObj.msngPickupState = `/on_status call for Fulfillment state - 'Order-picked-up' missing`; - } else if (!fulfillment.start.time.timestamp) { + if (!fulfillment.start.time.timestamp) { onStatusObj.msngPickupTimeErr = `Pickup timestamp (fulfillments/start/time/timestamp) is missing for fulfillment state - ${ffState}`; } } - if(fulfillment.tracking===true){ - onStatusObj.trackErr=`fulfillment tracking can be disabled (false) after the fulfillment is 'Cancelled` - } + if (fulfillment.start.time.timestamp && dao.getValue("pickupTime")) { if ( !_.isEqual( diff --git a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logUpdate.js b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logUpdate.js index a97eec7..d1edb5d 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logUpdate.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logUpdate.js @@ -7,12 +7,16 @@ const checkUpdate = (data, msgIdSet) => { let updtObj = {}; let update = data; let version = update.context.core_version; + let contextTimestamp = update.context.timestamp; let p2h2p = dao.getValue("p2h2p"); let awbNo= dao.getValue("awbNo"); dao.setValue("updateApi",true) update = update.message.order; + if (update?.updated_at > contextTimestamp) { + updtObj.updatedAtErr = `order/updated_at cannot be future dated w.r.t context/timestamp`; + } if (version === "1.1.0") rts = update?.fulfillments[0]?.tags["@ondc/org/order_ready_to_ship"]; else { diff --git a/utilities/logistics-b2b/log-verification-utility/utils/utils.js b/utilities/logistics-b2b/log-verification-utility/utils/utils.js index 55e29ab..04fd841 100755 --- a/utilities/logistics-b2b/log-verification-utility/utils/utils.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/utils.js @@ -197,9 +197,16 @@ const timestampCheck = (date) => { } }; -const getVersion = (data) => { - if (data?.search[0]?.context?.core_version === "1.1.0") return "v1.1"; +const getVersion = (data,vertical) => { + if(vertical==='logistics'){ + if (data?.search[0]?.context?.core_version === "1.1.0") return "v1.1"; else return "v1.2"; + } + if(vertical==='b2b'){ + if (data?.search[0]?.context?.version === "2.0.1") return "v1"; + else return "v2"; + } + }; function compareDates(dateString1, dateString2) { const date1 = new Date(dateString1);