@quiltr/sdk 1.3.0
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 +292 -0
- package/dist/client.d.ts +84 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +149 -0
- package/dist/client.js.map +1 -0
- package/dist/features/api-users/api-users.client.d.ts +52 -0
- package/dist/features/api-users/api-users.client.d.ts.map +1 -0
- package/dist/features/api-users/api-users.client.js +41 -0
- package/dist/features/api-users/api-users.client.js.map +1 -0
- package/dist/features/app-sessions/app-sessions.client.d.ts +22 -0
- package/dist/features/app-sessions/app-sessions.client.d.ts.map +1 -0
- package/dist/features/app-sessions/app-sessions.client.js +50 -0
- package/dist/features/app-sessions/app-sessions.client.js.map +1 -0
- package/dist/features/auth/auth.client.d.ts +32 -0
- package/dist/features/auth/auth.client.d.ts.map +1 -0
- package/dist/features/auth/auth.client.js +119 -0
- package/dist/features/auth/auth.client.js.map +1 -0
- package/dist/features/baskets/basket-operations.client.d.ts +89 -0
- package/dist/features/baskets/basket-operations.client.d.ts.map +1 -0
- package/dist/features/baskets/basket-operations.client.js +226 -0
- package/dist/features/baskets/basket-operations.client.js.map +1 -0
- package/dist/features/baskets/baskets.client.d.ts +10 -0
- package/dist/features/baskets/baskets.client.d.ts.map +1 -0
- package/dist/features/baskets/baskets.client.js +10 -0
- package/dist/features/baskets/baskets.client.js.map +1 -0
- package/dist/features/customers/customers.client.d.ts +10 -0
- package/dist/features/customers/customers.client.d.ts.map +1 -0
- package/dist/features/customers/customers.client.js +10 -0
- package/dist/features/customers/customers.client.js.map +1 -0
- package/dist/features/email-templates/email-templates.client.d.ts +9 -0
- package/dist/features/email-templates/email-templates.client.d.ts.map +1 -0
- package/dist/features/email-templates/email-templates.client.js +10 -0
- package/dist/features/email-templates/email-templates.client.js.map +1 -0
- package/dist/features/fascias/fascias.client.d.ts +9 -0
- package/dist/features/fascias/fascias.client.d.ts.map +1 -0
- package/dist/features/fascias/fascias.client.js +10 -0
- package/dist/features/fascias/fascias.client.js.map +1 -0
- package/dist/features/gift-cards/gift-card-operations.client.d.ts +24 -0
- package/dist/features/gift-cards/gift-card-operations.client.d.ts.map +1 -0
- package/dist/features/gift-cards/gift-card-operations.client.js +18 -0
- package/dist/features/gift-cards/gift-card-operations.client.js.map +1 -0
- package/dist/features/jobs/jobs.client.d.ts +20 -0
- package/dist/features/jobs/jobs.client.d.ts.map +1 -0
- package/dist/features/jobs/jobs.client.js +44 -0
- package/dist/features/jobs/jobs.client.js.map +1 -0
- package/dist/features/locations/locations.client.d.ts +9 -0
- package/dist/features/locations/locations.client.d.ts.map +1 -0
- package/dist/features/locations/locations.client.js +10 -0
- package/dist/features/locations/locations.client.js.map +1 -0
- package/dist/features/payments/payments.client.d.ts +22 -0
- package/dist/features/payments/payments.client.d.ts.map +1 -0
- package/dist/features/payments/payments.client.js +50 -0
- package/dist/features/payments/payments.client.js.map +1 -0
- package/dist/features/price-entries/price-entries.client.d.ts +9 -0
- package/dist/features/price-entries/price-entries.client.d.ts.map +1 -0
- package/dist/features/price-entries/price-entries.client.js +10 -0
- package/dist/features/price-entries/price-entries.client.js.map +1 -0
- package/dist/features/pricing/pricing.client.d.ts +20 -0
- package/dist/features/pricing/pricing.client.d.ts.map +1 -0
- package/dist/features/pricing/pricing.client.js +27 -0
- package/dist/features/pricing/pricing.client.js.map +1 -0
- package/dist/features/products/products.client.d.ts +20 -0
- package/dist/features/products/products.client.d.ts.map +1 -0
- package/dist/features/products/products.client.js +45 -0
- package/dist/features/products/products.client.js.map +1 -0
- package/dist/features/promotions/promotion.client.d.ts +33 -0
- package/dist/features/promotions/promotion.client.d.ts.map +1 -0
- package/dist/features/promotions/promotion.client.js +69 -0
- package/dist/features/promotions/promotion.client.js.map +1 -0
- package/dist/features/scripts/scripts.client.d.ts +17 -0
- package/dist/features/scripts/scripts.client.d.ts.map +1 -0
- package/dist/features/scripts/scripts.client.js +26 -0
- package/dist/features/scripts/scripts.client.js.map +1 -0
- package/dist/features/search/search.client.d.ts +17 -0
- package/dist/features/search/search.client.d.ts.map +1 -0
- package/dist/features/search/search.client.js +40 -0
- package/dist/features/search/search.client.js.map +1 -0
- package/dist/features/tasks/tasks.client.d.ts +9 -0
- package/dist/features/tasks/tasks.client.d.ts.map +1 -0
- package/dist/features/tasks/tasks.client.js +10 -0
- package/dist/features/tasks/tasks.client.js.map +1 -0
- package/dist/features/tax/tax-rule.client.d.ts +16 -0
- package/dist/features/tax/tax-rule.client.d.ts.map +1 -0
- package/dist/features/tax/tax-rule.client.js +18 -0
- package/dist/features/tax/tax-rule.client.js.map +1 -0
- package/dist/features/tenants/tenants.client.d.ts +21 -0
- package/dist/features/tenants/tenants.client.d.ts.map +1 -0
- package/dist/features/tenants/tenants.client.js +47 -0
- package/dist/features/tenants/tenants.client.js.map +1 -0
- package/dist/features/uploads/uploads.client.d.ts +21 -0
- package/dist/features/uploads/uploads.client.d.ts.map +1 -0
- package/dist/features/uploads/uploads.client.js +57 -0
- package/dist/features/uploads/uploads.client.js.map +1 -0
- package/dist/features/users/users.client.d.ts +9 -0
- package/dist/features/users/users.client.d.ts.map +1 -0
- package/dist/features/users/users.client.js +10 -0
- package/dist/features/users/users.client.js.map +1 -0
- package/dist/features/workflows/workflows.client.d.ts +38 -0
- package/dist/features/workflows/workflows.client.d.ts.map +1 -0
- package/dist/features/workflows/workflows.client.js +142 -0
- package/dist/features/workflows/workflows.client.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/base-crud.client.d.ts +31 -0
- package/dist/shared/base-crud.client.d.ts.map +1 -0
- package/dist/shared/base-crud.client.js +97 -0
- package/dist/shared/base-crud.client.js.map +1 -0
- package/dist/shared/errors.d.ts +27 -0
- package/dist/shared/errors.d.ts.map +1 -0
- package/dist/shared/errors.js +67 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/http-client.d.ts +56 -0
- package/dist/shared/http-client.d.ts.map +1 -0
- package/dist/shared/http-client.js +194 -0
- package/dist/shared/http-client.js.map +1 -0
- package/dist/shared/result.d.ts +15 -0
- package/dist/shared/result.d.ts.map +1 -0
- package/dist/shared/result.js +7 -0
- package/dist/shared/result.js.map +1 -0
- package/dist/shared/websocket.client.d.ts +40 -0
- package/dist/shared/websocket.client.d.ts.map +1 -0
- package/dist/shared/websocket.client.js +93 -0
- package/dist/shared/websocket.client.js.map +1 -0
- package/dist/types/common.types.d.ts +21 -0
- package/dist/types/common.types.d.ts.map +1 -0
- package/dist/types/common.types.js +5 -0
- package/dist/types/common.types.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/query-builder.d.ts +10 -0
- package/dist/utils/query-builder.d.ts.map +1 -0
- package/dist/utils/query-builder.js +33 -0
- package/dist/utils/query-builder.js.map +1 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# Quiltr SDK
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the Quiltr NestJS Multitenant API. Zero-dependency (uses native `fetch`), type-safe, and built on a `Result<T, E>` pattern for predictable error handling.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @quiltr/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { QuiltrClient } from '@quiltr/sdk';
|
|
15
|
+
|
|
16
|
+
const client = new QuiltrClient({ baseUrl: 'https://api.example.com' });
|
|
17
|
+
|
|
18
|
+
// Authenticate
|
|
19
|
+
const login = await client.auth.login({ username: 'admin', password: 'secret' });
|
|
20
|
+
if (!login.success) throw new Error(login.error.message);
|
|
21
|
+
|
|
22
|
+
// CRUD operations
|
|
23
|
+
const products = await client.products.findAll({ page: 1, limit: 20 });
|
|
24
|
+
if (products.success) {
|
|
25
|
+
console.log(products.data.data); // Product[]
|
|
26
|
+
console.log(products.data.meta.total); // total count
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Create
|
|
30
|
+
const result = await client.products.create({
|
|
31
|
+
sku: 'WIDGET-001',
|
|
32
|
+
priceInCents: 1999,
|
|
33
|
+
name: { en: 'Widget' },
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Result Pattern
|
|
38
|
+
|
|
39
|
+
Every SDK method returns `Result<T, SdkError>` — a discriminated union that forces you to handle errors:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const result = await client.products.findOne('abc123');
|
|
43
|
+
|
|
44
|
+
if (result.success) {
|
|
45
|
+
// result.data is fully typed
|
|
46
|
+
console.log(result.data.sku);
|
|
47
|
+
} else {
|
|
48
|
+
// result.error is SdkError
|
|
49
|
+
console.log(result.error.message, result.error.code);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Feature Clients
|
|
54
|
+
|
|
55
|
+
All clients are accessible as properties on `QuiltrClient`:
|
|
56
|
+
|
|
57
|
+
| Client | Path | Description |
|
|
58
|
+
|--------|------|-------------|
|
|
59
|
+
| `client.auth` | `/api/v1/auth` | Login, register, token refresh, password flows |
|
|
60
|
+
| `client.tenants` | `/api/v1/tenants` | Tenant management (global admin) |
|
|
61
|
+
| `client.apiUsers` | `/api/v1/api-users` | API user management (global admin) |
|
|
62
|
+
| `client.products` | `/api/v1/products` | Product catalog (tenant-scoped CRUD) |
|
|
63
|
+
| `client.customers` | `/api/v1/customers` | Customer profiles (tenant-scoped CRUD) |
|
|
64
|
+
| `client.baskets` | `/api/v1/baskets` | Shopping baskets (tenant-scoped CRUD) |
|
|
65
|
+
| `client.locations` | `/api/v1/locations` | Physical locations (tenant-scoped CRUD) |
|
|
66
|
+
| `client.fascias` | `/api/v1/fascias` | Brands/sub-brands (tenant-scoped CRUD) |
|
|
67
|
+
| `client.priceEntries` | `/api/v1/price-entries` | Price entries (tenant-scoped CRUD) |
|
|
68
|
+
| `client.pricing` | `/api/v1/prices` | Dynamic price resolution |
|
|
69
|
+
| `client.tasks` | `/api/v1/tasks` | Task management (tenant-scoped CRUD) |
|
|
70
|
+
| `client.emailTemplates` | `/api/v1/email-templates` | Email templates (tenant-scoped CRUD) |
|
|
71
|
+
| `client.users` | `/api/v1/users` | Tenant staff/employees (tenant-scoped CRUD) |
|
|
72
|
+
| `client.workflows` | `/api/v1/workflow-*` | Workflow definitions + instances |
|
|
73
|
+
| `client.scripts` | `/api/v1/scripts` | Script CRUD + async execution |
|
|
74
|
+
| `client.appSessions` | `/api/v1/app-sessions` | Workflow-driven UI sessions |
|
|
75
|
+
| `client.jobs` | `/api/v1/jobs` | Background job tracking |
|
|
76
|
+
| `client.payments` | `/api/v1/payments` | Payment processing |
|
|
77
|
+
| `client.search` | `/api/v1/search` | Full-text search, facets, suggestions |
|
|
78
|
+
| `client.uploads` | `/api/v1/uploads` | File uploads |
|
|
79
|
+
| `client.websocket` | WebSocket | Real-time events |
|
|
80
|
+
|
|
81
|
+
## CRUD Operations
|
|
82
|
+
|
|
83
|
+
All tenant-scoped entities share the same base operations via `BaseCrudClient`:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// List with pagination
|
|
87
|
+
await client.products.findAll({ page: 1, limit: 20, sortBy: 'createdAt', sortOrder: 'desc' });
|
|
88
|
+
|
|
89
|
+
// Get by ID
|
|
90
|
+
await client.products.findOne('id');
|
|
91
|
+
|
|
92
|
+
// Create
|
|
93
|
+
await client.products.create({ sku: 'SKU-001', priceInCents: 999 });
|
|
94
|
+
|
|
95
|
+
// Update (PATCH)
|
|
96
|
+
await client.products.update('id', { priceInCents: 1299 });
|
|
97
|
+
|
|
98
|
+
// Soft delete + restore
|
|
99
|
+
await client.products.delete('id');
|
|
100
|
+
await client.products.restore('id');
|
|
101
|
+
|
|
102
|
+
// Hard delete (permanent)
|
|
103
|
+
await client.products.hardDelete('id');
|
|
104
|
+
|
|
105
|
+
// Count
|
|
106
|
+
await client.products.count({ category: 'electronics' });
|
|
107
|
+
|
|
108
|
+
// Batch operations
|
|
109
|
+
await client.products.batchCreate([...]);
|
|
110
|
+
await client.products.batchUpdate([{ id: '...', data: { ... } }]);
|
|
111
|
+
await client.products.batchDelete({ ids: ['...'] });
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Workflows
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// Create a definition
|
|
118
|
+
const def = await client.workflows.createDefinition({
|
|
119
|
+
name: 'Order Processing',
|
|
120
|
+
stages: [
|
|
121
|
+
{ name: 'received', label: 'Received', order: 0, isInitial: true, transitions: [{ targetStage: 'processing', label: 'Start' }] },
|
|
122
|
+
{ name: 'processing', label: 'Processing', order: 1, transitions: [{ targetStage: 'shipped', label: 'Ship' }] },
|
|
123
|
+
{ name: 'shipped', label: 'Shipped', order: 2, isFinal: true, transitions: [] },
|
|
124
|
+
],
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Activate and run
|
|
128
|
+
await client.workflows.updateDefinition(def.data._id, { status: 'active' });
|
|
129
|
+
const run = await client.workflows.runDefinition(def.data._id, { orderId: '123' });
|
|
130
|
+
|
|
131
|
+
// Transition an instance
|
|
132
|
+
await client.workflows.transitionInstance(instanceId, { targetStage: 'processing' });
|
|
133
|
+
|
|
134
|
+
// Full instance lifecycle
|
|
135
|
+
await client.workflows.pauseInstance(instanceId);
|
|
136
|
+
await client.workflows.resumeInstance(instanceId);
|
|
137
|
+
await client.workflows.cancelInstance(instanceId);
|
|
138
|
+
await client.workflows.getInstanceHistory(instanceId);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Scripts
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// Create and execute a script
|
|
145
|
+
const script = await client.scripts.create({
|
|
146
|
+
name: 'Calculate Tax',
|
|
147
|
+
description: 'Calculates tax by region',
|
|
148
|
+
language: 'javascript',
|
|
149
|
+
code: 'return amount * taxRate;',
|
|
150
|
+
status: 'active',
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Execute asynchronously (returns a jobId)
|
|
154
|
+
const { data } = await client.scripts.execute(script.data._id, {
|
|
155
|
+
parameters: { amount: 1000, taxRate: 0.15 },
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Poll the job for results
|
|
159
|
+
const job = await client.jobs.waitForCompletion(data.jobId);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Pricing
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
// Resolve price for a single product
|
|
166
|
+
const price = await client.pricing.resolvePrice('product-id', {
|
|
167
|
+
country: 'US',
|
|
168
|
+
channel: 'web',
|
|
169
|
+
customerGroup: 'vip',
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Batch resolve (up to 200 products)
|
|
173
|
+
const prices = await client.pricing.resolvePrices(
|
|
174
|
+
['prod-1', 'prod-2', 'prod-3'],
|
|
175
|
+
{ country: 'GB', storeCode: 'LON-001' },
|
|
176
|
+
);
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## App Sessions
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// Start a workflow-driven UI session
|
|
183
|
+
const screen = await client.appSessions.create({
|
|
184
|
+
appId: 'checkout-flow',
|
|
185
|
+
initialData: { cartId: '123' },
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// Navigate between stages
|
|
189
|
+
await client.appSessions.navigate(screen.data.sessionId, {
|
|
190
|
+
targetStage: 'payment',
|
|
191
|
+
data: { selectedMethod: 'card' },
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Execute an action
|
|
195
|
+
await client.appSessions.executeAction(screen.data.sessionId, {
|
|
196
|
+
actionName: 'processPayment',
|
|
197
|
+
params: { amount: 5000 },
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Authentication
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
// Login
|
|
205
|
+
await client.auth.login({ username: 'user', password: 'pass' });
|
|
206
|
+
|
|
207
|
+
// Register
|
|
208
|
+
await client.auth.register({ username: 'new', password: 'Pass123!', email: 'a@b.com', tenantId: 'my-tenant' });
|
|
209
|
+
|
|
210
|
+
// Token refresh (automatic by default)
|
|
211
|
+
await client.auth.refresh();
|
|
212
|
+
|
|
213
|
+
// Get current user from JWT
|
|
214
|
+
const user = client.auth.getCurrentUser();
|
|
215
|
+
|
|
216
|
+
// Set tokens from external source
|
|
217
|
+
client.setTokens(accessToken, refreshToken);
|
|
218
|
+
|
|
219
|
+
// Password flows
|
|
220
|
+
await client.auth.forgotPassword({ email: 'user@example.com' });
|
|
221
|
+
await client.auth.changePassword({ currentPassword: 'old', newPassword: 'new' });
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## WebSocket (Real-time)
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
// Connect after authentication
|
|
228
|
+
client.websocket.connect();
|
|
229
|
+
|
|
230
|
+
// Listen for events
|
|
231
|
+
client.websocket.on('job:completed', (data) => console.log('Job done:', data));
|
|
232
|
+
client.websocket.on('workflow:transition', (data) => console.log('Transition:', data));
|
|
233
|
+
|
|
234
|
+
// Disconnect
|
|
235
|
+
client.websocket.disconnect();
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Health Checks
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
const health = await client.healthCheck(); // GET /health
|
|
242
|
+
const ready = await client.readinessCheck(); // GET /health/ready
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Extending the SDK
|
|
246
|
+
|
|
247
|
+
Create custom clients using `BaseCrudClient`:
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
import { BaseCrudClient, HttpClient } from '@quiltr/sdk';
|
|
251
|
+
|
|
252
|
+
interface Widget { _id: string; name: string; }
|
|
253
|
+
interface CreateWidgetDto { name: string; }
|
|
254
|
+
|
|
255
|
+
class WidgetsClient extends BaseCrudClient<Widget, CreateWidgetDto> {
|
|
256
|
+
constructor(http: HttpClient) {
|
|
257
|
+
super(http, '/api/v1/widgets');
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Configuration
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
const client = new QuiltrClient({
|
|
266
|
+
baseUrl: 'https://api.example.com',
|
|
267
|
+
timeout: 30000, // Request timeout (ms)
|
|
268
|
+
maxRetries: 2, // Retry transient failures
|
|
269
|
+
headers: { // Custom headers
|
|
270
|
+
'X-Custom': 'value',
|
|
271
|
+
},
|
|
272
|
+
onTokenRefresh: async (refreshToken) => {
|
|
273
|
+
// Custom refresh logic (default: uses client.auth.refresh)
|
|
274
|
+
return { accessToken: '...', refreshToken: '...' };
|
|
275
|
+
},
|
|
276
|
+
onAuthExpired: () => {
|
|
277
|
+
// Called when refresh fails — redirect to login, etc.
|
|
278
|
+
window.location.href = '/login';
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Seed Project
|
|
284
|
+
|
|
285
|
+
The seed toolkit has been consolidated into `@quiltr/seed` at `packages/seed/`. It combines Faker generators with static vertical data and supports bootstrap, global, and tenant seeding phases.
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# From the repo root:
|
|
289
|
+
npm run seed -- --all --vertical specialty
|
|
290
|
+
npm run seed -- --tenant tenant-123 --vertical charity
|
|
291
|
+
npm run seed -- --count 100
|
|
292
|
+
```
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QuiltrClient - Main SDK entry point.
|
|
3
|
+
* Wires all feature clients together with shared HTTP transport.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* const client = new QuiltrClient({ baseUrl: 'https://api.example.com' });
|
|
7
|
+
* await client.auth.login({ username: 'admin', password: 'secret' });
|
|
8
|
+
* const products = await client.products.findAll({ page: 1, limit: 20 });
|
|
9
|
+
*/
|
|
10
|
+
import type { SdkConfig } from './types/common.types';
|
|
11
|
+
import type { HealthStatus } from './types';
|
|
12
|
+
import type { Result } from './shared/result';
|
|
13
|
+
import type { SdkError } from './shared/errors';
|
|
14
|
+
import { BaseCrudClient } from './shared/base-crud.client';
|
|
15
|
+
import { WebSocketClient } from './shared/websocket.client';
|
|
16
|
+
import { AuthClient } from './features/auth/auth.client';
|
|
17
|
+
import { TenantsClient } from './features/tenants/tenants.client';
|
|
18
|
+
import { ProductsClient } from './features/products/products.client';
|
|
19
|
+
import { CustomersClient } from './features/customers/customers.client';
|
|
20
|
+
import { BasketsClient } from './features/baskets/baskets.client';
|
|
21
|
+
import { BasketOperationsClient } from './features/baskets/basket-operations.client';
|
|
22
|
+
import { ApiUsersClient } from './features/api-users/api-users.client';
|
|
23
|
+
import { WorkflowsClient } from './features/workflows/workflows.client';
|
|
24
|
+
import { JobsClient } from './features/jobs/jobs.client';
|
|
25
|
+
import { PaymentsClient } from './features/payments/payments.client';
|
|
26
|
+
import { SearchClient } from './features/search/search.client';
|
|
27
|
+
import { UploadsClient } from './features/uploads/uploads.client';
|
|
28
|
+
import { LocationsClient } from './features/locations/locations.client';
|
|
29
|
+
import { PriceEntriesClient } from './features/price-entries/price-entries.client';
|
|
30
|
+
import { FasciasClient } from './features/fascias/fascias.client';
|
|
31
|
+
import { TasksClient } from './features/tasks/tasks.client';
|
|
32
|
+
import { EmailTemplatesClient } from './features/email-templates/email-templates.client';
|
|
33
|
+
import { UsersClient } from './features/users/users.client';
|
|
34
|
+
import { ScriptsClient } from './features/scripts/scripts.client';
|
|
35
|
+
import { AppSessionsClient } from './features/app-sessions/app-sessions.client';
|
|
36
|
+
import { PricingClient } from './features/pricing/pricing.client';
|
|
37
|
+
import { GiftCardOperationsClient } from './features/gift-cards/gift-card-operations.client';
|
|
38
|
+
import { PromotionClient } from './features/promotions/promotion.client';
|
|
39
|
+
import { TaxRuleClient } from './features/tax/tax-rule.client';
|
|
40
|
+
export declare class QuiltrClient {
|
|
41
|
+
private readonly http;
|
|
42
|
+
readonly auth: AuthClient;
|
|
43
|
+
readonly tenants: TenantsClient;
|
|
44
|
+
readonly products: ProductsClient;
|
|
45
|
+
readonly customers: CustomersClient;
|
|
46
|
+
readonly baskets: BasketsClient;
|
|
47
|
+
readonly basketOperations: BasketOperationsClient;
|
|
48
|
+
readonly apiUsers: ApiUsersClient;
|
|
49
|
+
readonly workflows: WorkflowsClient;
|
|
50
|
+
readonly jobs: JobsClient;
|
|
51
|
+
readonly payments: PaymentsClient;
|
|
52
|
+
readonly search: SearchClient;
|
|
53
|
+
readonly uploads: UploadsClient;
|
|
54
|
+
readonly locations: LocationsClient;
|
|
55
|
+
readonly priceEntries: PriceEntriesClient;
|
|
56
|
+
readonly fascias: FasciasClient;
|
|
57
|
+
readonly tasks: TasksClient;
|
|
58
|
+
readonly emailTemplates: EmailTemplatesClient;
|
|
59
|
+
readonly users: UsersClient;
|
|
60
|
+
readonly scripts: ScriptsClient;
|
|
61
|
+
readonly appSessions: AppSessionsClient;
|
|
62
|
+
readonly pricing: PricingClient;
|
|
63
|
+
readonly giftCardOperations: GiftCardOperationsClient;
|
|
64
|
+
readonly promotions: PromotionClient;
|
|
65
|
+
readonly taxRules: TaxRuleClient;
|
|
66
|
+
readonly websocket: WebSocketClient;
|
|
67
|
+
readonly addresses: BaseCrudClient<Record<string, unknown>, Record<string, unknown>>;
|
|
68
|
+
readonly consents: BaseCrudClient<Record<string, unknown>, Record<string, unknown>>;
|
|
69
|
+
readonly policies: BaseCrudClient<Record<string, unknown>, Record<string, unknown>>;
|
|
70
|
+
readonly strings: BaseCrudClient<Record<string, unknown>, Record<string, unknown>>;
|
|
71
|
+
readonly clientConfigs: BaseCrudClient<Record<string, unknown>, Record<string, unknown>>;
|
|
72
|
+
readonly giftCards: BaseCrudClient<Record<string, unknown>, Record<string, unknown>>;
|
|
73
|
+
readonly discounts: BaseCrudClient<Record<string, unknown>, Record<string, unknown>>;
|
|
74
|
+
constructor(config: SdkConfig);
|
|
75
|
+
/** Health check - liveness */
|
|
76
|
+
healthCheck(): Promise<Result<HealthStatus, SdkError>>;
|
|
77
|
+
/** Health check - readiness (includes MongoDB status) */
|
|
78
|
+
readinessCheck(): Promise<Result<HealthStatus, SdkError>>;
|
|
79
|
+
/** Set tokens from external source (e.g., stored session) */
|
|
80
|
+
setTokens(accessToken: string, refreshToken: string): void;
|
|
81
|
+
/** Clear all auth state */
|
|
82
|
+
clearAuth(): void;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAoC,MAAM,SAAS,CAAC;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAA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,EAAE,OAAO,CAAC,CAAC,CAAC;IACpF,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnF,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzF,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACrF,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;gBAEzE,MAAM,EAAE,SAAS;IAuD7B,8BAA8B;IACxB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAQ5D,yDAAyD;IACnD,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAQ/D,6DAA6D;IAC7D,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAI1D,2BAA2B;IAC3B,SAAS,IAAI,IAAI;CAIlB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QuiltrClient - Main SDK entry point.
|
|
3
|
+
* Wires all feature clients together with shared HTTP transport.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* const client = new QuiltrClient({ baseUrl: 'https://api.example.com' });
|
|
7
|
+
* await client.auth.login({ username: 'admin', password: 'secret' });
|
|
8
|
+
* const products = await client.products.findAll({ page: 1, limit: 20 });
|
|
9
|
+
*/
|
|
10
|
+
import { HttpClient } from './shared/http-client';
|
|
11
|
+
import { BaseCrudClient } from './shared/base-crud.client';
|
|
12
|
+
import { WebSocketClient } from './shared/websocket.client';
|
|
13
|
+
import { AuthClient } from './features/auth/auth.client';
|
|
14
|
+
import { TenantsClient } from './features/tenants/tenants.client';
|
|
15
|
+
import { ProductsClient } from './features/products/products.client';
|
|
16
|
+
import { CustomersClient } from './features/customers/customers.client';
|
|
17
|
+
import { BasketsClient } from './features/baskets/baskets.client';
|
|
18
|
+
import { BasketOperationsClient } from './features/baskets/basket-operations.client';
|
|
19
|
+
import { ApiUsersClient } from './features/api-users/api-users.client';
|
|
20
|
+
import { WorkflowsClient } from './features/workflows/workflows.client';
|
|
21
|
+
import { JobsClient } from './features/jobs/jobs.client';
|
|
22
|
+
import { PaymentsClient } from './features/payments/payments.client';
|
|
23
|
+
import { SearchClient } from './features/search/search.client';
|
|
24
|
+
import { UploadsClient } from './features/uploads/uploads.client';
|
|
25
|
+
import { LocationsClient } from './features/locations/locations.client';
|
|
26
|
+
import { PriceEntriesClient } from './features/price-entries/price-entries.client';
|
|
27
|
+
import { FasciasClient } from './features/fascias/fascias.client';
|
|
28
|
+
import { TasksClient } from './features/tasks/tasks.client';
|
|
29
|
+
import { EmailTemplatesClient } from './features/email-templates/email-templates.client';
|
|
30
|
+
import { UsersClient } from './features/users/users.client';
|
|
31
|
+
import { ScriptsClient } from './features/scripts/scripts.client';
|
|
32
|
+
import { AppSessionsClient } from './features/app-sessions/app-sessions.client';
|
|
33
|
+
import { PricingClient } from './features/pricing/pricing.client';
|
|
34
|
+
import { GiftCardOperationsClient } from './features/gift-cards/gift-card-operations.client';
|
|
35
|
+
import { PromotionClient } from './features/promotions/promotion.client';
|
|
36
|
+
import { TaxRuleClient } from './features/tax/tax-rule.client';
|
|
37
|
+
export class QuiltrClient {
|
|
38
|
+
http;
|
|
39
|
+
auth;
|
|
40
|
+
tenants;
|
|
41
|
+
products;
|
|
42
|
+
customers;
|
|
43
|
+
baskets;
|
|
44
|
+
basketOperations;
|
|
45
|
+
apiUsers;
|
|
46
|
+
workflows;
|
|
47
|
+
jobs;
|
|
48
|
+
payments;
|
|
49
|
+
search;
|
|
50
|
+
uploads;
|
|
51
|
+
locations;
|
|
52
|
+
priceEntries;
|
|
53
|
+
fascias;
|
|
54
|
+
tasks;
|
|
55
|
+
emailTemplates;
|
|
56
|
+
users;
|
|
57
|
+
scripts;
|
|
58
|
+
appSessions;
|
|
59
|
+
pricing;
|
|
60
|
+
giftCardOperations;
|
|
61
|
+
promotions;
|
|
62
|
+
taxRules;
|
|
63
|
+
websocket;
|
|
64
|
+
// Dynamic entity convenience accessors (Clienteling frontend)
|
|
65
|
+
addresses;
|
|
66
|
+
consents;
|
|
67
|
+
policies;
|
|
68
|
+
strings;
|
|
69
|
+
clientConfigs;
|
|
70
|
+
giftCards;
|
|
71
|
+
discounts;
|
|
72
|
+
constructor(config) {
|
|
73
|
+
// Wire up automatic token refresh
|
|
74
|
+
const sdkConfig = {
|
|
75
|
+
...config,
|
|
76
|
+
onTokenRefresh: config.onTokenRefresh ?? (async (refreshToken) => {
|
|
77
|
+
const result = await this.auth.refresh({ refreshToken });
|
|
78
|
+
if (result.success) {
|
|
79
|
+
return {
|
|
80
|
+
accessToken: result.data.access_token,
|
|
81
|
+
refreshToken: result.data.refresh_token,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
this.http = new HttpClient(sdkConfig);
|
|
88
|
+
// Initialize all feature clients
|
|
89
|
+
this.auth = new AuthClient(this.http);
|
|
90
|
+
this.tenants = new TenantsClient(this.http);
|
|
91
|
+
this.products = new ProductsClient(this.http);
|
|
92
|
+
this.customers = new CustomersClient(this.http);
|
|
93
|
+
this.baskets = new BasketsClient(this.http);
|
|
94
|
+
this.basketOperations = new BasketOperationsClient(this.http);
|
|
95
|
+
this.apiUsers = new ApiUsersClient(this.http);
|
|
96
|
+
this.workflows = new WorkflowsClient(this.http);
|
|
97
|
+
this.jobs = new JobsClient(this.http);
|
|
98
|
+
this.payments = new PaymentsClient(this.http);
|
|
99
|
+
this.search = new SearchClient(this.http);
|
|
100
|
+
this.uploads = new UploadsClient(this.http, sdkConfig);
|
|
101
|
+
this.locations = new LocationsClient(this.http);
|
|
102
|
+
this.priceEntries = new PriceEntriesClient(this.http);
|
|
103
|
+
this.fascias = new FasciasClient(this.http);
|
|
104
|
+
this.tasks = new TasksClient(this.http);
|
|
105
|
+
this.emailTemplates = new EmailTemplatesClient(this.http);
|
|
106
|
+
this.users = new UsersClient(this.http);
|
|
107
|
+
this.scripts = new ScriptsClient(this.http);
|
|
108
|
+
this.appSessions = new AppSessionsClient(this.http);
|
|
109
|
+
this.pricing = new PricingClient(this.http);
|
|
110
|
+
this.giftCardOperations = new GiftCardOperationsClient(this.http);
|
|
111
|
+
this.promotions = new PromotionClient(this.http);
|
|
112
|
+
this.taxRules = new TaxRuleClient(this.http);
|
|
113
|
+
this.websocket = new WebSocketClient(sdkConfig, () => this.http.getAccessToken());
|
|
114
|
+
// Dynamic entity convenience clients (Clienteling frontend)
|
|
115
|
+
this.addresses = new BaseCrudClient(this.http, '/api/v1/entities/addresses');
|
|
116
|
+
this.consents = new BaseCrudClient(this.http, '/api/v1/entities/consents');
|
|
117
|
+
this.policies = new BaseCrudClient(this.http, '/api/v1/entities/policies');
|
|
118
|
+
this.strings = new BaseCrudClient(this.http, '/api/v1/entities/strings');
|
|
119
|
+
this.clientConfigs = new BaseCrudClient(this.http, '/api/v1/entities/client-configs');
|
|
120
|
+
this.giftCards = new BaseCrudClient(this.http, '/api/v1/gift-cards');
|
|
121
|
+
this.discounts = new BaseCrudClient(this.http, '/api/v1/entities/discounts');
|
|
122
|
+
}
|
|
123
|
+
/** Health check - liveness */
|
|
124
|
+
async healthCheck() {
|
|
125
|
+
return this.http.request({
|
|
126
|
+
method: 'GET',
|
|
127
|
+
path: '/health',
|
|
128
|
+
skipAuth: true,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/** Health check - readiness (includes MongoDB status) */
|
|
132
|
+
async readinessCheck() {
|
|
133
|
+
return this.http.request({
|
|
134
|
+
method: 'GET',
|
|
135
|
+
path: '/health/ready',
|
|
136
|
+
skipAuth: true,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/** Set tokens from external source (e.g., stored session) */
|
|
140
|
+
setTokens(accessToken, refreshToken) {
|
|
141
|
+
this.http.setTokens(accessToken, refreshToken);
|
|
142
|
+
}
|
|
143
|
+
/** Clear all auth state */
|
|
144
|
+
clearAuth() {
|
|
145
|
+
this.http.clearTokens();
|
|
146
|
+
this.websocket.disconnect();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,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,CAAC;IAED,yDAAyD;IACzD,KAAK,CAAC,cAAc;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;YACvB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,eAAe;YACrB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;IACL,CAAC;IAED,6DAA6D;IAC7D,SAAS,CAAC,WAAmB,EAAE,YAAoB;QACjD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC;IAED,2BAA2B;IAC3B,SAAS;QACP,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Users management client.
|
|
3
|
+
*/
|
|
4
|
+
import type { HttpClient } from '../../shared/http-client';
|
|
5
|
+
import type { Result } from '../../shared/result';
|
|
6
|
+
import type { SdkError } from '../../shared/errors';
|
|
7
|
+
import type { PaginatedResult, BaseQueryParams } from '../../types';
|
|
8
|
+
export interface ApiUser {
|
|
9
|
+
_id: string;
|
|
10
|
+
username: string;
|
|
11
|
+
email: string;
|
|
12
|
+
tenantId: string;
|
|
13
|
+
role: 'admin' | 'user' | 'viewer';
|
|
14
|
+
firstName?: string;
|
|
15
|
+
lastName?: string;
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CreateApiUserDto {
|
|
21
|
+
username: string;
|
|
22
|
+
email: string;
|
|
23
|
+
password: string;
|
|
24
|
+
tenantId: string;
|
|
25
|
+
role?: 'admin' | 'user' | 'viewer';
|
|
26
|
+
firstName?: string;
|
|
27
|
+
lastName?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface UpdateApiUserDto {
|
|
30
|
+
email?: string;
|
|
31
|
+
role?: 'admin' | 'user' | 'viewer';
|
|
32
|
+
firstName?: string;
|
|
33
|
+
lastName?: string;
|
|
34
|
+
isActive?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface QueryApiUserDto extends BaseQueryParams {
|
|
37
|
+
tenantId?: string;
|
|
38
|
+
role?: string;
|
|
39
|
+
isActive?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare class ApiUsersClient {
|
|
42
|
+
private readonly http;
|
|
43
|
+
constructor(http: HttpClient);
|
|
44
|
+
findAll(params?: QueryApiUserDto): Promise<Result<PaginatedResult<ApiUser>, SdkError>>;
|
|
45
|
+
findOne(id: string): Promise<Result<ApiUser, SdkError>>;
|
|
46
|
+
findByTenant(tenantId: string): Promise<Result<ApiUser[], SdkError>>;
|
|
47
|
+
create(dto: CreateApiUserDto): Promise<Result<ApiUser, SdkError>>;
|
|
48
|
+
update(id: string, dto: UpdateApiUserDto): Promise<Result<ApiUser, SdkError>>;
|
|
49
|
+
delete(id: string): Promise<Result<void, SdkError>>;
|
|
50
|
+
getStats(tenantId?: string): Promise<Result<Record<string, number>, SdkError>>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=api-users.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-users.client.d.ts","sourceRoot":"","sources":["../../../src/features/api-users/api-users.client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAY,MAAM,aAAa,CAAC;AAK9E,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAA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YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;IAIpE,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAIjE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAI7E,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAInD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;CAOrF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Users management client.
|
|
3
|
+
*/
|
|
4
|
+
import { buildQueryParams } from '../../utils/query-builder';
|
|
5
|
+
const BASE_PATH = '/api/v1/api-users';
|
|
6
|
+
export class ApiUsersClient {
|
|
7
|
+
http;
|
|
8
|
+
constructor(http) {
|
|
9
|
+
this.http = http;
|
|
10
|
+
}
|
|
11
|
+
async findAll(params) {
|
|
12
|
+
return this.http.request({
|
|
13
|
+
method: 'GET',
|
|
14
|
+
path: BASE_PATH,
|
|
15
|
+
query: buildQueryParams(params),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async findOne(id) {
|
|
19
|
+
return this.http.request({ method: 'GET', path: `${BASE_PATH}/${id}` });
|
|
20
|
+
}
|
|
21
|
+
async findByTenant(tenantId) {
|
|
22
|
+
return this.http.request({ method: 'GET', path: `${BASE_PATH}/tenant/${tenantId}` });
|
|
23
|
+
}
|
|
24
|
+
async create(dto) {
|
|
25
|
+
return this.http.request({ method: 'POST', path: BASE_PATH, body: dto });
|
|
26
|
+
}
|
|
27
|
+
async update(id, dto) {
|
|
28
|
+
return this.http.request({ method: 'PATCH', path: `${BASE_PATH}/${id}`, body: dto });
|
|
29
|
+
}
|
|
30
|
+
async delete(id) {
|
|
31
|
+
return this.http.request({ method: 'DELETE', path: `${BASE_PATH}/${id}` });
|
|
32
|
+
}
|
|
33
|
+
async getStats(tenantId) {
|
|
34
|
+
return this.http.request({
|
|
35
|
+
method: 'GET',
|
|
36
|
+
path: `${BASE_PATH}/stats`,
|
|
37
|
+
query: tenantId ? { tenantId } : undefined,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=api-users.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-users.client.js","sourceRoot":"","sources":["../../../src/features/api-users/api-users.client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,SAAS,GAAG,mBAAmB,CAAC;AAuCtC,MAAM,OAAO,cAAc;IACI;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,KAAK,CAAC,OAAO,CAAC,MAAwB;QACpC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;YACvB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC;SAChC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAgB;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MA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