fleetbo-svro 1.0.31 → 1.0.33

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 (2) hide show
  1. package/dist/cli.cjs +28 -28
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- var V=(t,o)=>()=>{try{return o||t((o={exports:{}}).exports,o),o.exports}catch(n){throw o=0,n}};var N=V((Fe,D)=>{var i=require("fs"),p=require("path"),q=require("https"),{execSync:H}=require("child_process"),K="\x1B[38;2;231;233;237m",W="\x1B[31m",_="\x1B[0m";function f(t){console.log(` ${K}${t}${_}`)}function u(t){console.error(` ${W}${t}${_}`)}function Y(t){let o={};return t.forEach(n=>{if(n.startsWith("--")){let[s,r]=n.slice(2).split("=");s&&r&&(o[s]=r)}}),o}function O(t,o){try{let n=JSON.parse(i.readFileSync(t,"utf8"));return!!(n.dependencies&&n.dependencies[o]||n.devDependencies&&n.devDependencies[o])}catch{return!1}}function X(t,o){if(!O(o,"fleetbo-svro")){f("\u2192 Installing fleetbo-svro into the project...");try{H("npm install fleetbo-svro",{cwd:t,stdio:"inherit"}),f("fleetbo-svro installed successfully!")}catch{u("\u26A0\uFE0F Automatic installation failed. Please run 'npm install fleetbo-svro' manually.")}}}function z(t){let o=p.join(t,"svro.schema.json");if(i.existsSync(o))return;let n=new Date().toISOString(),s={createdAt:n,patchedAt:n,schemaVersion:1,collections:{}};i.writeFileSync(o,JSON.stringify(s,null,2)+`
3
- `),f("\u2192 Created svro.schema.json at project root.")}function G(t){let o=p.join(t,".env"),n=`
4
- # Fleetbo Sandbox / Prototype Mode
5
- # true = BDD verrouill\xE9e, z\xE9ro crash, IDE alerte en Cyan
6
- # false = Mode strict production (sanction imm\xE9diate HTTP 422 si non scell\xE9, \xE9criture BDD)
2
+ var V=(t,n)=>()=>{try{return n||t((n={exports:{}}).exports,n),n.exports}catch(o){throw n=0,o}};var N=V((he,$)=>{var i=require("fs"),p=require("path"),q=require("https"),{execSync:W}=require("child_process"),H="\x1B[38;2;231;233;237m",K="\x1B[31m",j="\x1B[0m";function f(t){console.log(` ${H}${t}${j}`)}function d(t){console.error(` ${K}${t}${j}`)}function Y(t){let n={};return t.forEach(o=>{if(o.startsWith("--")){let[s,r]=o.slice(2).split("=");s&&r&&(n[s]=r)}}),n}function O(t,n){try{let o=JSON.parse(i.readFileSync(t,"utf8"));return!!(o.dependencies&&o.dependencies[n]||o.devDependencies&&o.devDependencies[n])}catch{return!1}}function X(t,n){try{return i.existsSync(p.join(t,"node_modules",n,"package.json"))}catch{return!1}}function z(t,n){if(i.existsSync(p.join(t,"pnpm-lock.yaml")))return"pnpm";if(i.existsSync(p.join(t,"yarn.lock")))return"yarn";if(i.existsSync(p.join(t,"bun.lockb")))return"bun";try{let o=JSON.parse(i.readFileSync(n,"utf8"));if(typeof o.packageManager=="string"){if(o.packageManager.startsWith("pnpm"))return"pnpm";if(o.packageManager.startsWith("yarn"))return"yarn";if(o.packageManager.startsWith("bun"))return"bun"}}catch{}return"npm"}function G(t,n){if(!O(n,"fleetbo-svro")||!X(t,"fleetbo-svro")){let o=z(t,n),s={pnpm:"pnpm add fleetbo-svro",yarn:"yarn add fleetbo-svro",bun:"bun add fleetbo-svro",npm:"npm install fleetbo-svro"}[o];f(`\u2192 Installing fleetbo-svro into the project (detected: ${o})...`);try{W(s,{cwd:t,stdio:"inherit"}),f("fleetbo-svro installed successfully!")}catch(r){d(`\u26A0\uFE0F Automatic installation failed: ${r.message}`),d(`\u{1F449} Please run '${s}' manually.`)}}}function Q(t){let n=p.join(t,"svro.schema.json");if(i.existsSync(n))return;let o=new Date().toISOString(),s={createdAt:o,patchedAt:o,schemaVersion:1,collections:{}};i.writeFileSync(n,JSON.stringify(s,null,2)+`
3
+ `),f("\u2192 Created svro.schema.json at project root.")}function Z(t){let n=p.join(t,".env"),o=`
4
+ # Fleetbo UI Sandbox Mode
5
+ # true = Sandbox mode: simulates writes locally for fluid UI testing; no DB access and IDE alert.
6
+ # false = Strict production mode: enforces schema contracts and persists to DB
7
7
  VITE_FLEETBO_PROTOTYPE=true
8
- `;if(!i.existsSync(o))i.writeFileSync(o,n.trimStart()),f("\u2192 Created .env with VITE_FLEETBO_PROTOTYPE=true");else{let s=i.readFileSync(o,"utf8");!s.includes("VITE_FLEETBO_PROTOTYPE")&&!s.includes("FLEETBO_PROTOTYPE")&&(i.appendFileSync(o,n),f("\u2192 Injected VITE_FLEETBO_PROTOTYPE=true into existing .env"))}}function Q(t){let o=p.join(t,"src");if(!i.existsSync(o))return;let n=p.join(o,"fleetbo.d.ts");if(i.existsSync(n))return;let s=`/* eslint-disable */
8
+ `;if(!i.existsSync(n))i.writeFileSync(n,o.trimStart()),f("\u2192 Created .env with VITE_FLEETBO_PROTOTYPE=true");else{let s=i.readFileSync(n,"utf8");!s.includes("VITE_FLEETBO_PROTOTYPE")&&!s.includes("FLEETBO_PROTOTYPE")&&(i.appendFileSync(n,o),f("\u2192 Injected VITE_FLEETBO_PROTOTYPE=true into existing .env"))}}function ee(t){let n=p.join(t,"src");if(!i.existsSync(n))return;let o=p.join(n,"fleetbo.d.ts");if(i.existsSync(o))return;let s=`/* eslint-disable */
9
9
  /* prettier-ignore */
10
10
  // @ts-nocheck
11
11
  export {}
@@ -89,15 +89,15 @@ declare module 'react' {
89
89
  }
90
90
  }
91
91
  }
92
- `;try{i.writeFileSync(n,s),f("\u2192 Created src/fleetbo.d.ts stub for instant IDE auto-completion.")}catch(r){u(`\u26A0\uFE0F Unable to create src/fleetbo.d.ts: ${r.message}`)}}function Z(t){let o=p.join(t,"index.d.ts");i.existsSync(o)||f("\u2192 Verified index.d.ts presence.")}function ee(t){let o=["tsconfig.json","jsconfig.json"];for(let n of o){let s=p.join(t,n);if(i.existsSync(s)){let r=new Date;i.utimesSync(s,r,r);break}}}function te(t){return new Promise((o,n)=>{let s=JSON.stringify({token:t}),r={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},b=q.request(r,e=>{let a="";e.on("data",l=>{a+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{o(JSON.parse(a))}catch{n(new Error("Invalid response received from Fleetbo server."))}else try{let l=JSON.parse(a);n(new Error(l.error||`Server error ${e.statusCode}`))}catch{n(new Error(`Server error ${e.statusCode}`))}})});b.on("error",e=>n(e)),b.write(s),b.end()})}async function oe(t,o=[]){let n=p.join(t,".env");if(i.existsSync(n)&&i.readFileSync(n,"utf8").includes("VITE_FLEETBO_DB_KEY")){f("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let s=Y(o),r=s.keyApp,b=s.token||s.bootstrapToken,e=s.email||"";(!r||!b)&&(u("\u26A0\uFE0F Missing required parameters."),u("\u{1F449} Usage: npx fleetbo-svro init --keyApp=YOUR_KEY --token=YOUR_TOKEN"),process.exit(1)),f("\u2192 Exchanging bootstrap token for project keys...");let a;try{a=await te(b)}catch(c){u(`\u26A0\uFE0F Token exchange failed: ${c.message}`),u("\u{1F449} The token may have expired (15 min limit) or was already used. Please regenerate one from the Fleetbo dashboard."),process.exit(1)}(!a.enterpriseId||!a.fleetboDBKey)&&(u("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let l=`
92
+ `;try{i.writeFileSync(o,s),f("\u2192 Created src/fleetbo.d.ts stub for instant IDE auto-completion.")}catch(r){d(`\u26A0\uFE0F Unable to create src/fleetbo.d.ts: ${r.message}`)}}function te(t){let n=p.join(t,"index.d.ts");i.existsSync(n)||f("\u2192 Verified index.d.ts presence.")}function oe(t){let n=["tsconfig.json","jsconfig.json"];for(let o of n){let s=p.join(t,o);if(i.existsSync(s)){let r=new Date;i.utimesSync(s,r,r);break}}}function ne(t){return new Promise((n,o)=>{let s=JSON.stringify({token:t}),r={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},b=q.request(r,e=>{let a="";e.on("data",l=>{a+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{n(JSON.parse(a))}catch{o(new Error("Invalid response received from Fleetbo server."))}else try{let l=JSON.parse(a);o(new Error(l.error||`Server error ${e.statusCode}`))}catch{o(new Error(`Server error ${e.statusCode}`))}})});b.on("error",e=>o(e)),b.write(s),b.end()})}async function se(t,n=[]){let o=p.join(t,".env");if(i.existsSync(o)&&i.readFileSync(o,"utf8").includes("VITE_FLEETBO_DB_KEY")){f("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let s=Y(n),r=s.keyApp,b=s.token||s.bootstrapToken,e=s.email||"";(!r||!b)&&(d("\u26A0\uFE0F Missing required parameters."),d("\u{1F449} Usage: npx fleetbo-svro init --keyApp=YOUR_KEY --token=YOUR_TOKEN"),process.exit(1)),f("\u2192 Exchanging bootstrap token for project keys...");let a;try{a=await ne(b)}catch(c){d(`\u26A0\uFE0F Token exchange failed: ${c.message}`),d("\u{1F449} The token may have expired (15 min limit) or was already used. Please regenerate one from the Fleetbo dashboard."),process.exit(1)}(!a.enterpriseId||!a.fleetboDBKey)&&(d("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let l=`
93
93
  VITE_FLEETBO_DB_KEY=${a.fleetboDBKey}
94
94
  VITE_FLEETBO_ENTERPRISE_ID=${a.enterpriseId}
95
95
  VITE_FLEETBO_KEY_APP=${r}
96
96
  ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
97
- `:""}`;i.appendFileSync(n,l),f(".env file updated successfully with Fleetbo keys!")}function k(t){let o=p.join(t,"svro.d.ts");if(i.existsSync(o))try{i.unlinkSync(o),f("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function C(t,o){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let n=p.join(t,"tsconfig.json"),s=p.join(t,"jsconfig.json"),r=i.existsSync(n)?n:s,b=!i.existsSync(r),e={};if(!b)try{e=JSON.parse(i.readFileSync(r,"utf8"))}catch{u(`\u26A0\uFE0F Unable to read ${p.basename(r)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let a=!1,l=O(o,"react");b?(e.compilerOptions.checkJs=!0,e.compilerOptions.allowJs=!0,e.compilerOptions.target=e.compilerOptions.target||"ES2020",e.compilerOptions.module=e.compilerOptions.module||"ESNext",e.compilerOptions.moduleResolution=e.compilerOptions.moduleResolution||"bundler",e.include=["src/**/*"],a=!0):(e.compilerOptions.checkJs===void 0&&(e.compilerOptions.checkJs=!0,a=!0),e.compilerOptions.allowJs===void 0&&(e.compilerOptions.allowJs=!0,a=!0)),l&&e.compilerOptions.jsx===void 0&&(e.compilerOptions.jsx="react-jsx",a=!0),a&&(i.writeFileSync(r,JSON.stringify(e,null,2)+`
98
- `),f(`\u2192 Updated ${p.basename(r)}.`))}function R(t){let o=["src/app/layout.tsx","src/app/layout.jsx","app/layout.tsx","app/layout.jsx","src/pages/_app.tsx","src/pages/_app.jsx","pages/_app.tsx","pages/_app.jsx","src/main.tsx","src/main.jsx","src/main.ts","src/main.js","src/index.tsx","src/index.jsx","src/index.ts","src/index.js","src/App.tsx","src/App.jsx","src/App.vue","app.vue","src/routes/+layout.svelte","src/routes/+layout.ts","src/main.singletons.ts"];for(let n of o){let s=p.join(t,n);if(i.existsSync(s)){let r=i.readFileSync(s,"utf8");r.includes("fleetbo-svro")||(r.startsWith('"use client"')||r.startsWith("'use client'")?r=r.replace(/(['"]use client['"];?\r?\n)/,`$1import 'fleetbo-svro';
97
+ `:""}`;i.appendFileSync(o,l),f(".env file updated successfully with Fleetbo keys!")}function _(t){let n=p.join(t,"svro.d.ts");if(i.existsSync(n))try{i.unlinkSync(n),f("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function C(t,n){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let o=p.join(t,"tsconfig.json"),s=p.join(t,"jsconfig.json"),r=i.existsSync(o)?o:s,b=!i.existsSync(r),e={};if(!b)try{e=JSON.parse(i.readFileSync(r,"utf8"))}catch{d(`\u26A0\uFE0F Unable to read ${p.basename(r)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let a=!1,l=O(n,"react");b?(e.compilerOptions.checkJs=!0,e.compilerOptions.allowJs=!0,e.compilerOptions.target=e.compilerOptions.target||"ES2020",e.compilerOptions.module=e.compilerOptions.module||"ESNext",e.compilerOptions.moduleResolution=e.compilerOptions.moduleResolution||"bundler",e.include=["src/**/*"],a=!0):(e.compilerOptions.checkJs===void 0&&(e.compilerOptions.checkJs=!0,a=!0),e.compilerOptions.allowJs===void 0&&(e.compilerOptions.allowJs=!0,a=!0)),l&&e.compilerOptions.jsx===void 0&&(e.compilerOptions.jsx="react-jsx",a=!0),Array.isArray(e.compilerOptions.types)&&e.compilerOptions.types.includes("vite/client")&&(e.compilerOptions.types=e.compilerOptions.types.filter(c=>c!=="vite/client"),e.compilerOptions.types.length===0&&delete e.compilerOptions.types,a=!0,f(`\u2192 Removed legacy "vite/client" entry from ${p.basename(r)}.`)),a&&(i.writeFileSync(r,JSON.stringify(e,null,2)+`
98
+ `),f(`\u2192 Updated ${p.basename(r)}.`))}function R(t){let n=["src/app/layout.tsx","src/app/layout.jsx","app/layout.tsx","app/layout.jsx","src/pages/_app.tsx","src/pages/_app.jsx","pages/_app.tsx","pages/_app.jsx","src/main.tsx","src/main.jsx","src/main.ts","src/main.js","src/index.tsx","src/index.jsx","src/index.ts","src/index.js","src/App.tsx","src/App.jsx","src/App.vue","app.vue","src/routes/+layout.svelte","src/routes/+layout.ts","src/main.singletons.ts"];for(let o of n){let s=p.join(t,o);if(i.existsSync(s)){let r=i.readFileSync(s,"utf8");r.includes("fleetbo-svro")||(r.startsWith('"use client"')||r.startsWith("'use client'")?r=r.replace(/(['"]use client['"];?\r?\n)/,`$1import 'fleetbo-svro';
99
99
  `):r=`import 'fleetbo-svro';
100
- `+r,i.writeFileSync(s,r));return}}}function L(t,o){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let s=["vite.config.ts","vite.config.js","vite.config.mjs"].map(l=>p.join(t,l)).find(l=>i.existsSync(l));if(!s)return;let r;try{r=i.readFileSync(s,"utf8")}catch{return}let b="fleetbo-svro",e=r,a=`{
100
+ `+r,i.writeFileSync(s,r));return}}}function L(t,n){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let s=["vite.config.ts","vite.config.js","vite.config.mjs"].map(l=>p.join(t,l)).find(l=>i.existsSync(l));if(!s)return;let r;try{r=i.readFileSync(s,"utf8")}catch{return}let b="fleetbo-svro",e=r,a=`{
101
101
  name: 'fleetbo-auto-runtime',
102
102
  transform(code, id) {
103
103
  if (!id.includes('node_modules') && !code.includes('fleetbo-svro') && /(src[\\\\/](main|index|App|root))\\.(jsx?|tsx?|vue|svelte)/i.test(id)) {
@@ -153,28 +153,28 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
153
153
  AutoImport({
154
154
  imports: [{ '${b}': ['Fleetbo', 'FleetboUI'] }],
155
155
  dts: 'src/auto-imports.d.ts'
156
- }),`;if(e=e.slice(0,c)+P+e.slice(c),!e.includes("import AutoImport")){let T=[...e.matchAll(/^import .+;?$/gm)].pop(),E=`import AutoImport from 'unplugin-auto-import/vite';
157
- `;if(T){let S=T.index+T[0].length;e=e.slice(0,S)+`
158
- `+E+e.slice(S)}else e=E+e}}}if(!e.includes("fleetbo-auto-runtime")){let l=e.match(/plugins\s*:\s*\[/);if(l){let c=l.index+l[0].length;e=e.slice(0,c)+`
159
- `+a+e.slice(c)}}e!==r&&i.writeFileSync(s,e)}function ne(t){let o=p.join(t,".vscode"),n=p.join(o,"settings.json");try{i.existsSync(o)||i.mkdirSync(o,{recursive:!0});let s={};if(i.existsSync(n))try{s=JSON.parse(i.readFileSync(n,"utf8"))}catch{s={}}s["workbench.colorCustomizations"]=s["workbench.colorCustomizations"]||{},s["workbench.colorCustomizations"]["editorInfo.foreground"]="#00feae",s["workbench.colorCustomizations"]["editorHint.foreground"]="#00feae",i.writeFileSync(n,JSON.stringify(s,null,2)+`
160
- `),f("\u2192 Configured Fleetbo Cyan visual hints in .vscode/settings.json.")}catch{}}function se(t,o,n={}){let{skipSelfInstall:s=!1}=n,r=p.join(__dirname,"..");s||X(t,o),z(t),G(t),Z(r),Q(t),ne(t),k(t),C(t,o),L(t,o),R(t)}D.exports={touchTsConfig:ee,log:f,logError:u,handleAuthAndEnv:oe,detectDependency:O,cleanupLegacyRootDts:k,patchJsOrTsConfig:C,attemptViteAutoImportPatch:L,injectUniversalRuntime:R,runFullSetup:se}});var m=require("fs"),y=require("path"),J=require("https"),{runFullSetup:re,handleAuthAndEnv:le,touchTsConfig:ie,attemptViteAutoImportPatch:ae,injectUniversalRuntime:ce}=N(),be="\x1B[34m",pe="\x1B[31m",$="\x1B[0m";function d(t){console.log(`${be}${t}${$}`)}function h(t){console.error(`${pe}${t}${$}`)}function fe(t,o){return new Promise((n,s)=>{let r=JSON.stringify({enterpriseID:t,schema:o}),b={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},e=J.request(b,a=>{let l="";a.on("data",c=>{l+=c}),a.on("end",()=>{a.statusCode>=200&&a.statusCode<300?n(JSON.parse(l)):s(new Error(`Edge sync failed with HTTP ${a.statusCode}`))})});e.on("error",a=>s(a)),e.write(r),e.end()})}function de(t){let o=y.join(t,".env");if(!m.existsSync(o))return{};let n=m.readFileSync(o,"utf8"),s={};return n.split(`
161
- `).forEach(r=>{let[b,...e]=r.split("=");b&&e.length>0&&(s[b.trim()]=e.join("=").trim())}),s}function ue(t){return new Promise((o,n)=>{let s=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),r={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},b=J.request(r,e=>{let a="";e.on("data",l=>{a+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let l=JSON.parse(a);if(l.success&&l.found&&l.module){let c=l.module.code||l.module.mockCode;o(typeof c=="string"?JSON.parse(c):c)}else n(new Error("Schema not found in Fleetbo Cloud."))}catch{n(new Error("Invalid JSON response received from Fleetbo server."))}else n(new Error(`Server error ${e.statusCode}`))})});b.on("error",e=>n(e)),b.write(s),b.end()})}var w=process.argv.slice(2),I=w[0];async function me(){let t=process.cwd(),o=y.join(t,"package.json");if(I==="init"||I==="doctor")d(`
162
- [Fleetbo] Initializing and configuring Fleetbo...`),await le(t,w),re(t,o),d(`
156
+ }),`;if(e=e.slice(0,c)+P+e.slice(c),!e.includes("import AutoImport")){let T=[...e.matchAll(/^import .+;?$/gm)].pop(),S=`import AutoImport from 'unplugin-auto-import/vite';
157
+ `;if(T){let E=T.index+T[0].length;e=e.slice(0,E)+`
158
+ `+S+e.slice(E)}else e=S+e}}}if(!e.includes("fleetbo-auto-runtime")){let l=e.match(/plugins\s*:\s*\[/);if(l){let c=l.index+l[0].length;e=e.slice(0,c)+`
159
+ `+a+e.slice(c)}}e!==r&&i.writeFileSync(s,e)}function re(t){let n=p.join(t,".vscode"),o=p.join(n,"settings.json");try{i.existsSync(n)||i.mkdirSync(n,{recursive:!0});let s={};if(i.existsSync(o))try{s=JSON.parse(i.readFileSync(o,"utf8"))}catch{s={}}s["workbench.colorCustomizations"]=s["workbench.colorCustomizations"]||{},s["workbench.colorCustomizations"]["editorInfo.foreground"]="#00feae",s["workbench.colorCustomizations"]["editorHint.foreground"]="#00feae",i.writeFileSync(o,JSON.stringify(s,null,2)+`
160
+ `),f("\u2192 Configured Fleetbo Cyan visual hints in .vscode/settings.json.")}catch{}}function le(t,n,o={}){let{skipSelfInstall:s=!1}=o,r=p.join(__dirname,"..");s||G(t,n),Q(t),Z(t),te(r),ee(t),re(t),_(t),C(t,n),L(t,n),R(t)}$.exports={touchTsConfig:oe,log:f,logError:d,handleAuthAndEnv:se,detectDependency:O,cleanupLegacyRootDts:_,patchJsOrTsConfig:C,attemptViteAutoImportPatch:L,injectUniversalRuntime:R,runFullSetup:le}});var m=require("fs"),y=require("path"),J=require("https"),{runFullSetup:ie,handleAuthAndEnv:ae,touchTsConfig:ce,attemptViteAutoImportPatch:be,injectUniversalRuntime:pe}=N(),fe="\x1B[34m",de="\x1B[31m",D="\x1B[0m";function u(t){console.log(`${fe}${t}${D}`)}function h(t){console.error(`${de}${t}${D}`)}function ue(t,n){return new Promise((o,s)=>{let r=JSON.stringify({enterpriseID:t,schema:n}),b={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},e=J.request(b,a=>{let l="";a.on("data",c=>{l+=c}),a.on("end",()=>{a.statusCode>=200&&a.statusCode<300?o(JSON.parse(l)):s(new Error(`Edge sync failed with HTTP ${a.statusCode}`))})});e.on("error",a=>s(a)),e.write(r),e.end()})}function me(t){let n=y.join(t,".env");if(!m.existsSync(n))return{};let o=m.readFileSync(n,"utf8"),s={};return o.split(`
161
+ `).forEach(r=>{let[b,...e]=r.split("=");b&&e.length>0&&(s[b.trim()]=e.join("=").trim())}),s}function ge(t){return new Promise((n,o)=>{let s=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),r={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},b=J.request(r,e=>{let a="";e.on("data",l=>{a+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let l=JSON.parse(a);if(l.success&&l.found&&l.module){let c=l.module.code||l.module.mockCode;n(typeof c=="string"?JSON.parse(c):c)}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}`))})});b.on("error",e=>o(e)),b.write(s),b.end()})}var k=process.argv.slice(2),I=k[0];async function Fe(){let t=process.cwd(),n=y.join(t,"package.json");if(I==="init"||I==="doctor")u(`
162
+ [Fleetbo] Initializing and configuring Fleetbo...`),await ae(t,k),ie(t,n),u(`
163
163
  [Fleetbo] Configuration completed successfully!
164
- `),d(`
165
- Next step:`),d(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
166
- `);else if(I==="sync"){let n=w.includes("--dry-run");d(`[Fleetbo] Syncing schema...${n?" (dry-run)":""}`);let s=y.join(t,"svro.schema.json"),r=y.join(__dirname,".."),b=y.join(r,"index.d.ts"),e=y.join(t,"src","fleetbo.d.ts"),l=de(t).VITE_FLEETBO_ENTERPRISE_ID;if(l)try{d("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let c=await ue(l);m.writeFileSync(s,JSON.stringify(c,null,2)+`
167
- `),d("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(c){h(`\u26A0\uFE0F Cloud fetch bypassed: ${c.message}. Using local file fallback.`)}else h("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");m.existsSync(s)||(h("Error: svro.schema.json not found."),process.exit(1));try{let c=JSON.parse(m.readFileSync(s,"utf8")),P=Object.keys(c.collections||{});if(l)try{await fe(l,c),d("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(g){h(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${g.message}`)}let T=c.collections||{},E=Object.entries(T).map(([g,j])=>{let B=j.fields||j.schema||{},U=Object.entries(B).map(([M,v])=>{let x="any",F=String(typeof v=="string"?v:v.type||"").toLowerCase();return F==="string"||F==="text"||F==="media"?x="string":F==="number"?x="number":F==="boolean"||F==="toggle"?x="boolean":F==="array"&&(x="any[]"),` ${M}?: ${x};`}).join(`
164
+ `),u(`
165
+ Next step:`),u(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
166
+ `);else if(I==="sync"){let o=k.includes("--dry-run");u(`[Fleetbo] Syncing schema...${o?" (dry-run)":""}`);let s=y.join(t,"svro.schema.json"),r=y.join(__dirname,".."),b=y.join(r,"index.d.ts"),e=y.join(t,"src","fleetbo.d.ts"),l=me(t).VITE_FLEETBO_ENTERPRISE_ID;if(l)try{u("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let c=await ge(l);m.writeFileSync(s,JSON.stringify(c,null,2)+`
167
+ `),u("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(c){h(`\u26A0\uFE0F Cloud fetch bypassed: ${c.message}. Using local file fallback.`)}else h("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");m.existsSync(s)||(h("Error: svro.schema.json not found."),process.exit(1));try{let c=JSON.parse(m.readFileSync(s,"utf8")),P=Object.keys(c.collections||{});if(l)try{await ue(l,c),u("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(g){h(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${g.message}`)}let T=c.collections||{},S=Object.entries(T).map(([g,w])=>{let U=w.fields||w.schema||{},B=Object.entries(U).map(([M,x])=>{let v="any",F=String(typeof x=="string"?x:x.type||"").toLowerCase();return F==="string"||F==="text"||F==="media"?v="string":F==="number"?v="number":F==="boolean"||F==="toggle"?v="boolean":F==="array"&&(v="any[]"),` ${M}?: ${v};`}).join(`
168
168
  `);return` ${g}: {
169
- ${U}
169
+ ${B}
170
170
  };`}).join(`
171
- `),S=P.length>0?P.map(g=>`'${g}'`).join(" | "):"string",A=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
171
+ `),E=P.length>0?P.map(g=>`'${g}'`).join(" | "):"string",A=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
172
172
 
173
173
  export interface FleetboSchemaMap {
174
- ${E}
174
+ ${S}
175
175
  }
176
176
 
177
- export type KnownFleetboTables = ${S};
177
+ export type KnownFleetboTables = ${E};
178
178
 
179
179
  export type FleetboTables =
180
180
  | KnownFleetboTables
@@ -436,11 +436,11 @@ type FleetboProp = {
436
436
  };
437
437
 
438
438
  interface FleetboSchemaMap {
439
- ${E}
439
+ ${S}
440
440
  }
441
441
 
442
442
  declare global {
443
- type KnownFleetboTables = ${S};
443
+ type KnownFleetboTables = ${E};
444
444
  type FleetboTables = KnownFleetboTables | (string & { _fleetboPending?: never });
445
445
  type FleetboData<T extends string> = T extends KnownFleetboTables
446
446
  ? Partial<FleetboSchemaMap[T]>
@@ -530,4 +530,4 @@ declare module 'svelte/elements' {
530
530
  'fleetbo-reference': FleetboProp;
531
531
  }
532
532
  }
533
- `;m.writeFileSync(e,g)}ie(t),ae(t,o),ce(t),d(`[Fleetbo] Schema synced successfully (${P.length} collection(s)).`),n&&d("\u2192 [Dry-run] Schema is valid.")}catch(c){h(`Error during synchronization: ${c.message}`),process.exit(1)}}else h('Unknown command. Usage: "npx fleetbo-svro init" or "npx fleetbo-svro sync"'),process.exit(1)}me().catch(t=>{h(`Fleetbo CLI Error: ${t.message}`),process.exit(1)});
533
+ `;m.writeFileSync(e,g)}ce(t),be(t,n),pe(t),u(`[Fleetbo] Schema synced successfully (${P.length} collection(s)).`),o&&u("\u2192 [Dry-run] Schema is valid.")}catch(c){h(`Error during synchronization: ${c.message}`),process.exit(1)}}else h('Unknown command. Usage: "npx fleetbo-svro init" or "npx fleetbo-svro sync"'),process.exit(1)}Fe().catch(t=>{h(`Fleetbo CLI Error: ${t.message}`),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-svro",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "exports": {