@fjell/client-api 4.4.43 → 4.4.45
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/MIGRATION_v3.md +231 -0
- package/README.md +169 -0
- package/dist/AItemAPI.d.ts +2 -2
- package/dist/CItemAPI.d.ts +5 -12
- package/dist/ClientApi.d.ts +13 -14
- package/dist/Instance.d.ts +2 -1
- package/dist/PItemAPI.d.ts +1 -13
- package/dist/index.d.ts +1 -0
- package/dist/index.js +174 -162
- package/dist/index.js.map +4 -4
- package/dist/ops/action.d.ts +2 -2
- package/dist/ops/all.d.ts +2 -2
- package/dist/ops/allAction.d.ts +2 -2
- package/dist/ops/allFacet.d.ts +2 -2
- package/dist/ops/create.d.ts +2 -2
- package/dist/ops/errorHandling.d.ts +1 -0
- package/dist/ops/facet.d.ts +2 -2
- package/dist/ops/find.d.ts +2 -2
- package/dist/ops/findOne.d.ts +2 -2
- package/dist/ops/get.d.ts +2 -2
- package/dist/ops/one.d.ts +2 -2
- package/dist/ops/remove.d.ts +2 -2
- package/dist/ops/update.d.ts +2 -2
- package/dist/ops/upsert.d.ts +5 -0
- package/package.json +5 -5
package/MIGRATION_v3.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Migration Guide: v4.4.x to v4.5.0
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Version 4.5.0 adopts the Operations interface from `@fjell/core`, providing a consistent API across all Fjell packages.
|
|
6
|
+
|
|
7
|
+
## Breaking Changes Summary
|
|
8
|
+
|
|
9
|
+
1. **Core Operations Interface**: `ClientApi` now extends `Operations` from `@fjell/core`
|
|
10
|
+
2. **Create Method**: Changed signature to use `CreateOptions`
|
|
11
|
+
3. **Action Methods**: Parameter name changed from `body` to `params`
|
|
12
|
+
4. **Upsert Operation**: Added missing `upsert` method
|
|
13
|
+
|
|
14
|
+
## Dependency Updates
|
|
15
|
+
|
|
16
|
+
Update your `package.json`:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @fjell/core@latest @fjell/client-api@latest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Code Migration
|
|
23
|
+
|
|
24
|
+
### 1. Create Method
|
|
25
|
+
|
|
26
|
+
The `create` method now uses `CreateOptions` instead of a simple `locations` parameter.
|
|
27
|
+
|
|
28
|
+
#### Before (v4.4.x)
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
// With locations
|
|
32
|
+
const item = await api.create(
|
|
33
|
+
{ name: 'Alice' },
|
|
34
|
+
[{ kt: 'org', lk: 'org-123' }]
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Without locations
|
|
38
|
+
const item = await api.create({ name: 'Alice' });
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### After (v4.5.0)
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// With locations - wrap in options object
|
|
45
|
+
const item = await api.create(
|
|
46
|
+
{ name: 'Alice' },
|
|
47
|
+
{ locations: [{ kt: 'org', lk: 'org-123' }] }
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Without locations - omit options or pass undefined
|
|
51
|
+
const item = await api.create({ name: 'Alice' });
|
|
52
|
+
|
|
53
|
+
// NEW: With specific key
|
|
54
|
+
const item = await api.create(
|
|
55
|
+
{ name: 'Alice' },
|
|
56
|
+
{ key: { kt: 'user', pk: 'custom-id' } }
|
|
57
|
+
);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 2. Action Methods
|
|
61
|
+
|
|
62
|
+
The parameter name changed from `body` to `params` to match the core Operations interface. **Functionally, it's the same** - just a naming change.
|
|
63
|
+
|
|
64
|
+
#### Before (v4.4.x)
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const [item, affectedKeys] = await api.action(
|
|
68
|
+
key,
|
|
69
|
+
'promote',
|
|
70
|
+
{ role: 'admin' } // called "body"
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const [items, affectedKeys] = await api.allAction(
|
|
74
|
+
'archive',
|
|
75
|
+
{ reason: 'expired' }, // called "body"
|
|
76
|
+
locations
|
|
77
|
+
);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### After (v4.5.0)
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// Same code - just know it's now called "params" internally
|
|
84
|
+
const [item, affectedKeys] = await api.action(
|
|
85
|
+
key,
|
|
86
|
+
'promote',
|
|
87
|
+
{ role: 'admin' } // now called "params"
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const [items, affectedKeys] = await api.allAction(
|
|
91
|
+
'archive',
|
|
92
|
+
{ reason: 'expired' }, // now called "params"
|
|
93
|
+
locations
|
|
94
|
+
);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 3. Upsert Operation (New)
|
|
98
|
+
|
|
99
|
+
A new `upsert` operation is now available:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
// Creates if doesn't exist, updates if it does
|
|
103
|
+
const user = await api.upsert(
|
|
104
|
+
{ kt: 'user', pk: 'user-123' },
|
|
105
|
+
{ name: 'Alice', email: 'alice@example.com' }
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// With locations (for contained items)
|
|
109
|
+
const comment = await api.upsert(
|
|
110
|
+
{ kt: 'comment', pk: 'comment-456', loc: [{ kt: 'post', lk: 'post-123' }] },
|
|
111
|
+
{ text: 'Updated comment' },
|
|
112
|
+
[{ kt: 'post', lk: 'post-123' }]
|
|
113
|
+
);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 4. Type Imports
|
|
117
|
+
|
|
118
|
+
Import types from the appropriate package:
|
|
119
|
+
|
|
120
|
+
#### Before (v4.4.x)
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { ClientApi } from '@fjell/client-api';
|
|
124
|
+
// No OperationParams or AffectedKeys available
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### After (v4.5.0)
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { ClientApi, OperationParams, AffectedKeys, CreateOptions } from '@fjell/client-api';
|
|
131
|
+
// Or import directly from core
|
|
132
|
+
import { Operations, OperationParams, AffectedKeys } from '@fjell/core';
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Type Compatibility
|
|
136
|
+
|
|
137
|
+
The `ClientApi` interface is now fully compatible with the core `Operations` interface:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import type { Operations } from '@fjell/core';
|
|
141
|
+
import type { ClientApi } from '@fjell/client-api';
|
|
142
|
+
|
|
143
|
+
// These are now compatible
|
|
144
|
+
function processItems(ops: Operations<User, 'user'>) {
|
|
145
|
+
// Can pass either ClientApi or any other Operations implementation
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const clientApi: ClientApi<User, 'user'> = ...;
|
|
149
|
+
processItems(clientApi); // ✅ Works!
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Benefits of Migration
|
|
153
|
+
|
|
154
|
+
### 1. Consistent Interface
|
|
155
|
+
|
|
156
|
+
All Fjell packages now share the same Operations interface:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
// All implement the same Operations interface
|
|
160
|
+
import { Operations } from '@fjell/lib';
|
|
161
|
+
import { ClientApi } from '@fjell/client-api';
|
|
162
|
+
import { Operations as FirestoreOps } from '@fjell/lib-firestore';
|
|
163
|
+
|
|
164
|
+
// Can be used interchangeably
|
|
165
|
+
function workWithOperations(ops: Operations<Item, string>) {
|
|
166
|
+
// Works with any implementation
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 2. Better Type Safety
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { OperationParams, AffectedKeys, CreateOptions } from '@fjell/core';
|
|
174
|
+
|
|
175
|
+
// Strongly typed parameters
|
|
176
|
+
const params: OperationParams = {
|
|
177
|
+
status: 'active',
|
|
178
|
+
limit: 10
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// Type-safe create options
|
|
182
|
+
const options: CreateOptions<'user'> = {
|
|
183
|
+
key: { kt: 'user', pk: 'user-123' }
|
|
184
|
+
};
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 3. Future Compatibility
|
|
188
|
+
|
|
189
|
+
By adopting the core interface, your code will be compatible with future Fjell enhancements and new operation implementations.
|
|
190
|
+
|
|
191
|
+
## Troubleshooting
|
|
192
|
+
|
|
193
|
+
### TypeScript Errors
|
|
194
|
+
|
|
195
|
+
If you see TypeScript errors after upgrading:
|
|
196
|
+
|
|
197
|
+
1. **Clear your TypeScript cache**: Delete `node_modules/.cache` and `dist/` directories
|
|
198
|
+
2. **Rebuild**: Run `npm run build`
|
|
199
|
+
3. **Update imports**: Ensure you're importing types from the correct packages
|
|
200
|
+
|
|
201
|
+
### Runtime Errors
|
|
202
|
+
|
|
203
|
+
If you encounter runtime errors:
|
|
204
|
+
|
|
205
|
+
1. **Check create calls**: Wrap `locations` in options object: `{ locations: [...] }`
|
|
206
|
+
2. **Verify dependencies**: Ensure `@fjell/core` is at the latest version
|
|
207
|
+
3. **Clear node_modules**: Delete and reinstall if necessary
|
|
208
|
+
|
|
209
|
+
## Migration Checklist
|
|
210
|
+
|
|
211
|
+
- [ ] Update package.json dependencies
|
|
212
|
+
- [ ] Run `npm install`
|
|
213
|
+
- [ ] Update `create` calls to use options object
|
|
214
|
+
- [ ] Update any type imports
|
|
215
|
+
- [ ] Test upsert operations if needed
|
|
216
|
+
- [ ] Run tests: `npm test`
|
|
217
|
+
- [ ] Build: `npm run build`
|
|
218
|
+
- [ ] Check for TypeScript errors: `npm run lint`
|
|
219
|
+
|
|
220
|
+
## Questions or Issues?
|
|
221
|
+
|
|
222
|
+
If you encounter any problems during migration:
|
|
223
|
+
|
|
224
|
+
1. Check the [API Reference](./docs/public/api-reference.md)
|
|
225
|
+
2. Review the [examples](./examples/)
|
|
226
|
+
3. File an issue on GitHub
|
|
227
|
+
|
|
228
|
+
## Previous Migrations
|
|
229
|
+
|
|
230
|
+
- For migrations from older versions, see previous migration guides
|
|
231
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# @fjell/client-api
|
|
2
|
+
|
|
3
|
+
HTTP client for Fjell operations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @fjell/client-api @fjell/http-api @fjell/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
`@fjell/client-api` provides HTTP client implementations for Fjell's Operations interface. It enables you to interact with Fjell-based APIs over HTTP using the same consistent interface as local operations.
|
|
14
|
+
|
|
15
|
+
## v4.5.0+ Breaking Changes
|
|
16
|
+
|
|
17
|
+
The `ClientApi` interface now directly extends `@fjell/core` Operations. This means:
|
|
18
|
+
- Consistent interface across all transport layers
|
|
19
|
+
- Better type safety
|
|
20
|
+
- Smaller bundle size
|
|
21
|
+
- Full compatibility with other Operations implementations
|
|
22
|
+
|
|
23
|
+
### Key Changes
|
|
24
|
+
|
|
25
|
+
1. **Core Operations Interface**: `ClientApi` now extends the core `Operations` interface
|
|
26
|
+
2. **Upsert Support**: Added missing `upsert` operation
|
|
27
|
+
3. **CreateOptions**: The `create` method now accepts `CreateOptions` for more flexibility
|
|
28
|
+
4. **Action Parameters**: Action methods now use `params` (OperationParams) instead of `body`
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### Basic Example
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { createClientApi } from '@fjell/client-api';
|
|
36
|
+
import { HttpApi } from '@fjell/http-api';
|
|
37
|
+
import type { Item } from '@fjell/core';
|
|
38
|
+
|
|
39
|
+
// Define your item type
|
|
40
|
+
interface User extends Item<'user'> {
|
|
41
|
+
name: string;
|
|
42
|
+
email: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Create HTTP API instance
|
|
46
|
+
const httpApi = new HttpApi({ baseUrl: 'https://api.example.com' });
|
|
47
|
+
|
|
48
|
+
// Create client API
|
|
49
|
+
const userApi = createClientApi<User, 'user'>(
|
|
50
|
+
httpApi,
|
|
51
|
+
'user',
|
|
52
|
+
['user']
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// Use the operations
|
|
56
|
+
const users = await userApi.all({});
|
|
57
|
+
const user = await userApi.get({ kt: 'user', pk: 'user-123' });
|
|
58
|
+
const created = await userApi.create({ name: 'Alice', email: 'alice@example.com' });
|
|
59
|
+
const updated = await userApi.update({ kt: 'user', pk: 'user-123' }, { name: 'Alice Smith' });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Contained Items
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { createCItemApi } from '@fjell/client-api';
|
|
66
|
+
|
|
67
|
+
interface Comment extends Item<'comment', 'post'> {
|
|
68
|
+
text: string;
|
|
69
|
+
author: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const commentApi = createCItemApi<Comment, 'comment', 'post'>(
|
|
73
|
+
httpApi,
|
|
74
|
+
'comment',
|
|
75
|
+
['post', 'comment']
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Operations scoped to a specific location
|
|
79
|
+
const comments = await commentApi.all({}, [{ kt: 'post', lk: 'post-123' }]);
|
|
80
|
+
const comment = await commentApi.create(
|
|
81
|
+
{ text: 'Great post!', author: 'alice' },
|
|
82
|
+
{ locations: [{ kt: 'post', lk: 'post-123' }] }
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### All Operations
|
|
87
|
+
|
|
88
|
+
The ClientApi implements all standard Operations:
|
|
89
|
+
|
|
90
|
+
- **CRUD**: `get`, `create`, `update`, `upsert`, `remove`
|
|
91
|
+
- **Query**: `all`, `one`, `find`, `findOne`
|
|
92
|
+
- **Actions**: `action`, `allAction`
|
|
93
|
+
- **Facets**: `facet`, `allFacet`
|
|
94
|
+
|
|
95
|
+
## Migration from v4.4.x
|
|
96
|
+
|
|
97
|
+
### Update Dependencies
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npm install @fjell/core@latest @fjell/client-api@latest
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Code Changes
|
|
104
|
+
|
|
105
|
+
The API is mostly backward compatible. Key changes:
|
|
106
|
+
|
|
107
|
+
#### 1. Create Method Signature
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
// Before (v4.4.x)
|
|
111
|
+
await api.create(item, locations);
|
|
112
|
+
|
|
113
|
+
// After (v4.5.0+) - still works
|
|
114
|
+
await api.create(item, { locations });
|
|
115
|
+
|
|
116
|
+
// New options
|
|
117
|
+
await api.create(item, { key: { kt: 'user', pk: 'custom-id' } });
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### 2. Action Parameters
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
// Before (v4.4.x) - "body" parameter
|
|
124
|
+
await api.action(key, 'promote', { role: 'admin' });
|
|
125
|
+
|
|
126
|
+
// After (v4.5.0+) - "params" parameter (works the same)
|
|
127
|
+
await api.action(key, 'promote', { role: 'admin' });
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### 3. Upsert Operation
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// Now available
|
|
134
|
+
const user = await api.upsert(
|
|
135
|
+
{ kt: 'user', pk: 'user-123' },
|
|
136
|
+
{ name: 'Alice', email: 'alice@example.com' }
|
|
137
|
+
);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Type Exports
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import type {
|
|
144
|
+
ClientApi,
|
|
145
|
+
CItemApi,
|
|
146
|
+
OperationParams,
|
|
147
|
+
AffectedKeys,
|
|
148
|
+
CreateOptions
|
|
149
|
+
} from '@fjell/client-api';
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Benefits
|
|
153
|
+
|
|
154
|
+
- **Consistent API**: Same Operations interface as `@fjell/lib`, `@fjell/lib-firestore`, etc.
|
|
155
|
+
- **Type Safety**: Full TypeScript support with generic types
|
|
156
|
+
- **Interchangeable**: Can be used anywhere that accepts Operations
|
|
157
|
+
- **HTTP Transport**: Built on `@fjell/http-api` for reliable HTTP communication
|
|
158
|
+
|
|
159
|
+
## Documentation
|
|
160
|
+
|
|
161
|
+
For detailed documentation, see:
|
|
162
|
+
- [API Reference](./docs/public/api-reference.md)
|
|
163
|
+
- [Examples](./examples/README.md)
|
|
164
|
+
- [Migration Guide](./MIGRATION_v3.md)
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
Apache-2.0
|
|
169
|
+
|
package/dist/AItemAPI.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Item
|
|
1
|
+
import { Item } from "@fjell/core";
|
|
2
2
|
import { HttpApi } from "@fjell/http-api";
|
|
3
3
|
import { ClientApiOptions } from "./ClientApiOptions";
|
|
4
4
|
import { ClientApi } from "./ClientApi";
|
|
@@ -30,5 +30,5 @@ export type PathNamesArray<L1 extends string = never, L2 extends string = never,
|
|
|
30
30
|
string,
|
|
31
31
|
string
|
|
32
32
|
]);
|
|
33
|
-
export declare const finderToParams: (finder: string, finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) =>
|
|
33
|
+
export declare const finderToParams: (finder: string, finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Record<string, string>;
|
|
34
34
|
export declare const createAItemAPI: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(api: HttpApi, pkType: S, pathNames: PathNamesArray<L1, L2, L3, L4, L5>, options?: ClientApiOptions) => ClientApi<V, S, L1, L2, L3, L4, L5>;
|
package/dist/CItemAPI.d.ts
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Item } from "@fjell/core";
|
|
2
2
|
import { HttpApi } from "@fjell/http-api";
|
|
3
3
|
import { PathNamesArray } from "./AItemAPI";
|
|
4
4
|
import { ClientApi } from "./ClientApi";
|
|
5
5
|
import { ClientApiOptions } from "./ClientApiOptions";
|
|
6
|
+
/**
|
|
7
|
+
* CItemApi extends ClientApi for contained items.
|
|
8
|
+
* No additional methods needed - pure Operations interface.
|
|
9
|
+
*/
|
|
6
10
|
export interface CItemApi<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> extends ClientApi<V, S, L1, L2, L3, L4, L5> {
|
|
7
|
-
action: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body: any) => Promise<[V, Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]>;
|
|
8
|
-
all: (query: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
|
|
9
|
-
allAction: (action: string, body?: any, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[V[], Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]>;
|
|
10
|
-
allFacet: (facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<any>;
|
|
11
|
-
get: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<V | null>;
|
|
12
|
-
create: (item: Partial<Item<S, L1, L2, L3, L4, L5>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V>;
|
|
13
|
-
remove: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<boolean>;
|
|
14
|
-
update: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: Partial<Item<S, L1, L2, L3, L4, L5>>) => Promise<V>;
|
|
15
|
-
facet: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<any>;
|
|
16
|
-
find: (finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
|
|
17
|
-
findOne: (finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V>;
|
|
18
11
|
}
|
|
19
12
|
export declare const createCItemApi: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(api: HttpApi, type: S, pathNames: PathNamesArray<L1, L2, L3, L4, L5>, options?: ClientApiOptions) => CItemApi<V, S, L1, L2, L3, L4, L5>;
|
package/dist/ClientApi.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
update: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: Partial<Item<S, L1, L2, L3, L4, L5>>) => Promise<V>;
|
|
1
|
+
import { AffectedKeys, Operations as CoreOperations, CreateOptions, Item, OperationParams } from "@fjell/core";
|
|
2
|
+
export type { OperationParams, AffectedKeys, CreateOptions };
|
|
3
|
+
/**
|
|
4
|
+
* ClientApi interface - HTTP transport layer for Operations.
|
|
5
|
+
* This is a direct mapping of the core Operations interface to HTTP calls.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const api: ClientApi<User, 'user'> = createClientApi(httpApi, 'user', ['user']);
|
|
10
|
+
* const users = await api.all({});
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export interface ClientApi<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> extends CoreOperations<V, S, L1, L2, L3, L4, L5> {
|
|
15
14
|
}
|
package/dist/Instance.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Item } from "@fjell/core";
|
|
2
|
-
import { Instance as BaseInstance,
|
|
2
|
+
import { Instance as BaseInstance, Registry } from "@fjell/registry";
|
|
3
3
|
import { ClientApi } from "./ClientApi";
|
|
4
|
+
import { Coordinate } from "@fjell/core";
|
|
4
5
|
/**
|
|
5
6
|
* The Client API Instance interface represents a client API model instance that extends the base Instance
|
|
6
7
|
* from @fjell/registry and adds client API operations for interacting with remote data.
|
package/dist/PItemAPI.d.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Item } from "@fjell/core";
|
|
2
2
|
import { HttpApi } from "@fjell/http-api";
|
|
3
3
|
import { ClientApi } from "./ClientApi";
|
|
4
4
|
import { ClientApiOptions } from "./ClientApiOptions";
|
|
5
5
|
export interface PItemApi<V extends Item<S>, S extends string> extends ClientApi<V, S> {
|
|
6
|
-
action: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, action: string, body: any) => Promise<[V, Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]>;
|
|
7
|
-
all: (query: ItemQuery) => Promise<V[]>;
|
|
8
|
-
allAction: (action: string, body?: any) => Promise<[V[], Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]>;
|
|
9
|
-
allFacet: (facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<any>;
|
|
10
|
-
one: (query: ItemQuery) => Promise<V | null>;
|
|
11
|
-
get: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>) => Promise<V | null>;
|
|
12
|
-
create: (item: Partial<Item<S>>) => Promise<V>;
|
|
13
|
-
remove: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>) => Promise<boolean>;
|
|
14
|
-
update: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, item: Partial<Item<S>>) => Promise<V>;
|
|
15
|
-
facet: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<any>;
|
|
16
|
-
find: (finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<V[]>;
|
|
17
|
-
findOne: (finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<V>;
|
|
18
6
|
}
|
|
19
7
|
export declare const createPItemApi: <V extends Item<S>, S extends string>(api: HttpApi, type: S, pathName: string, options?: ClientApiOptions) => PItemApi<V, S>;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export * from './InstanceFactory';
|
|
|
9
9
|
export * from './Registry';
|
|
10
10
|
export * from './errors/index';
|
|
11
11
|
export * from './ops/errorHandling';
|
|
12
|
+
export { FjellHttpError, isFjellHttpError, extractErrorInfo, type ErrorInfo } from '@fjell/http-api';
|
|
12
13
|
export * from './http/HttpWrapper';
|