fleetbo-svro 1.0.8 → 1.0.10

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 +110 -130
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -1,10 +1,19 @@
1
1
  #!/usr/bin/env node
2
- var U=(t,n)=>()=>{try{return n||t((n={exports:{}}).exports,n),n.exports}catch(o){throw n=0,o}};var w=U((ne,R)=>{var c=require("fs"),g=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 u(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{u("\u26A0\uFE0F Automatic installation failed. Please run 'npm install fleetbo-svro' manually.")}}}function J(t){let n=g.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
- `),b("\u2192 Created svro.schema.json at project root.")}function M(t){let n=g.join(t,"src");if(!c.existsSync(n))return;let o=g.join(n,"auto-imports.d.ts");if(c.existsSync(o))return;let r=`/* eslint-disable */
2
+ var U=(t,n)=>()=>{try{return n||t((n={exports:{}}).exports,n),n.exports}catch(o){throw n=0,o}};var N=U((ne,R)=>{var c=require("fs"),d=require("path"),D=require("https"),{execSync:j}=require("child_process"),C="\x1B[38;2;231;233;237m",L="\x1B[31m",S="\x1B[0m";function g(t){console.log(` ${C}${t}${S}`)}function f(t){console.error(` ${L}${t}${S}`)}function A(t){let n={};return t.forEach(o=>{if(o.startsWith("--")){let[r,l]=o.slice(2).split("=");r&&l&&(n[r]=l)}}),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 M(t,n){if(!E(n,"fleetbo-svro")){g("\u2192 Installing fleetbo-svro into the project...");try{j("npm install fleetbo-svro",{cwd:t,stdio:"inherit"}),g("fleetbo-svro installed successfully!")}catch{f("\u26A0\uFE0F Automatic installation failed. Please run 'npm install fleetbo-svro' manually.")}}}function J(t){let n=d.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
+ `),g("\u2192 Created svro.schema.json at project root.")}function $(t){let n=d.join(t,"src");if(!c.existsSync(n))return;let o=d.join(n,"auto-imports.d.ts");if(c.existsSync(o))return;let r=`/* eslint-disable */
4
4
  /* prettier-ignore */
5
5
  // @ts-nocheck
6
6
  // Generated by fleetbo-svro setup
7
7
  export {}
8
+
9
+ type FleetboTextProps = { value?: any; fallback?: string; class?: string; className?: string; children?: any; [key: string]: any };
10
+ type FleetboNumberProps = { value?: any; 'invalid-fallback'?: string; currency?: string; class?: string; className?: string; [key: string]: any };
11
+ type FleetboToggleProps = { value?: any; 'label-true'?: string; 'label-false'?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
12
+ type FleetboDateProps = { value?: any; locale?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
13
+ type FleetboEnumProps = { value?: any; allowed?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
14
+ type FleetboMediaProps = { value?: any; alt?: string; fallback?: string; class?: string; className?: string; [key: string]: any };
15
+ type FleetboRefProps = { table: any; id?: string; field?: string; 'orphan-fallback'?: string; 'loading-fallback'?: string; 'malformed-fallback'?: string; class?: string; className?: string; [key: string]: any };
16
+
8
17
  declare global {
9
18
  type FleetboTables = string;
10
19
  const Fleetbo: typeof import('fleetbo-svro')['Fleetbo'];
@@ -12,62 +21,43 @@ declare global {
12
21
 
13
22
  namespace JSX {
14
23
  interface IntrinsicElements {
15
- 'fleetbo-text': {
16
- value?: any;
17
- fallback?: string;
18
- class?: string;
19
- className?: string;
20
- };
21
- 'fleetbo-number': {
22
- value?: any;
23
- 'invalid-fallback'?: string;
24
- currency?: string;
25
- class?: string;
26
- className?: string;
27
- };
28
- 'fleetbo-toggle': {
29
- value?: any;
30
- 'label-true'?: string;
31
- 'label-false'?: string;
32
- 'invalid-fallback'?: string;
33
- class?: string;
34
- className?: string;
35
- };
36
- 'fleetbo-date': {
37
- value?: any;
38
- locale?: string;
39
- 'invalid-fallback'?: string;
40
- class?: string;
41
- className?: string;
42
- };
43
- 'fleetbo-enum': {
44
- value?: any;
45
- allowed?: string;
46
- 'invalid-fallback'?: string;
47
- class?: string;
48
- className?: string;
49
- };
50
- 'fleetbo-media': {
51
- value?: any;
52
- alt?: string;
53
- fallback?: string;
54
- class?: string;
55
- className?: string;
56
- };
57
- 'fleetbo-reference': {
58
- table: FleetboTables;
59
- id?: string;
60
- field?: string;
61
- 'orphan-fallback'?: string;
62
- 'loading-fallback'?: string;
63
- 'malformed-fallback'?: string;
64
- class?: string;
65
- className?: string;
66
- };
24
+ 'fleetbo-text': FleetboTextProps;
25
+ 'fleetbo-number': FleetboNumberProps;
26
+ 'fleetbo-toggle': FleetboToggleProps;
27
+ 'fleetbo-date': FleetboDateProps;
28
+ 'fleetbo-enum': FleetboEnumProps;
29
+ 'fleetbo-media': FleetboMediaProps;
30
+ 'fleetbo-reference': FleetboRefProps;
31
+ }
32
+ }
33
+
34
+ namespace React.JSX {
35
+ interface IntrinsicElements {
36
+ 'fleetbo-text': FleetboTextProps;
37
+ 'fleetbo-number': FleetboNumberProps;
38
+ 'fleetbo-toggle': FleetboToggleProps;
39
+ 'fleetbo-date': FleetboDateProps;
40
+ 'fleetbo-enum': FleetboEnumProps;
41
+ 'fleetbo-media': FleetboMediaProps;
42
+ 'fleetbo-reference': FleetboRefProps;
43
+ }
44
+ }
45
+ }
46
+
47
+ declare module 'react' {
48
+ namespace JSX {
49
+ interface IntrinsicElements {
50
+ 'fleetbo-text': FleetboTextProps;
51
+ 'fleetbo-number': FleetboNumberProps;
52
+ 'fleetbo-toggle': FleetboToggleProps;
53
+ 'fleetbo-date': FleetboDateProps;
54
+ 'fleetbo-enum': FleetboEnumProps;
55
+ 'fleetbo-media': FleetboMediaProps;
56
+ 'fleetbo-reference': FleetboRefProps;
67
57
  }
68
58
  }
69
59
  }
70
- `;try{c.writeFileSync(o,r),b("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(i){u(`\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=g.join(t,o);if(c.existsSync(r)){let i=new Date;c.utimesSync(r,i,i);break}}}function W(t){let n=g.join(t,"index.d.ts");if(c.existsSync(n))return;c.writeFileSync(n,`// File generated/synchronized by fleetbo-svro \u2014 do not edit manually
60
+ `;try{c.writeFileSync(o,r),g("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(l){f(`\u26A0\uFE0F Unable to create src/auto-imports.d.ts: ${l.message}`)}}function B(t){let n=["tsconfig.json","jsconfig.json"];for(let o of n){let r=d.join(t,o);if(c.existsSync(r)){let l=new Date;c.utimesSync(r,l,l);break}}}function W(t){let n=d.join(t,"index.d.ts");if(c.existsSync(n))return;c.writeFileSync(n,`// File generated/synchronized by fleetbo-svro \u2014 do not edit manually
71
61
 
72
62
  export type FleetboTables = string;
73
63
 
@@ -241,13 +231,13 @@ declare global {
241
231
  FleetboUI: typeof FleetboUI;
242
232
  }
243
233
  }
244
- `),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=g.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)&&(u("\u26A0\uFE0F Missing required parameters."),u("\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){u(`\u26A0\uFE0F Token exchange failed: ${a.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)}(!l.enterpriseId||!l.fleetboDBKey)&&(u("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let s=`
245
- VITE_FLEETBO_DB_KEY=${l.fleetboDBKey}
246
- VITE_FLEETBO_ENTERPRISE_ID=${l.enterpriseId}
247
- VITE_FLEETBO_KEY_APP=${i}
234
+ `),g("\u2192 Initialized index.d.ts.")}function q(t){return new Promise((n,o)=>{let r=JSON.stringify({token:t}),l={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},b=D.request(l,e=>{let a="";e.on("data",s=>{a+=s}),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 s=JSON.parse(a);o(new Error(s.error||`Server error ${e.statusCode}`))}catch{o(new Error(`Server error ${e.statusCode}`))}})});b.on("error",e=>o(e)),b.write(r),b.end()})}async function H(t,n=[]){let o=d.join(t,".env");if(c.existsSync(o)&&c.readFileSync(o,"utf8").includes("VITE_FLEETBO_DB_KEY")){g("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let r=A(n),l=r.keyApp,b=r.token||r.bootstrapToken,e=r.email||"";(!l||!b)&&(f("\u26A0\uFE0F Missing required parameters."),f("\u{1F449} Usage: npx fleetbo-svro init --keyApp=YOUR_KEY --token=YOUR_TOKEN"),process.exit(1)),g("\u2192 Exchanging bootstrap token for project keys...");let a;try{a=await q(b)}catch(i){f(`\u26A0\uFE0F Token exchange failed: ${i.message}`),f("\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)&&(f("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let s=`
235
+ VITE_FLEETBO_DB_KEY=${a.fleetboDBKey}
236
+ VITE_FLEETBO_ENTERPRISE_ID=${a.enterpriseId}
237
+ VITE_FLEETBO_KEY_APP=${l}
248
238
  ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
249
- `:""}`;c.appendFileSync(o,s),b(".env file updated successfully with Fleetbo keys!")}function O(t){let n=g.join(t,"svro.d.ts");if(c.existsSync(n))try{c.unlinkSync(n),b("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function k(t,n){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let o=g.join(t,"tsconfig.json"),r=g.join(t,"jsconfig.json"),i=c.existsSync(o)?o:r,d=!c.existsSync(i),e={};if(!d)try{e=JSON.parse(c.readFileSync(i,"utf8"))}catch{u(`\u26A0\uFE0F Unable to read ${g.basename(i)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let l=!1,s=E(n,"react"),a=E(n,"vite");d?(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=e.include||["src"],l=!0):(e.compilerOptions.checkJs===void 0&&(e.compilerOptions.checkJs=!0,l=!0),e.compilerOptions.allowJs===void 0&&(e.compilerOptions.allowJs=!0,l=!0)),s&&e.compilerOptions.jsx===void 0&&(e.compilerOptions.jsx="react-jsx",l=!0),a&&e.compilerOptions.types===void 0&&(e.compilerOptions.types=["vite/client"],l=!0),l&&(c.writeFileSync(i,JSON.stringify(e,null,2)+`
250
- `),b(`\u2192 Updated ${g.basename(i)}.`))}function P(t,n){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let r=["vite.config.ts","vite.config.js","vite.config.mjs"].map(s=>g.join(t,s)).find(s=>c.existsSync(s));if(!r)return;let i;try{i=c.readFileSync(r,"utf8")}catch{return}let d="fleetbo-svro",e=i,l=`{
239
+ `:""}`;c.appendFileSync(o,s),g(".env file updated successfully with Fleetbo keys!")}function x(t){let n=d.join(t,"svro.d.ts");if(c.existsSync(n))try{c.unlinkSync(n),g("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function k(t,n){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let o=d.join(t,"tsconfig.json"),r=d.join(t,"jsconfig.json"),l=c.existsSync(o)?o:r,b=!c.existsSync(l),e={};if(!b)try{e=JSON.parse(c.readFileSync(l,"utf8"))}catch{f(`\u26A0\uFE0F Unable to read ${d.basename(l)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let a=!1,s=E(n,"react"),i=E(n,"vite");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=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)),s&&e.compilerOptions.jsx===void 0&&(e.compilerOptions.jsx="react-jsx",a=!0),i&&e.compilerOptions.types===void 0&&(e.compilerOptions.types=["vite/client"],a=!0),a&&(c.writeFileSync(l,JSON.stringify(e,null,2)+`
240
+ `),g(`\u2192 Updated ${d.basename(l)}.`))}function O(t,n){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let r=["vite.config.ts","vite.config.js","vite.config.mjs"].map(s=>d.join(t,s)).find(s=>c.existsSync(s));if(!r)return;let l;try{l=c.readFileSync(r,"utf8")}catch{return}let b="fleetbo-svro",e=l,a=`{
251
241
  name: 'fleetbo-schema-sync-middleware',
252
242
  configureServer(server) {
253
243
  server.middlewares.use('/__fleetbo_sync_schema', (req, res) => {
@@ -290,24 +280,24 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
290
280
  watch: {
291
281
  ignored: ['**/svro.schema.json', '**/src/auto-imports.d.ts']
292
282
  }
293
- },`))),e.includes("unplugin-auto-import"))e.includes("fleetbo-svro")&&!e.includes("FleetboUI")&&(e=e.replace(/imports\s*:\s*\[\s*\{\s*['"]fleetbo-svro(?:|\/vue)['"]\s*:\s*\[[^\]]*\]\s*\}\s*\]/g,`imports: [{ '${d}': ['Fleetbo', 'FleetboUI'] }]`));else{let s=e.match(/plugins\s*:\s*\[/);if(s){let a=s.index+s[0].length,F=`
283
+ },`))),e.includes("unplugin-auto-import"))e.includes("fleetbo-svro")&&!e.includes("FleetboUI")&&(e=e.replace(/imports\s*:\s*\[\s*\{\s*['"]fleetbo-svro(?:|\/vue)['"]\s*:\s*\[[^\]]*\]\s*\}\s*\]/g,`imports: [{ '${b}': ['Fleetbo', 'FleetboUI'] }]`));else{let s=e.match(/plugins\s*:\s*\[/);if(s){let i=s.index+s[0].length,h=`
294
284
  AutoImport({
295
- imports: [{ '${d}': ['Fleetbo', 'FleetboUI'] }],
285
+ imports: [{ '${b}': ['Fleetbo', 'FleetboUI'] }],
296
286
  dts: 'src/auto-imports.d.ts'
297
- }),`;if(e=e.slice(0,a)+F+e.slice(a),!e.includes("import AutoImport")){let v=[...e.matchAll(/^import .+;?$/gm)].pop(),T=`import AutoImport from 'unplugin-auto-import/vite';
298
- `;if(v){let m=v.index+v[0].length;e=e.slice(0,m)+`
299
- `+T+e.slice(m)}else e=T+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)+`
300
- `+l+e.slice(a)}}if(e!==i)try{c.writeFileSync(r,e),b(`\u2192 Updated ${g.basename(r)} with Watcher and AutoImport configuration.`)}catch(s){u(`\u26A0\uFE0F Failed to write to ${g.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)+`
301
- `),b("\u2192 Added unplugin-auto-import to devDependencies."))}catch(s){u(`\u26A0\uFE0F Failed to update ${g.basename(n)}: ${s.message}`)}}function V(t,n,o={}){let{skipSelfInstall:r=!1}=o,i=g.join(__dirname,"..");r||$(t,n),J(t),W(i),M(t),O(t),k(t,n),P(t,n)}R.exports={touchTsConfig:B,log:b,logError:u,handleAuthAndEnv:H,detectDependency:E,cleanupLegacyRootDts:O,patchJsOrTsConfig:k,attemptViteAutoImportPatch:P,runFullSetup:V}});var p=require("fs"),y=require("path"),N=require("https"),{runFullSetup:K,handleAuthAndEnv:Y,touchTsConfig:G}=w(),z="\x1B[34m",X="\x1B[31m",_="\x1B[0m";function f(t){console.log(`${z}${t}${_}`)}function h(t){console.error(`${X}${t}${_}`)}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=N.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(`
302
- `).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=N.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(`
303
- [Fleetbo] Initializing and configuring Fleetbo...`),await Y(t,S),K(t,n),f(`
287
+ }),`;if(e=e.slice(0,i)+h+e.slice(i),!e.includes("import AutoImport")){let T=[...e.matchAll(/^import .+;?$/gm)].pop(),v=`import AutoImport from 'unplugin-auto-import/vite';
288
+ `;if(T){let p=T.index+T[0].length;e=e.slice(0,p)+`
289
+ `+v+e.slice(p)}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,a),g("\u2192 Updated legacy Fleetbo middleware to modern ESM version."))}}else{let s=e.match(/plugins\s*:\s*\[/);if(s){let i=s.index+s[0].length;e=e.slice(0,i)+`
290
+ `+a+e.slice(i)}}if(e!==l)try{c.writeFileSync(r,e),g(`\u2192 Updated ${d.basename(r)} with Watcher and AutoImport configuration.`)}catch(s){f(`\u26A0\uFE0F Failed to write to ${d.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)+`
291
+ `),g("\u2192 Added unplugin-auto-import to devDependencies."))}catch(s){f(`\u26A0\uFE0F Failed to update ${d.basename(n)}: ${s.message}`)}}function V(t,n,o={}){let{skipSelfInstall:r=!1}=o,l=d.join(__dirname,"..");r||M(t,n),J(t),W(l),$(t),x(t),k(t,n),O(t,n)}R.exports={touchTsConfig:B,log:g,logError:f,handleAuthAndEnv:H,detectDependency:E,cleanupLegacyRootDts:x,patchJsOrTsConfig:k,attemptViteAutoImportPatch:O,runFullSetup:V}});var m=require("fs"),y=require("path"),w=require("https"),{runFullSetup:K,handleAuthAndEnv:Y,touchTsConfig:X}=N(),G="\x1B[34m",z="\x1B[31m",_="\x1B[0m";function u(t){console.log(`${G}${t}${_}`)}function F(t){console.error(`${z}${t}${_}`)}function Q(t,n){return new Promise((o,r)=>{let l=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(l)}},e=w.request(b,a=>{let s="";a.on("data",i=>{s+=i}),a.on("end",()=>{a.statusCode>=200&&a.statusCode<300?o(JSON.parse(s)):r(new Error(`Edge sync failed with HTTP ${a.statusCode}`))})});e.on("error",a=>r(a)),e.write(l),e.end()})}function Z(t){let n=y.join(t,".env");if(!m.existsSync(n))return{};let o=m.readFileSync(n,"utf8"),r={};return o.split(`
292
+ `).forEach(l=>{let[b,...e]=l.split("=");b&&e.length>0&&(r[b.trim()]=e.join("=").trim())}),r}function ee(t){return new Promise((n,o)=>{let r=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),l={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},b=w.request(l,e=>{let a="";e.on("data",s=>{a+=s}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let s=JSON.parse(a);if(s.success&&s.found&&s.module){let i=s.module.code||s.module.mockCode;n(typeof i=="string"?JSON.parse(i):i)}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(r),b.end()})}var I=process.argv.slice(2),P=I[0];async function te(){let t=process.cwd(),n=y.join(t,"package.json");if(P==="init"||P==="doctor")u(`
293
+ [Fleetbo] Initializing and configuring Fleetbo...`),await Y(t,I),K(t,n),u(`
304
294
  [Fleetbo] Configuration completed successfully!
305
- `),f(`
306
- Next step:`),f(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
307
- `);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)+`
308
- `),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 v=F.length>0?F.map(m=>`'${m}'`).join(" | "):"string",T=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sql sync
295
+ `),u(`
296
+ Next step:`),u(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
297
+ `);else if(P==="sync"){let o=I.includes("--dry-run");u(`[Fleetbo] Syncing schema...${o?" (dry-run)":""}`);let r=y.join(t,"svro.schema.json"),l=y.join(__dirname,".."),b=y.join(l,"index.d.ts"),e=y.join(t,"src","auto-imports.d.ts"),s=Z(t).VITE_FLEETBO_ENTERPRISE_ID;if(s)try{u("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let i=await ee(s);m.writeFileSync(r,JSON.stringify(i,null,2)+`
298
+ `),u("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(i){F(`\u26A0\uFE0F Cloud fetch bypassed: ${i.message}. Using local file fallback.`)}else F("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");m.existsSync(r)||(F("Error: svro.schema.json not found."),process.exit(1));try{let i=JSON.parse(m.readFileSync(r,"utf8")),h=Object.keys(i.collections||{});if(s)try{await Q(s,i),u("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(p){F(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${p.message}`)}let T=h.length>0?h.map(p=>`'${p}'`).join(" | "):"string",v=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sql sync
309
299
 
310
- export type FleetboTables = ${v};
300
+ export type FleetboTables = ${T};
311
301
 
312
302
  declare global {
313
303
  interface ImportMetaEnv {
@@ -479,71 +469,61 @@ declare global {
479
469
  FleetboUI: typeof FleetboUI;
480
470
  }
481
471
  }
482
- `;if(p.writeFileSync(d,T),p.existsSync(y.dirname(e))){let m=`/* eslint-disable */
472
+ `;if(m.writeFileSync(b,v),m.existsSync(y.dirname(e))){let p=`/* eslint-disable */
483
473
  /* prettier-ignore */
484
474
  // @ts-nocheck
485
475
  // Generated by fleetbo-svro \u2014 Updated via fleetbo sync
486
476
  export {}
477
+
478
+ type FleetboTextProps = { value?: any; fallback?: string; class?: string; className?: string; children?: any; [key: string]: any };
479
+ type FleetboNumberProps = { value?: any; 'invalid-fallback'?: string; currency?: string; class?: string; className?: string; [key: string]: any };
480
+ type FleetboToggleProps = { value?: any; 'label-true'?: string; 'label-false'?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
481
+ type FleetboDateProps = { value?: any; locale?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
482
+ type FleetboEnumProps = { value?: any; allowed?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
483
+ type FleetboMediaProps = { value?: any; alt?: string; fallback?: string; class?: string; className?: string; [key: string]: any };
484
+ type FleetboRefProps = { table: any; id?: string; field?: string; 'orphan-fallback'?: string; 'loading-fallback'?: string; 'malformed-fallback'?: string; class?: string; className?: string; [key: string]: any };
485
+
487
486
  declare global {
488
- type FleetboTables = ${v};
487
+ type FleetboTables = ${T};
489
488
  const Fleetbo: typeof import('fleetbo-svro')['Fleetbo'];
490
489
  const FleetboUI: typeof import('fleetbo-svro')['FleetboUI'];
491
490
 
492
491
  namespace JSX {
493
492
  interface IntrinsicElements {
494
- 'fleetbo-text': {
495
- value?: any;
496
- fallback?: string;
497
- class?: string;
498
- className?: string;
499
- };
500
- 'fleetbo-number': {
501
- value?: any;
502
- 'invalid-fallback'?: string;
503
- currency?: string;
504
- class?: string;
505
- className?: string;
506
- };
507
- 'fleetbo-toggle': {
508
- value?: any;
509
- 'label-true'?: string;
510
- 'label-false'?: string;
511
- 'invalid-fallback'?: string;
512
- class?: string;
513
- className?: string;
514
- };
515
- 'fleetbo-date': {
516
- value?: any;
517
- locale?: string;
518
- 'invalid-fallback'?: string;
519
- class?: string;
520
- className?: string;
521
- };
522
- 'fleetbo-enum': {
523
- value?: any;
524
- allowed?: string;
525
- 'invalid-fallback'?: string;
526
- class?: string;
527
- className?: string;
528
- };
529
- 'fleetbo-media': {
530
- value?: any;
531
- alt?: string;
532
- fallback?: string;
533
- class?: string;
534
- className?: string;
535
- };
536
- 'fleetbo-reference': {
537
- table: FleetboTables;
538
- id?: string;
539
- field?: string;
540
- 'orphan-fallback'?: string;
541
- 'loading-fallback'?: string;
542
- 'malformed-fallback'?: string;
543
- class?: string;
544
- className?: string;
545
- };
493
+ 'fleetbo-text': FleetboTextProps;
494
+ 'fleetbo-number': FleetboNumberProps;
495
+ 'fleetbo-toggle': FleetboToggleProps;
496
+ 'fleetbo-date': FleetboDateProps;
497
+ 'fleetbo-enum': FleetboEnumProps;
498
+ 'fleetbo-media': FleetboMediaProps;
499
+ 'fleetbo-reference': FleetboRefProps;
500
+ }
501
+ }
502
+
503
+ namespace React.JSX {
504
+ interface IntrinsicElements {
505
+ 'fleetbo-text': FleetboTextProps;
506
+ 'fleetbo-number': FleetboNumberProps;
507
+ 'fleetbo-toggle': FleetboToggleProps;
508
+ 'fleetbo-date': FleetboDateProps;
509
+ 'fleetbo-enum': FleetboEnumProps;
510
+ 'fleetbo-media': FleetboMediaProps;
511
+ 'fleetbo-reference': FleetboRefProps;
512
+ }
513
+ }
514
+ }
515
+
516
+ declare module 'react' {
517
+ namespace JSX {
518
+ interface IntrinsicElements {
519
+ 'fleetbo-text': FleetboTextProps;
520
+ 'fleetbo-number': FleetboNumberProps;
521
+ 'fleetbo-toggle': FleetboToggleProps;
522
+ 'fleetbo-date': FleetboDateProps;
523
+ 'fleetbo-enum': FleetboEnumProps;
524
+ 'fleetbo-media': FleetboMediaProps;
525
+ 'fleetbo-reference': FleetboRefProps;
546
526
  }
547
527
  }
548
528
  }
549
- `;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)});
529
+ `;m.writeFileSync(e,p)}X(t),u(`[Fleetbo] Schema synced successfully (${h.length} collection(s)).`),o&&u("\u2192 [Dry-run] Schema is valid.")}catch(i){F(`Error during synchronization: ${i.message}`),process.exit(1)}}else F('Unknown command. Usage: "npx fleetbo-svro init" or "npx fleetbo-svro sync"'),process.exit(1)}te().catch(t=>{F(`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.8",
3
+ "version": "1.0.10",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "types": "index.d.ts",