@cravery/core 0.0.13 → 0.0.14

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.
@@ -11,4 +11,6 @@ export type ApiErrorResponse = {
11
11
  };
12
12
  };
13
13
  export type ApiResponse<T> = ApiSuccessResponse<T> | ApiErrorResponse;
14
+ export declare function success<T>(data: T): ApiSuccessResponse<T>;
15
+ export declare function failure(code: string, message: string, details?: unknown): ApiErrorResponse;
14
16
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/types/core/api.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;IAClC,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/types/core/api.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;IAClC,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC;AAEtE,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAEzD;AAED,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,OAAO,GAChB,gBAAgB,CAKlB"}
@@ -1,3 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.success = success;
4
+ exports.failure = failure;
5
+ function success(data) {
6
+ return { success: true, data };
7
+ }
8
+ function failure(code, message, details) {
9
+ return {
10
+ success: false,
11
+ error: { code, message, details },
12
+ };
13
+ }
3
14
  //# sourceMappingURL=api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/types/core/api.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/types/core/api.ts"],"names":[],"mappings":";;AAgBA,0BAEC;AAED,0BASC;AAbD,SAAgB,OAAO,CAAI,IAAO;IAChC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC;AAED,SAAgB,OAAO,CACrB,IAAY,EACZ,OAAe,EACf,OAAiB;IAEjB,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;KAClC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cravery/core",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Clean architecture foundation for Cravery",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,3 +13,18 @@ export type ApiErrorResponse = {
13
13
  };
14
14
 
15
15
  export type ApiResponse<T> = ApiSuccessResponse<T> | ApiErrorResponse;
16
+
17
+ export function success<T>(data: T): ApiSuccessResponse<T> {
18
+ return { success: true, data };
19
+ }
20
+
21
+ export function failure(
22
+ code: string,
23
+ message: string,
24
+ details?: unknown,
25
+ ): ApiErrorResponse {
26
+ return {
27
+ success: false,
28
+ error: { code, message, details },
29
+ };
30
+ }