fleetbo-svro 1.0.3 → 1.0.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 +24 -17
- package/dist/cli.cjs +16 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
- @fleetbo/svro
|
|
2
|
-
Le connecteur backend Fleetbo ultra-léger configuré automatiquement depuis votre terminal.
|
|
3
1
|
|
|
2
|
+
# fleetbo-svro #
|
|
4
3
|
|
|
5
|
-
#
|
|
4
|
+
# The Client-Side Data OS for Modern Web Apps & AI Vibe-Coding.
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
Lencez simplement l'installation à la racine de votre projet Vite (React, Vue, etc.) :
|
|
9
|
-
Bash
|
|
10
|
-
npm install @fleetbo/svro
|
|
6
|
+
Fleetbo manages the complete data lifecycle: from AI-assisted schema modeling (Alex AI DBA) to deterministic Edge-enforced execution and natural language intelligence (Alex AI Data Analyst).
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
Dès l'installation terminée, le script de configuration prend le relais :
|
|
14
|
-
Authentification OTP : Le terminal vous demande votre email et un code à 6 chiffres.
|
|
15
|
-
Injection des clés : Les identifiants (VITE_FLEETBO_DB_KEY, etc.) sont écrits directement dans votre fichier .env.
|
|
8
|
+
Like an architect drafting blueprints before construction begins, Alex AI models your business domain and spins up an instant, production-ready backend. Fleetbo delivers relational integrity, strict typing, and Edge security to MongoDB Atlas without writing a single line of backend boilerplate.
|
|
16
9
|
|
|
17
|
-
|
|
18
|
-
Création de svro.schema.json et initialisation des types TypeScript.
|
|
19
|
-
Patch de tsconfig.json / jsconfig.json pour l'autocomplétion.
|
|
20
|
-
Injection du plugin d'auto-import et du middleware de synchronisation dans vite.config.
|
|
21
|
-
Ajout de fleetbo sql sync dans le script build du package.json.
|
|
10
|
+
# Why Fleetbo?
|
|
22
11
|
|
|
23
|
-
|
|
12
|
+
100% Frontend Focus: Zero servers, zero ORMs, and zero SQL migrations. Build full-stack applications purely from the client.
|
|
13
|
+
AI Agent Accelerator: Eliminates hallucinations and cuts token usage by 90% via deterministic contracts (svro.schema.json, svro.workflow.json). Agents (Cursor, Lovable, Windsurf) focus 100% of their reasoning on UX.
|
|
14
|
+
Deterministic Edge Gatekeeper: Sub-millisecond $O(1)$ schema validation at the cloud edge before writes hit MongoDB Atlas.
|
|
15
|
+
Zero-Crash Native Web Components: 7 built-in, framework-agnostic Custom Elements (<fleetbo-*>) preventing white-screen crashes on malformed data.
|
|
16
|
+
Built-in Data Intelligence: Query live database metrics in plain human language without external ETL or BI tools.
|
|
17
|
+
|
|
18
|
+
Quick Start
|
|
19
|
+
|
|
20
|
+
# 1. Initialize project & configure Vite auto-imports
|
|
21
|
+
npx fleetbo-svro init --keyApp=<APP_KEY> --token=<TOKEN>
|
|
22
|
+
|
|
23
|
+
# 2. Sync cloud schema & generate IDE types
|
|
24
|
+
npx fleetbo-svro sync
|
|
25
|
+
|
|
26
|
+
# Update SDK & refresh bindings
|
|
27
|
+
npm i fleetbo-svro@latest && npx fleetbo-svro sync
|
|
28
|
+
|
|
29
|
+
# 3. Consommation immédiate dans votre code
|
|
24
30
|
Ouvrez vos composants et utilisez directement l'objet Fleetbo. Grâce à la configuration Vite, aucun import n'est requis (l'import reste possible si vous le préférez) :
|
|
25
31
|
JavaScript
|
|
26
32
|
// Fonctionne directement dans vos composants React / Vue
|
|
@@ -74,3 +80,4 @@ Fleetbo.getDocsU(table) → Récupère les documents de l'utilisateur connecté.
|
|
|
74
80
|
Fleetbo.getAuthUser(table) → Récupère les données du profil de l'utilisateur connecté.
|
|
75
81
|
|
|
76
82
|
|
|
83
|
+
|
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var N=(t,n)=>()=>{try{return n||t((n={exports:{}}).exports,n),n.exports}catch(o){throw n=0,o}};var k=N((ne,w)=>{var c=require("fs"),u=require("path"),j=require("https"),{execSync:C}=require("child_process"),L="\x1B[38;2;231;233;237m",A="\x1B[31m",x="\x1B[0m";function b(t){console.log(` ${L}${t}${x}`)}function g(t){console.error(` ${A}${t}${x}`)}function D(t){let n={};return t.forEach(o=>{if(o.startsWith("--")){let[r,i]=o.slice(2).split("=");r&&i&&(n[r]=i)}}),n}function E(t,n){try{let o=JSON.parse(c.readFileSync(t,"utf8"));return!!(o.dependencies&&o.dependencies[n]||o.devDependencies&&o.devDependencies[n])}catch{return!1}}function $(t,n){if(!E(n,"fleetbo-svro")){b("\u2192 Installing fleetbo-svro into the project...");try{C("npm install fleetbo-svro",{cwd:t,stdio:"inherit"}),b("fleetbo-svro installed successfully!")}catch{g("\u26A0\uFE0F Automatic installation failed. Please run 'npm install fleetbo-svro' manually.")}}}function J(t){let n=u.join(t,"svro.schema.json");if(c.existsSync(n))return;let o=new Date().toISOString(),r={createdAt:o,patchedAt:o,schemaVersion:1,collections:{}};c.writeFileSync(n,JSON.stringify(r,null,2)+`
|
|
3
3
|
`),b("\u2192 Created svro.schema.json at project root.")}function M(t){let n=u.join(t,"src");if(!c.existsSync(n))return;let o=u.join(n,"auto-imports.d.ts");if(c.existsSync(o))return;let r=`/* eslint-disable */
|
|
4
4
|
/* prettier-ignore */
|
|
5
5
|
// @ts-nocheck
|
|
@@ -9,7 +9,7 @@ declare global {
|
|
|
9
9
|
const Fleetbo: typeof import('fleetbo-svro')['Fleetbo']
|
|
10
10
|
const FleetboUI: typeof import('fleetbo-svro')['FleetboUI']
|
|
11
11
|
}
|
|
12
|
-
`;try{c.writeFileSync(o,r),b("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(i){g(`\u26A0\uFE0F Unable to create src/auto-imports.d.ts: ${i.message}`)}}function B(t){let n=["tsconfig.json","jsconfig.json"];for(let o of n){let r=u.join(t,o);if(c.existsSync(r)){let i=new Date;c.utimesSync(r,i,i);break}}}function
|
|
12
|
+
`;try{c.writeFileSync(o,r),b("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(i){g(`\u26A0\uFE0F Unable to create src/auto-imports.d.ts: ${i.message}`)}}function B(t){let n=["tsconfig.json","jsconfig.json"];for(let o of n){let r=u.join(t,o);if(c.existsSync(r)){let i=new Date;c.utimesSync(r,i,i);break}}}function W(t){let n=u.join(t,"index.d.ts");if(c.existsSync(n))return;c.writeFileSync(n,`// File generated/synchronized by fleetbo-svro \u2014 do not edit manually
|
|
13
13
|
|
|
14
14
|
export type FleetboTables = string;
|
|
15
15
|
|
|
@@ -183,7 +183,7 @@ declare global {
|
|
|
183
183
|
FleetboUI: typeof FleetboUI;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
`),b("\u2192 Initialized index.d.ts.")}function
|
|
186
|
+
`),b("\u2192 Initialized index.d.ts.")}function q(t){return new Promise((n,o)=>{let r=JSON.stringify({token:t}),i={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},d=j.request(i,e=>{let l="";e.on("data",s=>{l+=s}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{n(JSON.parse(l))}catch{o(new Error("Invalid response received from Fleetbo server."))}else try{let s=JSON.parse(l);o(new Error(s.error||`Server error ${e.statusCode}`))}catch{o(new Error(`Server error ${e.statusCode}`))}})});d.on("error",e=>o(e)),d.write(r),d.end()})}async function H(t,n=[]){let o=u.join(t,".env");if(c.existsSync(o)&&c.readFileSync(o,"utf8").includes("VITE_FLEETBO_DB_KEY")){b("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let r=D(n),i=r.keyApp,d=r.token||r.bootstrapToken,e=r.email||"";(!i||!d)&&(g("\u26A0\uFE0F Missing required parameters."),g("\u{1F449} Usage: npx fleetbo-svro init --keyApp=YOUR_KEY --token=YOUR_TOKEN"),process.exit(1)),b("\u2192 Exchanging bootstrap token for project keys...");let l;try{l=await q(d)}catch(a){g(`\u26A0\uFE0F Token exchange failed: ${a.message}`),g("\u{1F449} The token may have expired (15 min limit) or was already used. Please regenerate one from the Fleetbo dashboard."),process.exit(1)}(!l.enterpriseId||!l.fleetboDBKey)&&(g("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let s=`
|
|
187
187
|
VITE_FLEETBO_DB_KEY=${l.fleetboDBKey}
|
|
188
188
|
VITE_FLEETBO_ENTERPRISE_ID=${l.enterpriseId}
|
|
189
189
|
VITE_FLEETBO_KEY_APP=${i}
|
|
@@ -206,9 +206,9 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
|
|
|
206
206
|
const schemaPath = path.join(process.cwd(), 'svro.schema.json');
|
|
207
207
|
fs.writeFileSync(schemaPath, JSON.stringify(schema, null, 2) + '\\n');
|
|
208
208
|
try {
|
|
209
|
-
execSync('node ./node_modules/fleetbo-svro/bin/cli.js
|
|
209
|
+
execSync('node ./node_modules/fleetbo-svro/bin/cli.js sync', { stdio: 'ignore' });
|
|
210
210
|
} catch (_) {
|
|
211
|
-
execSync('npx fleetbo-svro
|
|
211
|
+
execSync('npx fleetbo-svro sync', { stdio: 'ignore' });
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
@@ -237,15 +237,17 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
|
|
|
237
237
|
imports: [{ '${d}': ['Fleetbo', 'FleetboUI'] }],
|
|
238
238
|
dts: 'src/auto-imports.d.ts'
|
|
239
239
|
}),`;if(e=e.slice(0,a)+F+e.slice(a),!e.includes("import AutoImport")){let T=[...e.matchAll(/^import .+;?$/gm)].pop(),v=`import AutoImport from 'unplugin-auto-import/vite';
|
|
240
|
-
`;if(T){let
|
|
241
|
-
`+v+e.slice(
|
|
240
|
+
`;if(T){let m=T.index+T[0].length;e=e.slice(0,m)+`
|
|
241
|
+
`+v+e.slice(m)}else e=v+e}}}if(e.includes("__fleetbo_sync_schema")){if(e.includes("require('fs')")||e.includes('require("fs")')){let s=/\{\s*name:\s*['"]fleetbo-schema-sync-middleware['"][\s\S]*?\},/g;s.test(e)&&(e=e.replace(s,l),b("\u2192 Updated legacy Fleetbo middleware to modern ESM version."))}}else{let s=e.match(/plugins\s*:\s*\[/);if(s){let a=s.index+s[0].length;e=e.slice(0,a)+`
|
|
242
242
|
`+l+e.slice(a)}}if(e!==i)try{c.writeFileSync(r,e),b(`\u2192 Updated ${u.basename(r)} with Watcher and AutoImport configuration.`)}catch(s){g(`\u26A0\uFE0F Failed to write to ${u.basename(r)}: ${s.message}`)}try{let s=JSON.parse(c.readFileSync(n,"utf8"));s.devDependencies=s.devDependencies||{},s.devDependencies["unplugin-auto-import"]||(s.devDependencies["unplugin-auto-import"]="^0.18.0",c.writeFileSync(n,JSON.stringify(s,null,2)+`
|
|
243
|
-
`),b("\u2192 Added unplugin-auto-import to devDependencies."))}catch(s){g(`\u26A0\uFE0F Failed to update ${u.basename(n)}: ${s.message}`)}}function V(t,n,o={}){let{skipSelfInstall:r=!1}=o,i=u.join(__dirname,"..");r||$(t,n),J(t),
|
|
244
|
-
`).forEach(i=>{let[d,...e]=i.split("=");d&&e.length>0&&(r[d.trim()]=e.join("=").trim())}),r}function ee(t){return new Promise((n,o)=>{let r=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),i={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},d=_.request(i,e=>{let l="";e.on("data",s=>{l+=s}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let s=JSON.parse(l);if(s.success&&s.found&&s.module){let a=s.module.code||s.module.mockCode;n(typeof a=="string"?JSON.parse(a):a)}else o(new Error("Schema not found in Fleetbo Cloud."))}catch{o(new Error("Invalid JSON response received from Fleetbo server."))}else o(new Error(`Server error ${e.statusCode}`))})});d.on("error",e=>o(e)),d.write(r),d.end()})}var
|
|
245
|
-
[Fleetbo] Initializing and configuring Fleetbo...`),await Y(t,
|
|
243
|
+
`),b("\u2192 Added unplugin-auto-import to devDependencies."))}catch(s){g(`\u26A0\uFE0F Failed to update ${u.basename(n)}: ${s.message}`)}}function V(t,n,o={}){let{skipSelfInstall:r=!1}=o,i=u.join(__dirname,"..");r||$(t,n),J(t),W(i),M(t),O(t),P(t,n),R(t,n)}w.exports={touchTsConfig:B,log:b,logError:g,handleAuthAndEnv:H,detectDependency:E,cleanupLegacyRootDts:O,patchJsOrTsConfig:P,attemptViteAutoImportPatch:R,runFullSetup:V}});var p=require("fs"),y=require("path"),_=require("https"),{runFullSetup:K,handleAuthAndEnv:Y,touchTsConfig:G}=k(),z="\x1B[34m",X="\x1B[31m",U="\x1B[0m";function f(t){console.log(`${z}${t}${U}`)}function h(t){console.error(`${X}${t}${U}`)}function Q(t,n){return new Promise((o,r)=>{let i=JSON.stringify({enterpriseID:t,schema:n}),d={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(i)}},e=_.request(d,l=>{let s="";l.on("data",a=>{s+=a}),l.on("end",()=>{l.statusCode>=200&&l.statusCode<300?o(JSON.parse(s)):r(new Error(`Edge sync failed with HTTP ${l.statusCode}`))})});e.on("error",l=>r(l)),e.write(i),e.end()})}function Z(t){let n=y.join(t,".env");if(!p.existsSync(n))return{};let o=p.readFileSync(n,"utf8"),r={};return o.split(`
|
|
244
|
+
`).forEach(i=>{let[d,...e]=i.split("=");d&&e.length>0&&(r[d.trim()]=e.join("=").trim())}),r}function ee(t){return new Promise((n,o)=>{let r=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),i={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},d=_.request(i,e=>{let l="";e.on("data",s=>{l+=s}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let s=JSON.parse(l);if(s.success&&s.found&&s.module){let a=s.module.code||s.module.mockCode;n(typeof a=="string"?JSON.parse(a):a)}else o(new Error("Schema not found in Fleetbo Cloud."))}catch{o(new Error("Invalid JSON response received from Fleetbo server."))}else o(new Error(`Server error ${e.statusCode}`))})});d.on("error",e=>o(e)),d.write(r),d.end()})}var S=process.argv.slice(2),I=S[0];async function te(){let t=process.cwd(),n=y.join(t,"package.json");if(I==="init"||I==="doctor")f(`
|
|
245
|
+
[Fleetbo] Initializing and configuring Fleetbo...`),await Y(t,S),K(t,n),f(`
|
|
246
246
|
[Fleetbo] Configuration completed successfully!
|
|
247
|
-
`)
|
|
248
|
-
|
|
247
|
+
`),f(`
|
|
248
|
+
Next step:`),f(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
|
|
249
|
+
`);else if(I==="sync"){let o=S.includes("--dry-run");f(`[Fleetbo] Syncing schema...${o?" (dry-run)":""}`);let r=y.join(t,"svro.schema.json"),i=y.join(__dirname,".."),d=y.join(i,"index.d.ts"),e=y.join(t,"src","auto-imports.d.ts"),s=Z(t).VITE_FLEETBO_ENTERPRISE_ID;if(s)try{f("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let a=await ee(s);p.writeFileSync(r,JSON.stringify(a,null,2)+`
|
|
250
|
+
`),f("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(a){h(`\u26A0\uFE0F Cloud fetch bypassed: ${a.message}. Using local file fallback.`)}else h("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");p.existsSync(r)||(h("Error: svro.schema.json not found."),process.exit(1));try{let a=JSON.parse(p.readFileSync(r,"utf8")),F=Object.keys(a.collections||{});if(s)try{await Q(s,a),f("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(m){h(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${m.message}`)}let T=F.length>0?F.map(m=>`'${m}'`).join(" | "):"string",v=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sql sync
|
|
249
251
|
|
|
250
252
|
export type FleetboTables = ${T};
|
|
251
253
|
|
|
@@ -419,7 +421,7 @@ declare global {
|
|
|
419
421
|
FleetboUI: typeof FleetboUI;
|
|
420
422
|
}
|
|
421
423
|
}
|
|
422
|
-
`;if(p.writeFileSync(d,v),p.existsSync(y.dirname(e))){let
|
|
424
|
+
`;if(p.writeFileSync(d,v),p.existsSync(y.dirname(e))){let m=`/* eslint-disable */
|
|
423
425
|
/* prettier-ignore */
|
|
424
426
|
// @ts-nocheck
|
|
425
427
|
// Generated by fleetbo-svro \u2014 Updated via fleetbo sql sync
|
|
@@ -429,4 +431,4 @@ declare global {
|
|
|
429
431
|
const Fleetbo: typeof import('fleetbo-svro')['Fleetbo'];
|
|
430
432
|
const FleetboUI: typeof import('fleetbo-svro')['FleetboUI'];
|
|
431
433
|
}
|
|
432
|
-
`;p.writeFileSync(e,
|
|
434
|
+
`;p.writeFileSync(e,m)}G(t),f(`[Fleetbo] Schema synced successfully (${F.length} collection(s)).`),o&&f("\u2192 [Dry-run] Schema is valid.")}catch(a){h(`Error during synchronization: ${a.message}`),process.exit(1)}}else h('Unknown command. Usage: "npx fleetbo-svro init" or "npx fleetbo-svro sync"'),process.exit(1)}te().catch(t=>{h(`Fleetbo CLI Error: ${t.message}`),process.exit(1)});
|