@applite/js-sdk 0.0.2 → 0.0.4
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 +184 -67
- package/dist/index.d.mts +713 -0
- package/dist/index.d.ts +713 -0
- package/dist/index.js +107 -107
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,137 +1,254 @@
|
|
|
1
1
|
# @applite/js-sdk
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A comprehensive JavaScript/TypeScript SDK for interacting with the Applite Customer API. This library provides a structured, typed interface to manage application data, e-commerce operations, and service bookings.
|
|
4
|
+
|
|
5
|
+
> **Full Documentation**: For detailed API references and guides, visit [docs.appliteui.com/sdk](https://docs.appliteui.com/sdk).
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
10
|
pnpm add @applite/js-sdk
|
|
11
|
+
# or
|
|
12
|
+
npm install @applite/js-sdk
|
|
13
|
+
# or
|
|
14
|
+
yarn add @applite/js-sdk
|
|
9
15
|
```
|
|
10
16
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
Each method accepts a **single object** that always includes `appId` and `apiKey`, plus fields required by the specific route.
|
|
17
|
+
## Quick Start
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
Initialize the client with your API base URL (optional if using relative paths in a same-origin environment).
|
|
16
20
|
|
|
17
21
|
```ts
|
|
18
22
|
import { AppliteUI } from "@applite/js-sdk";
|
|
19
23
|
|
|
20
24
|
const client = new AppliteUI({
|
|
21
|
-
baseUrl: "https://api.
|
|
25
|
+
baseUrl: "https://api.applite.com", // Optional: Defaults to relative path
|
|
22
26
|
});
|
|
23
27
|
```
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
## Core Concepts
|
|
30
|
+
|
|
31
|
+
### Authentication & Context
|
|
32
|
+
|
|
33
|
+
Every request requires two key parameters to identify the context and authorize the user:
|
|
34
|
+
|
|
35
|
+
- **`appId`**: The unique identifier of your application (e.g., used in URL paths).
|
|
36
|
+
- **`apiKey`**: The secret key used to authenticate requests.
|
|
37
|
+
|
|
38
|
+
### Method Signature
|
|
39
|
+
|
|
40
|
+
All SDK methods accept a **single object** containing all parameters. This ensures better type safety and extensibility.
|
|
26
41
|
|
|
27
42
|
```ts
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
// Example signature
|
|
44
|
+
await client.module.resource.action({
|
|
45
|
+
appId: "...",
|
|
46
|
+
apiKey: "...",
|
|
47
|
+
...specificParams,
|
|
32
48
|
});
|
|
33
49
|
```
|
|
34
50
|
|
|
35
|
-
|
|
51
|
+
## Architecture
|
|
52
|
+
|
|
53
|
+
The SDK is organized into three main modules:
|
|
54
|
+
|
|
55
|
+
1. **App Module (`client.app`)**: Core application logic (Customers, Stats, Finance).
|
|
56
|
+
2. **Store Module (`client.app.store`)**: E-commerce functionality (Products, Orders, Sellers).
|
|
57
|
+
3. **Multi-Service Module (`client.app.multiService`)**: Service booking and appointments.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## App Management (`client.app`)
|
|
62
|
+
|
|
63
|
+
Manage your application's users and core settings.
|
|
64
|
+
|
|
65
|
+
### Customers
|
|
66
|
+
|
|
67
|
+
Manage end-users of your application.
|
|
68
|
+
|
|
69
|
+
#### Authenticate / Register a Customer
|
|
70
|
+
|
|
71
|
+
Checks if a user exists; if not, creates a new one.
|
|
36
72
|
|
|
37
73
|
```ts
|
|
38
|
-
await client.app.customer.
|
|
74
|
+
const user = await client.app.customer.auth({
|
|
39
75
|
appId: "app_123",
|
|
40
|
-
apiKey: "
|
|
41
|
-
|
|
76
|
+
apiKey: "your_api_key",
|
|
77
|
+
fullname: "John Doe",
|
|
78
|
+
telephone: "+2250700000000",
|
|
79
|
+
email: "john@example.com", // Optional
|
|
80
|
+
plateform: "STORE", // Optional: "STORE", "MULTI_SERVICE", etc.
|
|
42
81
|
});
|
|
43
82
|
```
|
|
44
83
|
|
|
45
|
-
|
|
84
|
+
#### Check Customer Existence
|
|
85
|
+
|
|
86
|
+
Verify if a phone number is already registered.
|
|
46
87
|
|
|
47
88
|
```ts
|
|
48
|
-
await client.app.customer.
|
|
89
|
+
const user = await client.app.customer.check({
|
|
49
90
|
appId: "app_123",
|
|
50
|
-
apiKey: "
|
|
51
|
-
fullname: "Ada Lovelace",
|
|
91
|
+
apiKey: "your_api_key",
|
|
52
92
|
telephone: "+2250700000000",
|
|
53
|
-
email: "ada@example.com", // optional
|
|
54
|
-
plateform: "STORE", // optional
|
|
55
93
|
});
|
|
56
94
|
```
|
|
57
95
|
|
|
58
|
-
|
|
96
|
+
#### List Customers
|
|
97
|
+
|
|
98
|
+
Retrieve a list of customers with optional filtering.
|
|
59
99
|
|
|
60
100
|
```ts
|
|
61
|
-
await client.app.customer.
|
|
101
|
+
const customers = await client.app.customer.list({
|
|
62
102
|
appId: "app_123",
|
|
63
|
-
apiKey: "
|
|
64
|
-
|
|
65
|
-
plateform: "STORE", // optional
|
|
103
|
+
apiKey: "your_api_key",
|
|
104
|
+
plateformType: ["STORE"], // Optional filter
|
|
66
105
|
});
|
|
67
106
|
```
|
|
68
107
|
|
|
69
|
-
|
|
108
|
+
#### Get & Update Customer
|
|
109
|
+
|
|
110
|
+
Retrieve details or update profile information.
|
|
70
111
|
|
|
71
112
|
```ts
|
|
72
|
-
|
|
113
|
+
// Get details
|
|
114
|
+
const detail = await client.app.customer.get({
|
|
115
|
+
appId: "app_123",
|
|
116
|
+
apiKey: "your_api_key",
|
|
117
|
+
id: "customer_id",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Update profile
|
|
121
|
+
await client.app.customer.update({
|
|
73
122
|
appId: "app_123",
|
|
74
|
-
apiKey: "
|
|
75
|
-
id: "
|
|
123
|
+
apiKey: "your_api_key",
|
|
124
|
+
id: "customer_id",
|
|
125
|
+
fullname: "Jane Doe",
|
|
126
|
+
email: "jane@example.com",
|
|
76
127
|
});
|
|
77
128
|
```
|
|
78
129
|
|
|
79
|
-
###
|
|
130
|
+
### Other App Resources
|
|
131
|
+
|
|
132
|
+
- **Stats**: `client.app.stats.create(...)`
|
|
133
|
+
- **Finance**: `client.app.finance.balance(...)`
|
|
134
|
+
- **Info**: `client.app.info.list(...)`
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## E-Commerce (`client.app.store`)
|
|
139
|
+
|
|
140
|
+
Full-featured e-commerce management.
|
|
141
|
+
|
|
142
|
+
### Products
|
|
143
|
+
|
|
144
|
+
Create and manage products.
|
|
80
145
|
|
|
81
146
|
```ts
|
|
82
|
-
|
|
147
|
+
// Create a product
|
|
148
|
+
await client.app.store.product.create({
|
|
149
|
+
appId: "app_123",
|
|
150
|
+
apiKey: "your_api_key",
|
|
151
|
+
name: "Premium T-Shirt",
|
|
152
|
+
price: 2500,
|
|
153
|
+
sellerId: "seller_123",
|
|
154
|
+
categoryId: "category_123",
|
|
155
|
+
variants: [], // Array of product variants
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// List products
|
|
159
|
+
await client.app.store.product.list({
|
|
83
160
|
appId: "app_123",
|
|
84
|
-
apiKey: "
|
|
85
|
-
id: "customer_456",
|
|
86
|
-
fullname: "New Name", // optional
|
|
87
|
-
email: "new-email@example.com", // optional
|
|
88
|
-
photoUrl: "https://cdn.example.com/avatar.png", // optional
|
|
89
|
-
gender: "F", // optional, "M" | "F"
|
|
90
|
-
dob: "1990-01-01", // optional
|
|
91
|
-
country: "CI", // optional
|
|
161
|
+
apiKey: "your_api_key",
|
|
92
162
|
});
|
|
93
163
|
```
|
|
94
164
|
|
|
95
|
-
###
|
|
165
|
+
### Orders
|
|
96
166
|
|
|
97
|
-
|
|
167
|
+
Handle customer orders.
|
|
98
168
|
|
|
99
169
|
```ts
|
|
100
|
-
//
|
|
101
|
-
await client.app.
|
|
102
|
-
|
|
103
|
-
// Create a product inside the store module
|
|
104
|
-
await client.app.store.product.create({
|
|
170
|
+
// Create an order
|
|
171
|
+
await client.app.store.order.create({
|
|
105
172
|
appId: "app_123",
|
|
106
|
-
apiKey: "
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
173
|
+
apiKey: "your_api_key",
|
|
174
|
+
items: [
|
|
175
|
+
{ productId: "prod_1", quantity: 2 }
|
|
176
|
+
],
|
|
177
|
+
customerId: "cust_1",
|
|
178
|
+
totalAmount: 5000,
|
|
179
|
+
shippingAddress: { ... }
|
|
111
180
|
});
|
|
112
181
|
|
|
113
|
-
//
|
|
114
|
-
await client.app.
|
|
182
|
+
// List orders
|
|
183
|
+
await client.app.store.order.list({
|
|
115
184
|
appId: "app_123",
|
|
116
|
-
apiKey: "
|
|
117
|
-
type: "ORDERS",
|
|
118
|
-
year: 2024,
|
|
119
|
-
month: "JANUARY",
|
|
120
|
-
amount: 10,
|
|
185
|
+
apiKey: "your_api_key",
|
|
121
186
|
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Available Store Modules
|
|
190
|
+
|
|
191
|
+
- `badge`
|
|
192
|
+
- `category`
|
|
193
|
+
- `collection`
|
|
194
|
+
- `discount`
|
|
195
|
+
- `option`
|
|
196
|
+
- `seller`
|
|
197
|
+
- `shipping`
|
|
198
|
+
- `tag`
|
|
199
|
+
- `tax`
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Multi-Service (`client.app.multiService`)
|
|
122
204
|
|
|
123
|
-
|
|
205
|
+
Booking system for service-based applications.
|
|
124
206
|
|
|
125
|
-
|
|
126
|
-
|
|
207
|
+
### Appointments
|
|
208
|
+
|
|
209
|
+
Manage bookings between customers and agents/companies.
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
// Create an appointment
|
|
213
|
+
await client.app.multiService.appointment.create({
|
|
127
214
|
appId: "app_123",
|
|
128
|
-
apiKey: "
|
|
129
|
-
|
|
130
|
-
|
|
215
|
+
apiKey: "your_api_key",
|
|
216
|
+
serviceId: "srv_123",
|
|
217
|
+
customerId: "cust_123",
|
|
218
|
+
date: "2024-12-25T10:00:00Z",
|
|
219
|
+
status: "PENDING",
|
|
131
220
|
});
|
|
221
|
+
|
|
222
|
+
// Update status
|
|
223
|
+
await client.app.multiService.appointment.updateStatus({
|
|
224
|
+
appId: "app_123",
|
|
225
|
+
apiKey: "your_api_key",
|
|
226
|
+
id: "apt_123",
|
|
227
|
+
status: "CONFIRMED",
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Available Service Modules
|
|
232
|
+
|
|
233
|
+
- `company`: Manage service providers.
|
|
234
|
+
- `service`: Define services offered.
|
|
235
|
+
- `agent`: Manage individual staff members.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## TypeScript Support
|
|
240
|
+
|
|
241
|
+
The SDK is written in TypeScript and ships with full type definitions. You can import types directly to type your application logic.
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
import {
|
|
245
|
+
AppCustomer,
|
|
246
|
+
CreateProductParams,
|
|
247
|
+
AppCustomerAuthParams,
|
|
248
|
+
} from "@applite/js-sdk";
|
|
132
249
|
```
|
|
133
250
|
|
|
134
251
|
## Scripts
|
|
135
252
|
|
|
136
|
-
- `pnpm build
|
|
137
|
-
- `pnpm test
|
|
253
|
+
- `pnpm build`: Build the SDK (ESM/CJS).
|
|
254
|
+
- `pnpm test`: Run type checks.
|