@bisondesk/core-sdk 1.0.642 → 1.0.644
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/lib/types/internal-events.d.ts +1 -0
- package/lib/types/internal-events.d.ts.map +1 -1
- package/lib/types/internal-events.js +1 -0
- package/lib/types/internal-events.js.map +1 -1
- package/lib/types/marketing-emails.d.ts +28 -0
- package/lib/types/marketing-emails.d.ts.map +1 -1
- package/lib/types/marketing-emails.js.map +1 -1
- package/lib/types/vehicles.d.ts.map +1 -1
- package/lib/types/vehicles.js.map +1 -1
- package/lib/utils/vehicles.d.ts +3 -0
- package/lib/utils/vehicles.d.ts.map +1 -1
- package/lib/utils/vehicles.js +3 -0
- package/lib/utils/vehicles.js.map +1 -1
- package/lib/utils/vehicles.test.js +22 -1
- package/lib/utils/vehicles.test.js.map +1 -1
- package/package.json +1 -1
- package/src/types/internal-events.ts +1 -0
- package/src/types/marketing-emails.ts +33 -0
- package/src/types/vehicles.ts +4 -1
- package/src/utils/vehicles.test.ts +26 -0
- package/src/utils/vehicles.ts +12 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,8 +3,34 @@ import {
|
|
|
3
3
|
convertLettersToNumber,
|
|
4
4
|
convertNumberToLetters,
|
|
5
5
|
getNextRelatedStockNumber,
|
|
6
|
+
isValidVin,
|
|
6
7
|
} from './vehicles.js';
|
|
7
8
|
|
|
9
|
+
describe('isValidVin', () => {
|
|
10
|
+
it('should accept valid VINs', () => {
|
|
11
|
+
expect(isValidVin('1M8GDM9AXKP042788')).toBe(true);
|
|
12
|
+
expect(isValidVin('5YJSA1DG9DFP14705')).toBe(true);
|
|
13
|
+
expect(isValidVin('WDB96340310876052')).toBe(true);
|
|
14
|
+
expect(isValidVin('XLRTE47MS0E756907')).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should reject strings that are not 17 characters', () => {
|
|
18
|
+
expect(isValidVin('1M8GDM9AXKP04278')).toBe(false);
|
|
19
|
+
expect(isValidVin('1M8GDM9AXKP0427889')).toBe(false);
|
|
20
|
+
expect(isValidVin('')).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should reject VINs with invalid characters (I, O, Q)', () => {
|
|
24
|
+
expect(isValidVin('1M8GDM9AXKPI42788')).toBe(false);
|
|
25
|
+
expect(isValidVin('1M8GDM9AXKPO42788')).toBe(false);
|
|
26
|
+
expect(isValidVin('1M8GDM9AXKPQ42788')).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should reject lowercase', () => {
|
|
30
|
+
expect(isValidVin('1m8gdm9axkp042788')).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
8
34
|
describe('stock number utils', () => {
|
|
9
35
|
describe('convertNumberToLetters', () => {
|
|
10
36
|
it('should convert numbers to letters correctly', () => {
|
package/src/utils/vehicles.ts
CHANGED
|
@@ -190,6 +190,18 @@ export const getNextRelatedStockNumber = (stockNumber: string): string => {
|
|
|
190
190
|
return `${baseStockNumber}${nextCounterLetters}`;
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Canonical VIN shape: exactly 17 characters from the VIN alphabet — letters A–Z and
|
|
195
|
+
* digits 0–9, excluding I, O and Q. Unanchored so callers can wrap their own
|
|
196
|
+
* boundary/anchor policy when scanning free text (mirror of {@link buildStockNumberPattern}).
|
|
197
|
+
* Use {@link VIN_PATTERN} / {@link isValidVin} to validate a whole string.
|
|
198
|
+
*/
|
|
199
|
+
export const VIN_BODY_PATTERN = '[A-HJ-NPR-Z0-9]{17}';
|
|
200
|
+
|
|
201
|
+
export const VIN_PATTERN = new RegExp(`^${VIN_BODY_PATTERN}$`);
|
|
202
|
+
|
|
203
|
+
export const isValidVin = (vin: string): boolean => VIN_PATTERN.test(vin);
|
|
204
|
+
|
|
193
205
|
export const getVehicleDescription = (
|
|
194
206
|
external: VehicleExternalInfo,
|
|
195
207
|
{
|