@ooneex/types 0.0.1 → 0.0.5

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/README.md CHANGED
@@ -1 +1,357 @@
1
- # @ooneex/router
1
+ # @ooneex/types
2
+
3
+ Shared TypeScript types, interfaces, and base definitions used across the Ooneex framework. This package provides common type definitions for HTTP methods, character encodings, scalar values, and base entity interfaces that ensure consistency throughout your application.
4
+
5
+ ![Browser](https://img.shields.io/badge/Browser-Compatible-green?style=flat-square&logo=googlechrome)
6
+ ![Bun](https://img.shields.io/badge/Bun-Compatible-orange?style=flat-square&logo=bun)
7
+ ![Deno](https://img.shields.io/badge/Deno-Compatible-blue?style=flat-square&logo=deno)
8
+ ![Node.js](https://img.shields.io/badge/Node.js-Compatible-green?style=flat-square&logo=node.js)
9
+ ![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue?style=flat-square&logo=typescript)
10
+ ![MIT License](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)
11
+
12
+ ## Features
13
+
14
+ ✅ **HTTP Method Types** - Type-safe HTTP method definitions (GET, POST, PUT, DELETE, etc.)
15
+
16
+ ✅ **Base Interfaces** - Common entity interfaces with standard fields (id, timestamps, etc.)
17
+
18
+ ✅ **Scalar Types** - Union type for primitive values (boolean, number, bigint, string)
19
+
20
+ ✅ **Filter Result Type** - Standardized pagination and filtering result structure
21
+
22
+ ✅ **Encoding Types** - Character encoding and compression type definitions
23
+
24
+ ✅ **Zero Runtime** - Pure type definitions with no runtime overhead
25
+
26
+ ## Installation
27
+
28
+ ### Bun
29
+ ```bash
30
+ bun add @ooneex/types
31
+ ```
32
+
33
+ ### pnpm
34
+ ```bash
35
+ pnpm add @ooneex/types
36
+ ```
37
+
38
+ ### Yarn
39
+ ```bash
40
+ yarn add @ooneex/types
41
+ ```
42
+
43
+ ### npm
44
+ ```bash
45
+ npm install @ooneex/types
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ ### HTTP Method Types
51
+
52
+ ```typescript
53
+ import { HTTP_METHODS, type HttpMethodType } from '@ooneex/types';
54
+
55
+ // Type-safe HTTP method
56
+ const method: HttpMethodType = 'GET';
57
+
58
+ // Use the constant array
59
+ HTTP_METHODS.forEach(m => console.log(m));
60
+ // GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD
61
+
62
+ // Function with HTTP method parameter
63
+ function makeRequest(url: string, method: HttpMethodType): void {
64
+ fetch(url, { method });
65
+ }
66
+
67
+ makeRequest('/api/users', 'POST'); // ✓ Valid
68
+ makeRequest('/api/users', 'INVALID'); // ✗ Type error
69
+ ```
70
+
71
+ ### Base Entity Interface
72
+
73
+ ```typescript
74
+ import type { IBase } from '@ooneex/types';
75
+
76
+ interface User extends IBase {
77
+ email: string;
78
+ name: string;
79
+ }
80
+
81
+ const user: User = {
82
+ id: 'user-123',
83
+ email: 'john@example.com',
84
+ name: 'John Doe',
85
+ createdAt: new Date(),
86
+ updatedAt: new Date(),
87
+ isPublic: true
88
+ };
89
+ ```
90
+
91
+ ### Stat Interface for Social Features
92
+
93
+ ```typescript
94
+ import type { IStat } from '@ooneex/types';
95
+
96
+ interface Post extends IStat {
97
+ title: string;
98
+ content: string;
99
+ }
100
+
101
+ const post: Post = {
102
+ id: 'post-456',
103
+ title: 'Hello World',
104
+ content: 'My first post',
105
+ commentsCount: 42,
106
+ likesCount: 156,
107
+ viewsCount: 1200,
108
+ sharesCount: 23,
109
+ // ... other IStat fields
110
+ };
111
+ ```
112
+
113
+ ### Scalar Types
114
+
115
+ ```typescript
116
+ import type { ScalarType } from '@ooneex/types';
117
+
118
+ // ScalarType accepts boolean, number, bigint, or string
119
+ const values: ScalarType[] = [
120
+ true,
121
+ 42,
122
+ BigInt(9007199254740991),
123
+ 'hello'
124
+ ];
125
+
126
+ // Useful for generic key-value data
127
+ function logData(data: Record<string, ScalarType>): void {
128
+ for (const [key, value] of Object.entries(data)) {
129
+ console.log(`${key}: ${value}`);
130
+ }
131
+ }
132
+
133
+ logData({
134
+ name: 'John',
135
+ age: 30,
136
+ active: true
137
+ });
138
+ ```
139
+
140
+ ### Filter Result Type
141
+
142
+ ```typescript
143
+ import type { FilterResultType } from '@ooneex/types';
144
+
145
+ interface Product {
146
+ id: string;
147
+ name: string;
148
+ price: number;
149
+ }
150
+
151
+ // Paginated response type
152
+ type ProductListResponse = FilterResultType<Product>;
153
+
154
+ const response: ProductListResponse = {
155
+ resources: [
156
+ { id: '1', name: 'Widget', price: 9.99 },
157
+ { id: '2', name: 'Gadget', price: 19.99 }
158
+ ],
159
+ total: 50,
160
+ totalPages: 5,
161
+ page: 1,
162
+ limit: 10
163
+ };
164
+ ```
165
+
166
+ ## API Reference
167
+
168
+ ### Constants
169
+
170
+ #### `HTTP_METHODS`
171
+
172
+ Array of valid HTTP method strings.
173
+
174
+ ```typescript
175
+ const HTTP_METHODS = ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"] as const;
176
+ ```
177
+
178
+ ### Types
179
+
180
+ #### `HttpMethodType`
181
+
182
+ Union type of valid HTTP methods.
183
+
184
+ ```typescript
185
+ type HttpMethodType = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD";
186
+ ```
187
+
188
+ #### `ScalarType`
189
+
190
+ Union type for primitive scalar values.
191
+
192
+ ```typescript
193
+ type ScalarType = boolean | number | bigint | string;
194
+ ```
195
+
196
+ #### `EncodingType`
197
+
198
+ Valid HTTP content encoding types.
199
+
200
+ ```typescript
201
+ type EncodingType = "deflate" | "gzip" | "compress" | "br" | "identity" | "*";
202
+ ```
203
+
204
+ #### `CharsetType`
205
+
206
+ Common character set encodings.
207
+
208
+ ```typescript
209
+ type CharsetType = "ISO-8859-1" | "7-BIT" | "UTF-8" | "UTF-16" | "US-ASCII";
210
+ ```
211
+
212
+ #### `FilterResultType<T>`
213
+
214
+ Generic type for paginated results.
215
+
216
+ ```typescript
217
+ type FilterResultType<T> = {
218
+ resources: T[];
219
+ total: number;
220
+ totalPages: number;
221
+ page: number;
222
+ limit: number;
223
+ };
224
+ ```
225
+
226
+ ### Interfaces
227
+
228
+ #### `IBase`
229
+
230
+ Base interface for all entities with common fields.
231
+
232
+ ```typescript
233
+ interface IBase {
234
+ id: string;
235
+ isLocked?: boolean;
236
+ lockedAt?: Date;
237
+ isBlocked?: boolean;
238
+ blockedAt?: Date;
239
+ blockReason?: string;
240
+ isPublic?: boolean;
241
+ createdAt?: Date;
242
+ updatedAt?: Date;
243
+ deletedAt?: Date;
244
+ language?: LocaleType;
245
+ }
246
+ ```
247
+
248
+ #### `IStat`
249
+
250
+ Extended interface for entities with social/engagement statistics.
251
+
252
+ ```typescript
253
+ interface IStat extends IBase {
254
+ commentsCount: number;
255
+ likesCount: number;
256
+ dislikesCount: number;
257
+ sharesCount: number;
258
+ viewsCount: number;
259
+ downloadsCount: number;
260
+ savesCount: number;
261
+ bookmarksCount: number;
262
+ repostsCount: number;
263
+ impressionsCount: number;
264
+ clicksCount: number;
265
+ engagementRate: number;
266
+ reach: number;
267
+ followersCount: number;
268
+ followingCount: number;
269
+ blockedCount: number;
270
+ reportsCount: number;
271
+ }
272
+ ```
273
+
274
+ ## Advanced Usage
275
+
276
+ ### Building Custom Entity Types
277
+
278
+ ```typescript
279
+ import type { IBase, ScalarType } from '@ooneex/types';
280
+
281
+ // Extend IBase for your domain entities
282
+ interface Article extends IBase {
283
+ title: string;
284
+ slug: string;
285
+ content: string;
286
+ authorId: string;
287
+ publishedAt?: Date;
288
+ tags: string[];
289
+ }
290
+
291
+ // Use ScalarType for metadata
292
+ interface ArticleMeta {
293
+ [key: string]: ScalarType;
294
+ }
295
+ ```
296
+
297
+ ### Type-Safe API Responses
298
+
299
+ ```typescript
300
+ import type { FilterResultType, HttpMethodType } from '@ooneex/types';
301
+
302
+ interface ApiResponse<T> {
303
+ data: T;
304
+ success: boolean;
305
+ }
306
+
307
+ interface PaginatedApiResponse<T> extends ApiResponse<FilterResultType<T>> {}
308
+
309
+ // Type-safe API client
310
+ async function fetchPaginated<T>(
311
+ endpoint: string,
312
+ method: HttpMethodType = 'GET'
313
+ ): Promise<PaginatedApiResponse<T>> {
314
+ const response = await fetch(endpoint, { method });
315
+ return response.json();
316
+ }
317
+ ```
318
+
319
+ ### Generic Repository Interface
320
+
321
+ ```typescript
322
+ import type { IBase, FilterResultType } from '@ooneex/types';
323
+
324
+ interface IRepository<T extends IBase> {
325
+ findById(id: string): Promise<T | null>;
326
+ findAll(page: number, limit: number): Promise<FilterResultType<T>>;
327
+ create(data: Omit<T, keyof IBase>): Promise<T>;
328
+ update(id: string, data: Partial<T>): Promise<T>;
329
+ delete(id: string): Promise<boolean>;
330
+ }
331
+ ```
332
+
333
+ ## License
334
+
335
+ This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
336
+
337
+ ## Contributing
338
+
339
+ Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
340
+
341
+ ### Development Setup
342
+
343
+ 1. Clone the repository
344
+ 2. Install dependencies: `bun install`
345
+ 3. Run tests: `bun run test`
346
+ 4. Build the project: `bun run build`
347
+
348
+ ### Guidelines
349
+
350
+ - Write tests for new features
351
+ - Follow the existing code style
352
+ - Update documentation for API changes
353
+ - Ensure all tests pass before submitting PR
354
+
355
+ ---
356
+
357
+ Made with ❤️ by the Ooneex team
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { LocaleType } from "@ooneex/translation";
2
- type HttpMethodType = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD";
2
+ declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"];
3
+ type HttpMethodType = (typeof HTTP_METHODS)[number];
3
4
  type EncodingType = "deflate" | "gzip" | "compress" | "br" | "identity" | "*";
4
5
  type CharsetType = "ISO-8859-1" | "7-BIT" | "UTF-8" | "UTF-16" | "US-ASCII";
5
6
  type ScalarType = boolean | number | bigint | string;
@@ -17,19 +18,23 @@ interface IBase {
17
18
  language?: LocaleType;
18
19
  }
19
20
  interface IStat extends IBase {
20
- commentCount: number;
21
- likeCount: number;
22
- shareCount: number;
23
- viewCount: number;
24
- downloadCount: number;
25
- bookmarkCount: number;
26
- repostCount: number;
27
- impressionCount: number;
28
- clickCount: number;
21
+ commentsCount: number;
22
+ likesCount: number;
23
+ dislikesCount: number;
24
+ sharesCount: number;
25
+ viewsCount: number;
26
+ downloadsCount: number;
27
+ savesCount: number;
28
+ bookmarksCount: number;
29
+ repostsCount: number;
30
+ impressionsCount: number;
31
+ clicksCount: number;
29
32
  engagementRate: number;
30
33
  reach: number;
31
- followerCount: number;
34
+ followersCount: number;
32
35
  followingCount: number;
36
+ blockedCount: number;
37
+ reportsCount: number;
33
38
  }
34
39
  type FilterResultType<T> = {
35
40
  resources: T[];
@@ -38,4 +43,4 @@ type FilterResultType<T> = {
38
43
  page: number;
39
44
  limit: number;
40
45
  };
41
- export { ScalarType, IStat, IBase, HttpMethodType, FilterResultType, EncodingType, CharsetType };
46
+ export { ScalarType, IStat, IBase, HttpMethodType, HTTP_METHODS, FilterResultType, EncodingType, CharsetType };
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ var e=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD"];export{e as HTTP_METHODS};
1
2
 
2
- //# debugId=8B7D82A81ED7E36264756E2164756E21
3
+ //# debugId=F2931533DC4FF1F964756E2164756E21
package/dist/index.js.map CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
3
+ "sources": ["src/index.ts"],
4
4
  "sourcesContent": [
5
+ "import type { LocaleType } from \"@ooneex/translation\";\n\nexport const HTTP_METHODS = [\"GET\", \"POST\", \"PUT\", \"DELETE\", \"PATCH\", \"OPTIONS\", \"HEAD\"] as const;\n\nexport type HttpMethodType = (typeof HTTP_METHODS)[number];\nexport type EncodingType = \"deflate\" | \"gzip\" | \"compress\" | \"br\" | \"identity\" | \"*\";\nexport type CharsetType = \"ISO-8859-1\" | \"7-BIT\" | \"UTF-8\" | \"UTF-16\" | \"US-ASCII\";\nexport type ScalarType = boolean | number | bigint | string;\n\nexport interface IBase {\n id: string;\n isLocked?: boolean;\n lockedAt?: Date;\n isBlocked?: boolean;\n blockedAt?: Date;\n blockReason?: string;\n isPublic?: boolean;\n createdAt?: Date;\n updatedAt?: Date;\n deletedAt?: Date;\n language?: LocaleType;\n}\n\nexport interface IStat extends IBase {\n commentsCount: number;\n likesCount: number;\n dislikesCount: number;\n sharesCount: number;\n viewsCount: number;\n downloadsCount: number;\n savesCount: number;\n bookmarksCount: number;\n repostsCount: number;\n impressionsCount: number;\n clicksCount: number;\n engagementRate: number;\n reach: number;\n followersCount: number;\n followingCount: number;\n blockedCount: number;\n reportsCount: number;\n}\n\nexport type FilterResultType<T> = {\n resources: T[];\n total: number;\n totalPages: number;\n page: number;\n limit: number;\n};\n"
5
6
  ],
6
- "mappings": "",
7
- "debugId": "8B7D82A81ED7E36264756E2164756E21",
7
+ "mappings": "AAEO,IAAM,EAAe,CAAC,MAAO,OAAQ,MAAO,SAAU,QAAS,UAAW,MAAM",
8
+ "debugId": "F2931533DC4FF1F964756E2164756E21",
8
9
  "names": []
9
10
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ooneex/types",
3
- "description": "",
4
- "version": "0.0.1",
3
+ "description": "Shared TypeScript types, interfaces, and base definitions used across the Ooneex framework",
4
+ "version": "0.0.5",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -25,11 +25,17 @@
25
25
  "test": "bun test tests",
26
26
  "build": "bunup",
27
27
  "lint": "tsgo --noEmit && bunx biome lint",
28
- "publish:prod": "bun publish --tolerate-republish --access public",
29
- "publish:pack": "bun pm pack --destination ./dist",
30
- "publish:dry": "bun publish --dry-run"
28
+ "npm:publish": "bun publish --tolerate-republish --access public"
31
29
  },
32
30
  "devDependencies": {
33
31
  "@ooneex/translation": "0.0.1"
34
- }
32
+ },
33
+ "keywords": [
34
+ "bun",
35
+ "definitions",
36
+ "ooneex",
37
+ "types",
38
+ "typescript",
39
+ "typings"
40
+ ]
35
41
  }
Binary file