@aifabrix/builder 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +6 -2
  2. package/bin/aifabrix.js +9 -3
  3. package/jest.config.integration.js +30 -0
  4. package/lib/app-config.js +157 -0
  5. package/lib/app-deploy.js +233 -82
  6. package/lib/app-dockerfile.js +112 -0
  7. package/lib/app-prompts.js +244 -0
  8. package/lib/app-push.js +172 -0
  9. package/lib/app-run.js +334 -133
  10. package/lib/app.js +208 -274
  11. package/lib/audit-logger.js +2 -0
  12. package/lib/build.js +209 -98
  13. package/lib/cli.js +76 -86
  14. package/lib/commands/app.js +414 -0
  15. package/lib/commands/login.js +304 -0
  16. package/lib/config.js +78 -0
  17. package/lib/deployer.js +225 -81
  18. package/lib/env-reader.js +45 -30
  19. package/lib/generator.js +308 -191
  20. package/lib/github-generator.js +67 -7
  21. package/lib/infra.js +156 -61
  22. package/lib/push.js +105 -10
  23. package/lib/schema/application-schema.json +30 -2
  24. package/lib/schema/infrastructure-schema.json +589 -0
  25. package/lib/secrets.js +229 -24
  26. package/lib/template-validator.js +205 -0
  27. package/lib/templates.js +305 -170
  28. package/lib/utils/api.js +329 -0
  29. package/lib/utils/cli-utils.js +97 -0
  30. package/lib/utils/dockerfile-utils.js +131 -0
  31. package/lib/utils/environment-checker.js +125 -0
  32. package/lib/utils/error-formatter.js +61 -0
  33. package/lib/utils/health-check.js +187 -0
  34. package/lib/utils/logger.js +53 -0
  35. package/lib/utils/template-helpers.js +223 -0
  36. package/lib/utils/variable-transformer.js +271 -0
  37. package/lib/validator.js +27 -112
  38. package/package.json +13 -10
  39. package/templates/README.md +75 -3
  40. package/templates/applications/keycloak/Dockerfile +36 -0
  41. package/templates/applications/keycloak/env.template +32 -0
  42. package/templates/applications/keycloak/rbac.yaml +37 -0
  43. package/templates/applications/keycloak/variables.yaml +56 -0
  44. package/templates/applications/miso-controller/Dockerfile +125 -0
  45. package/templates/applications/miso-controller/env.template +129 -0
  46. package/templates/applications/miso-controller/rbac.yaml +168 -0
  47. package/templates/applications/miso-controller/variables.yaml +56 -0
  48. package/templates/github/release.yaml.hbs +5 -26
  49. package/templates/github/steps/npm.hbs +24 -0
  50. package/templates/infra/compose.yaml +6 -6
  51. package/templates/python/docker-compose.hbs +19 -12
  52. package/templates/python/main.py +80 -0
  53. package/templates/python/requirements.txt +4 -0
  54. package/templates/typescript/Dockerfile.hbs +2 -2
  55. package/templates/typescript/docker-compose.hbs +19 -12
  56. package/templates/typescript/index.ts +116 -0
  57. package/templates/typescript/package.json +26 -0
  58. package/templates/typescript/tsconfig.json +24 -0
@@ -0,0 +1,589 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://docs.aifabrix.ai/schemas/Configuration-Schema-Infra.json",
4
+ "title": "AI Fabrix Infrastructure Configuration Schema",
5
+ "description": "Infrastructure-level configuration schema for AI Fabrix deployment",
6
+ "metadata": {
7
+ "key": "infrastructure-schema",
8
+ "name": "Infrastructure Configuration Schema",
9
+ "description": "JSON schema for validating AI Fabrix infrastructure configuration files",
10
+ "version": "1.0.0",
11
+ "type": "schema",
12
+ "category": "infrastructure",
13
+ "author": "AI Fabrix Team",
14
+ "createdAt": "2024-01-01T00:00:00Z",
15
+ "updatedAt": "2024-01-01T00:00:00Z",
16
+ "compatibility": {
17
+ "minVersion": "1.0.0",
18
+ "maxVersion": "2.0.0",
19
+ "deprecated": false
20
+ },
21
+ "tags": ["schema", "infrastructure", "validation", "configuration"],
22
+ "dependencies": [],
23
+ "changelog": [
24
+ {
25
+ "version": "1.0.0",
26
+ "date": "2024-01-01T00:00:00Z",
27
+ "changes": [
28
+ "Initial infrastructure configuration schema",
29
+ "Added infrastructure resource validation",
30
+ "Added network configuration validation",
31
+ "Added deployment configuration validation"
32
+ ],
33
+ "breaking": false
34
+ }
35
+ ]
36
+ },
37
+ "type": "object",
38
+ "required": [
39
+ "key",
40
+ "environment",
41
+ "preset",
42
+ "serviceName",
43
+ "location",
44
+ "deploymentType",
45
+ "deployment",
46
+ "subscriptionId",
47
+ "tenantId"
48
+ ],
49
+ "properties": {
50
+ "key": {
51
+ "type": "string",
52
+ "description": "Unique infrastructure identifier (cannot be changed after creation)",
53
+ "pattern": "^[a-z0-9-]+$",
54
+ "minLength": 3,
55
+ "maxLength": 40
56
+ },
57
+ "environment": {
58
+ "type": "string",
59
+ "description": "Environment",
60
+ "enum": ["miso", "dev", "tst", "pro"]
61
+ },
62
+ "preset": {
63
+ "type": "string",
64
+ "description": "Resource preset - determines service configurations and sizing",
65
+ "enum": ["evaluation", "s", "m", "l", "xl"],
66
+ "default": "s"
67
+ },
68
+ "serviceName": {
69
+ "type": "string",
70
+ "description": "Service name",
71
+ "pattern": "^[a-z0-9-]{3,40}$"
72
+ },
73
+ "location": {
74
+ "type": "string",
75
+ "description": "Azure region"
76
+ },
77
+ "subscriptionId": {
78
+ "type": "string",
79
+ "description": "Azure subscription ID",
80
+ "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
81
+ },
82
+ "tenantId": {
83
+ "type": "string",
84
+ "description": "Azure tenant ID",
85
+ "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
86
+ },
87
+ "networkAddressSpace": {
88
+ "type": "string",
89
+ "description": "Network address space",
90
+ "pattern": "^(\\d{1,3}\\.){3}\\d{1,3}(\\/\\d{1,2})?$"
91
+ },
92
+ "customDomain": {
93
+ "type": "object",
94
+ "description": "Custom domain configuration",
95
+ "properties": {
96
+ "enabled": {
97
+ "type": "boolean"
98
+ },
99
+ "name": {
100
+ "type": "string",
101
+ "description": "Domain name"
102
+ }
103
+ },
104
+ "required": ["enabled"]
105
+ },
106
+ "frontDoor": {
107
+ "type": "object",
108
+ "description": "Front Door configuration",
109
+ "properties": {
110
+ "tier": {
111
+ "type": "string",
112
+ "enum": ["Standard", "Premium"]
113
+ }
114
+ },
115
+ "additionalProperties": false
116
+ },
117
+ "networking": {
118
+ "type": "object",
119
+ "description": "Networking configuration",
120
+ "properties": {
121
+ "enablePrivateNetworking": {
122
+ "type": "boolean"
123
+ },
124
+ "enableAzureDns": {
125
+ "type": "boolean"
126
+ }
127
+ }
128
+ },
129
+ "deployment": {
130
+ "type": "object",
131
+ "description": "Deployment configuration",
132
+ "required": ["mode"],
133
+ "properties": {
134
+ "skipValidation": {
135
+ "type": "boolean"
136
+ },
137
+ "dryRun": {
138
+ "type": "boolean"
139
+ },
140
+ "mode": {
141
+ "type": "string",
142
+ "enum": ["marketplace", "infrastructure"]
143
+ }
144
+ }
145
+ },
146
+ "smtp": {
147
+ "type": "object",
148
+ "description": "SMTP configuration",
149
+ "properties": {
150
+ "enabled": {
151
+ "type": "boolean"
152
+ },
153
+ "host": {
154
+ "type": "string"
155
+ },
156
+ "port": {
157
+ "type": "integer",
158
+ "minimum": 1,
159
+ "maximum": 65535
160
+ },
161
+ "user": {
162
+ "type": "string"
163
+ },
164
+ "senderEmail": {
165
+ "type": "string",
166
+ "format": "email"
167
+ },
168
+ "useKeyVault": {
169
+ "type": "boolean"
170
+ }
171
+ }
172
+ },
173
+ "containerRegistry": {
174
+ "type": "object",
175
+ "description": "Container Registry configuration",
176
+ "properties": {
177
+ "enabled": {
178
+ "type": "boolean"
179
+ }
180
+ },
181
+ "additionalProperties": false
182
+ },
183
+ "ai": {
184
+ "type": "object",
185
+ "description": "AI services configuration",
186
+ "properties": {
187
+ "enabled": {
188
+ "type": "boolean"
189
+ },
190
+ "sku": {
191
+ "type": "string",
192
+ "enum": ["S0", "S1", "S2", "S3"]
193
+ },
194
+ "kind": {
195
+ "type": "string",
196
+ "enum": ["OpenAI", "CognitiveServices"]
197
+ }
198
+ },
199
+ "additionalProperties": false
200
+ },
201
+ "storage": {
202
+ "type": "object",
203
+ "description": "Storage configuration",
204
+ "properties": {
205
+ "postgres": {
206
+ "type": "string",
207
+ "description": "PostgreSQL storage size (e.g., 128GB, 1TB)",
208
+ "pattern": "^\\d+(GB|TB)$"
209
+ },
210
+ "blob": {
211
+ "type": "string",
212
+ "description": "Blob storage size (e.g., 128GB, 1TB)",
213
+ "pattern": "^\\d+(GB|TB)$"
214
+ },
215
+ "fileShare": {
216
+ "type": "string",
217
+ "description": "File share storage size (e.g., 64GB, 512GB)",
218
+ "pattern": "^\\d+(GB|TB)$"
219
+ }
220
+ },
221
+ "additionalProperties": false
222
+ },
223
+ "serviceMapping": {
224
+ "type": "object",
225
+ "description": "Service mapping configuration based on preset and environment",
226
+ "properties": {
227
+ "appServicePlan": {
228
+ "type": "object",
229
+ "properties": {
230
+ "sku": { "type": "string" },
231
+ "instances": {
232
+ "type": "object",
233
+ "properties": {
234
+ "min": { "type": "integer" },
235
+ "max": { "type": "integer" }
236
+ }
237
+ }
238
+ }
239
+ },
240
+ "redis": {
241
+ "type": "object",
242
+ "properties": {
243
+ "enabled": { "type": "boolean" },
244
+ "sku": { "type": "string" }
245
+ }
246
+ },
247
+ "postgres": {
248
+ "type": "object",
249
+ "properties": {
250
+ "sku": { "type": "string" },
251
+ "storage": { "type": "string" }
252
+ }
253
+ },
254
+ "storage": {
255
+ "type": "object",
256
+ "properties": {
257
+ "size": { "type": "string" }
258
+ }
259
+ },
260
+ "frontDoor": {
261
+ "type": "object",
262
+ "properties": {
263
+ "enabled": { "type": "boolean" },
264
+ "tier": { "type": "string" }
265
+ }
266
+ },
267
+ "monitoring": {
268
+ "type": "object",
269
+ "properties": {
270
+ "applicationInsights": { "type": "boolean" },
271
+ "logAnalytics": { "type": "boolean" },
272
+ "alerts": { "type": "boolean" },
273
+ "dashboards": { "type": "boolean" }
274
+ }
275
+ },
276
+ "networking": {
277
+ "type": "object",
278
+ "properties": {
279
+ "enablePrivateNetworking": { "type": "boolean" },
280
+ "enableAzureDns": { "type": "boolean" },
281
+ "privateEndpoints": { "type": "boolean" }
282
+ }
283
+ }
284
+ }
285
+ },
286
+ "modules": {
287
+ "type": "object",
288
+ "description": "Infrastructure modules configuration",
289
+ "properties": {
290
+ "core": {
291
+ "type": "object",
292
+ "properties": {
293
+ "resourceGroup": {
294
+ "type": "object",
295
+ "properties": {
296
+ "enabled": { "type": "boolean" },
297
+ "required": { "type": "boolean" },
298
+ "description": { "type": "string" }
299
+ }
300
+ },
301
+ "network": {
302
+ "type": "object",
303
+ "properties": {
304
+ "enabled": { "type": "boolean" },
305
+ "required": { "type": "boolean" },
306
+ "description": { "type": "string" }
307
+ }
308
+ },
309
+ "keyVault": {
310
+ "type": "object",
311
+ "properties": {
312
+ "enabled": { "type": "boolean" },
313
+ "required": { "type": "boolean" },
314
+ "description": { "type": "string" }
315
+ }
316
+ },
317
+ "managedIdentity": {
318
+ "type": "object",
319
+ "properties": {
320
+ "enabled": { "type": "boolean" },
321
+ "required": { "type": "boolean" },
322
+ "description": { "type": "string" }
323
+ }
324
+ },
325
+ "appServicePlan": {
326
+ "type": "object",
327
+ "properties": {
328
+ "enabled": { "type": "boolean" },
329
+ "required": { "type": "boolean" },
330
+ "description": { "type": "string" }
331
+ }
332
+ }
333
+ }
334
+ },
335
+ "storage": {
336
+ "type": "object",
337
+ "properties": {
338
+ "storageAccount": {
339
+ "type": "object",
340
+ "properties": {
341
+ "enabled": { "type": "boolean" },
342
+ "required": { "type": "boolean" },
343
+ "description": { "type": "string" },
344
+ "default": { "type": "boolean" }
345
+ }
346
+ },
347
+ "blobStorage": {
348
+ "type": "object",
349
+ "properties": {
350
+ "enabled": { "type": "boolean" },
351
+ "required": { "type": "boolean" },
352
+ "description": { "type": "string" },
353
+ "default": { "type": "boolean" },
354
+ "dependsOn": {
355
+ "type": "array",
356
+ "items": { "type": "string" }
357
+ }
358
+ }
359
+ },
360
+ "fileShare": {
361
+ "type": "object",
362
+ "properties": {
363
+ "enabled": { "type": "boolean" },
364
+ "required": { "type": "boolean" },
365
+ "description": { "type": "string" },
366
+ "default": { "type": "boolean" },
367
+ "dependsOn": {
368
+ "type": "array",
369
+ "items": { "type": "string" }
370
+ }
371
+ }
372
+ }
373
+ }
374
+ },
375
+ "database": {
376
+ "type": "object",
377
+ "properties": {
378
+ "postgresServer": {
379
+ "type": "object",
380
+ "properties": {
381
+ "enabled": { "type": "boolean" },
382
+ "required": { "type": "boolean" },
383
+ "description": { "type": "string" },
384
+ "default": { "type": "boolean" }
385
+ }
386
+ },
387
+ "postgresDatabases": {
388
+ "type": "object",
389
+ "properties": {
390
+ "enabled": { "type": "boolean" },
391
+ "required": { "type": "boolean" },
392
+ "description": { "type": "string" },
393
+ "default": { "type": "boolean" },
394
+ "dependsOn": {
395
+ "type": "array",
396
+ "items": { "type": "string" }
397
+ }
398
+ }
399
+ },
400
+ "postgresAccess": {
401
+ "type": "object",
402
+ "properties": {
403
+ "enabled": { "type": "boolean" },
404
+ "required": { "type": "boolean" },
405
+ "description": { "type": "string" },
406
+ "default": { "type": "boolean" },
407
+ "dependsOn": {
408
+ "type": "array",
409
+ "items": { "type": "string" }
410
+ }
411
+ }
412
+ }
413
+ }
414
+ },
415
+ "cache": {
416
+ "type": "object",
417
+ "properties": {
418
+ "redis": {
419
+ "type": "object",
420
+ "properties": {
421
+ "enabled": { "type": "boolean" },
422
+ "required": { "type": "boolean" },
423
+ "description": { "type": "string" },
424
+ "default": { "type": "boolean" }
425
+ }
426
+ }
427
+ }
428
+ },
429
+ "networking": {
430
+ "type": "object",
431
+ "properties": {
432
+ "frontDoor": {
433
+ "type": "object",
434
+ "properties": {
435
+ "enabled": { "type": "boolean" },
436
+ "required": { "type": "boolean" },
437
+ "description": { "type": "string" },
438
+ "default": { "type": "boolean" }
439
+ }
440
+ },
441
+ "customDomain": {
442
+ "type": "object",
443
+ "properties": {
444
+ "enabled": { "type": "boolean" },
445
+ "required": { "type": "boolean" },
446
+ "description": { "type": "string" },
447
+ "default": { "type": "boolean" },
448
+ "standalone": { "type": "boolean" },
449
+ "directWebAppBinding": { "type": "boolean" }
450
+ }
451
+ },
452
+ "privateEndpoints": {
453
+ "type": "object",
454
+ "properties": {
455
+ "enabled": { "type": "boolean" },
456
+ "required": { "type": "boolean" },
457
+ "description": { "type": "string" },
458
+ "default": { "type": "boolean" }
459
+ }
460
+ },
461
+ "dnsZones": {
462
+ "type": "object",
463
+ "properties": {
464
+ "enabled": { "type": "boolean" },
465
+ "required": { "type": "boolean" },
466
+ "description": { "type": "string" },
467
+ "default": { "type": "boolean" },
468
+ "dependsOn": {
469
+ "type": "array",
470
+ "items": { "type": "string" }
471
+ }
472
+ }
473
+ }
474
+ }
475
+ },
476
+ "monitoring": {
477
+ "type": "object",
478
+ "properties": {
479
+ "applicationInsights": {
480
+ "type": "object",
481
+ "properties": {
482
+ "enabled": { "type": "boolean" },
483
+ "required": { "type": "boolean" },
484
+ "description": { "type": "string" },
485
+ "default": { "type": "boolean" }
486
+ }
487
+ },
488
+ "logAnalytics": {
489
+ "type": "object",
490
+ "properties": {
491
+ "enabled": { "type": "boolean" },
492
+ "required": { "type": "boolean" },
493
+ "description": { "type": "string" },
494
+ "default": { "type": "boolean" }
495
+ }
496
+ },
497
+ "alerts": {
498
+ "type": "object",
499
+ "properties": {
500
+ "enabled": { "type": "boolean" },
501
+ "required": { "type": "boolean" },
502
+ "description": { "type": "string" },
503
+ "default": { "type": "boolean" },
504
+ "dependsOn": {
505
+ "type": "array",
506
+ "items": { "type": "string" }
507
+ }
508
+ }
509
+ },
510
+ "dashboards": {
511
+ "type": "object",
512
+ "properties": {
513
+ "enabled": { "type": "boolean" },
514
+ "required": { "type": "boolean" },
515
+ "description": { "type": "string" },
516
+ "default": { "type": "boolean" },
517
+ "dependsOn": {
518
+ "type": "array",
519
+ "items": { "type": "string" }
520
+ }
521
+ }
522
+ }
523
+ }
524
+ },
525
+ "containerRegistry": {
526
+ "type": "object",
527
+ "properties": {
528
+ "acr": {
529
+ "type": "object",
530
+ "properties": {
531
+ "enabled": { "type": "boolean" },
532
+ "required": { "type": "boolean" },
533
+ "description": { "type": "string" },
534
+ "default": { "type": "boolean" }
535
+ }
536
+ }
537
+ }
538
+ }
539
+ }
540
+ }
541
+ },
542
+ "allOf": [
543
+ {
544
+ "if": {
545
+ "properties": {
546
+ "customDomain": {
547
+ "properties": {
548
+ "enabled": {
549
+ "const": true
550
+ }
551
+ }
552
+ }
553
+ }
554
+ },
555
+ "then": {
556
+ "required": ["customDomain"],
557
+ "properties": {
558
+ "customDomain": {
559
+ "required": ["name"]
560
+ }
561
+ }
562
+ }
563
+ },
564
+ {
565
+ "if": {
566
+ "properties": {
567
+ "frontDoor": {
568
+ "properties": {
569
+ "enablePrivateLink": {
570
+ "const": true
571
+ }
572
+ }
573
+ }
574
+ }
575
+ },
576
+ "then": {
577
+ "properties": {
578
+ "frontDoor": {
579
+ "properties": {
580
+ "tier": {
581
+ "const": "Premium"
582
+ }
583
+ }
584
+ }
585
+ }
586
+ }
587
+ }
588
+ ]
589
+ }