@honestdigital/vehicle-service-types 1.0.13

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.
Files changed (41) hide show
  1. package/README.md +76 -0
  2. package/dist/context.d.ts +53 -0
  3. package/dist/context.d.ts.map +1 -0
  4. package/dist/repositories/vehicleConfigOptions.d.ts +165 -0
  5. package/dist/repositories/vehicleConfigOptions.d.ts.map +1 -0
  6. package/dist/routers/index.d.ts +793 -0
  7. package/dist/routers/index.d.ts.map +1 -0
  8. package/dist/schemas/comparison.schema.d.ts +37 -0
  9. package/dist/schemas/comparison.schema.d.ts.map +1 -0
  10. package/dist/schemas/externalApi.schema.d.ts +1532 -0
  11. package/dist/schemas/externalApi.schema.d.ts.map +1 -0
  12. package/dist/schemas/filters.schema.d.ts +276 -0
  13. package/dist/schemas/filters.schema.d.ts.map +1 -0
  14. package/dist/schemas/vehicle.schema.d.ts +1204 -0
  15. package/dist/schemas/vehicle.schema.d.ts.map +1 -0
  16. package/dist/services/lenderdesk.d.ts +139 -0
  17. package/dist/services/lenderdesk.d.ts.map +1 -0
  18. package/dist/services/mmt.d.ts +52 -0
  19. package/dist/services/mmt.d.ts.map +1 -0
  20. package/dist/types/comparison.d.ts +157 -0
  21. package/dist/types/comparison.d.ts.map +1 -0
  22. package/dist/types/filters.d.ts +95 -0
  23. package/dist/types/filters.d.ts.map +1 -0
  24. package/dist/types/guards.d.ts +32 -0
  25. package/dist/types/guards.d.ts.map +1 -0
  26. package/dist/types/index.d.ts +18 -0
  27. package/dist/types/index.d.ts.map +1 -0
  28. package/dist/types/jdp.d.ts +210 -0
  29. package/dist/types/jdp.d.ts.map +1 -0
  30. package/dist/types/search.d.ts +475 -0
  31. package/dist/types/search.d.ts.map +1 -0
  32. package/dist/types/sync.d.ts +102 -0
  33. package/dist/types/sync.d.ts.map +1 -0
  34. package/dist/types/vehicle.d.ts +75 -0
  35. package/dist/types/vehicle.d.ts.map +1 -0
  36. package/dist/types.d.ts +17 -0
  37. package/dist/types.d.ts.map +1 -0
  38. package/dist/types.js +4213 -0
  39. package/dist/utilities/error.d.ts +49 -0
  40. package/dist/utilities/error.d.ts.map +1 -0
  41. package/package.json +112 -0
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Utility for standardized error handling in vehicle service
3
+ */
4
+ export type ErrorCode = 'INTERNAL_ERROR' | 'NOT_FOUND' | 'INVALID_INPUT' | 'DATABASE_ERROR' | 'CACHE_ERROR' | 'UNAUTHORIZED' | 'VALIDATION_ERROR' | 'RATE_LIMITED' | 'EXTERNAL_API_ERROR';
5
+ export declare class AppError extends Error {
6
+ code: ErrorCode;
7
+ statusCode: number;
8
+ context?: Record<string, unknown>;
9
+ constructor(code: ErrorCode, message: string, statusCode: number, context?: Record<string, unknown>);
10
+ /**
11
+ * Returns true if this is a client error (4xx status code)
12
+ * Client errors are expected conditions, not server failures
13
+ */
14
+ isClientError(): boolean;
15
+ /**
16
+ * Creates a safe version of the error for client consumption
17
+ * Removes sensitive information from context
18
+ */
19
+ toSafeError(): Omit<AppError, 'context'> & {
20
+ context?: Record<string, unknown>;
21
+ };
22
+ }
23
+ /**
24
+ * Common error factory functions
25
+ * Use these instead of direct AppError construction to ensure consistency
26
+ */
27
+ export declare const API_ERRORS: {
28
+ NOT_FOUND: (resource?: string) => AppError;
29
+ INVALID_INPUT: (message?: string, context?: Record<string, unknown>) => AppError;
30
+ DATABASE_ERROR: (message?: string, context?: Record<string, unknown>) => AppError;
31
+ CACHE_ERROR: (message?: string, context?: Record<string, unknown>) => AppError;
32
+ UNAUTHORIZED: (message?: string) => AppError;
33
+ VALIDATION_ERROR: (message?: string, context?: Record<string, unknown>) => AppError;
34
+ RATE_LIMITED: (message?: string) => AppError;
35
+ EXTERNAL_API_ERROR: (message?: string, context?: Record<string, unknown>) => AppError;
36
+ INTERNAL_ERROR: (message?: string) => AppError;
37
+ FORBIDDEN: (message?: string) => AppError;
38
+ };
39
+ /**
40
+ * Serializes an error into a plain object that JSON.stringify can handle
41
+ * Captures message, name, stack, and any custom properties (like Postgres error details)
42
+ */
43
+ export declare function serializeError(error: unknown): Record<string, unknown>;
44
+ /**
45
+ * Safe error handler that ensures a consistent error response format
46
+ * and prevents sensitive error details from leaking to clients
47
+ */
48
+ export declare function handleError(error: unknown): AppError;
49
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/utilities/error.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,MAAM,SAAS,GACjB,gBAAgB,GAChB,WAAW,GACX,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,kBAAkB,GAClB,cAAc,GACd,oBAAoB,CAAA;AAExB,qBAAa,QAAS,SAAQ,KAAK;IAC1B,IAAI,EAAE,SAAS,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;gBAGtC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IASnC;;;OAGG;IACI,aAAa,IAAI,OAAO;IAI/B;;;OAGG;IACI,WAAW,IAAI,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;CAexF;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU;;gDAGgC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;iDAGZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;8CAG7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;mDAKrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;qDAKpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;CAOvF,CAAA;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuDtE;AAcD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAqCpD"}
package/package.json ADDED
@@ -0,0 +1,112 @@
1
+ {
2
+ "name": "@honestdigital/vehicle-service-types",
3
+ "version": "1.0.13",
4
+ "description": "Dedicated microservice for vehicle inventory management",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/types.d.ts",
8
+ "files": [
9
+ "dist/types.d.ts",
10
+ "dist/types.d.ts.map",
11
+ "dist/types.js",
12
+ "dist/types/**/*.d.ts",
13
+ "dist/types/**/*.d.ts.map",
14
+ "dist/routers/index.d.ts",
15
+ "dist/routers/index.d.ts.map",
16
+ "dist/schemas/**/*.d.ts",
17
+ "dist/schemas/**/*.d.ts.map",
18
+ "dist/services/mmt.d.ts",
19
+ "dist/services/mmt.d.ts.map",
20
+ "dist/services/lenderdesk.d.ts",
21
+ "dist/services/lenderdesk.d.ts.map",
22
+ "dist/context.d.ts",
23
+ "dist/context.d.ts.map",
24
+ "dist/utilities/error.d.ts",
25
+ "dist/utilities/error.d.ts.map",
26
+ "dist/repositories/vehicleConfigOptions.d.ts",
27
+ "dist/repositories/vehicleConfigOptions.d.ts.map",
28
+ "README.md"
29
+ ],
30
+ "exports": {
31
+ "./types": {
32
+ "types": "./dist/types.d.ts",
33
+ "default": "./dist/types.js"
34
+ },
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "default": "./dist/index.js"
38
+ }
39
+ },
40
+ "scripts": {
41
+ "build:types": "tsc --declaration --emitDeclarationOnly --outDir dist && bun build src/types.ts --outdir dist --target node",
42
+ "verify:package": "npm pack --dry-run",
43
+ "dev": "wrangler dev --port 3002 --ip 0.0.0.0",
44
+ "dev:stress": "wrangler dev -e stress --port 3002",
45
+ "dev:stress:local": "POSTGRES_URL=postgresql://stress_test:stress_test_local@localhost:5434/vehicle_stress DISABLE_RATE_LIMIT=true bun run stress-test/server.ts",
46
+ "dev:old": "tsx watch src/index.ts",
47
+ "build": "tsc && wrangler deploy --dry-run",
48
+ "deploy": "wrangler deploy",
49
+ "deploy:staging": "wrangler deploy --env staging",
50
+ "deploy:production": "wrangler deploy --env production",
51
+ "deploy:production:sentry": "wrangler deploy --env production --outdir ./dist --define __SENTRY_RELEASE__:\\\"$(git rev-parse --short HEAD)\\\" && bun run sentry:sourcemaps",
52
+ "sentry:sourcemaps": "sentry-cli sourcemaps inject ./dist && sentry-cli sourcemaps upload --release=$(git rev-parse --short HEAD) ./dist",
53
+ "deploy:legacy": "node scripts/deploy-legacy.js",
54
+ "test": "bun test",
55
+ "test:integration": "STRESS_TEST_DB=true POSTGRES_URL=postgresql://stress_test:stress_test_local@localhost:5434/vehicle_stress vitest run --config vitest.integration.config.ts",
56
+ "test:watch": "vitest",
57
+ "bench": "vitest bench",
58
+ "bench:live": "BENCH_DB=live vitest bench",
59
+ "bench:local": "STRESS_TEST_DB=true POSTGRES_URL=postgresql://stress_test:stress_test_local@localhost:5434/vehicle_stress BENCH_DB=local vitest bench",
60
+ "bench:staging": "POSTGRES_URL='postgresql://neondb_owner:npg_nqE6Wpj1arDZ@ep-long-base-aiysy8lg-pooler.c-4.us-east-1.aws.neon.tech/neondb?sslmode=require&channel_binding=require' BENCH_DB=staging vitest bench",
61
+ "bench:gate": "BENCH_DB=staging vitest run --config vitest.gate.config.ts",
62
+ "typecheck": "tsc --noEmit",
63
+ "lint": "biome check --write --max-diagnostics 1000 ./src",
64
+ "lint:fix": "biome check --write --max-diagnostics 1000 ./src",
65
+ "format": "biome format --write --max-diagnostics 1000 ./src",
66
+ "sync": "bun scripts/run-sftp-sync.ts --latest --skip-images",
67
+ "sync:full": "bun scripts/run-sftp-sync.ts --latest",
68
+ "sync:images": "bun scripts/run-sftp-sync.ts --images-only",
69
+ "sync:all": "bun scripts/run-sftp-sync.ts",
70
+ "sync:list": "bun scripts/run-sftp-sync.ts --list",
71
+ "sync:status": "bun scripts/run-sftp-sync.ts --status"
72
+ },
73
+ "dependencies": {
74
+ "@hono/trpc-server": "^0.4.0",
75
+ "@neondatabase/serverless": "^1.0.2",
76
+ "@sentry/cloudflare": "^10.29.0",
77
+ "@trpc/server": "^11.6.0",
78
+ "dotenv": "^17.2.3",
79
+ "drizzle-kit": "^0.31.5",
80
+ "drizzle-orm": "^0.44.6",
81
+ "hono": "^4.7.11",
82
+ "pg": "^8.16.3",
83
+ "postgres": "^3.4.7",
84
+ "ssh2": "^1.17.0",
85
+ "ssh2-sftp-client": "^12.0.1",
86
+ "superjson": "^2.2.5",
87
+ "zod": "^3.25.76"
88
+ },
89
+ "devDependencies": {
90
+ "@biomejs/biome": "^2.3.2",
91
+ "@cloudflare/workers-types": "^4.20250117.0",
92
+ "@sentry/cli": "^2.58.2",
93
+ "@types/node": "^22.18.10",
94
+ "@types/pg": "^8.16.0",
95
+ "@types/sharp": "^0.32.0",
96
+ "@types/ssh2": "^1.15.5",
97
+ "@types/ssh2-sftp-client": "9",
98
+ "@types/ws": "^8.18.1",
99
+ "sharp": "^0.34.5",
100
+ "tsx": "^4.20.6",
101
+ "typescript": "5.7.3",
102
+ "vitest": "^3.2.4",
103
+ "wrangler": "^3.100.0",
104
+ "ws": "^8.19.0"
105
+ },
106
+ "engines": {
107
+ "node": "^18.20.2 || >=20.9.0"
108
+ },
109
+ "publishConfig": {
110
+ "access": "public"
111
+ }
112
+ }