@koala-ts/framework 2.0.0 → 2.1.1

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 (47) hide show
  1. package/dist/Http/Request/index.d.ts +2 -0
  2. package/dist/Http/Request/index.d.ts.map +1 -0
  3. package/dist/Http/Request/index.js +1 -0
  4. package/dist/Http/Request/index.js.map +1 -0
  5. package/dist/Http/Request/types.d.ts +10 -0
  6. package/dist/Http/Request/types.d.ts.map +1 -0
  7. package/dist/Http/Request/types.js.map +1 -0
  8. package/dist/Http/Response/index.d.ts +2 -0
  9. package/dist/Http/Response/index.d.ts.map +1 -0
  10. package/dist/Http/Response/index.js +1 -0
  11. package/dist/Http/Response/index.js.map +1 -0
  12. package/dist/Http/Response/types.d.ts +6 -0
  13. package/dist/Http/Response/types.d.ts.map +1 -0
  14. package/dist/Http/Response/types.js +1 -0
  15. package/dist/Http/Response/types.js.map +1 -0
  16. package/dist/Http/Scope/State/ScopeStoreFactory.d.ts +3 -0
  17. package/dist/Http/Scope/State/ScopeStoreFactory.d.ts.map +1 -0
  18. package/dist/Http/Scope/State/ScopeStoreFactory.js +45 -0
  19. package/dist/Http/Scope/State/ScopeStoreFactory.js.map +1 -0
  20. package/dist/Http/Scope/State/ScopeStoreFactory.test.d.ts +2 -0
  21. package/dist/Http/Scope/State/ScopeStoreFactory.test.d.ts.map +1 -0
  22. package/dist/Http/Scope/State/ScopeStoreFactory.test.js +134 -0
  23. package/dist/Http/Scope/State/ScopeStoreFactory.test.js.map +1 -0
  24. package/dist/Http/Scope/State/index.d.ts +4 -0
  25. package/dist/Http/Scope/State/index.d.ts.map +1 -0
  26. package/dist/Http/Scope/State/index.js +3 -0
  27. package/dist/Http/Scope/State/index.js.map +1 -0
  28. package/dist/Http/Scope/State/types.d.ts +11 -0
  29. package/dist/Http/Scope/State/types.d.ts.map +1 -0
  30. package/dist/Http/Scope/State/types.js +7 -0
  31. package/dist/Http/Scope/State/types.js.map +1 -0
  32. package/dist/Http/Scope/index.d.ts +3 -0
  33. package/dist/Http/Scope/index.d.ts.map +1 -0
  34. package/dist/Http/Scope/index.js +2 -0
  35. package/dist/Http/Scope/index.js.map +1 -0
  36. package/dist/Http/Scope/types.d.ts +11 -0
  37. package/dist/Http/Scope/types.d.ts.map +1 -0
  38. package/dist/Http/Scope/types.js +1 -0
  39. package/dist/Http/{types.js.map → Scope/types.js.map} +1 -1
  40. package/dist/Http/index.d.ts +3 -1
  41. package/dist/Http/index.d.ts.map +1 -1
  42. package/dist/Http/index.js +1 -0
  43. package/dist/Http/index.js.map +1 -1
  44. package/package.json +5 -1
  45. package/dist/Http/types.d.ts +0 -21
  46. package/dist/Http/types.d.ts.map +0 -1
  47. /package/dist/Http/{types.js → Request/types.js} +0 -0
@@ -0,0 +1,2 @@
1
+ export type * from './types.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Http/Request/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Http/Request/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { File } from 'formidable';
2
+ import type { Request } from 'koa';
3
+ export type UploadedFile = File;
4
+ export type UploadedFilesMap = Record<string, UploadedFile | UploadedFile[]>;
5
+ export interface HttpRequest extends Request {
6
+ body?: Record<string, unknown>;
7
+ files?: UploadedFilesMap;
8
+ params: Record<string, unknown>;
9
+ }
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Http/Request/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC;AAChC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC,CAAC;AAE7E,MAAM,WAAW,WAAY,SAAQ,OAAO;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Http/Request/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type * from './types.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Http/Response/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Http/Response/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { Response } from 'koa';
2
+ export interface HttpResponse extends Response {
3
+ setHeader(name: string, value: string | string[]): HttpResponse;
4
+ withHeaders(headers: Record<string, string | string[]>): HttpResponse;
5
+ }
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Http/Response/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC5C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,YAAY,CAAC;IAEhE,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,YAAY,CAAC;CACvE"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Http/Response/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { type ScopeStore } from './types.js';
2
+ export declare function createStore<TState extends object>(): ScopeStore<TState>;
3
+ //# sourceMappingURL=ScopeStoreFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScopeStoreFactory.d.ts","sourceRoot":"","sources":["../../../../src/Http/Scope/State/ScopeStoreFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,SAAS,CAAC;AAE3D,wBAAgB,WAAW,CAAC,MAAM,SAAS,MAAM,KAAK,UAAU,CAAC,MAAM,CAAC,CAuDvE"}
@@ -0,0 +1,45 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import { ScopeStoreError } from './types.js';
3
+ export function createStore() {
4
+ const asyncLocalStorage = new AsyncLocalStorage();
5
+ function run(initialState, callback) {
6
+ const clonedState = { ...initialState };
7
+ return asyncLocalStorage.run(clonedState, callback);
8
+ }
9
+ function set(key, value) {
10
+ const state = asyncLocalStorage.getStore();
11
+ if (undefined === state) {
12
+ throw new ScopeStoreError('No active scope store found. Make sure to call set() within a run() context.');
13
+ }
14
+ state[key] = value;
15
+ }
16
+ function get(key) {
17
+ const state = asyncLocalStorage.getStore();
18
+ if (undefined === state) {
19
+ throw new ScopeStoreError('No active scope store found. Make sure to call get() within a run() context.');
20
+ }
21
+ return state[key];
22
+ }
23
+ function has(key) {
24
+ const state = asyncLocalStorage.getStore();
25
+ if (undefined === state) {
26
+ throw new ScopeStoreError('No active scope store found. Make sure to call has() within a run() context.');
27
+ }
28
+ return key in state;
29
+ }
30
+ function all() {
31
+ const store = asyncLocalStorage.getStore();
32
+ if (undefined === store) {
33
+ throw new ScopeStoreError('No active scope store found. Make sure to call all() within a run() context.');
34
+ }
35
+ return { ...store };
36
+ }
37
+ return {
38
+ run,
39
+ set,
40
+ get,
41
+ has,
42
+ all,
43
+ };
44
+ }
45
+ //# sourceMappingURL=ScopeStoreFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScopeStoreFactory.js","sourceRoot":"","sources":["../../../../src/Http/Scope/State/ScopeStoreFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAmB,eAAe,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,UAAU,WAAW;IACzB,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAU,CAAC;IAE1D,SAAS,GAAG,CAAU,YAAoB,EAAE,QAAuB;QACjE,MAAM,WAAW,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;QACxC,OAAO,iBAAiB,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,SAAS,GAAG,CAA4B,GAAS,EAAE,KAAmB;QACpE,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;QAE3C,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CAAC,8EAA8E,CAAC,CAAC;QAC5G,CAAC;QAED,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,SAAS,GAAG,CAA4B,GAAS;QAC/C,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;QAE3C,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CAAC,8EAA8E,CAAC,CAAC;QAC5G,CAAC;QAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,SAAS,GAAG,CAAC,GAAiB;QAC5B,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;QAE3C,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CAAC,8EAA8E,CAAC,CAAC;QAC5G,CAAC;QAED,OAAO,GAAG,IAAI,KAAK,CAAC;IACtB,CAAC;IAED,SAAS,GAAG;QACV,MAAM,KAAK,GAAuB,iBAAiB,CAAC,QAAQ,EAAE,CAAC;QAE/D,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CAAC,8EAA8E,CAAC,CAAC;QAC5G,CAAC;QAED,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,OAAO;QACL,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;KACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ScopeStoreFactory.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScopeStoreFactory.test.d.ts","sourceRoot":"","sources":["../../../../src/Http/Scope/State/ScopeStoreFactory.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,134 @@
1
+ import { describe, expect, test, vi } from 'vitest';
2
+ import { createStore } from './ScopeStoreFactory.js';
3
+ import { ScopeStoreError } from './types.js';
4
+ describe('createStore', () => {
5
+ test('create a store & run', () => {
6
+ const store = createStore();
7
+ const callback = vi.fn();
8
+ store.run({ id: 1 }, callback);
9
+ expect(callback).toHaveBeenCalledTimes(1);
10
+ });
11
+ test('set should fail if no active store found', () => {
12
+ const store = createStore();
13
+ expect(() => {
14
+ store.set('id', 2);
15
+ }).toThrowError(ScopeStoreError);
16
+ expect(() => {
17
+ store.set('id', 2);
18
+ }).toThrowError('No active scope store found. Make sure to call set() within a run() context.');
19
+ });
20
+ test('get should fail if no active store found', () => {
21
+ const store = createStore();
22
+ expect(() => {
23
+ store.get('id');
24
+ }).toThrowError(ScopeStoreError);
25
+ });
26
+ test('has should fail if no active store found', () => {
27
+ const store = createStore();
28
+ expect(() => {
29
+ store.has('id');
30
+ }).toThrowError(ScopeStoreError);
31
+ });
32
+ test('all should fail if no active store found', () => {
33
+ const store = createStore();
34
+ expect(() => {
35
+ store.all();
36
+ }).toThrowError(ScopeStoreError);
37
+ });
38
+ test('set, get and all should work with active store', () => {
39
+ const store = createStore();
40
+ store.run({ id: 1 }, () => {
41
+ expect(store.get('id')).toBe(1);
42
+ store.set('id', 2);
43
+ expect(store.get('id')).toBe(2);
44
+ expect(store.all()).toEqual({ id: 2 });
45
+ });
46
+ });
47
+ test('has() returns true for existing keys', () => {
48
+ const store = createStore();
49
+ store.run({ id: 1 }, () => {
50
+ expect(store.has('id')).toBe(true);
51
+ });
52
+ });
53
+ test('has() returns true for undefined values', () => {
54
+ const store = createStore();
55
+ store.run({ id: 1, name: undefined }, () => {
56
+ expect(store.has('name')).toBe(true);
57
+ });
58
+ });
59
+ test('initial state is cloned to prevent external mutation', () => {
60
+ const store = createStore();
61
+ const initialState = { id: 1, data: { count: 0 } };
62
+ store.run(initialState, () => {
63
+ store.set('id', 2);
64
+ expect(store.get('id')).toBe(2);
65
+ });
66
+ expect(initialState.id).toBe(1);
67
+ });
68
+ test('all() returns a clone to prevent external mutation', () => {
69
+ const store = createStore();
70
+ store.run({ id: 1 }, () => {
71
+ const snapshot = store.all();
72
+ snapshot.id = 999;
73
+ expect(store.get('id')).toBe(1);
74
+ });
75
+ });
76
+ test('nested runs maintain separate contexts', () => {
77
+ const store = createStore();
78
+ const results = [];
79
+ store.run({ id: 1 }, () => {
80
+ results.push(store.get('id'));
81
+ store.run({ id: 2 }, () => {
82
+ results.push(store.get('id'));
83
+ });
84
+ results.push(store.get('id'));
85
+ });
86
+ expect(results).toEqual([1, 2, 1]);
87
+ });
88
+ test('concurrent runs maintain isolation', async () => {
89
+ const store = createStore();
90
+ const results = [];
91
+ const promise1 = Promise.resolve().then(() => store.run({ id: 1 }, () => {
92
+ results.push(store.get('id'));
93
+ return store.get('id');
94
+ }));
95
+ const promise2 = Promise.resolve().then(() => store.run({ id: 2 }, () => {
96
+ results.push(store.get('id'));
97
+ return store.get('id');
98
+ }));
99
+ const [result1, result2] = await Promise.all([promise1, promise2]);
100
+ expect(result1).toBe(1);
101
+ expect(result2).toBe(2);
102
+ expect(results).toHaveLength(2);
103
+ });
104
+ test('run() returns callback result', () => {
105
+ const store = createStore();
106
+ const result = store.run({ id: 1 }, () => {
107
+ return 'success';
108
+ });
109
+ expect(result).toBe('success');
110
+ });
111
+ test('run() propagates errors from callback', () => {
112
+ const store = createStore();
113
+ expect(() => {
114
+ store.run({ id: 1 }, () => {
115
+ throw new Error('callback error');
116
+ });
117
+ }).toThrowError('callback error');
118
+ });
119
+ test('supports complex state types', () => {
120
+ const store = createStore();
121
+ store.run({
122
+ user: { id: 1, email: 'test@example.com' },
123
+ metadata: { timestamp: Date.now() },
124
+ tags: ['a', 'b'],
125
+ }, () => {
126
+ expect(store.get('user')).toEqual({ id: 1, email: 'test@example.com' });
127
+ expect(store.get('tags')).toEqual(['a', 'b']);
128
+ expect(store.has('metadata')).toBe(true);
129
+ store.set('tags', ['c', 'd']);
130
+ expect(store.get('tags')).toEqual(['c', 'd']);
131
+ });
132
+ });
133
+ });
134
+ //# sourceMappingURL=ScopeStoreFactory.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScopeStoreFactory.test.js","sourceRoot":"","sources":["../../../../src/Http/Scope/State/ScopeStoreFactory.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,CAAC,sBAAs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EAAgB,CAAC;QAE1C,KAAK,CAAC,GAAG,CACP;YACE,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE;YAC1C,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE;YACnC,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;SACjB,EACD,GAAG,EAAE;YACH,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC;YACxE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;YAC9C,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEzC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;YAC9B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAChD,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export type * from './types.js';
2
+ export { ScopeStoreError } from './types.js';
3
+ export * from './ScopeStoreFactory.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Http/Scope/State/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,SAAS,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { ScopeStoreError } from './types.js';
2
+ export * from './ScopeStoreFactory.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Http/Scope/State/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare class ScopeStoreError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export interface ScopeStore<TState extends object> {
5
+ run<TResult>(initialState: TState, callback: () => TResult): TResult;
6
+ set<TKey extends keyof TState>(key: TKey, value: TState[TKey]): void;
7
+ get<TKey extends keyof TState>(key: TKey): TState[TKey];
8
+ has(key: keyof TState): boolean;
9
+ all(): TState;
10
+ }
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/Http/Scope/State/types.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,UAAU,CAAC,MAAM,SAAS,MAAM;IAC/C,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC;IAErE,GAAG,CAAC,IAAI,SAAS,MAAM,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAErE,GAAG,CAAC,IAAI,SAAS,MAAM,MAAM,EAAE,GAAG,EAAE,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAExD,GAAG,CAAC,GAAG,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC;IAEhC,GAAG,IAAI,MAAM,CAAC;CACf"}
@@ -0,0 +1,7 @@
1
+ export class ScopeStoreError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = 'ScopeStoreError';
5
+ }
6
+ }
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/Http/Scope/State/types.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export type * from './types.js';
2
+ export * from './State/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Http/Scope/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,SAAS,CAAC;AAC7B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './State/index.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Http/Scope/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Context, DefaultState, Next } from 'koa';
2
+ import { type HttpRequest } from '../Request/index.js';
3
+ import { type HttpResponse } from '../Response/index.js';
4
+ export interface HttpScope extends Context {
5
+ request: HttpRequest;
6
+ response: HttpResponse;
7
+ }
8
+ export type NextMiddleware = Next;
9
+ export type HttpMiddleware = (scope: HttpScope, next: NextMiddleware) => Promise<unknown>;
10
+ export type AppState = DefaultState;
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Http/Scope/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,SAAU,SAAQ,OAAO;IACxC,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC;AAClC,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1F,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Http/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Http/Scope/types.ts"],"names":[],"mappings":""}
@@ -1,2 +1,4 @@
1
- export type * from './types.js';
1
+ export type * from './Request/index.js';
2
+ export type * from './Response/index.js';
3
+ export * from './Scope/index.js';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Http/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Http/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,YAAY,CAAC;AAChC,cAAc,SAAS,CAAC"}
@@ -1 +1,2 @@
1
+ export * from './Scope/index.js';
1
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Http/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Http/index.ts"],"names":[],"mappings":"AAEA,cAAc,SAAS,CAAC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@koala-ts/framework",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "2.0.0",
5
+ "version": "2.1.1",
6
6
  "description": "A NodeJS framework for lazy developers",
7
7
  "keywords": [
8
8
  "koala",
@@ -64,5 +64,9 @@
64
64
  "typescript": "^5.9.3",
65
65
  "typescript-eslint": "^8.46.2",
66
66
  "vitest": "^3.2.4"
67
+ },
68
+ "publishConfig": {
69
+ "access": "public",
70
+ "registry": "https://registry.npmjs.org/"
67
71
  }
68
72
  }
@@ -1,21 +0,0 @@
1
- import type { File } from 'formidable';
2
- import type { Context, DefaultState, Next, Request, Response } from 'koa';
3
- export type UploadedFile = File;
4
- export type UploadedFilesMap = Record<string, UploadedFile | UploadedFile[]>;
5
- export interface HttpRequest extends Request {
6
- body?: Record<string, unknown>;
7
- files?: UploadedFilesMap;
8
- params: Record<string, unknown>;
9
- }
10
- export interface HttpResponse extends Response {
11
- setHeader(name: string, value: string | string[]): HttpResponse;
12
- withHeaders(headers: Record<string, string | string[]>): HttpResponse;
13
- }
14
- export interface HttpScope extends Context {
15
- request: HttpRequest;
16
- response: HttpResponse;
17
- }
18
- export type NextMiddleware = Next;
19
- export type HttpMiddleware = (scope: HttpScope, next: NextMiddleware) => Promise<unknown>;
20
- export type AppState = DefaultState;
21
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/Http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE1E,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC;AAChC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC,CAAC;AAE7E,MAAM,WAAW,WAAY,SAAQ,OAAO;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC5C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,YAAY,CAAC;IAEhE,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,YAAY,CAAC;CACvE;AAED,MAAM,WAAW,SAAU,SAAQ,OAAO;IACxC,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC;AAClC,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1F,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC"}
File without changes