@akis05/akis 0.1.4 → 0.1.5

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 CHANGED
@@ -1,30 +1,30 @@
1
1
  # AKIS - Appwrite CLI Tool
2
2
 
3
- **AKIS** est un outil CLI qui synchronise automatiquement vos collections Appwrite avec vos types TypeScript. Définissez vos types une seule fois, et AKIS crée/met à jour vos collections et génère le schéma correspondant.
3
+ **AKIS** is a CLI tool that automatically syncs your Appwrite collections with your TypeScript types. Define your types once, and AKIS creates/updates your collections and generates the corresponding schema.
4
4
 
5
- ## Fonctionnalités
5
+ ## Features
6
6
 
7
- - **Génération automatique** : Crée les collections Appwrite depuis vos types TypeScript
8
- - **Synchronisation** : Détecte les différences entre vos types et Appwrite
9
- - **Schema auto-généré** : Le fichier `schema.ts` est généré automatiquement lors de la migration
10
- - **Indexes automatiques** : Crée les indexes pour les champs courants (storeId, email, etc.)
11
- - **Mode dry-run** : Prévisualisez les changements avant de les appliquer
7
+ - **Auto-generation**: Creates Appwrite collections from your TypeScript types
8
+ - **Synchronization**: Detects differences between your types and Appwrite
9
+ - **Auto-generated schema**: The `schema.ts` file is automatically generated during migration
10
+ - **Automatic indexes**: Creates indexes for common fields (storeId, email, etc.)
11
+ - **Dry-run mode**: Preview changes before applying them
12
12
 
13
13
  ---
14
14
 
15
15
  ## Installation
16
16
 
17
- ### Avec npm
17
+ ### With npm
18
18
  ```bash
19
19
  npm install @akis05/akis
20
20
  ```
21
21
 
22
- ### Avec pnpm
22
+ ### With pnpm
23
23
  ```bash
24
24
  pnpm add @akis05/akis
25
25
  ```
26
26
 
27
- ### Installation globale (optionnel)
27
+ ### Global installation (optional)
28
28
  ```bash
29
29
  npm install -g @akis05/akis
30
30
  ```
@@ -33,97 +33,97 @@ npm install -g @akis05/akis
33
33
 
34
34
  ## Configuration
35
35
 
36
- ### 1. Variables d'environnement
36
+ ### 1. Environment Variables
37
37
 
38
- Créez un fichier `.env` à la racine de votre projet:
38
+ Create a `.env` file at the root of your project:
39
39
 
40
40
  ```env
41
- # Endpoint Appwrite (Cloud ou Self-hosted)
41
+ # Appwrite Endpoint (Cloud or Self-hosted)
42
42
  APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
43
43
 
44
- # ID de votre projet Appwrite
45
- APPWRITE_PROJECT_ID=votre_project_id
44
+ # Your Appwrite project ID
45
+ APPWRITE_PROJECT_ID=your_project_id
46
46
 
47
- # ID de votre base de données
48
- APPWRITE_DATABASE_ID=votre_database_id
47
+ # Your database ID
48
+ APPWRITE_DATABASE_ID=your_database_id
49
49
 
50
- # Clé API avec permissions Database (Create, Read, Update, Delete)
51
- APPWRITE_API_KEY=votre_api_key
50
+ # API Key with Database permissions (Create, Read, Update, Delete)
51
+ APPWRITE_API_KEY=your_api_key
52
52
  ```
53
53
 
54
- ### 2. Obtenir les identifiants Appwrite
54
+ ### 2. Getting Appwrite Credentials
55
55
 
56
- 1. Connectez-vous à [Appwrite Console](https://cloud.appwrite.io)
57
- 2. **Project ID** : Settings → Project ID
58
- 3. **Database ID** : Databases → Cliquez sur votre DB → Settings
59
- 4. **API Key** : Settings → API Keys → Create API Key (cochez Database permissions)
56
+ 1. Log in to [Appwrite Console](https://cloud.appwrite.io)
57
+ 2. **Project ID**: Settings → Project ID
58
+ 3. **Database ID**: Databases → Click on your DB → Settings
59
+ 4. **API Key**: Settings → API Keys → Create API Key (check Database permissions)
60
60
 
61
61
  ---
62
62
 
63
- ## Démarrage rapide
63
+ ## Quick Start
64
64
 
65
- ### Étape 1 : Initialiser le projet
65
+ ### Step 1: Initialize the project
66
66
 
67
67
  ```bash
68
68
  npx akis init
69
69
  ```
70
70
 
71
- Cette commande crée la structure suivante:
71
+ This command creates the following structure:
72
72
 
73
73
  ```
74
74
  core/
75
75
  └── appwrite-model/
76
- ├── types.ts # Vos définitions TypeScript
77
- ├── schema.ts # Schéma généré (ne pas modifier manuellement)
78
- ├── client.ts # Client Appwrite configuré
79
- └── setup-collections.ts # Fonctions utilitaires
76
+ ├── types.ts # Your TypeScript definitions
77
+ ├── schema.ts # Generated schema (do not edit manually)
78
+ ├── client.ts # Configured Appwrite client
79
+ └── setup-collections.ts # Utility functions
80
80
  ```
81
81
 
82
- ### Étape 2 : Définir vos types
82
+ ### Step 2: Define your types
83
83
 
84
- Éditez `core/appwrite-model/types.ts`:
84
+ Edit `core/appwrite-model/types.ts`:
85
85
 
86
86
  ```typescript
87
87
  export type Client = {
88
- _id: string; // ID Appwrite (obligatoire)
89
- _creationTime: number; // Timestamp création (obligatoire)
90
- nom: string; // Champ requis
91
- email?: string; // Champ optionnel (?)
92
- telephone?: string;
93
- statut: "actif" | "inactif"; // Enum
94
- tags?: string[]; // Array de strings
88
+ _id: string; // Appwrite ID (required)
89
+ _creationTime: number; // Creation timestamp (required)
90
+ name: string; // Required field
91
+ email?: string; // Optional field (?)
92
+ phone?: string;
93
+ status: "active" | "inactive"; // Enum
94
+ tags?: string[]; // String array
95
95
  storeId: string;
96
96
  createdAt: number;
97
97
  deletedAt?: number;
98
98
  };
99
99
 
100
- export type Produit = {
100
+ export type Product = {
101
101
  _id: string;
102
102
  _creationTime: number;
103
- nom: string;
104
- prix: number;
105
- quantite: number;
106
- categorie: "electronique" | "vetement" | "alimentaire";
103
+ name: string;
104
+ price: number;
105
+ quantity: number;
106
+ category: "electronics" | "clothing" | "food";
107
107
  storeId: string;
108
108
  createdAt: number;
109
109
  };
110
110
  ```
111
111
 
112
- ### Étape 3 : Migrer vers Appwrite
112
+ ### Step 3: Migrate to Appwrite
113
113
 
114
114
  ```bash
115
- # Prévisualiser les changements (recommandé)
115
+ # Preview changes (recommended)
116
116
  npx akis migrate --dry-run
117
117
 
118
- # Créer les collections
118
+ # Create collections
119
119
  npx akis migrate
120
120
  ```
121
121
 
122
- **Résultat** :
123
- - Collections créées dans Appwrite
124
- - Fichier `schema.ts` généré automatiquement
122
+ **Result**:
123
+ - Collections created in Appwrite
124
+ - `schema.ts` file automatically generated
125
125
 
126
- ### Étape 4 : Vérifier le statut
126
+ ### Step 4: Check status
127
127
 
128
128
  ```bash
129
129
  npx akis status
@@ -131,212 +131,212 @@ npx akis status
131
131
 
132
132
  ---
133
133
 
134
- ## Commandes
134
+ ## Commands
135
135
 
136
136
  ### `akis init`
137
137
 
138
- Initialise la structure du projet.
138
+ Initializes the project structure.
139
139
 
140
140
  ```bash
141
- npx akis init # Créer les fichiers
142
- npx akis init --force # Écraser les fichiers existants
141
+ npx akis init # Create files
142
+ npx akis init --force # Overwrite existing files
143
143
  ```
144
144
 
145
145
  **Options:**
146
146
  | Option | Description |
147
147
  |--------|-------------|
148
- | `-f, --force` | Écrase les fichiers existants |
148
+ | `-f, --force` | Overwrites existing files |
149
149
 
150
150
  ---
151
151
 
152
152
  ### `akis migrate`
153
153
 
154
- Crée les collections manquantes dans Appwrite et génère `schema.ts`.
154
+ Creates missing collections in Appwrite and generates `schema.ts`.
155
155
 
156
156
  ```bash
157
- npx akis migrate # Migrer toutes les collections
158
- npx akis migrate --name clients # Migrer une collection spécifique
159
- npx akis migrate --dry-run # Prévisualiser sans exécuter
157
+ npx akis migrate # Migrate all collections
158
+ npx akis migrate --name clients # Migrate a specific collection
159
+ npx akis migrate --dry-run # Preview without executing
160
160
  ```
161
161
 
162
162
  **Options:**
163
163
  | Option | Description |
164
164
  |--------|-------------|
165
- | `-n, --name <name>` | Nom de la collection à migrer |
166
- | `-d, --dry-run` | Affiche les actions sans les exécuter |
165
+ | `-n, --name <name>` | Name of the collection to migrate |
166
+ | `-d, --dry-run` | Shows actions without executing them |
167
167
 
168
- **Exemple de sortie:**
168
+ **Example output:**
169
169
  ```
170
- 🚀 AKIS Migrate - Création des collections manquantes
170
+ 🚀 AKIS Migrate - Creating missing collections
171
171
 
172
- 📖 Lecture de types.ts...
173
- 2 collection(s) à traiter
172
+ 📖 Reading types.ts...
173
+ 2 collection(s) to process
174
174
 
175
- 📡 Connexion à Appwrite...
175
+ 📡 Connecting to Appwrite...
176
176
 
177
- 📦 Création de clients...
178
- nom
177
+ 📦 Creating clients...
178
+ name
179
179
  ✓ email
180
- telephone
181
- statut
180
+ phone
181
+ status
182
182
  ✓ storeId
183
183
  🔑 idx_storeId
184
184
  🔑 idx_email
185
- ✅ clients créée
185
+ ✅ clients created
186
186
 
187
- 📝 schema.ts généré avec 2 collections
187
+ 📝 schema.ts generated with 2 collections
188
188
 
189
- ✨ Migration terminée: 1 créées, 1 ignorées
189
+ ✨ Migration complete: 1 created, 1 skipped
190
190
  ```
191
191
 
192
192
  ---
193
193
 
194
194
  ### `akis update`
195
195
 
196
- Ajoute les nouveaux attributs aux collections existantes.
196
+ Adds new attributes to existing collections.
197
197
 
198
198
  ```bash
199
- npx akis update # Mettre à jour toutes les collections
200
- npx akis update --name clients # Mettre à jour une collection spécifique
201
- npx akis update --dry-run # Prévisualiser sans exécuter
199
+ npx akis update # Update all collections
200
+ npx akis update --name clients # Update a specific collection
201
+ npx akis update --dry-run # Preview without executing
202
202
  ```
203
203
 
204
204
  **Options:**
205
205
  | Option | Description |
206
206
  |--------|-------------|
207
- | `-n, --name <name>` | Nom de la collection à mettre à jour |
208
- | `-d, --dry-run` | Affiche les actions sans les exécuter |
207
+ | `-n, --name <name>` | Name of the collection to update |
208
+ | `-d, --dry-run` | Shows actions without executing them |
209
209
 
210
- **Cas d'utilisation:**
211
- - Vous avez ajouté un nouveau champ dans `types.ts`
212
- - Vous voulez synchroniser sans recréer la collection
210
+ **Use cases:**
211
+ - You added a new field in `types.ts`
212
+ - You want to sync without recreating the collection
213
213
 
214
214
  ---
215
215
 
216
216
  ### `akis status`
217
217
 
218
- Compare les types locaux avec les collections Appwrite.
218
+ Compares local types with Appwrite collections.
219
219
 
220
220
  ```bash
221
- npx akis status # Voir toutes les collections
222
- npx akis status --name clients # Voir une collection spécifique
221
+ npx akis status # View all collections
222
+ npx akis status --name clients # View a specific collection
223
223
  ```
224
224
 
225
225
  **Options:**
226
226
  | Option | Description |
227
227
  |--------|-------------|
228
- | `-n, --name <name>` | Nom de la collection à vérifier |
228
+ | `-n, --name <name>` | Name of the collection to check |
229
229
 
230
- **Exemple de sortie:**
230
+ **Example output:**
231
231
  ```
232
- 📊 AKIS Status - État des collections
232
+ 📊 AKIS Status - Collection Status
233
233
 
234
234
  ┌─────────────────────────────┬────────┬────────────┬─────────────┐
235
- │ Collection │ Status │ Attributs Manquants
235
+ │ Collection │ Status │ Attributes Missing
236
236
  ├─────────────────────────────┼────────┼────────────┼─────────────┤
237
237
  │ clients │ ✅ │ 9/9 │ 0 │
238
- produits │ ⚠️ │ 5/7 │ 2 │
239
- commandes │ ❌ │ - │ - │
238
+ products │ ⚠️ │ 5/7 │ 2 │
239
+ orders │ ❌ │ - │ - │
240
240
  └─────────────────────────────┴────────┴────────────┴─────────────┘
241
241
 
242
- 📈 Résumé:
243
- ✅ 1 synchronisées
244
- ⚠️ 1 à mettre à jour (akis update)
245
- ❌ 1 manquantes (akis migrate)
242
+ 📈 Summary:
243
+ ✅ 1 synchronized
244
+ ⚠️ 1 needs update (akis update)
245
+ ❌ 1 missing (akis migrate)
246
246
  ```
247
247
 
248
248
  ---
249
249
 
250
250
  ### `akis delete`
251
251
 
252
- Supprime des collections dans Appwrite.
252
+ Deletes collections in Appwrite.
253
253
 
254
254
  ```bash
255
- npx akis delete --name clients # Supprimer une collection (avec confirmation)
256
- npx akis delete --force # Supprimer TOUTES les collections sans confirmation
257
- npx akis delete --name clients -f # Supprimer sans confirmation
255
+ npx akis delete --name clients # Delete a collection (with confirmation)
256
+ npx akis delete --force # Delete ALL collections without confirmation
257
+ npx akis delete --name clients -f # Delete without confirmation
258
258
  ```
259
259
 
260
260
  **Options:**
261
261
  | Option | Description |
262
262
  |--------|-------------|
263
- | `-n, --name <name>` | Nom de la collection à supprimer |
264
- | `-f, --force` | Supprimer sans demander confirmation |
263
+ | `-n, --name <name>` | Name of the collection to delete |
264
+ | `-f, --force` | Delete without asking for confirmation |
265
265
 
266
- ⚠️ **Attention** : Cette action est irréversible !
266
+ ⚠️ **Warning**: This action is irreversible!
267
267
 
268
268
  ---
269
269
 
270
- ## Types TypeScript supportés
270
+ ## Supported TypeScript Types
271
271
 
272
- AKIS reconnaît automatiquement les types suivants:
272
+ AKIS automatically recognizes the following types:
273
273
 
274
274
  | TypeScript | Appwrite Attribute |
275
275
  |------------|-------------------|
276
- | `string` | String (size auto-détectée) |
277
- | `number` | Float ou Integer (selon le nom du champ) |
276
+ | `string` | String (auto-detected size) |
277
+ | `number` | Float or Integer (based on field name) |
278
278
  | `boolean` | Boolean |
279
279
  | `string[]` | String Array |
280
280
  | `number[]` | Integer Array |
281
281
  | `"a" \| "b" \| "c"` | Enum |
282
282
 
283
- ### Conventions de nommage
283
+ ### Naming Conventions
284
284
 
285
- AKIS infère automatiquement certaines propriétés:
285
+ AKIS automatically infers certain properties:
286
286
 
287
- | Nom du champ | Type inféré | Taille |
288
- |--------------|-------------|--------|
287
+ | Field Name | Inferred Type | Size |
288
+ |------------|---------------|------|
289
289
  | `*Id`, `storeId` | string | 36 |
290
290
  | `email` | string | 255 |
291
- | `telephone`, `tel` | string | 50 |
291
+ | `phone`, `tel` | string | 50 |
292
292
  | `note`, `description` | string | 2000 |
293
- | `adresse` | string | 500 |
294
- | `quantite*`, `*Minutes` | integer | - |
293
+ | `address` | string | 500 |
294
+ | `quantity*`, `*Minutes` | integer | - |
295
295
  | `createdAt`, `deletedAt` | integer | - |
296
296
 
297
- ### Champs système (ignorés)
297
+ ### System Fields (ignored)
298
298
 
299
- Ces champs sont automatiquement ignorés car gérés par Appwrite:
300
- - `_id` - ID du document
301
- - `_creationTime` - Timestamp de création
299
+ These fields are automatically ignored as they are managed by Appwrite:
300
+ - `_id` - Document ID
301
+ - `_creationTime` - Creation timestamp
302
302
 
303
303
  ---
304
304
 
305
- ## Workflow recommandé
305
+ ## Recommended Workflow
306
306
 
307
307
  ```
308
308
  ┌─────────────────────────────────────────────────────────────┐
309
- │ 1. Définir les types dans types.ts
309
+ │ 1. Define types in types.ts
310
310
  │ export type Client = { ... } │
311
311
  └─────────────────────────────────────────────────────────────┘
312
312
 
313
313
  ┌─────────────────────────────────────────────────────────────┐
314
- │ 2. Prévisualiser les changements
314
+ │ 2. Preview changes
315
315
  │ npx akis migrate --dry-run │
316
316
  └─────────────────────────────────────────────────────────────┘
317
317
 
318
318
  ┌─────────────────────────────────────────────────────────────┐
319
- │ 3. Migrer vers Appwrite
319
+ │ 3. Migrate to Appwrite
320
320
  │ npx akis migrate │
321
- │ → Collections créées + schema.ts généré
321
+ │ → Collections created + schema.ts generated
322
322
  └─────────────────────────────────────────────────────────────┘
323
323
 
324
324
  ┌─────────────────────────────────────────────────────────────┐
325
- │ 4. Vérifier la synchronisation
325
+ │ 4. Verify synchronization
326
326
  │ npx akis status │
327
327
  └─────────────────────────────────────────────────────────────┘
328
328
 
329
329
  ┌─────────────────────────────────────────────────────────────┐
330
- │ 5. Ajouter de nouveaux champs ? → Retour à l'étape 1
330
+ │ 5. Adding new fields? → Back to step 1
331
331
  │ npx akis update │
332
332
  └─────────────────────────────────────────────────────────────┘
333
333
  ```
334
334
 
335
335
  ---
336
336
 
337
- ## Utilisation avec pnpm
337
+ ## Using with pnpm
338
338
 
339
- Si vous utilisez pnpm, ajoutez un script dans votre `package.json`:
339
+ If you use pnpm, add a script to your `package.json`:
340
340
 
341
341
  ```json
342
342
  {
@@ -346,7 +346,7 @@ Si vous utilisez pnpm, ajoutez un script dans votre `package.json`:
346
346
  }
347
347
  ```
348
348
 
349
- Puis utilisez:
349
+ Then use:
350
350
  ```bash
351
351
  pnpm akis status
352
352
  pnpm akis migrate
@@ -355,85 +355,85 @@ pnpm akis update
355
355
 
356
356
  ---
357
357
 
358
- ## Exemples
358
+ ## Examples
359
359
 
360
- ### Exemple complet de types.ts
360
+ ### Complete types.ts Example
361
361
 
362
362
  ```typescript
363
363
  /* ═══════════════════════════════════════════════════════════
364
- Types pour mon application
364
+ Types for my application
365
365
  ═══════════════════════════════════════════════════════════ */
366
366
 
367
367
  export type Client = {
368
368
  _id: string;
369
369
  _creationTime: number;
370
- nom: string;
370
+ name: string;
371
371
  email?: string;
372
- telephone?: string;
373
- adresse?: string;
374
- statut: "actif" | "inactif" | "prospect";
375
- remise?: number;
372
+ phone?: string;
373
+ address?: string;
374
+ status: "active" | "inactive" | "prospect";
375
+ discount?: number;
376
376
  tags?: string[];
377
377
  storeId: string;
378
378
  createdAt: number;
379
379
  deletedAt?: number;
380
380
  };
381
381
 
382
- export type Produit = {
382
+ export type Product = {
383
383
  _id: string;
384
384
  _creationTime: number;
385
- nom: string;
385
+ name: string;
386
386
  description?: string;
387
- prix: number;
388
- prixAchat?: number;
389
- quantite: number;
390
- stockMin?: number;
391
- categorie: "electronique" | "vetement" | "alimentaire" | "autre";
387
+ price: number;
388
+ costPrice?: number;
389
+ quantity: number;
390
+ minStock?: number;
391
+ category: "electronics" | "clothing" | "food" | "other";
392
392
  image?: string;
393
393
  storeId: string;
394
394
  createdAt: number;
395
395
  };
396
396
 
397
- export type Vente = {
397
+ export type Sale = {
398
398
  _id: string;
399
399
  _creationTime: number;
400
- numero: string;
400
+ number: string;
401
401
  clientId?: string;
402
- lignes: string; // JSON stringifié
402
+ lines: string; // Stringified JSON
403
403
  total: number;
404
- statut: "brouillon" | "validee" | "payee" | "annulee";
404
+ status: "draft" | "validated" | "paid" | "cancelled";
405
405
  storeId: string;
406
406
  createdAt: number;
407
407
  };
408
408
 
409
- // Utilitaires
409
+ // Utilities
410
410
  export type NewDoc<T> = Omit<T, "_id" | "_creationTime">;
411
411
  export type UpdateDoc<T> = Partial<Omit<T, "_id" | "_creationTime">>;
412
412
  ```
413
413
 
414
414
  ---
415
415
 
416
- ## Dépannage
416
+ ## Troubleshooting
417
417
 
418
- ### Erreur: APPWRITE_API_KEY non configurée
418
+ ### Error: APPWRITE_API_KEY not configured
419
419
 
420
- Vérifiez que votre fichier `.env` existe et contient la clé API:
420
+ Check that your `.env` file exists and contains the API key:
421
421
  ```bash
422
422
  cat .env | grep APPWRITE_API_KEY
423
423
  ```
424
424
 
425
- ### Erreur: Collection non trouvée dans types.ts
425
+ ### Error: Collection not found in types.ts
426
426
 
427
- Assurez-vous que le nom du type correspond à un nom reconnu par AKIS:
427
+ Make sure the type name corresponds to a name recognized by AKIS:
428
428
  - `Client` → `clients`
429
- - `Produit` → `produits`
430
- - `Vente` → `ventes`
429
+ - `Product` → `products`
430
+ - `Sale` → `sales`
431
431
 
432
- ### Les attributs ne sont pas créés
432
+ ### Attributes are not created
433
433
 
434
- Appwrite a une limite de taille pour les attributs. Vérifiez:
435
- - Taille des strings (max 16000 caractères)
436
- - Nombre d'attributs par collection (max ~100)
434
+ Appwrite has size limits for attributes. Check:
435
+ - String size (max 16000 characters)
436
+ - Number of attributes per collection (max ~100)
437
437
 
438
438
  ---
439
439
 
@@ -443,7 +443,7 @@ MIT
443
443
 
444
444
  ---
445
445
 
446
- ## Liens
446
+ ## Links
447
447
 
448
448
  - [Appwrite Documentation](https://appwrite.io/docs)
449
449
  - [npm Package](https://www.npmjs.com/package/@akis05/akis)