@unchainedshop/core-quotations 4.4.0 → 4.6.0

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/README.md CHANGED
@@ -70,7 +70,7 @@ const quotations = await quotationsModule.findQuotations({
70
70
 
71
71
  | Export | Description |
72
72
  |--------|-------------|
73
- | `QuotationStatus` | Status values (REQUESTED, PROCESSING, PROPOSED, FULLFILLED, REJECTED) |
73
+ | `QuotationStatus` | Status values (REQUESTED, PROCESSING, PROPOSED, FULFILLED, REJECTED) |
74
74
 
75
75
  ### Settings
76
76
 
@@ -3,7 +3,7 @@ export declare const QuotationStatus: {
3
3
  readonly REQUESTED: "REQUESTED";
4
4
  readonly PROCESSING: "PROCESSING";
5
5
  readonly PROPOSED: "PROPOSED";
6
- readonly FULLFILLED: "FULLFILLED";
6
+ readonly FULFILLED: "FULFILLED";
7
7
  readonly REJECTED: "REJECTED";
8
8
  };
9
9
  export type QuotationStatus = (typeof QuotationStatus)[keyof typeof QuotationStatus];
@@ -29,7 +29,7 @@ export type Quotation = {
29
29
  countryCode?: string;
30
30
  currencyCode?: string;
31
31
  expires?: Date;
32
- fullfilled?: Date;
32
+ fulfilled?: Date;
33
33
  meta?: any;
34
34
  price?: number;
35
35
  productId: string;
@@ -3,7 +3,7 @@ export const QuotationStatus = {
3
3
  REQUESTED: 'REQUESTED',
4
4
  PROCESSING: 'PROCESSING',
5
5
  PROPOSED: 'PROPOSED',
6
- FULLFILLED: 'FULLFILLED',
6
+ FULFILLED: 'FULFILLED',
7
7
  REJECTED: 'REJECTED',
8
8
  };
9
9
  export const QuotationsCollection = async (db) => {
@@ -16,16 +16,12 @@ export const QuotationsCollection = async (db) => {
16
16
  userId: 'text',
17
17
  quotationNumber: 'text',
18
18
  status: 'text',
19
- 'contact.telNumber': 'text',
20
- 'contact.emailAddress': 'text',
21
19
  },
22
20
  options: {
23
21
  weights: {
24
22
  _id: 8,
25
23
  userId: 3,
26
24
  quotationNumber: 6,
27
- 'contact.telNumber': 5,
28
- 'contact.emailAddress': 4,
29
25
  status: 1,
30
26
  },
31
27
  name: 'quotation_fulltext_search',
@@ -2,9 +2,10 @@ import { type SortOption } from '@unchainedshop/utils';
2
2
  import { type Quotation, QuotationStatus } from '../db/QuotationsCollection.ts';
3
3
  import { mongodb, type ModuleInput } from '@unchainedshop/mongodb';
4
4
  import { type QuotationsSettingsOptions } from '../quotations-settings.ts';
5
- export interface QuotationQuery extends mongodb.Filter<Quotation> {
5
+ export interface QuotationQuery {
6
6
  userId?: string;
7
7
  queryString?: string;
8
+ quotationIds?: string[];
8
9
  }
9
10
  export interface QuotationData {
10
11
  configuration?: {
@@ -15,7 +16,7 @@ export interface QuotationData {
15
16
  productId: string;
16
17
  userId: string;
17
18
  }
18
- export declare const buildFindSelector: ({ userId, queryString, ...rest }?: QuotationQuery) => mongodb.Filter<Quotation>;
19
+ export declare const buildFindSelector: ({ userId, queryString, quotationIds }?: QuotationQuery) => mongodb.Filter<Quotation>;
19
20
  export declare const configureQuotationsModule: ({ db, migrationRepository, options: quotationsOptions, }: ModuleInput<QuotationsSettingsOptions>) => Promise<{
20
21
  count: (query: QuotationQuery) => Promise<number>;
21
22
  openQuotationWithProduct: ({ productId }: {
@@ -6,11 +6,14 @@ import { QuotationsCollection } from "../db/QuotationsCollection.js";
6
6
  import { quotationsSettings } from "../quotations-settings.js";
7
7
  import renameCurrencyCode from "../migrations/20250502111800-currency-code.js";
8
8
  const QUOTATION_EVENTS = ['QUOTATION_REQUEST_CREATE', 'QUOTATION_REMOVE', 'QUOTATION_UPDATE'];
9
- export const buildFindSelector = ({ userId, queryString, ...rest } = {}) => {
10
- const selector = { ...rest };
9
+ export const buildFindSelector = ({ userId, queryString, quotationIds } = {}) => {
10
+ const selector = {};
11
11
  if (userId) {
12
12
  selector.userId = userId;
13
13
  }
14
+ if (quotationIds) {
15
+ selector._id = { $in: quotationIds };
16
+ }
14
17
  if (queryString) {
15
18
  assertDocumentDBCompatMode();
16
19
  selector.$text = { $search: queryString };
@@ -42,9 +45,9 @@ export const configureQuotationsModule = async ({ db, migrationRepository, optio
42
45
  updated: new Date(),
43
46
  };
44
47
  switch (status) {
45
- case QuotationStatus.FULLFILLED:
46
- if (!quotation.fullfilled) {
47
- $set.fullfilled = date;
48
+ case QuotationStatus.FULFILLED:
49
+ if (!quotation.fulfilled) {
50
+ $set.fulfilled = date;
48
51
  }
49
52
  $set.expires = date;
50
53
  case QuotationStatus.PROCESSING:
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-quotations",
3
- "version": "4.4.0",
3
+ "description": "Quotation and RFQ management module for the Unchained Engine",
4
+ "version": "4.6.0",
4
5
  "main": "lib/quotations-index.js",
5
6
  "types": "lib/quotations-index.d.ts",
6
7
  "type": "module",
8
+ "sideEffects": false,
7
9
  "scripts": {
8
10
  "clean": "tsc -b --clean",
9
11
  "build": "tsc -b",
@@ -33,9 +35,9 @@
33
35
  },
34
36
  "homepage": "https://github.com/unchainedshop/unchained#readme",
35
37
  "dependencies": {
36
- "@unchainedshop/events": "^4.4.0",
37
- "@unchainedshop/logger": "^4.4.0",
38
- "@unchainedshop/utils": "^4.4.0"
38
+ "@unchainedshop/events": "^4.6.0",
39
+ "@unchainedshop/logger": "^4.6.0",
40
+ "@unchainedshop/utils": "^4.6.0"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@types/node": "^25.0.0",