@karpeleslab/klbfw 0.2.0 → 0.2.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 (39) hide show
  1. package/index.d.ts +81 -0
  2. package/package.json +8 -1
  3. package/CLAUDE.md +0 -50
  4. package/coverage/clover.xml +0 -835
  5. package/coverage/coverage-final.json +0 -9
  6. package/coverage/lcov-report/base.css +0 -224
  7. package/coverage/lcov-report/block-navigation.js +0 -87
  8. package/coverage/lcov-report/cookies.js.html +0 -334
  9. package/coverage/lcov-report/favicon.png +0 -0
  10. package/coverage/lcov-report/fw-wrapper.js.html +0 -163
  11. package/coverage/lcov-report/index.html +0 -131
  12. package/coverage/lcov-report/index.js.html +0 -196
  13. package/coverage/lcov-report/internal.js.html +0 -604
  14. package/coverage/lcov-report/klbfw/cookies.js.html +0 -490
  15. package/coverage/lcov-report/klbfw/fw-wrapper.js.html +0 -745
  16. package/coverage/lcov-report/klbfw/index.html +0 -206
  17. package/coverage/lcov-report/klbfw/index.js.html +0 -235
  18. package/coverage/lcov-report/klbfw/internal.js.html +0 -811
  19. package/coverage/lcov-report/klbfw/rest.js.html +0 -565
  20. package/coverage/lcov-report/klbfw/test/index.html +0 -116
  21. package/coverage/lcov-report/klbfw/test/setup.js.html +0 -1105
  22. package/coverage/lcov-report/klbfw/upload.js.html +0 -3487
  23. package/coverage/lcov-report/klbfw/util.js.html +0 -388
  24. package/coverage/lcov-report/prettify.css +0 -1
  25. package/coverage/lcov-report/prettify.js +0 -2
  26. package/coverage/lcov-report/rest.js.html +0 -472
  27. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  28. package/coverage/lcov-report/sorter.js +0 -196
  29. package/coverage/lcov-report/upload.js.html +0 -1789
  30. package/coverage/lcov-report/util.js.html +0 -313
  31. package/coverage/lcov.info +0 -1617
  32. package/test/README.md +0 -62
  33. package/test/api.test.js +0 -102
  34. package/test/cookies.test.js +0 -65
  35. package/test/integration.test.js +0 -481
  36. package/test/rest.test.js +0 -93
  37. package/test/setup.js +0 -341
  38. package/test/upload.test.js +0 -689
  39. package/test/util.test.js +0 -46
package/index.d.ts ADDED
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Type definitions for @karpeleslab/klbfw
3
+ */
4
+
5
+ // Framework wrapper types
6
+ declare function GET(): Record<string, string>;
7
+ declare function Get(key?: string): string | Record<string, string> | undefined;
8
+ declare function flushGet(): void;
9
+ declare function getPrefix(): string;
10
+ declare function getSettings(): Record<string, any>;
11
+ declare function getRealm(): Record<string, any>;
12
+ declare function getContext(): Record<string, any>;
13
+ declare function setContext(key: string, value: any): void;
14
+ declare function getMode(): string;
15
+ declare function getHostname(): string;
16
+ declare function getRegistry(): Record<string, any> | undefined;
17
+ declare function getLocale(): string;
18
+ declare function getUserGroup(): string | undefined;
19
+ declare function getCurrency(): string;
20
+ declare function getToken(): string | undefined;
21
+ declare function getUrl(): { path: string; full: string };
22
+ declare function getPath(): string;
23
+ declare function getUuid(): string | undefined;
24
+ declare function getInitialState(): Record<string, any> | undefined;
25
+
26
+ // Cookie handling types
27
+ declare function getCookie(name: string): string | null;
28
+ declare function hasCookie(name: string): boolean;
29
+ declare function setCookie(name: string, value: string, expires?: Date | number, path?: string, domain?: string, secure?: boolean): void;
30
+
31
+ // REST API types
32
+ declare function rest(name: string, verb: string, params?: Record<string, any> | string, context?: Record<string, any>): Promise<any>;
33
+ declare function rest_get(name: string, params?: Record<string, any> | string): Promise<any>; // Backward compatibility
34
+ declare function restGet(name: string, params?: Record<string, any> | string): Promise<any>;
35
+
36
+ // Upload module types
37
+ interface UploadOptions {
38
+ progress?: (progress: number) => void;
39
+ endpoint?: string;
40
+ headers?: Record<string, string>;
41
+ retry?: number;
42
+ chunk_size?: number;
43
+ params?: Record<string, any>;
44
+ }
45
+
46
+ declare function upload(file: File, options?: UploadOptions): Promise<any>;
47
+
48
+ // Utility types
49
+ declare function getI18N(key: string, args?: Record<string, any>): string;
50
+ declare function trimPrefix(path: string): string;
51
+
52
+ export {
53
+ GET,
54
+ Get,
55
+ flushGet,
56
+ getPrefix,
57
+ getSettings,
58
+ getRealm,
59
+ getContext,
60
+ setContext,
61
+ getMode,
62
+ getHostname,
63
+ getRegistry,
64
+ getLocale,
65
+ getUserGroup,
66
+ getCurrency,
67
+ getToken,
68
+ getUrl,
69
+ getPath,
70
+ getUuid,
71
+ getInitialState,
72
+ getCookie,
73
+ hasCookie,
74
+ setCookie,
75
+ rest,
76
+ rest_get,
77
+ restGet,
78
+ upload,
79
+ getI18N,
80
+ trimPrefix
81
+ };
package/package.json CHANGED
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "@karpeleslab/klbfw",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Frontend Framework",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "files": [
8
+ "*.js",
9
+ "*.d.ts",
10
+ "LICENSE",
11
+ "README.md"
12
+ ],
6
13
  "scripts": {
7
14
  "test": "jest",
8
15
  "test:watch": "jest --watch",
package/CLAUDE.md DELETED
@@ -1,50 +0,0 @@
1
- # KarpelesLab Frontend Framework (klbfw) Guidelines
2
-
3
- ## Commands
4
- ```
5
- # Install dependencies
6
- npm install
7
-
8
- # Run tests
9
- npm test
10
-
11
- # Run tests in watch mode
12
- npm run test:watch
13
- ```
14
-
15
- ## Code Style Guidelines
16
-
17
- ### Formatting
18
- - Use 'use strict' directive at top of files
19
- - 4-space indentation (configured in vim: et:ts=4:sw=4)
20
- - Use semicolons consistently
21
- - Use single quotes for strings
22
-
23
- ### Imports/Exports
24
- - Use CommonJS module system (require/module.exports)
25
- - Export using module.exports.<func> = <func>
26
-
27
- ### Variables & Functions
28
- - Use camelCase for variables and functions
29
- - Use snake_case for some function names (rest_get, get_timezone_data)
30
- - Function declarations: mix of standard functions and arrow functions
31
-
32
- ### Error Handling
33
- - Use Promise-based error handling with reject/resolve pattern
34
- - Include descriptive error objects with properties (message, body, headers)
35
- - Check input parameters and provide defaults (params = params || {})
36
-
37
- ### Browser Compatibility
38
- - Check for feature availability before using (typeof window, Intl.DateTimeFormat)
39
- - Handle both browser and non-browser environments
40
-
41
- ### Documentation
42
- - Include comments for complex functions
43
- - Add function descriptions where appropriate
44
-
45
- ### Testing
46
- - Tests are written using Jest
47
- - Test modules are in the test/ directory
48
- - Each module has a separate test file
49
- - Tests should cover both SSR and client modes
50
- - Use setup.js for test utilities and mocks