@karbonjs/types 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KarbonJS
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,39 @@
1
+ # @karbonjs/types
2
+
3
+ Shared TypeScript types for Karbon API responses. Used by `@karbonjs/api` and your application code.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @karbonjs/types
9
+ ```
10
+
11
+ ## Types
12
+
13
+ ```typescript
14
+ import type { ApiList, ApiResult, ApiError, ApiCallOptions, BaseContent, AuthUser, PaginationParams } from '@karbonjs/types'
15
+
16
+ // Paginated API response
17
+ const res: ApiList<Article> = await callApi('/articles')
18
+ res.data // Article[]
19
+ res.meta.total // number
20
+ res.meta.page // number
21
+
22
+ // Base content fields (common to all CMS content types)
23
+ interface Article extends BaseContent {
24
+ body: string
25
+ bodyShort: string
26
+ }
27
+
28
+ // Auth user
29
+ const user: AuthUser = {
30
+ id: 1,
31
+ username: 'admin',
32
+ email: 'admin@example.com',
33
+ roles: ['ROLE_ADMIN'],
34
+ }
35
+ ```
36
+
37
+ ## License
38
+
39
+ MIT
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Standard paginated API response from Karbon backend.
3
+ */
4
+ export interface ApiList<T> {
5
+ ok?: boolean;
6
+ data: T[];
7
+ meta: {
8
+ page: number;
9
+ per_page: number;
10
+ total: number;
11
+ total_pages: number;
12
+ has_next: boolean;
13
+ has_prev: boolean;
14
+ };
15
+ }
16
+ /**
17
+ * Standard API error response.
18
+ */
19
+ export interface ApiError {
20
+ ok: false;
21
+ status: number;
22
+ error?: string;
23
+ message: string;
24
+ }
25
+ /**
26
+ * Generic API result — either success with data, or error.
27
+ */
28
+ export interface ApiResult {
29
+ ok: boolean;
30
+ status?: number;
31
+ message?: string;
32
+ [key: string]: any;
33
+ }
34
+ /**
35
+ * Options for server-side API calls.
36
+ */
37
+ export interface ApiCallOptions {
38
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
39
+ body?: Record<string, any>;
40
+ token?: string | null;
41
+ headers?: Record<string, string>;
42
+ timeout?: number;
43
+ }
44
+ /**
45
+ * Pagination query params.
46
+ */
47
+ export interface PaginationParams {
48
+ page?: number;
49
+ per_page?: number;
50
+ sort?: string;
51
+ order?: 'asc' | 'desc';
52
+ search?: string;
53
+ }
54
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,EAAE,CAAC,EAAE,OAAO,CAAA;IACZ,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,EAAE,MAAM,CAAA;QACnB,QAAQ,EAAE,OAAO,CAAA;QACjB,QAAQ,EAAE,OAAO,CAAA;KAClB,CAAA;CACF;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,KAAK,CAAA;IACT,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * User session info.
3
+ */
4
+ export interface AuthUser {
5
+ id: number;
6
+ username: string;
7
+ email: string;
8
+ roles: string[];
9
+ }
10
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './api';
2
+ export * from './auth';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './api';
2
+ export * from './auth';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA"}
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@karbonjs/types",
3
+ "version": "0.1.0",
4
+ "description": "Shared TypeScript types for Karbon API responses",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "license": "MIT",
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "dev": "tsc --watch"
24
+ }
25
+ }