Skip to content

Commit 1f61ba3

Browse files
authored
Merge pull request #992 from vaibhavsharmawits/release-RETINVL-1.2.5
fix:(removed L1 custom for now)
2 parents 534fa6d + 9287682 commit 1f61ba3

File tree

9 files changed

+5007
-5007
lines changed

9 files changed

+5007
-5007
lines changed
Lines changed: 154 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,166 @@
1-
import _ from "lodash";
2-
import constants, {
3-
ApiSequence,
4-
buyerCancellationRid,
5-
} from "../utils/constants";
6-
import { addActionToRedisSet, isValidISO8601Duration } from "../utils/helper";
7-
import { RedisService } from "ondc-automation-cache-lib";
8-
import { contextChecker }from "../utils/contextUtils"
9-
const addError = (result: any[], code: number, description: string): void => {
10-
result.push({
11-
valid: false,
12-
code,
13-
description,
14-
});
15-
};
16-
export const cancel = async (data: any) => {
17-
const TTL_IN_SECONDS: number = Number(process.env.TTL_IN_SECONDS) || 3600;
18-
const result: any[] = [];
19-
const { message, context }: any = data;
20-
try {
21-
try {
22-
await contextChecker(
23-
context,
24-
result,
25-
constants.CANCEL,
26-
constants.ON_CONFIRM,
27-
true
28-
);
29-
} catch (err: any) {
30-
addError(result, 20000, `Error checking context: ${err.message}`);
31-
return result;
32-
}
1+
// import _ from "lodash";
2+
// import constants, {
3+
// ApiSequence,
4+
// buyerCancellationRid,
5+
// } from "../utils/constants";
6+
// import { addActionToRedisSet, isValidISO8601Duration } from "../utils/helper";
7+
// import { RedisService } from "ondc-automation-cache-lib";
8+
// import { contextChecker }from "../utils/contextUtils"
9+
// const addError = (result: any[], code: number, description: string): void => {
10+
// result.push({
11+
// valid: false,
12+
// code,
13+
// description,
14+
// });
15+
// };
16+
// export const cancel = async (data: any) => {
17+
// const TTL_IN_SECONDS: number = Number(process.env.TTL_IN_SECONDS) || 3600;
18+
// const result: any[] = [];
19+
// const { message, context }: any = data;
20+
// try {
21+
// try {
22+
// await contextChecker(
23+
// context,
24+
// result,
25+
// constants.CANCEL,
26+
// constants.ON_CONFIRM,
27+
// true
28+
// );
29+
// } catch (err: any) {
30+
// addError(result, 20000, `Error checking context: ${err.message}`);
31+
// return result;
32+
// }
3333

34-
const confirmOrderIdKey = `${context.transaction_id}_cnfrmOrdrId`;
35-
const cancelMsgIdKey = `${context.transaction_id}_${ApiSequence.CANCEL}_msgId`;
36-
const cancelDataKey = `${context.transaction_id}_${ApiSequence.CANCEL}`;
37-
const cancelReasonIdKey = `${context.transaction_id}_cnclRid`;
34+
// const confirmOrderIdKey = `${context.transaction_id}_cnfrmOrdrId`;
35+
// const cancelMsgIdKey = `${context.transaction_id}_${ApiSequence.CANCEL}_msgId`;
36+
// const cancelDataKey = `${context.transaction_id}_${ApiSequence.CANCEL}`;
37+
// const cancelReasonIdKey = `${context.transaction_id}_cnclRid`;
3838

39-
// Store cancel data
40-
await RedisService.setKey(
41-
cancelDataKey,
42-
JSON.stringify(data),
43-
TTL_IN_SECONDS
44-
);
39+
// // Store cancel data
40+
// await RedisService.setKey(
41+
// cancelDataKey,
42+
// JSON.stringify(data),
43+
// TTL_IN_SECONDS
44+
// );
4545

46-
const cancel = message;
46+
// const cancel = message;
4747

48-
try {
49-
console.info("Checking the validity of cancellation reason id for buyer");
50-
if (!buyerCancellationRid.has(cancel?.cancellation_reason_id)) {
51-
console.info(
52-
`cancellation_reason_id should be a valid cancellation id (buyer app initiated)`
53-
);
54-
result.push({
55-
valid: false,
56-
code: 30012,
57-
description: `Cancellation reason id is not a valid reason id (buyer app initiated)`,
58-
});
59-
} else {
60-
await RedisService.setKey(
61-
cancelReasonIdKey,
62-
cancel?.cancellation_reason_id,
63-
TTL_IN_SECONDS
64-
);
65-
}
66-
} catch (error: any) {
67-
console.info(
68-
`Error while checking validity of cancellation reason id /${constants.CANCEL}, ${error.stack}`
69-
);
70-
}
48+
// try {
49+
// console.info("Checking the validity of cancellation reason id for buyer");
50+
// if (!buyerCancellationRid.has(cancel?.cancellation_reason_id)) {
51+
// console.info(
52+
// `cancellation_reason_id should be a valid cancellation id (buyer app initiated)`
53+
// );
54+
// result.push({
55+
// valid: false,
56+
// code: 30012,
57+
// description: `Cancellation reason id is not a valid reason id (buyer app initiated)`,
58+
// });
59+
// } else {
60+
// await RedisService.setKey(
61+
// cancelReasonIdKey,
62+
// cancel?.cancellation_reason_id,
63+
// TTL_IN_SECONDS
64+
// );
65+
// }
66+
// } catch (error: any) {
67+
// console.info(
68+
// `Error while checking validity of cancellation reason id /${constants.CANCEL}, ${error.stack}`
69+
// );
70+
// }
7171

72-
if (cancel.descriptor) {
73-
const { name, short_desc, tags } = cancel.descriptor;
72+
// if (cancel.descriptor) {
73+
// const { name, short_desc, tags } = cancel.descriptor;
7474

75-
// Validate descriptor fields
76-
if (!name || name !== "fulfillment") {
77-
result.push({
78-
valid: false,
79-
code: 40000,
80-
description: `message/descriptor/name must be 'fulfillment' in /${constants.CANCEL}`,
81-
});
82-
}
83-
if (!short_desc) {
84-
result.push({
85-
valid: false,
86-
code: 40000,
87-
description: `message/descriptor/short_desc is missing in /${constants.CANCEL}`,
88-
});
89-
}
75+
// // Validate descriptor fields
76+
// if (!name || name !== "fulfillment") {
77+
// result.push({
78+
// valid: false,
79+
// code: 40000,
80+
// description: `message/descriptor/name must be 'fulfillment' in /${constants.CANCEL}`,
81+
// });
82+
// }
83+
// if (!short_desc) {
84+
// result.push({
85+
// valid: false,
86+
// code: 40000,
87+
// description: `message/descriptor/short_desc is missing in /${constants.CANCEL}`,
88+
// });
89+
// }
9090

91-
// Validate tags array
92-
if (!tags || !Array.isArray(tags) || tags.length === 0) {
93-
} else {
94-
const paramsTag = tags.find((tag: any) => tag.code === "params");
95-
if (!paramsTag || !paramsTag.list || !Array.isArray(paramsTag.list)) {
96-
result.push({
97-
valid: false,
98-
code: 40000,
99-
description: `message/descriptor/tags must contain a 'params' tag with a valid list in /${constants.CANCEL}`,
100-
});
101-
} else {
102-
const forceParam = paramsTag.list.find(
103-
(item: any) => item.code === "force"
104-
);
105-
const ttlResponseParam = paramsTag.list.find(
106-
(item: any) => item.code === "ttl_response"
107-
);
91+
// // Validate tags array
92+
// if (!tags || !Array.isArray(tags) || tags.length === 0) {
93+
// } else {
94+
// const paramsTag = tags.find((tag: any) => tag.code === "params");
95+
// if (!paramsTag || !paramsTag.list || !Array.isArray(paramsTag.list)) {
96+
// result.push({
97+
// valid: false,
98+
// code: 40000,
99+
// description: `message/descriptor/tags must contain a 'params' tag with a valid list in /${constants.CANCEL}`,
100+
// });
101+
// } else {
102+
// const forceParam = paramsTag.list.find(
103+
// (item: any) => item.code === "force"
104+
// );
105+
// const ttlResponseParam = paramsTag.list.find(
106+
// (item: any) => item.code === "ttl_response"
107+
// );
108108

109-
// Validate force parameter
110-
if (!forceParam || !forceParam.code) {
111-
result.push({
112-
valid: false,
113-
code: 40000,
114-
description: `message/descriptor/tags/params must contain a 'force' parameter in /${constants.CANCEL}`,
115-
});
116-
} else if (!["yes", "no"].includes(forceParam.value)) {
117-
result.push({
118-
valid: false,
119-
code: 30024,
120-
description: `message/descriptor/tags/params/force must be 'yes' or 'no' in /${constants.CANCEL}`,
121-
});
122-
}
109+
// // Validate force parameter
110+
// if (!forceParam || !forceParam.code) {
111+
// result.push({
112+
// valid: false,
113+
// code: 40000,
114+
// description: `message/descriptor/tags/params must contain a 'force' parameter in /${constants.CANCEL}`,
115+
// });
116+
// } else if (!["yes", "no"].includes(forceParam.value)) {
117+
// result.push({
118+
// valid: false,
119+
// code: 30024,
120+
// description: `message/descriptor/tags/params/force must be 'yes' or 'no' in /${constants.CANCEL}`,
121+
// });
122+
// }
123123

124-
if (!ttlResponseParam || !ttlResponseParam.value) {
125-
result.push({
126-
valid: false,
127-
code: 40000,
128-
description: `message/descriptor/tags/params must contain a 'ttl_response' parameter in /${constants.CANCEL}`,
129-
});
130-
} else if (!isValidISO8601Duration(ttlResponseParam.value)) {
131-
result.push({
132-
valid: false,
133-
code: 30025,
134-
description: `message/descriptor/tags/params/ttl_response must be a valid ISO8601 duration in /${constants.CANCEL}`,
135-
});
136-
}
137-
}
138-
}
139-
}
124+
// if (!ttlResponseParam || !ttlResponseParam.value) {
125+
// result.push({
126+
// valid: false,
127+
// code: 40000,
128+
// description: `message/descriptor/tags/params must contain a 'ttl_response' parameter in /${constants.CANCEL}`,
129+
// });
130+
// } else if (!isValidISO8601Duration(ttlResponseParam.value)) {
131+
// result.push({
132+
// valid: false,
133+
// code: 30025,
134+
// description: `message/descriptor/tags/params/ttl_response must be a valid ISO8601 duration in /${constants.CANCEL}`,
135+
// });
136+
// }
137+
// }
138+
// }
139+
// }
140140

141-
// Store confirm data
142-
await RedisService.setKey(
143-
`${context.transaction_id}_${ApiSequence.CANCEL}`,
144-
JSON.stringify(data),
145-
TTL_IN_SECONDS
146-
);
147-
await addActionToRedisSet(
148-
context.transaction_id,
149-
ApiSequence.CANCEL,
150-
ApiSequence.CANCEL
151-
);
141+
// // Store confirm data
142+
// await RedisService.setKey(
143+
// `${context.transaction_id}_${ApiSequence.CANCEL}`,
144+
// JSON.stringify(data),
145+
// TTL_IN_SECONDS
146+
// );
147+
// await addActionToRedisSet(
148+
// context.transaction_id,
149+
// ApiSequence.CANCEL,
150+
// ApiSequence.CANCEL
151+
// );
152152

153153

154-
return result;
155-
} catch (err: any) {
156-
console.error(
157-
`!!Some error occurred while checking /${constants.CANCEL} API, ${err.stack}`
158-
);
159-
result.push({
160-
valid: false,
161-
code: 40000,
162-
description: `Some error occurred while checking /${constants.CANCEL} API`,
163-
});
164-
return result;
165-
}
166-
};
154+
// return result;
155+
// } catch (err: any) {
156+
// console.error(
157+
// `!!Some error occurred while checking /${constants.CANCEL} API, ${err.stack}`
158+
// );
159+
// result.push({
160+
// valid: false,
161+
// code: 40000,
162+
// description: `Some error occurred while checking /${constants.CANCEL} API`,
163+
// });
164+
// return result;
165+
// }
166+
// };

0 commit comments

Comments
 (0)