tango-app-api-store-builder 1.0.0-beta-33 → 1.0.0-beta-35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-store-builder",
|
|
3
|
-
"version": "1.0.0-beta-
|
|
3
|
+
"version": "1.0.0-beta-35",
|
|
4
4
|
"description": "storeBuilder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"joi": "^17.13.3",
|
|
24
24
|
"mongodb": "^6.12.0",
|
|
25
25
|
"nodemon": "^3.1.9",
|
|
26
|
-
"tango-api-schema": "^2.2.
|
|
26
|
+
"tango-api-schema": "^2.2.60",
|
|
27
27
|
"tango-app-api-middleware": "^3.1.48",
|
|
28
28
|
"winston": "^3.17.0",
|
|
29
29
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -12,6 +12,8 @@ import * as planoProductService from '../service/planoProduct.service.js';
|
|
|
12
12
|
import * as planoMappingService from '../service/planoMapping.service.js';
|
|
13
13
|
import * as planoComplianceService from '../service/planoCompliance.service.js';
|
|
14
14
|
import * as planoTaskComplianceService from '../service/planoTask.service.js';
|
|
15
|
+
import * as planoQrConversionRequestService from '../service/planoQrConversionRequest.service.js';
|
|
16
|
+
|
|
15
17
|
import path from 'path';
|
|
16
18
|
|
|
17
19
|
|
|
@@ -2074,15 +2076,14 @@ export async function storeFixturesTask( req, res ) {
|
|
|
2074
2076
|
}
|
|
2075
2077
|
}
|
|
2076
2078
|
|
|
2077
|
-
|
|
2078
|
-
export const qrVideoUpload = async ( req, res ) => {
|
|
2079
|
+
export const qrFileUpload = async ( req, res ) => {
|
|
2079
2080
|
try {
|
|
2080
2081
|
if ( !req.files?.file ) {
|
|
2081
2082
|
return res.sendError( { message: 'Please upload a file' }, 400 );
|
|
2082
2083
|
}
|
|
2083
2084
|
|
|
2084
2085
|
const { file } = req.files;
|
|
2085
|
-
const { fixtureId } = req.body;
|
|
2086
|
+
const { fixtureId, type } = req.body;
|
|
2086
2087
|
|
|
2087
2088
|
if ( !fixtureId ) {
|
|
2088
2089
|
return res.sendError( { message: 'Missing fixtureId' }, 400 );
|
|
@@ -2102,7 +2103,13 @@ export const qrVideoUpload = async ( req, res ) => {
|
|
|
2102
2103
|
return res.sendError( { message: 'Storage bucket not configured' }, 500 );
|
|
2103
2104
|
}
|
|
2104
2105
|
|
|
2105
|
-
|
|
2106
|
+
let uploadPath;
|
|
2107
|
+
|
|
2108
|
+
if ( type === 'video' ) {
|
|
2109
|
+
uploadPath = `planoQrVideos/${dayjs().format( 'YYYY-MM-DD' )}/${fixture.toObject().storeId}`;
|
|
2110
|
+
} else if ( type === 'image' ) {
|
|
2111
|
+
uploadPath = `planoQrFixtureImages/${dayjs().format( 'YYYY-MM-DD' )}/${fixture.toObject().storeId}`;
|
|
2112
|
+
}
|
|
2106
2113
|
|
|
2107
2114
|
const params = {
|
|
2108
2115
|
fileName: `/${fixtureId}.${format}`,
|
|
@@ -2114,11 +2121,37 @@ export const qrVideoUpload = async ( req, res ) => {
|
|
|
2114
2121
|
|
|
2115
2122
|
const fileUrl = await fileUpload( params );
|
|
2116
2123
|
|
|
2124
|
+
res.sendSuccess( fileUrl.Key );
|
|
2125
|
+
} catch ( error ) {
|
|
2126
|
+
logger.error( 'fixtureQrUpdate =>', error );
|
|
2127
|
+
return res.sendError( { message: 'Internal Server Error' }, 500 );
|
|
2128
|
+
}
|
|
2129
|
+
};
|
|
2130
|
+
|
|
2131
|
+
export const updateQrCvProcessRequest = async ( req, res ) => {
|
|
2132
|
+
try {
|
|
2133
|
+
const { fixtureId, videoPath, imagePath, videoComment, imageComment } = req.body;
|
|
2134
|
+
|
|
2135
|
+
if ( !fixtureId ) {
|
|
2136
|
+
return res.sendError( { message: 'Missing fixtureId' }, 400 );
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
const fixture = await storeFixtureService.findOne( { _id: fixtureId } );
|
|
2140
|
+
|
|
2141
|
+
if ( !fixture ) {
|
|
2142
|
+
return res.sendError( { message: 'Fixture not found' }, 400 );
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
const bucket = JSON.parse( process.env.BUCKET || '{}' );
|
|
2146
|
+
if ( !bucket.storeBuilder ) {
|
|
2147
|
+
return res.sendError( { message: 'Storage bucket not configured' }, 500 );
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2117
2150
|
const message = {
|
|
2118
2151
|
'fixtureId': fixtureId,
|
|
2119
2152
|
'date': dayjs().format( 'YYYY-MM-DD' ),
|
|
2120
2153
|
'bucket': bucket.storeBuilder,
|
|
2121
|
-
'videoPath':
|
|
2154
|
+
'videoPath': videoPath,
|
|
2122
2155
|
};
|
|
2123
2156
|
|
|
2124
2157
|
const sqs = JSON.parse( process.env.SQS || '{}' );
|
|
@@ -2128,7 +2161,88 @@ export const qrVideoUpload = async ( req, res ) => {
|
|
|
2128
2161
|
|
|
2129
2162
|
const sqsPush = await sendMessageToQueue( `${sqs.url}${sqs.qrVideoTopic}`, JSON.stringify( message ) );
|
|
2130
2163
|
|
|
2131
|
-
|
|
2164
|
+
if ( !sqsPush?.MessageId ) {
|
|
2165
|
+
return res.sendError( { message: 'Failed to send SQS message' }, 500 );
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
const fixtureData = fixture.toObject();
|
|
2169
|
+
|
|
2170
|
+
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
2171
|
+
|
|
2172
|
+
const data = {
|
|
2173
|
+
clientId: fixtureData?.clientId,
|
|
2174
|
+
storeName: fixtureData?.storeName,
|
|
2175
|
+
storeId: fixtureData?.storeId,
|
|
2176
|
+
planoId: fixtureData?.planoId,
|
|
2177
|
+
floorId: fixtureData?.floorId,
|
|
2178
|
+
fixtureId: fixtureData?._id,
|
|
2179
|
+
date: currentDate,
|
|
2180
|
+
status: 'initiated',
|
|
2181
|
+
fixtureImage: {
|
|
2182
|
+
filePath: imagePath,
|
|
2183
|
+
comment: imageComment,
|
|
2184
|
+
},
|
|
2185
|
+
fixtureVideo: {
|
|
2186
|
+
filePath: videoPath,
|
|
2187
|
+
comment: videoComment,
|
|
2188
|
+
},
|
|
2189
|
+
};
|
|
2190
|
+
|
|
2191
|
+
await planoQrConversionRequestService.upsertOne( { fixtureId: fixtureData?._id, date: currentDate }, data );
|
|
2192
|
+
|
|
2193
|
+
return res.sendSuccess( { message: 'Updated successfully', data } );
|
|
2194
|
+
} catch ( error ) {
|
|
2195
|
+
logger.error( 'uploadFixtureVideo =>', error );
|
|
2196
|
+
return res.sendError( { message: 'Internal Server Error' }, 500 );
|
|
2197
|
+
}
|
|
2198
|
+
};
|
|
2199
|
+
|
|
2200
|
+
export const getQrCvProcessRequest = async ( req, res ) => {
|
|
2201
|
+
try {
|
|
2202
|
+
const { fixtureId } = req.body;
|
|
2203
|
+
|
|
2204
|
+
if ( !fixtureId ) {
|
|
2205
|
+
return res.sendError( { message: 'Missing fixtureId' }, 400 );
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
const fixture = await storeFixtureService.findOne( { _id: fixtureId } );
|
|
2209
|
+
|
|
2210
|
+
if ( !fixture ) {
|
|
2211
|
+
return res.sendError( { message: 'Fixture not found' }, 400 );
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
2215
|
+
|
|
2216
|
+
const planoCvReq = await planoQrConversionRequestService.findOne( { fixtureId: new mongoose.Types.ObjectId( fixtureId ), date: currentDate } );
|
|
2217
|
+
|
|
2218
|
+
if ( !planoCvReq ) {
|
|
2219
|
+
return res.sendError( 'No data found', 204 );
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
const bucket = JSON.parse( process.env.BUCKET || '{}' );
|
|
2223
|
+
if ( !bucket.storeBuilder ) {
|
|
2224
|
+
return res.sendError( { message: 'Storage bucket not configured' }, 500 );
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
let planoCvReqData = planoCvReq.toObject();
|
|
2228
|
+
|
|
2229
|
+
if ( planoCvReqData?.fixtureImage?.filePath ) {
|
|
2230
|
+
const params = {
|
|
2231
|
+
Bucket: bucket.storeBuilder,
|
|
2232
|
+
file_path: planoCvReqData.fixtureImage.filePath,
|
|
2233
|
+
};
|
|
2234
|
+
planoCvReqData.fixtureImage.filePath = await signedUrl( params );
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
if ( planoCvReqData?.fixtureVideo?.filePath ) {
|
|
2238
|
+
const params = {
|
|
2239
|
+
Bucket: bucket.storeBuilder,
|
|
2240
|
+
file_path: planoCvReqData.fixtureVideo.filePath,
|
|
2241
|
+
};
|
|
2242
|
+
planoCvReqData.fixtureVideo.filePath = await signedUrl( params );
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
return res.sendSuccess( planoCvReqData );
|
|
2132
2246
|
} catch ( error ) {
|
|
2133
2247
|
logger.error( 'uploadFixtureVideo =>', error );
|
|
2134
2248
|
return res.sendError( { message: 'Internal Server Error' }, 500 );
|
|
@@ -2183,6 +2297,8 @@ export const fixtureQrUpdate = async ( req, res ) => {
|
|
|
2183
2297
|
} ),
|
|
2184
2298
|
);
|
|
2185
2299
|
|
|
2300
|
+
await planoQrConversionRequestService.updateOne( { fixtureId: new mongoose.Types.ObjectId( fixtureId ), date: currentDate }, { status: 'data-received' } );
|
|
2301
|
+
|
|
2186
2302
|
return res.sendSuccess( updateStatus );
|
|
2187
2303
|
} catch ( error ) {
|
|
2188
2304
|
logger.error( 'fixtureQrUpdate =>', error );
|
|
@@ -2190,3 +2306,4 @@ export const fixtureQrUpdate = async ( req, res ) => {
|
|
|
2190
2306
|
}
|
|
2191
2307
|
};
|
|
2192
2308
|
|
|
2309
|
+
|
|
@@ -254,7 +254,7 @@ export async function uploadImage( req, res ) {
|
|
|
254
254
|
|
|
255
255
|
let params = {
|
|
256
256
|
Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
257
|
-
Key: `${req.body.taskId}/${req.body.qno}/${
|
|
257
|
+
Key: `${req.body.taskId}/${req.body.qno}/${Date.now()}/`,
|
|
258
258
|
fileName: req.files.file.name,
|
|
259
259
|
ContentType: req.files.file.mimeType,
|
|
260
260
|
body: req.files.file.data,
|
|
@@ -304,7 +304,8 @@ export async function updateAnswers( req, res ) {
|
|
|
304
304
|
|
|
305
305
|
req.body.answers.forEach( ( ans ) => {
|
|
306
306
|
if ( ans.image && ans.image.includes( 'http' ) ) {
|
|
307
|
-
ans.image =
|
|
307
|
+
ans.image = ans.image.split( '.com/' )[1].split( '?' )[0];
|
|
308
|
+
ans.image = decodeURIComponent( ans.image );
|
|
308
309
|
}
|
|
309
310
|
} );
|
|
310
311
|
|
|
@@ -28,6 +28,8 @@ storeBuilderRouter
|
|
|
28
28
|
.post( '/bulkFixtureUpload', storeBuilderController.bulkFixtureUpload )
|
|
29
29
|
.post( '/uploadImage', storeBuilderController.uploadImage )
|
|
30
30
|
.post( '/storeFixturesTask', storeBuilderController.storeFixturesTask )
|
|
31
|
-
.post( '/
|
|
31
|
+
.post( '/qrFileUpload', storeBuilderController.qrFileUpload )
|
|
32
|
+
.post( '/updateQrCvProcessRequest', storeBuilderController.updateQrCvProcessRequest )
|
|
33
|
+
.post( '/getQrCvProcessRequest', storeBuilderController.getQrCvProcessRequest )
|
|
32
34
|
.post( '/fixtureQrUpdate', storeBuilderController.fixtureQrUpdate );
|
|
33
35
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import model from 'tango-api-schema';
|
|
2
|
+
|
|
3
|
+
export async function find( query={}, field={} ) {
|
|
4
|
+
return model.planoQrConversionRequest.find( query, field );
|
|
5
|
+
}
|
|
6
|
+
export async function findOne( query={}, field={} ) {
|
|
7
|
+
return model.planoQrConversionRequest.findOne( query, field );
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function insertMany( data ) {
|
|
11
|
+
return model.planoQrConversionRequest.insertMany( data );
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function aggregate( query ) {
|
|
15
|
+
return model.planoQrConversionRequest.aggregate( query );
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function updateOne( query, record ) {
|
|
19
|
+
return model.planoQrConversionRequest.updateOne( query, { $set: record } );
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function count( query ) {
|
|
23
|
+
return model.planoQrConversionRequest.countDocuments( query );
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function create( data ) {
|
|
27
|
+
return model.planoQrConversionRequest.create( data );
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function upsertOne( query, record ) {
|
|
31
|
+
return model.planoQrConversionRequest.updateOne( query, { $set: record }, { upsert: true } );
|
|
32
|
+
}
|