@crmy/shared 0.5.1 → 0.5.2
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/dist/errors.d.ts +21 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +36 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/index.ts → dist/index.js} +1 -1
- package/dist/index.js.map +1 -0
- package/dist/schemas.d.ts +2129 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +724 -0
- package/dist/schemas.js.map +1 -0
- package/dist/types.d.ts +462 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +42 -0
- package/dist/types.js.map +1 -0
- package/package.json +5 -1
- package/src/errors.ts +0 -49
- package/src/schemas.ts +0 -858
- package/src/types.ts +0 -577
- package/tsconfig.json +0 -9
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ErrorCode = 'VALIDATION_ERROR' | 'NOT_FOUND' | 'PERMISSION_DENIED' | 'QUOTA_EXCEEDED' | 'CONFLICT' | 'UNAUTHORIZED' | 'INTERNAL_ERROR';
|
|
2
|
+
export declare class CrmyError extends Error {
|
|
3
|
+
readonly code: ErrorCode;
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
6
|
+
constructor(code: ErrorCode, message: string, status?: number, details?: Record<string, unknown> | undefined);
|
|
7
|
+
toJSON(): {
|
|
8
|
+
type: string;
|
|
9
|
+
title: string;
|
|
10
|
+
status: number;
|
|
11
|
+
detail: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function notFound(entity: string, id: string): CrmyError;
|
|
15
|
+
export declare function validationError(message: string, errors?: {
|
|
16
|
+
field: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}[]): CrmyError;
|
|
19
|
+
export declare function permissionDenied(message?: string): CrmyError;
|
|
20
|
+
export declare function unauthorized(message?: string): CrmyError;
|
|
21
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GACjB,kBAAkB,GAClB,WAAW,GACX,mBAAmB,GACnB,gBAAgB,GAChB,UAAU,GACV,cAAc,GACd,gBAAgB,CAAC;AAErB,qBAAa,SAAU,SAAQ,KAAK;aAEhB,IAAI,EAAE,SAAS;aAEf,MAAM,EAAE,MAAM;aACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAHjC,IAAI,EAAE,SAAS,EAC/B,OAAO,EAAE,MAAM,EACC,MAAM,GAAE,MAAY,EACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;IAMnD,MAAM;;;;;;CASP;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,SAAS,CAEzG;AAED,wBAAgB,gBAAgB,CAAC,OAAO,SAAsB,GAAG,SAAS,CAEzE;AAED,wBAAgB,YAAY,CAAC,OAAO,SAAiB,GAAG,SAAS,CAEhE"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright 2026 CRMy Contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export class CrmyError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
status;
|
|
6
|
+
details;
|
|
7
|
+
constructor(code, message, status = 400, details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.status = status;
|
|
11
|
+
this.details = details;
|
|
12
|
+
this.name = 'CrmyError';
|
|
13
|
+
}
|
|
14
|
+
toJSON() {
|
|
15
|
+
return {
|
|
16
|
+
type: `https://crmy.ai/errors/${this.code.toLowerCase()}`,
|
|
17
|
+
title: this.code.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase()),
|
|
18
|
+
status: this.status,
|
|
19
|
+
detail: this.message,
|
|
20
|
+
...this.details,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function notFound(entity, id) {
|
|
25
|
+
return new CrmyError('NOT_FOUND', `${entity} ${id} not found`, 404);
|
|
26
|
+
}
|
|
27
|
+
export function validationError(message, errors) {
|
|
28
|
+
return new CrmyError('VALIDATION_ERROR', message, 422, errors ? { errors } : undefined);
|
|
29
|
+
}
|
|
30
|
+
export function permissionDenied(message = 'Permission denied') {
|
|
31
|
+
return new CrmyError('PERMISSION_DENIED', message, 403);
|
|
32
|
+
}
|
|
33
|
+
export function unauthorized(message = 'Unauthorized') {
|
|
34
|
+
return new CrmyError('UNAUTHORIZED', message, 401);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,sCAAsC;AAWtC,MAAM,OAAO,SAAU,SAAQ,KAAK;IAEhB;IAEA;IACA;IAJlB,YACkB,IAAe,EAC/B,OAAe,EACC,SAAiB,GAAG,EACpB,OAAiC;QAEjD,KAAK,CAAC,OAAO,CAAC,CAAC;QALC,SAAI,GAAJ,IAAI,CAAW;QAEf,WAAM,GAAN,MAAM,CAAc;QACpB,YAAO,GAAP,OAAO,CAA0B;QAGjD,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,0BAA0B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE;YACzD,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;YAC1E,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,GAAG,IAAI,CAAC,OAAO;SAChB,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,EAAU;IACjD,OAAO,IAAI,SAAS,CAAC,WAAW,EAAE,GAAG,MAAM,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,MAA6C;IAC5F,OAAO,IAAI,SAAS,CAAC,kBAAkB,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAC1F,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAO,GAAG,mBAAmB;IAC5D,OAAO,IAAI,SAAS,CAAC,mBAAmB,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAO,GAAG,cAAc;IACnD,OAAO,IAAI,SAAS,CAAC,cAAc,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,sCAAsC;AAEtC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|