@unchainedshop/core-quotations 1.1.3
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/.npm/package/README +7 -0
- package/.npm/package/npm-shrinkwrap.json +190 -0
- package/.versions +55 -0
- package/README.md +5 -0
- package/lib/db/QuotationStatus.d.ts +7 -0
- package/lib/db/QuotationStatus.js +9 -0
- package/lib/db/QuotationStatus.js.map +1 -0
- package/lib/db/QuotationsCollection.d.ts +3 -0
- package/lib/db/QuotationsCollection.js +33 -0
- package/lib/db/QuotationsCollection.js.map +1 -0
- package/lib/db/QuotationsSchema.d.ts +1 -0
- package/lib/db/QuotationsSchema.js +31 -0
- package/lib/db/QuotationsSchema.js.map +1 -0
- package/lib/director/QuotationAdapter.d.ts +2 -0
- package/lib/director/QuotationAdapter.js +40 -0
- package/lib/director/QuotationAdapter.js.map +1 -0
- package/lib/director/QuotationDirector.d.ts +2 -0
- package/lib/director/QuotationDirector.js +86 -0
- package/lib/director/QuotationDirector.js.map +1 -0
- package/lib/director/QuotationError.d.ts +6 -0
- package/lib/director/QuotationError.js +8 -0
- package/lib/director/QuotationError.js.map +1 -0
- package/lib/module/configureQuotationsModule.d.ts +3 -0
- package/lib/module/configureQuotationsModule.js +263 -0
- package/lib/module/configureQuotationsModule.js.map +1 -0
- package/lib/quotations-index.d.ts +5 -0
- package/lib/quotations-index.js +6 -0
- package/lib/quotations-index.js.map +1 -0
- package/lib/quotations-settings.d.ts +10 -0
- package/lib/quotations-settings.js +8 -0
- package/lib/quotations-settings.js.map +1 -0
- package/package.js +34 -0
- package/package.json +44 -0
- package/plugins/manual.ts +27 -0
- package/quotations.js +15 -0
- package/src/db/QuotationStatus.ts +7 -0
- package/src/db/QuotationsCollection.ts +37 -0
- package/src/db/QuotationsSchema.js +35 -0
- package/src/director/QuotationAdapter.ts +52 -0
- package/src/director/QuotationDirector.ts +100 -0
- package/src/director/QuotationError.ts +6 -0
- package/src/module/configureQuotationsModule.ts +386 -0
- package/src/quotations-index.ts +8 -0
- package/src/quotations-settings.js +9 -0
- package/tests/quotations-index.test.ts +73 -0
- package/tsconfig.build.json +26 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { emit, registerEvents } from '@unchainedshop/events';
|
|
2
|
+
import { log } from '@unchainedshop/logger';
|
|
3
|
+
import { generateDbFilterById, generateDbMutations, buildSortOptions } from '@unchainedshop/utils';
|
|
4
|
+
import { QuotationsCollection } from '../db/QuotationsCollection';
|
|
5
|
+
import { QuotationsSchema } from '../db/QuotationsSchema';
|
|
6
|
+
import { QuotationStatus } from '../db/QuotationStatus';
|
|
7
|
+
import { QuotationDirector } from '../quotations-index';
|
|
8
|
+
import { quotationsSettings } from '../quotations-settings';
|
|
9
|
+
const QUOTATION_EVENTS = ['QUOTATION_REQUEST_CREATE', 'QUOTATION_REMOVE', 'QUOTATION_UPDATE'];
|
|
10
|
+
const buildFindSelector = (query = {}) => {
|
|
11
|
+
const selector = {};
|
|
12
|
+
if (query.userId) {
|
|
13
|
+
selector.userId = query.userId;
|
|
14
|
+
}
|
|
15
|
+
if (query.queryString) {
|
|
16
|
+
selector.$text = { $search: query.queryString };
|
|
17
|
+
}
|
|
18
|
+
return selector;
|
|
19
|
+
};
|
|
20
|
+
const isExpired = (quotation, { referenceDate }) => {
|
|
21
|
+
const relevantDate = referenceDate ? new Date(referenceDate) : new Date();
|
|
22
|
+
const expiryDate = new Date(quotation.expires);
|
|
23
|
+
const isQuotationExpired = relevantDate.getTime() > expiryDate.getTime();
|
|
24
|
+
return isQuotationExpired;
|
|
25
|
+
};
|
|
26
|
+
export const configureQuotationsModule = async ({ db, options: quotationsOptions = {}, }) => {
|
|
27
|
+
registerEvents(QUOTATION_EVENTS);
|
|
28
|
+
quotationsSettings.configureSettings(quotationsOptions);
|
|
29
|
+
const Quotations = await QuotationsCollection(db);
|
|
30
|
+
const mutations = generateDbMutations(Quotations, QuotationsSchema);
|
|
31
|
+
const findNewQuotationNumber = async (quotation, index = 0) => {
|
|
32
|
+
// let quotationNumber = null;
|
|
33
|
+
// let i = 0;
|
|
34
|
+
// while (!quotationNumber) {
|
|
35
|
+
const newHashID = quotationsSettings.quotationNumberHashFn(quotation, index);
|
|
36
|
+
if ((await Quotations.countDocuments({ quotationNumber: newHashID }, { limit: 1 })) === 0) {
|
|
37
|
+
return newHashID;
|
|
38
|
+
}
|
|
39
|
+
return findNewQuotationNumber(quotation, index + 1);
|
|
40
|
+
// }
|
|
41
|
+
// return quotationNumber;
|
|
42
|
+
};
|
|
43
|
+
const findNextStatus = async (quotation, requestContext) => {
|
|
44
|
+
let status = quotation.status;
|
|
45
|
+
const director = await QuotationDirector.actions({ quotation }, requestContext);
|
|
46
|
+
if (status === QuotationStatus.REQUESTED) {
|
|
47
|
+
if (!(await director.isManualRequestVerificationRequired())) {
|
|
48
|
+
status = QuotationStatus.PROCESSING;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (status === QuotationStatus.PROCESSING) {
|
|
52
|
+
if (!(await director.isManualProposalRequired())) {
|
|
53
|
+
status = QuotationStatus.PROPOSED;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return status;
|
|
57
|
+
};
|
|
58
|
+
const updateStatus = async (quotationId, { status, info = '' }, userId) => {
|
|
59
|
+
const selector = generateDbFilterById(quotationId);
|
|
60
|
+
const quotation = await Quotations.findOne(selector, {});
|
|
61
|
+
if (quotation.status === status)
|
|
62
|
+
return quotation;
|
|
63
|
+
const date = new Date();
|
|
64
|
+
const $set = {
|
|
65
|
+
status,
|
|
66
|
+
updated: new Date(),
|
|
67
|
+
updatedBy: userId,
|
|
68
|
+
};
|
|
69
|
+
switch (status) {
|
|
70
|
+
// explicitly use fallthrough here!
|
|
71
|
+
case QuotationStatus.FULLFILLED:
|
|
72
|
+
if (!quotation.fullfilled) {
|
|
73
|
+
$set.fullfilled = date;
|
|
74
|
+
}
|
|
75
|
+
$set.expires = date;
|
|
76
|
+
case QuotationStatus.PROCESSING: // eslint-disable-line no-fallthrough
|
|
77
|
+
if (!quotation.quotationNumber) {
|
|
78
|
+
$set.quotationNumber = findNewQuotationNumber(quotation);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case QuotationStatus.REJECTED:
|
|
82
|
+
$set.expires = date;
|
|
83
|
+
$set.rejected = date;
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
const modifier = {
|
|
89
|
+
$set,
|
|
90
|
+
$push: {
|
|
91
|
+
log: {
|
|
92
|
+
date,
|
|
93
|
+
status,
|
|
94
|
+
info,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
log(`New Status: ${status}`, { quotationId });
|
|
99
|
+
await Quotations.updateOne(selector, modifier);
|
|
100
|
+
const updatedQuotation = await Quotations.findOne(selector, {});
|
|
101
|
+
emit('QUOTATION_UPDATE', { quotation, field: 'status' });
|
|
102
|
+
return updatedQuotation;
|
|
103
|
+
};
|
|
104
|
+
const processQuotation = async (initialQuotation, params, requestContext) => {
|
|
105
|
+
const { modules, userId } = requestContext;
|
|
106
|
+
const quotationId = initialQuotation._id;
|
|
107
|
+
let quotation = initialQuotation;
|
|
108
|
+
let nextStatus = await findNextStatus(quotation, requestContext);
|
|
109
|
+
const director = await QuotationDirector.actions({ quotation }, requestContext);
|
|
110
|
+
if (quotation.status === QuotationStatus.REQUESTED && nextStatus !== QuotationStatus.REQUESTED) {
|
|
111
|
+
await director.submitRequest(params.quotationContext);
|
|
112
|
+
}
|
|
113
|
+
quotation = await modules.quotations.findQuotation({ quotationId });
|
|
114
|
+
nextStatus = await findNextStatus(quotation, requestContext);
|
|
115
|
+
if (nextStatus !== QuotationStatus.PROCESSING) {
|
|
116
|
+
await director.verifyRequest(params.quotationContext);
|
|
117
|
+
}
|
|
118
|
+
quotation = await modules.quotations.findQuotation({ quotationId });
|
|
119
|
+
nextStatus = await findNextStatus(quotation, requestContext);
|
|
120
|
+
if (nextStatus === QuotationStatus.REJECTED) {
|
|
121
|
+
await director.rejectRequest(params.quotationContext);
|
|
122
|
+
}
|
|
123
|
+
quotation = await modules.quotations.findQuotation({ quotationId });
|
|
124
|
+
nextStatus = await findNextStatus(quotation, requestContext);
|
|
125
|
+
if (nextStatus === QuotationStatus.PROPOSED) {
|
|
126
|
+
const proposal = await director.quote();
|
|
127
|
+
quotation = await modules.quotations.updateProposal(quotation._id, proposal, userId);
|
|
128
|
+
nextStatus = await findNextStatus(quotation, requestContext);
|
|
129
|
+
}
|
|
130
|
+
return updateStatus(quotation._id, { status: nextStatus, info: 'quotation processed' }, requestContext.userId);
|
|
131
|
+
};
|
|
132
|
+
const sendStatusToCustomer = async (quotation, requestContext) => {
|
|
133
|
+
const { modules, userId } = requestContext;
|
|
134
|
+
const user = await modules.users.findUserById(quotation.userId);
|
|
135
|
+
const locale = modules.users.userLocale(user, requestContext);
|
|
136
|
+
await modules.worker.addWork({
|
|
137
|
+
type: 'MESSAGE',
|
|
138
|
+
retries: 0,
|
|
139
|
+
input: {
|
|
140
|
+
locale,
|
|
141
|
+
template: 'QUOTATION_STATUS',
|
|
142
|
+
quotationId: quotation._id,
|
|
143
|
+
},
|
|
144
|
+
}, userId);
|
|
145
|
+
return quotation;
|
|
146
|
+
};
|
|
147
|
+
const updateQuotationFields = (fieldKeys) => async (quotationId, values, userId) => {
|
|
148
|
+
log(`Update quotation fields ${fieldKeys.join(', ').toUpperCase()}`, {
|
|
149
|
+
quotationId,
|
|
150
|
+
userId,
|
|
151
|
+
});
|
|
152
|
+
const modifier = {
|
|
153
|
+
$set: fieldKeys.reduce((set, key) => ({ ...set, [key]: values[key] }), {}),
|
|
154
|
+
};
|
|
155
|
+
await mutations.update(quotationId, modifier, userId);
|
|
156
|
+
const selector = generateDbFilterById(quotationId);
|
|
157
|
+
const quotation = await Quotations.findOne(selector, {});
|
|
158
|
+
emit('QUOTATION_UPDATE', { quotation, fields: fieldKeys });
|
|
159
|
+
return quotation;
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
// Queries
|
|
163
|
+
count: async (query) => {
|
|
164
|
+
const quotationCount = await Quotations.countDocuments(buildFindSelector(query));
|
|
165
|
+
return quotationCount;
|
|
166
|
+
},
|
|
167
|
+
findQuotation: async ({ quotationId }, options) => {
|
|
168
|
+
const selector = generateDbFilterById(quotationId);
|
|
169
|
+
return Quotations.findOne(selector, options);
|
|
170
|
+
},
|
|
171
|
+
findQuotations: async ({ limit, offset, sort, ...query }, options) => {
|
|
172
|
+
const quotations = Quotations.find(buildFindSelector(query), {
|
|
173
|
+
limit,
|
|
174
|
+
skip: offset,
|
|
175
|
+
sort: buildSortOptions(sort),
|
|
176
|
+
...options,
|
|
177
|
+
});
|
|
178
|
+
return quotations.toArray();
|
|
179
|
+
},
|
|
180
|
+
// Transformations
|
|
181
|
+
normalizedStatus: (quotation) => {
|
|
182
|
+
return quotation.status === null
|
|
183
|
+
? QuotationStatus.REQUESTED
|
|
184
|
+
: quotation.status;
|
|
185
|
+
},
|
|
186
|
+
isExpired,
|
|
187
|
+
isProposalValid: (quotation) => {
|
|
188
|
+
return quotation.status === QuotationStatus.PROPOSED && !isExpired(quotation);
|
|
189
|
+
},
|
|
190
|
+
// Processing
|
|
191
|
+
fullfillQuotation: async (quotationId, info, requestContext) => {
|
|
192
|
+
const selector = generateDbFilterById(quotationId);
|
|
193
|
+
const quotation = await Quotations.findOne(selector, {});
|
|
194
|
+
if (quotation.status === QuotationStatus.FULLFILLED)
|
|
195
|
+
return quotation;
|
|
196
|
+
let updatedQuotation = await updateStatus(quotation._id, {
|
|
197
|
+
status: QuotationStatus.FULLFILLED,
|
|
198
|
+
info: JSON.stringify(info),
|
|
199
|
+
}, requestContext.userId);
|
|
200
|
+
updatedQuotation = await processQuotation(updatedQuotation, {}, requestContext);
|
|
201
|
+
return sendStatusToCustomer(updatedQuotation, requestContext);
|
|
202
|
+
},
|
|
203
|
+
proposeQuotation: async (quotation, { quotationContext }, requestContext) => {
|
|
204
|
+
if (quotation.status !== QuotationStatus.PROCESSING)
|
|
205
|
+
return quotation;
|
|
206
|
+
let updatedQuotation = await updateStatus(quotation._id, {
|
|
207
|
+
status: QuotationStatus.PROPOSED,
|
|
208
|
+
info: 'proposed manually',
|
|
209
|
+
}, requestContext.userId);
|
|
210
|
+
updatedQuotation = await processQuotation(updatedQuotation, { quotationContext }, requestContext);
|
|
211
|
+
return sendStatusToCustomer(updatedQuotation, requestContext);
|
|
212
|
+
},
|
|
213
|
+
rejectQuotation: async (quotation, { quotationContext }, requestContext) => {
|
|
214
|
+
if (quotation.status === QuotationStatus.FULLFILLED)
|
|
215
|
+
return quotation;
|
|
216
|
+
let updatedQuotation = await updateStatus(quotation._id, {
|
|
217
|
+
status: QuotationStatus.REJECTED,
|
|
218
|
+
info: 'rejected manually',
|
|
219
|
+
}, requestContext.userId);
|
|
220
|
+
updatedQuotation = await processQuotation(updatedQuotation, { quotationContext }, requestContext);
|
|
221
|
+
return sendStatusToCustomer(updatedQuotation, requestContext);
|
|
222
|
+
},
|
|
223
|
+
verifyQuotation: async (quotation, { quotationContext }, requestContext) => {
|
|
224
|
+
if (quotation.status !== QuotationStatus.REQUESTED)
|
|
225
|
+
return quotation;
|
|
226
|
+
let updatedQuotation = await updateStatus(quotation._id, {
|
|
227
|
+
status: QuotationStatus.PROCESSING,
|
|
228
|
+
info: 'verified elligibility manually',
|
|
229
|
+
}, requestContext.userId);
|
|
230
|
+
updatedQuotation = await processQuotation(updatedQuotation, { quotationContext }, requestContext);
|
|
231
|
+
return sendStatusToCustomer(updatedQuotation, requestContext);
|
|
232
|
+
},
|
|
233
|
+
transformItemConfiguration: async (quotation, configuration, requestContext) => {
|
|
234
|
+
const director = await QuotationDirector.actions({ quotation }, requestContext);
|
|
235
|
+
return director.transformItemConfiguration(configuration);
|
|
236
|
+
},
|
|
237
|
+
// Mutations
|
|
238
|
+
create: async ({ countryCode, ...quotationData }, requestContext) => {
|
|
239
|
+
const { services, userId } = requestContext;
|
|
240
|
+
log('Create Quotation', { userId });
|
|
241
|
+
const currency = await services.countries.resolveDefaultCurrencyCode({
|
|
242
|
+
isoCode: countryCode,
|
|
243
|
+
}, requestContext);
|
|
244
|
+
const quotationId = await mutations.create({
|
|
245
|
+
...quotationData,
|
|
246
|
+
configuration: quotationData.configuration || [],
|
|
247
|
+
countryCode,
|
|
248
|
+
currency,
|
|
249
|
+
log: [],
|
|
250
|
+
status: QuotationStatus.REQUESTED,
|
|
251
|
+
}, userId);
|
|
252
|
+
const newQuotation = await Quotations.findOne(generateDbFilterById(quotationId), {});
|
|
253
|
+
let quotation = await processQuotation(newQuotation, {}, requestContext);
|
|
254
|
+
quotation = await sendStatusToCustomer(quotation, requestContext);
|
|
255
|
+
emit('QUOTATION_REQUEST_CREATE', { quotation });
|
|
256
|
+
return quotation;
|
|
257
|
+
},
|
|
258
|
+
updateContext: updateQuotationFields(['context']),
|
|
259
|
+
updateProposal: updateQuotationFields(['price', 'expires', 'meta']),
|
|
260
|
+
updateStatus,
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
//# sourceMappingURL=configureQuotationsModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureQuotationsModule.js","sourceRoot":"","sources":["../../src/module/configureQuotationsModule.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBA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aAAa,IAAI,EAAE;gBAChD,WAAW;gBACX,QAAQ;gBACR,GAAG,EAAE,EAAE;gBACP,MAAM,EAAE,eAAe,CAAC,SAAS;aAClC,EACD,MAAM,CACP,CAAC;YAEF,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;YAErF,IAAI,SAAS,GAAG,MAAM,gBAAgB,CAAC,YAAY,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;YAEzE,SAAS,GAAG,MAAM,oBAAoB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;YAElE,IAAI,CAAC,0BAA0B,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YAEhD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,aAAa,EAAE,qBAAqB,CAAC,CAAC,SAAS,CAAC,CAAC;QACjD,cAAc,EAAE,qBAAqB,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAEnE,YAAY;KACb,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { configureQuotationsModule } from './module/configureQuotationsModule';
|
|
2
|
+
export { QuotationStatus } from './db/QuotationStatus';
|
|
3
|
+
export { QuotationAdapter } from './director/QuotationAdapter';
|
|
4
|
+
export { QuotationDirector } from './director/QuotationDirector';
|
|
5
|
+
export { quotationsSettings } from './quotations-settings';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { configureQuotationsModule } from './module/configureQuotationsModule';
|
|
2
|
+
export { QuotationStatus } from './db/QuotationStatus';
|
|
3
|
+
export { QuotationAdapter } from './director/QuotationAdapter';
|
|
4
|
+
export { QuotationDirector } from './director/QuotationDirector';
|
|
5
|
+
export { quotationsSettings } from './quotations-settings';
|
|
6
|
+
//# sourceMappingURL=quotations-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotations-index.js","sourceRoot":"","sources":["../src/quotations-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export namespace quotationsSettings {
|
|
2
|
+
const quotationNumberHashFn: any;
|
|
3
|
+
function configureSettings({ quotationNumberHashFn }?: {
|
|
4
|
+
quotationNumberHashFn?: typeof generateRandomHash;
|
|
5
|
+
}): void;
|
|
6
|
+
function configureSettings({ quotationNumberHashFn }?: {
|
|
7
|
+
quotationNumberHashFn?: typeof generateRandomHash;
|
|
8
|
+
}): void;
|
|
9
|
+
}
|
|
10
|
+
import { generateRandomHash } from "@unchainedshop/utils";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { generateRandomHash } from '@unchainedshop/utils';
|
|
2
|
+
export const quotationsSettings = {
|
|
3
|
+
quotationNumberHashFn: null,
|
|
4
|
+
configureSettings({ quotationNumberHashFn = generateRandomHash } = {}) {
|
|
5
|
+
this.quotationNumberHashFn = quotationNumberHashFn;
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=quotations-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotations-settings.js","sourceRoot":"","sources":["../src/quotations-settings.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,qBAAqB,EAAE,IAAI;IAE3B,iBAAiB,CAAC,EAAE,qBAAqB,GAAG,kBAAkB,EAAE,GAAG,EAAE;QACnE,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACrD,CAAC;CACF,CAAC"}
|
package/package.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Package.describe({
|
|
2
|
+
name: 'unchained:core-quotations',
|
|
3
|
+
version: '1.1.3',
|
|
4
|
+
summary: 'Unchained Engine Core: Quotations',
|
|
5
|
+
git: 'https://github.com/unchainedshop/unchained',
|
|
6
|
+
documentation: 'README.md',
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
Npm.depends({
|
|
10
|
+
'simpl-schema': '1.12.0',
|
|
11
|
+
'@unchainedshop/logger': '1.1.3',
|
|
12
|
+
'@unchainedshop/utils': '1.1.3',
|
|
13
|
+
// '@unchainedshop/events': '1.1.4', // PEER
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
Package.onUse((api) => {
|
|
17
|
+
api.versionsFrom('2.7.3');
|
|
18
|
+
api.use('ecmascript');
|
|
19
|
+
api.use('typescript');
|
|
20
|
+
|
|
21
|
+
api.mainModule('src/quotations-index.ts', 'server');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
Package.onTest((api) => {
|
|
25
|
+
api.use('meteortesting:mocha');
|
|
26
|
+
api.use('ecmascript');
|
|
27
|
+
api.use('typescript');
|
|
28
|
+
|
|
29
|
+
api.use('unchained:mongodb');
|
|
30
|
+
api.use('unchained:core-users');
|
|
31
|
+
api.use('unchained:core-quotations');
|
|
32
|
+
|
|
33
|
+
api.mainModule('tests/quotations-index.test.ts');
|
|
34
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unchainedshop/core-quotations",
|
|
3
|
+
"version": "1.1.3",
|
|
4
|
+
"main": "lib/quotations-index.js",
|
|
5
|
+
"types": "lib/quotations-index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"clean": "rm -rf lib",
|
|
9
|
+
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
10
|
+
"watch": "tsc --watch",
|
|
11
|
+
"link:core": "npm link @unchainedshop/types",
|
|
12
|
+
"test": "cross-env METEOR_PACKAGE_DIRS=../ TEST_CLIENT=0 TEST_WATCH=1 meteor test-packages ./ --driver-package meteortesting:mocha --port 4200"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/unchainedshop/unchained.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"unchained",
|
|
20
|
+
"ecommerce",
|
|
21
|
+
"core"
|
|
22
|
+
],
|
|
23
|
+
"author": "Joël Meiller",
|
|
24
|
+
"license": "EUPL-1.2",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/unchainedshop/unchained/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@unchainedshop/events": "latest",
|
|
31
|
+
"@unchainedshop/logger": "latest",
|
|
32
|
+
"@unchainedshop/utils": "latest",
|
|
33
|
+
"simpl-schema": "^1.12.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/chai": "^4.3.1",
|
|
37
|
+
"@types/locale": "^0.1.1",
|
|
38
|
+
"@types/mocha": "^9.1.1",
|
|
39
|
+
"@unchainedshop/types": "latest",
|
|
40
|
+
"chai": "^4.3.6",
|
|
41
|
+
"cross-env": "^7.0.3",
|
|
42
|
+
"typescript": "^4.7.4"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IQuotationAdapter } from '@unchainedshop/types/quotations';
|
|
2
|
+
import { QuotationDirector, QuotationAdapter } from 'meteor/unchained:core-quotations';
|
|
3
|
+
|
|
4
|
+
const ManualOffering: IQuotationAdapter = {
|
|
5
|
+
...QuotationAdapter,
|
|
6
|
+
|
|
7
|
+
key: 'shop.unchained.quotations.manual',
|
|
8
|
+
version: '1.0',
|
|
9
|
+
label: 'Manual Offerings',
|
|
10
|
+
orderIndex: 0,
|
|
11
|
+
|
|
12
|
+
isActivatedFor: () => true,
|
|
13
|
+
|
|
14
|
+
actions: (params) => {
|
|
15
|
+
return {
|
|
16
|
+
...QuotationAdapter.actions(params),
|
|
17
|
+
|
|
18
|
+
quote: async () => {
|
|
19
|
+
return {
|
|
20
|
+
expires: new Date(new Date().getTime() + 3600 * 1000),
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
QuotationDirector.registerAdapter(ManualOffering);
|
package/quotations.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import './db/quotations/helpers';
|
|
2
|
+
import './db/quotation-documents/helpers';
|
|
3
|
+
|
|
4
|
+
import createIndexes from './db/quotations/schema';
|
|
5
|
+
import settings from './settings';
|
|
6
|
+
|
|
7
|
+
export * from './director';
|
|
8
|
+
export * from './db/quotations/collections';
|
|
9
|
+
export * from './db/quotations/schema';
|
|
10
|
+
export * from './db/quotation-documents/schema';
|
|
11
|
+
|
|
12
|
+
export default (options) => {
|
|
13
|
+
settings.load(options);
|
|
14
|
+
createIndexes();
|
|
15
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Db } from '@unchainedshop/types/common';
|
|
2
|
+
import { buildDbIndexes } from '@unchainedshop/utils';
|
|
3
|
+
import { Quotation } from '@unchainedshop/types/quotations';
|
|
4
|
+
|
|
5
|
+
export const QuotationsCollection = async (db: Db) => {
|
|
6
|
+
const Quotations = db.collection<Quotation>('quotations');
|
|
7
|
+
|
|
8
|
+
// Quotation Indexes
|
|
9
|
+
await buildDbIndexes<Quotation>(Quotations, [
|
|
10
|
+
{ index: { userId: 1 } },
|
|
11
|
+
{ index: { productId: 1 } },
|
|
12
|
+
{ index: { status: 1 } },
|
|
13
|
+
{
|
|
14
|
+
index: {
|
|
15
|
+
_id: 'text',
|
|
16
|
+
userId: 'text',
|
|
17
|
+
quotationNumber: 'text',
|
|
18
|
+
status: 'text',
|
|
19
|
+
'contact.telNumber': 'text',
|
|
20
|
+
'contact.emailAddress': 'text',
|
|
21
|
+
},
|
|
22
|
+
options: {
|
|
23
|
+
weights: {
|
|
24
|
+
_id: 8,
|
|
25
|
+
userId: 3,
|
|
26
|
+
quotationNumber: 6,
|
|
27
|
+
'contact.telNumber': 5,
|
|
28
|
+
'contact.emailAddress': 4,
|
|
29
|
+
status: 1,
|
|
30
|
+
},
|
|
31
|
+
name: 'quotation_fulltext_search',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
return Quotations;
|
|
37
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Schemas } from '@unchainedshop/utils';
|
|
2
|
+
import SimpleSchema from 'simpl-schema';
|
|
3
|
+
|
|
4
|
+
export const QuotationsSchema = new SimpleSchema(
|
|
5
|
+
{
|
|
6
|
+
userId: { type: String, required: true },
|
|
7
|
+
productId: { type: String, required: true },
|
|
8
|
+
status: { type: String, required: true },
|
|
9
|
+
quotationNumber: String,
|
|
10
|
+
price: String,
|
|
11
|
+
expires: Date,
|
|
12
|
+
rejected: Date,
|
|
13
|
+
meta: { type: Object, blackbox: true },
|
|
14
|
+
fullfilled: Date,
|
|
15
|
+
context: { type: Object, blackbox: true },
|
|
16
|
+
currency: String,
|
|
17
|
+
countryCode: String,
|
|
18
|
+
configuration: Array,
|
|
19
|
+
'configuration.$': {
|
|
20
|
+
type: Object,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
'configuration.$.key': {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
'configuration.$.value': {
|
|
28
|
+
type: String,
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
...Schemas.logFields,
|
|
32
|
+
...Schemas.timestampFields,
|
|
33
|
+
},
|
|
34
|
+
{ requiredByDefault: false },
|
|
35
|
+
);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
|
|
3
|
+
import { IQuotationAdapter } from '@unchainedshop/types/quotations';
|
|
4
|
+
import { QuotationError } from './QuotationError';
|
|
5
|
+
|
|
6
|
+
export const QuotationAdapter: Omit<IQuotationAdapter, 'key' | 'label' | 'version'> = {
|
|
7
|
+
orderIndex: 0,
|
|
8
|
+
|
|
9
|
+
isActivatedFor: () => {
|
|
10
|
+
return false;
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
actions: () => {
|
|
14
|
+
return {
|
|
15
|
+
configurationError: () => {
|
|
16
|
+
return QuotationError.NOT_IMPLEMENTED;
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
isManualRequestVerificationRequired: async () => {
|
|
20
|
+
return true;
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
isManualProposalRequired: async () => {
|
|
24
|
+
return true;
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
quote: async () => {
|
|
28
|
+
return {};
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
rejectRequest: async () => {
|
|
32
|
+
return true;
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
submitRequest: async () => {
|
|
36
|
+
return true;
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
verifyRequest: async () => {
|
|
40
|
+
return true;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
transformItemConfiguration: async ({ quantity, configuration }) => {
|
|
44
|
+
return { quantity, configuration };
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
log(message: string, { level = LogLevel.Debug, ...options } = {}) {
|
|
50
|
+
return log(message, { level, ...options });
|
|
51
|
+
},
|
|
52
|
+
};
|