@ipetsadmin/contracts 1.0.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +21 -0
  3. package/README.md +118 -0
  4. package/dist/enums/errors.d.ts +17 -0
  5. package/dist/enums/errors.d.ts.map +1 -0
  6. package/dist/enums/errors.js +21 -0
  7. package/dist/enums/errors.js.map +1 -0
  8. package/dist/errors/BaseError.d.ts +8 -0
  9. package/dist/errors/BaseError.d.ts.map +1 -0
  10. package/dist/errors/BaseError.js +13 -0
  11. package/dist/errors/BaseError.js.map +1 -0
  12. package/dist/errors/BusinessError.d.ts +6 -0
  13. package/dist/errors/BusinessError.d.ts.map +1 -0
  14. package/dist/errors/BusinessError.js +17 -0
  15. package/dist/errors/BusinessError.js.map +1 -0
  16. package/dist/errors/ForbiddenError.d.ts +6 -0
  17. package/dist/errors/ForbiddenError.d.ts.map +1 -0
  18. package/dist/errors/ForbiddenError.js +17 -0
  19. package/dist/errors/ForbiddenError.js.map +1 -0
  20. package/dist/errors/NotFoundError.d.ts +6 -0
  21. package/dist/errors/NotFoundError.d.ts.map +1 -0
  22. package/dist/errors/NotFoundError.js +17 -0
  23. package/dist/errors/NotFoundError.js.map +1 -0
  24. package/dist/errors/ServerError.d.ts +6 -0
  25. package/dist/errors/ServerError.d.ts.map +1 -0
  26. package/dist/errors/ServerError.js +17 -0
  27. package/dist/errors/ServerError.js.map +1 -0
  28. package/dist/errors/UnauthorizedError.d.ts +6 -0
  29. package/dist/errors/UnauthorizedError.d.ts.map +1 -0
  30. package/dist/errors/UnauthorizedError.js +17 -0
  31. package/dist/errors/UnauthorizedError.js.map +1 -0
  32. package/dist/index.d.ts +10 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +26 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/interfaces/general/IApiResponse.d.ts +9 -0
  37. package/dist/interfaces/general/IApiResponse.d.ts.map +1 -0
  38. package/dist/interfaces/general/IApiResponse.js +3 -0
  39. package/dist/interfaces/general/IApiResponse.js.map +1 -0
  40. package/dist/interfaces/general/IConfig.d.ts +26 -0
  41. package/dist/interfaces/general/IConfig.d.ts.map +1 -0
  42. package/dist/interfaces/general/IConfig.js +3 -0
  43. package/dist/interfaces/general/IConfig.js.map +1 -0
  44. package/dist/interfaces/general/IPaginatedResponse.d.ts +6 -0
  45. package/dist/interfaces/general/IPaginatedResponse.d.ts.map +1 -0
  46. package/dist/interfaces/general/IPaginatedResponse.js +3 -0
  47. package/dist/interfaces/general/IPaginatedResponse.js.map +1 -0
  48. package/dist/interfaces/general/IPagination.d.ts +7 -0
  49. package/dist/interfaces/general/IPagination.d.ts.map +1 -0
  50. package/dist/interfaces/general/IPagination.js +3 -0
  51. package/dist/interfaces/general/IPagination.js.map +1 -0
  52. package/dist/interfaces/general/IServerInit.d.ts +9 -0
  53. package/dist/interfaces/general/IServerInit.d.ts.map +1 -0
  54. package/dist/interfaces/general/IServerInit.js +3 -0
  55. package/dist/interfaces/general/IServerInit.js.map +1 -0
  56. package/package.json +62 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ ### Changed
13
+
14
+ ### Deprecated
15
+
16
+ ### Removed
17
+
18
+ ### Fixed
19
+
20
+ ### Security
21
+
22
+ ## [1.0.0] - 2026-04-02
23
+
24
+ ### Added
25
+
26
+ - Initial public release of `@ipetsadmin/contracts`.
27
+ - Shared interfaces: `IConfig`, `IApiResponse`, `IPaginatedResponse`, `IServerInit`.
28
+ - `Errors` enum for error class names.
29
+ - Error classes: `BaseError`, `BusinessError`, `ForbiddenError`, `NotFoundError`.
30
+ - MIT license, README, and npm publish tooling (validate, build, Husky, lint-staged).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ipetsadmin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # @ipetsadmin/contracts
2
+
3
+ Shared TypeScript types, enums, and error classes for Truffa projects. Published as a scoped npm package (`@ipetsadmin/contracts`).
4
+
5
+ ## Requirements
6
+
7
+ - Node.js **18.18+** (see `engines` in `package.json`)
8
+ - [pnpm](https://pnpm.io/) is used in this repo (npm/yarn work for consumers)
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ pnpm add @ipetsadmin/contracts
14
+ # or
15
+ npm install @ipetsadmin/contracts
16
+ ```
17
+
18
+ For a **scoped public** package, publishing typically uses:
19
+
20
+ ```bash
21
+ pnpm publish --access public
22
+ ```
23
+
24
+ Configure your registry in `.npmrc` if you use GitHub Packages or another host.
25
+
26
+ ### From Git (alternative)
27
+
28
+ ```bash
29
+ pnpm add git+https://github.com/your-org/contracts.git
30
+ pnpm add git+https://github.com/your-org/contracts.git#v1.0.0
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```typescript
36
+ import {
37
+ Errors,
38
+ IConfig,
39
+ IApiResponse,
40
+ IPaginatedResponse,
41
+ IServerInit,
42
+ BaseError,
43
+ BusinessError,
44
+ ForbiddenError,
45
+ NotFoundError,
46
+ } from '@ipetsadmin/contracts';
47
+ ```
48
+
49
+ Path aliases (`@/…`) apply only inside this package’s source; consumers import from `@ipetsadmin/contracts` as above.
50
+
51
+ ## Development
52
+
53
+ Install dependencies and (on first clone) install Git hooks:
54
+
55
+ ```bash
56
+ pnpm install
57
+ ```
58
+
59
+ | Script | Description |
60
+ | ----------------------- | ---------------------------------------------------------- |
61
+ | `pnpm run build` | Compile `src/` → `dist/` (TypeScript + path alias rewrite) |
62
+ | `pnpm run clean` | Remove `dist/` |
63
+ | `pnpm run typecheck` | `tsc --noEmit` (no emit, full typecheck) |
64
+ | `pnpm run lint` | ESLint with cache (`.eslintcache`) |
65
+ | `pnpm run lint:fix` | ESLint with `--fix` |
66
+ | `pnpm run format` | Prettier write (respects `.prettierignore`) |
67
+ | `pnpm run format:check` | Prettier check only |
68
+ | `pnpm run validate` | `typecheck` → `lint` → `format:check` (use in CI) |
69
+
70
+ **Pre-commit:** [Husky](https://typicode.github.io/husky/) runs [lint-staged](https://github.com/lint-staged/lint-staged): ESLint + Prettier on staged `*.ts` / `*.tsx`, Prettier on staged `*.json` / `*.md`.
71
+
72
+ **Before publish:** `prepublishOnly` runs `validate` then `build`, so broken code should not ship.
73
+
74
+ ### Tooling in this repo
75
+
76
+ - **ESLint** — `eslint.config.mjs` (flat config), TypeScript type-aware rules via `typescript-eslint`, conflicts with Prettier disabled via `eslint-config-prettier`
77
+ - **Prettier** — `.prettierrc.json`, `.prettierignore`
78
+ - **Editor defaults** — `.editorconfig`
79
+
80
+ ## Publishing
81
+
82
+ 1. Bump the version in `package.json`.
83
+ 2. Run `pnpm run validate` and fix any issues.
84
+ 3. Publish: `pnpm publish` (or your registry-specific command).
85
+
86
+ `pnpm run build` runs automatically in `prepublishOnly` after `validate`.
87
+
88
+ ## Package layout
89
+
90
+ Source lives under `src/`:
91
+
92
+ - `enums/` — shared enums (e.g. `Errors`)
93
+ - `errors/` — error classes (`BaseError`, domain errors, …)
94
+ - `interfaces/general/` — cross-cutting interfaces (`IConfig`, pagination, API responses, server bootstrap types, …)
95
+
96
+ The public API is whatever `src/index.ts` re-exports. Additional error classes may exist under `src/errors/` but only appear in consumers if listed in `index.ts`.
97
+
98
+ ## Serverless / private registry notes
99
+
100
+ - **Private npm:** set `@ipetsadmin:registry=…` and auth in `.npmrc` (or `NPM_TOKEN` in CI).
101
+ - **Git installs:** ensure deploy environments can reach the repo and run `pnpm install` / `npm install` as usual.
102
+
103
+ ### AWS Lambda / Serverless Framework (example)
104
+
105
+ ```yaml
106
+ package:
107
+ patterns:
108
+ - '!node_modules/**'
109
+ - 'node_modules/@ipetsadmin/contracts/**'
110
+ ```
111
+
112
+ ### Vercel
113
+
114
+ Dependencies resolve at build time; ensure registry or Git access is configured for private packages.
115
+
116
+ ## License
117
+
118
+ See [LICENSE](./LICENSE) (MIT).
@@ -0,0 +1,17 @@
1
+ export declare enum Errors {
2
+ NOT_FOUND_ERROR = "NotFoundError",
3
+ BUSINESS_ERROR = "BusinessError",
4
+ FORBIDDEN_ERROR = "ForbiddenError",
5
+ SERVER_ERROR = "ServerError",
6
+ UNAUTHORIZED_ERROR = "UnauthorizedError",
7
+ BAD_REQUEST_ERROR = "BadRequestError",
8
+ UNPROCESSABLE_ENTITY_ERROR = "UnprocessableEntityError",
9
+ TOO_MANY_REQUESTS_ERROR = "TooManyRequestsError",
10
+ INTERNAL_SERVER_ERROR = "InternalServerError",
11
+ SERVICE_UNAVAILABLE_ERROR = "ServiceUnavailableError",
12
+ GATEWAY_TIMEOUT_ERROR = "GatewayTimeoutError",
13
+ BAD_GATEWAY_ERROR = "BadGatewayError",
14
+ PRECONDITION_FAILED_ERROR = "PreconditionFailedError",
15
+ PAYLOAD_TOO_LARGE_ERROR = "PayloadTooLargeError"
16
+ }
17
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/enums/errors.ts"],"names":[],"mappings":"AAAA,oBAAY,MAAM;IAChB,eAAe,kBAAkB;IACjC,cAAc,kBAAkB;IAChC,eAAe,mBAAmB;IAClC,YAAY,gBAAgB;IAC5B,kBAAkB,sBAAsB;IACxC,iBAAiB,oBAAoB;IACrC,0BAA0B,6BAA6B;IACvD,uBAAuB,yBAAyB;IAChD,qBAAqB,wBAAwB;IAC7C,yBAAyB,4BAA4B;IACrD,qBAAqB,wBAAwB;IAC7C,iBAAiB,oBAAoB;IACrC,yBAAyB,4BAA4B;IACrD,uBAAuB,yBAAyB;CACjD"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Errors = void 0;
4
+ var Errors;
5
+ (function (Errors) {
6
+ Errors["NOT_FOUND_ERROR"] = "NotFoundError";
7
+ Errors["BUSINESS_ERROR"] = "BusinessError";
8
+ Errors["FORBIDDEN_ERROR"] = "ForbiddenError";
9
+ Errors["SERVER_ERROR"] = "ServerError";
10
+ Errors["UNAUTHORIZED_ERROR"] = "UnauthorizedError";
11
+ Errors["BAD_REQUEST_ERROR"] = "BadRequestError";
12
+ Errors["UNPROCESSABLE_ENTITY_ERROR"] = "UnprocessableEntityError";
13
+ Errors["TOO_MANY_REQUESTS_ERROR"] = "TooManyRequestsError";
14
+ Errors["INTERNAL_SERVER_ERROR"] = "InternalServerError";
15
+ Errors["SERVICE_UNAVAILABLE_ERROR"] = "ServiceUnavailableError";
16
+ Errors["GATEWAY_TIMEOUT_ERROR"] = "GatewayTimeoutError";
17
+ Errors["BAD_GATEWAY_ERROR"] = "BadGatewayError";
18
+ Errors["PRECONDITION_FAILED_ERROR"] = "PreconditionFailedError";
19
+ Errors["PAYLOAD_TOO_LARGE_ERROR"] = "PayloadTooLargeError";
20
+ })(Errors || (exports.Errors = Errors = {}));
21
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/enums/errors.ts"],"names":[],"mappings":";;;AAAA,IAAY,MAeX;AAfD,WAAY,MAAM;IAChB,2CAAiC,CAAA;IACjC,0CAAgC,CAAA;IAChC,4CAAkC,CAAA;IAClC,sCAA4B,CAAA;IAC5B,kDAAwC,CAAA;IACxC,+CAAqC,CAAA;IACrC,iEAAuD,CAAA;IACvD,0DAAgD,CAAA;IAChD,uDAA6C,CAAA;IAC7C,+DAAqD,CAAA;IACrD,uDAA6C,CAAA;IAC7C,+CAAqC,CAAA;IACrC,+DAAqD,CAAA;IACrD,0DAAgD,CAAA;AAClD,CAAC,EAfW,MAAM,sBAAN,MAAM,QAejB"}
@@ -0,0 +1,8 @@
1
+ export default class BaseError extends Error {
2
+ details?: Record<string, unknown>;
3
+ toErrorRecord(): {
4
+ error: string;
5
+ details?: unknown;
6
+ };
7
+ }
8
+ //# sourceMappingURL=BaseError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseError.d.ts","sourceRoot":"","sources":["../../src/errors/BaseError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,KAAK;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,aAAa,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;CAO7D"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class BaseError extends Error {
4
+ toErrorRecord() {
5
+ const obj = { error: this.message };
6
+ if (this.details) {
7
+ obj.details = this.details;
8
+ }
9
+ return obj;
10
+ }
11
+ }
12
+ exports.default = BaseError;
13
+ //# sourceMappingURL=BaseError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseError.js","sourceRoot":"","sources":["../../src/errors/BaseError.ts"],"names":[],"mappings":";;AAAA,MAAqB,SAAU,SAAQ,KAAK;IAEnC,aAAa;QAClB,MAAM,GAAG,GAAyC,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QAC1E,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AATD,4BASC"}
@@ -0,0 +1,6 @@
1
+ import BaseError from '../errors/BaseError';
2
+ export default class BusinessError extends BaseError {
3
+ details?: Record<string, unknown>;
4
+ constructor(message: string, details?: Record<string, unknown>);
5
+ }
6
+ //# sourceMappingURL=BusinessError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BusinessError.d.ts","sourceRoot":"","sources":["../../src/errors/BusinessError.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAG3C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAS;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAMtE"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseError_1 = __importDefault(require("../errors/BaseError"));
7
+ const errors_1 = require("../enums/errors");
8
+ class BusinessError extends BaseError_1.default {
9
+ constructor(message, details) {
10
+ super(message);
11
+ this.name = errors_1.Errors.BUSINESS_ERROR;
12
+ this.details = details || {};
13
+ Object.setPrototypeOf(this, BusinessError.prototype);
14
+ }
15
+ }
16
+ exports.default = BusinessError;
17
+ //# sourceMappingURL=BusinessError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BusinessError.js","sourceRoot":"","sources":["../../src/errors/BusinessError.ts"],"names":[],"mappings":";;;;;AAAA,mEAA2C;AAC3C,2CAAwC;AAExC,MAAqB,aAAc,SAAQ,mBAAS;IAElD,YAAmB,OAAe,EAAE,OAAiC;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAM,CAAC,cAAc,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AARD,gCAQC"}
@@ -0,0 +1,6 @@
1
+ import BaseError from './BaseError';
2
+ export default class ForbiddenError extends BaseError {
3
+ details?: Record<string, unknown>;
4
+ constructor(message: string, details?: Record<string, unknown>);
5
+ }
6
+ //# sourceMappingURL=ForbiddenError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForbiddenError.d.ts","sourceRoot":"","sources":["../../src/errors/ForbiddenError.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,SAAS;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAMtE"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseError_1 = __importDefault(require("./BaseError"));
7
+ const errors_1 = require("../enums/errors");
8
+ class ForbiddenError extends BaseError_1.default {
9
+ constructor(message, details) {
10
+ super(message);
11
+ this.name = errors_1.Errors.FORBIDDEN_ERROR;
12
+ this.details = details || {};
13
+ Object.setPrototypeOf(this, ForbiddenError.prototype);
14
+ }
15
+ }
16
+ exports.default = ForbiddenError;
17
+ //# sourceMappingURL=ForbiddenError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForbiddenError.js","sourceRoot":"","sources":["../../src/errors/ForbiddenError.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AACpC,4CAAyC;AAEzC,MAAqB,cAAe,SAAQ,mBAAS;IAEnD,YAAmB,OAAe,EAAE,OAAiC;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAM,CAAC,eAAe,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;CACF;AARD,iCAQC"}
@@ -0,0 +1,6 @@
1
+ import BaseError from './BaseError';
2
+ export default class NotFoundError extends BaseError {
3
+ details?: Record<string, unknown>;
4
+ constructor(message: string, details?: Record<string, unknown>);
5
+ }
6
+ //# sourceMappingURL=NotFoundError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotFoundError.d.ts","sourceRoot":"","sources":["../../src/errors/NotFoundError.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAS;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAMtE"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseError_1 = __importDefault(require("./BaseError"));
7
+ const errors_1 = require("../enums/errors");
8
+ class NotFoundError extends BaseError_1.default {
9
+ constructor(message, details) {
10
+ super(message);
11
+ this.name = errors_1.Errors.NOT_FOUND_ERROR;
12
+ this.details = details || {};
13
+ Object.setPrototypeOf(this, NotFoundError.prototype);
14
+ }
15
+ }
16
+ exports.default = NotFoundError;
17
+ //# sourceMappingURL=NotFoundError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotFoundError.js","sourceRoot":"","sources":["../../src/errors/NotFoundError.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AACpC,4CAAyC;AAEzC,MAAqB,aAAc,SAAQ,mBAAS;IAElD,YAAmB,OAAe,EAAE,OAAiC;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAM,CAAC,eAAe,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AARD,gCAQC"}
@@ -0,0 +1,6 @@
1
+ import BaseError from './BaseError';
2
+ export default class ServerError extends BaseError {
3
+ details?: Record<string, unknown>;
4
+ constructor(message: string, details?: Record<string, unknown>);
5
+ }
6
+ //# sourceMappingURL=ServerError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServerError.d.ts","sourceRoot":"","sources":["../../src/errors/ServerError.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAAS;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAMtE"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseError_1 = __importDefault(require("./BaseError"));
7
+ const errors_1 = require("../enums/errors");
8
+ class ServerError extends BaseError_1.default {
9
+ constructor(message, details) {
10
+ super(message);
11
+ this.name = errors_1.Errors.SERVER_ERROR;
12
+ this.details = details || {};
13
+ Object.setPrototypeOf(this, ServerError.prototype);
14
+ }
15
+ }
16
+ exports.default = ServerError;
17
+ //# sourceMappingURL=ServerError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServerError.js","sourceRoot":"","sources":["../../src/errors/ServerError.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AACpC,4CAAyC;AAEzC,MAAqB,WAAY,SAAQ,mBAAS;IAEhD,YAAmB,OAAe,EAAE,OAAiC;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAM,CAAC,YAAY,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;CACF;AARD,8BAQC"}
@@ -0,0 +1,6 @@
1
+ import BaseError from './BaseError';
2
+ export default class UnauthorizedError extends BaseError {
3
+ details?: Record<string, unknown>;
4
+ constructor(message: string, details?: Record<string, unknown>);
5
+ }
6
+ //# sourceMappingURL=UnauthorizedError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnauthorizedError.d.ts","sourceRoot":"","sources":["../../src/errors/UnauthorizedError.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,SAAS;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAMtE"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseError_1 = __importDefault(require("./BaseError"));
7
+ const errors_1 = require("../enums/errors");
8
+ class UnauthorizedError extends BaseError_1.default {
9
+ constructor(message, details) {
10
+ super(message);
11
+ this.name = errors_1.Errors.UNAUTHORIZED_ERROR;
12
+ this.details = details || {};
13
+ Object.setPrototypeOf(this, UnauthorizedError.prototype);
14
+ }
15
+ }
16
+ exports.default = UnauthorizedError;
17
+ //# sourceMappingURL=UnauthorizedError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnauthorizedError.js","sourceRoot":"","sources":["../../src/errors/UnauthorizedError.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AACpC,4CAAyC;AAEzC,MAAqB,iBAAkB,SAAQ,mBAAS;IAEtD,YAAmB,OAAe,EAAE,OAAiC;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAM,CAAC,kBAAkB,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;CACF;AARD,oCAQC"}
@@ -0,0 +1,10 @@
1
+ export * from './interfaces/general/IConfig';
2
+ export * from './interfaces/general/IPaginatedResponse';
3
+ export * from './interfaces/general/IServerInit';
4
+ export * from './interfaces/general/IApiResponse';
5
+ export * from './enums/errors';
6
+ export * from './errors/BaseError';
7
+ export * from './errors/BusinessError';
8
+ export * from './errors/ForbiddenError';
9
+ export * from './errors/NotFoundError';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yCAAyC,CAAC;AACxD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAGlD,cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./interfaces/general/IConfig"), exports);
18
+ __exportStar(require("./interfaces/general/IPaginatedResponse"), exports);
19
+ __exportStar(require("./interfaces/general/IServerInit"), exports);
20
+ __exportStar(require("./interfaces/general/IApiResponse"), exports);
21
+ __exportStar(require("./enums/errors"), exports);
22
+ __exportStar(require("./errors/BaseError"), exports);
23
+ __exportStar(require("./errors/BusinessError"), exports);
24
+ __exportStar(require("./errors/ForbiddenError"), exports);
25
+ __exportStar(require("./errors/NotFoundError"), exports);
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAMA,+DAA6C;AAC7C,0EAAwD;AACxD,mEAAiD;AACjD,oEAAkD;AAGlD,iDAA+B;AAG/B,qDAAmC;AACnC,yDAAuC;AACvC,0DAAwC;AACxC,yDAAuC"}
@@ -0,0 +1,9 @@
1
+ import type { IPagination } from '../../interfaces/general/IPagination';
2
+ export interface IApiResponse<T = unknown> {
3
+ success: boolean;
4
+ data?: T;
5
+ pagination?: IPagination;
6
+ error?: string;
7
+ message?: string;
8
+ }
9
+ //# sourceMappingURL=IApiResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IApiResponse.d.ts","sourceRoot":"","sources":["../../../src/interfaces/general/IApiResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAEpE,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IApiResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IApiResponse.js","sourceRoot":"","sources":["../../../src/interfaces/general/IApiResponse.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ export interface IConfig {
2
+ port: number;
3
+ cors: {
4
+ origin: string;
5
+ };
6
+ environment: string;
7
+ apiVersions: string[];
8
+ mongodbUri?: string;
9
+ mongodbDbName?: string;
10
+ maxRequestRateLimit?: number;
11
+ maxTimeoutRateLimit?: number;
12
+ jwtSecret?: string;
13
+ jwtExpirationTime?: string;
14
+ saltRounds?: number;
15
+ redisUrl?: string;
16
+ jwtRecoveryPasswordSecret?: string;
17
+ jwtRecoveryPasswordExpirationTime?: string;
18
+ resendApiKey?: string;
19
+ frontendUrl?: string;
20
+ emailFromDomain?: string;
21
+ auth0Domain?: string;
22
+ auth0ClientId?: string;
23
+ auth0ClientSecret?: string;
24
+ auth0Audience?: string;
25
+ }
26
+ //# sourceMappingURL=IConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IConfig.d.ts","sourceRoot":"","sources":["../../../src/interfaces/general/IConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IConfig.js","sourceRoot":"","sources":["../../../src/interfaces/general/IConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { IPagination } from '../../interfaces/general/IPagination';
2
+ export interface IPaginatedResponse<T> {
3
+ data: T[];
4
+ pagination: IPagination;
5
+ }
6
+ //# sourceMappingURL=IPaginatedResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPaginatedResponse.d.ts","sourceRoot":"","sources":["../../../src/interfaces/general/IPaginatedResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAEpE,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,EAAE,WAAW,CAAC;CACzB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IPaginatedResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPaginatedResponse.js","sourceRoot":"","sources":["../../../src/interfaces/general/IPaginatedResponse.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export interface IPagination {
2
+ page: number;
3
+ limit: number;
4
+ total: number;
5
+ totalPages: number;
6
+ }
7
+ //# sourceMappingURL=IPagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPagination.d.ts","sourceRoot":"","sources":["../../../src/interfaces/general/IPagination.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IPagination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPagination.js","sourceRoot":"","sources":["../../../src/interfaces/general/IPagination.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { Application } from 'express';
2
+ import type { Logger } from 'winston';
3
+ import type { IConfig } from '../../interfaces/general/IConfig';
4
+ export interface IServerInit {
5
+ app: Application;
6
+ config: IConfig;
7
+ logger: Logger;
8
+ }
9
+ //# sourceMappingURL=IServerInit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IServerInit.d.ts","sourceRoot":"","sources":["../../../src/interfaces/general/IServerInit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,WAAW,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IServerInit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IServerInit.js","sourceRoot":"","sources":["../../../src/interfaces/general/IServerInit.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@ipetsadmin/contracts",
3
+ "version": "1.0.0",
4
+ "description": "Shared types, enums, and interfaces for Truffa projects",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md",
10
+ "LICENSE",
11
+ "CHANGELOG.md"
12
+ ],
13
+ "lint-staged": {
14
+ "*.{ts,tsx}": [
15
+ "eslint --fix --max-warnings 0",
16
+ "prettier --write"
17
+ ],
18
+ "*.{json,md}": "prettier --write"
19
+ },
20
+ "engines": {
21
+ "node": ">=18.18.0"
22
+ },
23
+ "keywords": [
24
+ "types",
25
+ "typescript",
26
+ "shared"
27
+ ],
28
+ "author": "",
29
+ "license": "MIT",
30
+ "devDependencies": {
31
+ "@eslint/js": "^10.0.1",
32
+ "@types/express": "^5.0.5",
33
+ "@types/node": "^24.10.0",
34
+ "eslint": "^10.1.0",
35
+ "eslint-config-prettier": "^10.1.8",
36
+ "husky": "^9.1.7",
37
+ "lint-staged": "^16.4.0",
38
+ "prettier": "^3.8.1",
39
+ "tsc-alias": "^1.8.16",
40
+ "typescript": "^5.9.3",
41
+ "typescript-eslint": "^8.58.0"
42
+ },
43
+ "peerDependencies": {
44
+ "express": "^5.1.0",
45
+ "mongodb": "^6.2.0",
46
+ "winston": "^3.18.3"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "scripts": {
52
+ "build": "tsc && tsc-alias",
53
+ "clean": "rm -rf dist",
54
+ "typecheck": "tsc --noEmit",
55
+ "lint": "eslint . --cache --cache-location .eslintcache",
56
+ "lint:fix": "eslint . --fix --cache --cache-location .eslintcache",
57
+ "format": "prettier --write .",
58
+ "format:check": "prettier --check .",
59
+ "validate": "pnpm run typecheck && pnpm run lint && pnpm run format:check",
60
+ "publish:npm": "pnpm publish --access public --no-git-checks"
61
+ }
62
+ }