@fjell/client-api 4.4.13 → 4.4.15

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 (89) hide show
  1. package/dist/AItemAPI.d.ts +4 -4
  2. package/dist/CItemAPI.d.ts +5 -5
  3. package/dist/ClientApi.d.ts +1 -1
  4. package/dist/ClientApiOptions.d.ts +3 -3
  5. package/dist/Instance.d.ts +3 -3
  6. package/dist/InstanceFactory.d.ts +3 -3
  7. package/dist/PItemAPI.d.ts +4 -4
  8. package/dist/Utilities.d.ts +1 -1
  9. package/dist/index.d.ts +6 -6
  10. package/dist/index.js +544 -5
  11. package/dist/index.js.map +7 -1
  12. package/dist/logger.d.ts +1 -1
  13. package/dist/ops/action.d.ts +4 -4
  14. package/dist/ops/all.d.ts +4 -4
  15. package/dist/ops/allAction.d.ts +4 -4
  16. package/dist/ops/allFacet.d.ts +4 -4
  17. package/dist/ops/create.d.ts +4 -4
  18. package/dist/ops/facet.d.ts +4 -4
  19. package/dist/ops/find.d.ts +4 -4
  20. package/dist/ops/findOne.d.ts +4 -4
  21. package/dist/ops/get.d.ts +4 -4
  22. package/dist/ops/index.d.ts +5 -5
  23. package/dist/ops/one.d.ts +4 -4
  24. package/dist/ops/remove.d.ts +4 -4
  25. package/dist/ops/update.d.ts +4 -4
  26. package/package.json +11 -14
  27. package/vitest.config.ts +25 -0
  28. package/dist/AItemAPI.js +0 -52
  29. package/dist/AItemAPI.js.map +0 -1
  30. package/dist/CItemAPI.js +0 -30
  31. package/dist/CItemAPI.js.map +0 -1
  32. package/dist/Instance.js +0 -19
  33. package/dist/Instance.js.map +0 -1
  34. package/dist/InstanceFactory.js +0 -19
  35. package/dist/InstanceFactory.js.map +0 -1
  36. package/dist/PItemAPI.js +0 -44
  37. package/dist/PItemAPI.js.map +0 -1
  38. package/dist/Registry.js +0 -31
  39. package/dist/Registry.js.map +0 -1
  40. package/dist/Utilities.js +0 -153
  41. package/dist/Utilities.js.map +0 -1
  42. package/dist/index.cjs +0 -586
  43. package/dist/index.cjs.map +0 -1
  44. package/dist/logger.js +0 -6
  45. package/dist/logger.js.map +0 -1
  46. package/dist/ops/action.js +0 -21
  47. package/dist/ops/action.js.map +0 -1
  48. package/dist/ops/all.js +0 -25
  49. package/dist/ops/all.js.map +0 -1
  50. package/dist/ops/allAction.js +0 -24
  51. package/dist/ops/allAction.js.map +0 -1
  52. package/dist/ops/allFacet.js +0 -24
  53. package/dist/ops/allFacet.js.map +0 -1
  54. package/dist/ops/create.js +0 -23
  55. package/dist/ops/create.js.map +0 -1
  56. package/dist/ops/facet.js +0 -34
  57. package/dist/ops/facet.js.map +0 -1
  58. package/dist/ops/find.js +0 -26
  59. package/dist/ops/find.js.map +0 -1
  60. package/dist/ops/findOne.js +0 -27
  61. package/dist/ops/findOne.js.map +0 -1
  62. package/dist/ops/get.js +0 -19
  63. package/dist/ops/get.js.map +0 -1
  64. package/dist/ops/index.js +0 -32
  65. package/dist/ops/index.js.map +0 -1
  66. package/dist/ops/one.js +0 -30
  67. package/dist/ops/one.js.map +0 -1
  68. package/dist/ops/remove.js +0 -19
  69. package/dist/ops/remove.js.map +0 -1
  70. package/dist/ops/update.js +0 -20
  71. package/dist/ops/update.js.map +0 -1
  72. package/docs/docs.config.ts +0 -77
  73. package/docs/index.html +0 -18
  74. package/docs/package.json +0 -34
  75. package/docs/public/README.md +0 -165
  76. package/docs/public/api-reference.md +0 -408
  77. package/docs/public/examples-README.md +0 -387
  78. package/docs/public/fjell-icon.svg +0 -1
  79. package/docs/public/package.json +0 -5
  80. package/docs/src/index.css +0 -34
  81. package/docs/src/main.tsx +0 -12
  82. package/docs/src/test/setup.ts +0 -1
  83. package/docs/src/types.d.ts +0 -44
  84. package/docs/tsconfig.node.json +0 -13
  85. package/docs/vitest.config.ts +0 -14
  86. package/examples/README.md +0 -387
  87. package/examples/enterprise-example.ts +0 -852
  88. package/examples/multi-level-keys.ts +0 -467
  89. package/examples/simple-example.ts +0 -346
@@ -1,20 +0,0 @@
1
- import LibLogger from '../logger.js';
2
-
3
- const logger = LibLogger.get('client-api', 'ops', 'update');
4
- const getUpdateOperation = (api, apiOptions, utilities)=>{
5
- const update = async (ik, item)=>{
6
- const requestOptions = Object.assign({}, apiOptions.putOptions, {
7
- isAuthenticated: apiOptions.writeAuthenticated
8
- });
9
- logger.default('update', {
10
- ik,
11
- item,
12
- requestOptions
13
- });
14
- return utilities.validatePK(await utilities.processOne(api.httpPut(utilities.getPath(ik), item, requestOptions)));
15
- };
16
- return update;
17
- };
18
-
19
- export { getUpdateOperation };
20
- //# sourceMappingURL=update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.js","sources":["../../src/ops/update.ts"],"sourcesContent":["import {\n ComKey,\n Item,\n PriKey\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"@/ClientApiOptions\";\nimport LibLogger from \"@/logger\";\nimport { Utilities } from \"@/Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'update');\n\nexport const getUpdateOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ) => {\n\n const update = async (\n ik: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,\n item: Partial<Item<S, L1, L2, L3, L4, L5>>,\n ): Promise<V> => {\n const requestOptions = Object.assign({}, apiOptions.putOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('update', { ik, item, requestOptions });\n\n return utilities.validatePK(await utilities.processOne(\n api.httpPut<V>(\n utilities.getPath(ik),\n item,\n requestOptions,\n ))) as V;\n }\n\n return update;\n}\n"],"names":["logger","LibLogger","get","getUpdateOperation","api","apiOptions","utilities","update","ik","item","requestOptions","Object","assign","putOptions","isAuthenticated","writeAuthenticated","default","validatePK","processOne","httpPut","getPath"],"mappings":";;AAWA,MAAMA,MAAAA,GAASC,SAAAA,CAAUC,GAAG,CAAC,cAAc,KAAA,EAAO,QAAA,CAAA;AAE3C,MAAMC,kBAAAA,GAAqB,CAQ9BC,GAAAA,EACAC,UAAAA,EACAC,SAAAA,GAAAA;IAIF,MAAMC,MAAAA,GAAS,OACbC,EAAAA,EACAC,IAAAA,GAAAA;QAEA,MAAMC,cAAAA,GAAiBC,OAAOC,MAAM,CAAC,EAAC,EAAGP,UAAAA,CAAWQ,UAAU,EAAE;AAAEC,YAAAA,eAAAA,EAAiBT,WAAWU;AAAmB,SAAA,CAAA;QACjHf,MAAAA,CAAOgB,OAAO,CAAC,QAAA,EAAU;AAAER,YAAAA,EAAAA;AAAIC,YAAAA,IAAAA;AAAMC,YAAAA;AAAe,SAAA,CAAA;AAEpD,QAAA,OAAOJ,SAAAA,CAAUW,UAAU,CAAC,MAAMX,UAAUY,UAAU,CACpDd,GAAAA,CAAIe,OAAO,CACTb,SAAAA,CAAUc,OAAO,CAACZ,KAClBC,IAAAA,EACAC,cAAAA,CAAAA,CAAAA,CAAAA;AAEN,IAAA,CAAA;IAEA,OAAOH,MAAAA;AACT;;;;"}
@@ -1,77 +0,0 @@
1
- interface DocsConfig {
2
- projectName: string;
3
- basePath: string;
4
- port: number;
5
- branding: {
6
- theme: string;
7
- tagline: string;
8
- logo?: string;
9
- backgroundImage?: string;
10
- primaryColor?: string;
11
- accentColor?: string;
12
- github?: string;
13
- npm?: string;
14
- };
15
- sections: Array<{
16
- id: string;
17
- title: string;
18
- subtitle: string;
19
- file: string;
20
- }>;
21
- filesToCopy: Array<{
22
- source: string;
23
- destination: string;
24
- }>;
25
- plugins?: any[];
26
- version: {
27
- source: string;
28
- };
29
- customContent?: {
30
- [key: string]: (content: string) => string;
31
- };
32
- }
33
-
34
- const config: DocsConfig = {
35
- projectName: 'Fjell Client API',
36
- basePath: '/client-api/',
37
- port: 3002,
38
- branding: {
39
- theme: 'client-api',
40
- tagline: 'HTTP Client Library for Fjell',
41
- backgroundImage: '/pano.png',
42
- github: 'https://github.com/getfjell/client-api',
43
- npm: 'https://www.npmjs.com/package/@fjell/client-api'
44
- },
45
- sections: [
46
- {
47
- id: 'overview',
48
- title: 'Foundation',
49
- subtitle: 'Core concepts & HTTP client capabilities',
50
- file: '/client-api/README.md'
51
- },
52
- {
53
- id: 'api-reference',
54
- title: 'API Reference',
55
- subtitle: 'Complete method documentation',
56
- file: '/client-api/api-reference.md'
57
- },
58
- {
59
- id: 'examples',
60
- title: 'Examples',
61
- subtitle: 'Code examples & usage patterns',
62
- file: '/client-api/examples-README.md'
63
- }
64
- ],
65
- filesToCopy: [
66
- {
67
- source: '../examples/README.md',
68
- destination: 'public/examples-README.md'
69
- }
70
- ],
71
- plugins: [],
72
- version: {
73
- source: 'package.json'
74
- }
75
- }
76
-
77
- export default config
package/docs/index.html DELETED
@@ -1,18 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <link rel="icon" type="image/svg+xml" href="/fjell-icon.svg" />
7
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
- <title>Fjell Client API - TypeScript Client Library</title>
9
- <meta name="description"
10
- content="Client API for Fjell - A powerful TypeScript client library for service consumption">
11
- </head>
12
-
13
- <body>
14
- <div id="root"></div>
15
- <script type="module" src="/src/main.tsx"></script>
16
- </body>
17
-
18
- </html>
package/docs/package.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "name": "fjell-client-api-docs",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "copy-docs": "node node_modules/@fjell/docs-template/scripts/copy-docs.js",
8
- "dev": "pnpm run copy-docs && vite",
9
- "build": "pnpm run copy-docs && tsc && vite build",
10
- "preview": "vite preview",
11
- "test": "vitest run --coverage",
12
- "test:watch": "vitest --watch"
13
- },
14
- "dependencies": {
15
- "@fjell/docs-template": "1.0.5",
16
- "react": "^19.1.0",
17
- "react-dom": "^19.1.0"
18
- },
19
- "devDependencies": {
20
- "@testing-library/jest-dom": "^6.6.3",
21
- "@testing-library/react": "^16.3.0",
22
- "@testing-library/user-event": "^14.6.1",
23
- "@types/react": "^19.1.8",
24
- "@types/react-dom": "^19.1.6",
25
- "@types/react-syntax-highlighter": "^15.5.13",
26
- "@vitejs/plugin-react": "^4.6.0",
27
- "@vitest/coverage-v8": "^3.2.4",
28
- "@vitest/ui": "^3.2.4",
29
- "jsdom": "^26.1.0",
30
- "typescript": "^5.8.3",
31
- "vite": "^7.0.0",
32
- "vitest": "^3.2.4"
33
- }
34
- }
@@ -1,165 +0,0 @@
1
- # Fjell Client API
2
-
3
- A comprehensive HTTP client library for the Fjell ecosystem. The Client API provides powerful abstractions for HTTP-based data operations, making it easy to build robust client applications that consume REST APIs.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @fjell/client-api
9
- ```
10
-
11
- ## Quick Start
12
-
13
- ```typescript
14
- import { createPItemApi, createCItemApi } from '@fjell/client-api'
15
-
16
- // Configure API endpoints
17
- const apiConfig = {
18
- baseUrl: 'https://api.example.com',
19
- headers: { 'Authorization': 'Bearer token' }
20
- }
21
-
22
- // Create Primary Item API (independent entities)
23
- const userApi = createPItemApi<User, 'user'>('user', ['users'], apiConfig)
24
-
25
- // Create Contained Item API (hierarchical entities)
26
- const taskApi = createCItemApi<Task, 'task', 'user'>('task', ['users', 'tasks'], apiConfig)
27
-
28
- // Basic operations
29
- const users = await userApi.all(query)
30
- const user = await userApi.create(userData)
31
- const tasks = await taskApi.all(query, [userId]) // Location-based query
32
- ```
33
-
34
- ## Key Features
35
-
36
- - **HTTP-based Operations**: Complete CRUD operations over HTTP
37
- - **Type-safe APIs**: Full TypeScript support with generic type parameters
38
- - **Hierarchical Data**: Support for nested resource relationships
39
- - **Business Logic**: Actions and facets for complex operations
40
- - **Authentication**: Built-in support for various auth patterns
41
- - **Error Handling**: Comprehensive error handling and retry logic
42
-
43
- ## Architecture
44
-
45
- The Client API is built around two main concepts:
46
-
47
- ### Primary Items (PItemApi)
48
- Independent entities that exist at the top level of your API hierarchy. These represent resources that don't require parent context, such as Users, Products, or Organizations.
49
-
50
- ### Contained Items (CItemApi)
51
- Entities that belong to parent resources and require location context. These represent hierarchical data like Tasks within Projects, OrderItems within Orders, or Comments within Posts.
52
-
53
- This design mirrors RESTful API patterns while providing powerful abstractions for complex business operations.
54
-
55
- ## Core Concepts
56
-
57
- ### API Configuration
58
- Configure your client with base URLs, authentication headers, and other options:
59
-
60
- ```typescript
61
- const config = {
62
- baseUrl: 'https://api.example.com',
63
- headers: {
64
- 'Content-Type': 'application/json',
65
- 'Authorization': 'Bearer your-token'
66
- },
67
- timeout: 5000
68
- }
69
- ```
70
-
71
- ### Primary Item API
72
- For independent resources:
73
-
74
- ```typescript
75
- const userApi = createPItemApi<User, 'user'>('user', ['users'], config)
76
-
77
- // CRUD operations
78
- const users = await userApi.all()
79
- const user = await userApi.get(userKey)
80
- const newUser = await userApi.create({ name: 'John', email: 'john@example.com' })
81
- const updatedUser = await userApi.update(userKey, { name: 'John Smith' })
82
- await userApi.remove(userKey)
83
- ```
84
-
85
- ### Contained Item API
86
- For hierarchical resources:
87
-
88
- ```typescript
89
- const taskApi = createCItemApi<Task, 'task', 'user'>('task', ['users', 'tasks'], config)
90
-
91
- // Operations with location context
92
- const userTasks = await taskApi.all({}, [userId])
93
- const task = await taskApi.get(taskKey)
94
- const newTask = await taskApi.create({ title: 'Complete project' }, [userId])
95
- ```
96
-
97
- ### Actions and Facets
98
- Execute business logic and retrieve analytics:
99
-
100
- ```typescript
101
- // Actions - execute business operations
102
- await userApi.action(userKey, 'activate', { reason: 'manual activation' })
103
- await taskApi.action(taskKey, 'complete', { completedAt: new Date() })
104
-
105
- // Facets - retrieve computed data and analytics
106
- const userStats = await userApi.facet(userKey, 'activity-stats')
107
- const taskMetrics = await taskApi.allFacet('completion-metrics', { period: 'monthly' })
108
- ```
109
-
110
- ## Examples
111
-
112
- See the `/examples` directory for comprehensive usage patterns:
113
-
114
- - **Simple Example**: Basic CRUD operations and client setup
115
- - **Multi-Level Keys**: Complex hierarchical data with nested relationships
116
- - **Enterprise Example**: Complete business application with e-commerce workflows
117
-
118
- ## TypeScript Support
119
-
120
- The Client API is built with TypeScript-first design, providing:
121
-
122
- - Full type safety for API operations
123
- - Generic type parameters for custom data models
124
- - Compile-time validation of API method signatures
125
- - IntelliSense support for better developer experience
126
-
127
- ## Error Handling
128
-
129
- Built-in error handling with detailed error information:
130
-
131
- ```typescript
132
- try {
133
- const user = await userApi.get(userKey)
134
- } catch (error) {
135
- console.error('API error:', error.message)
136
- // Handle specific error types
137
- if (error.status === 404) {
138
- // Handle not found
139
- } else if (error.status === 401) {
140
- // Handle authentication error
141
- }
142
- }
143
- ```
144
-
145
- ## Advanced Features
146
-
147
- ### Authentication
148
- Support for various authentication patterns including Bearer tokens, API keys, and custom headers.
149
-
150
- ### Request Configuration
151
- Fine-tune requests with timeout settings, retry logic, and custom middleware.
152
-
153
- ### Response Processing
154
- Automatic response parsing and error handling for consistent API interactions.
155
-
156
- ### Location-based Operations
157
- Powerful location context system for hierarchical data operations.
158
-
159
- ## Contributing
160
-
161
- This library is part of the Fjell ecosystem. For contributing guidelines and development setup, please refer to the main Fjell documentation.
162
-
163
- ## License
164
-
165
- Licensed under Apache-2.0. See LICENSE file for details.