fleetbo-svro 1.0.7 → 1.0.9

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 +111 -130
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -1,10 +1,20 @@
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
+ #!/usr/bin/env node
3
+ 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)+`
4
+ `),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
5
  /* prettier-ignore */
5
6
  // @ts-nocheck
6
7
  // Generated by fleetbo-svro setup
7
8
  export {}
9
+
10
+ type FleetboTextProps = { value?: any; fallback?: string; class?: string; className?: string; children?: any; [key: string]: any };
11
+ type FleetboNumberProps = { value?: any; 'invalid-fallback'?: string; currency?: string; class?: string; className?: string; [key: string]: any };
12
+ type FleetboToggleProps = { value?: any; 'label-true'?: string; 'label-false'?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
13
+ type FleetboDateProps = { value?: any; locale?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
14
+ type FleetboEnumProps = { value?: any; allowed?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
15
+ type FleetboMediaProps = { value?: any; alt?: string; fallback?: string; class?: string; className?: string; [key: string]: any };
16
+ type FleetboRefProps = { table: any; id?: string; field?: string; 'orphan-fallback'?: string; 'loading-fallback'?: string; 'malformed-fallback'?: string; class?: string; className?: string; [key: string]: any };
17
+
8
18
  declare global {
9
19
  type FleetboTables = string;
10
20
  const Fleetbo: typeof import('fleetbo-svro')['Fleetbo'];
@@ -12,62 +22,43 @@ declare global {
12
22
 
13
23
  namespace JSX {
14
24
  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
- };
25
+ 'fleetbo-text': FleetboTextProps;
26
+ 'fleetbo-number': FleetboNumberProps;
27
+ 'fleetbo-toggle': FleetboToggleProps;
28
+ 'fleetbo-date': FleetboDateProps;
29
+ 'fleetbo-enum': FleetboEnumProps;
30
+ 'fleetbo-media': FleetboMediaProps;
31
+ 'fleetbo-reference': FleetboRefProps;
32
+ }
33
+ }
34
+
35
+ namespace React.JSX {
36
+ interface IntrinsicElements {
37
+ 'fleetbo-text': FleetboTextProps;
38
+ 'fleetbo-number': FleetboNumberProps;
39
+ 'fleetbo-toggle': FleetboToggleProps;
40
+ 'fleetbo-date': FleetboDateProps;
41
+ 'fleetbo-enum': FleetboEnumProps;
42
+ 'fleetbo-media': FleetboMediaProps;
43
+ 'fleetbo-reference': FleetboRefProps;
44
+ }
45
+ }
46
+ }
47
+
48
+ declare module 'react' {
49
+ namespace JSX {
50
+ interface IntrinsicElements {
51
+ 'fleetbo-text': FleetboTextProps;
52
+ 'fleetbo-number': FleetboNumberProps;
53
+ 'fleetbo-toggle': FleetboToggleProps;
54
+ 'fleetbo-date': FleetboDateProps;
55
+ 'fleetbo-enum': FleetboEnumProps;
56
+ 'fleetbo-media': FleetboMediaProps;
57
+ 'fleetbo-reference': FleetboRefProps;
67
58
  }
68
59
  }
69
60
  }
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
61
+ `;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
62
 
72
63
  export type FleetboTables = string;
73
64
 
@@ -241,13 +232,13 @@ declare global {
241
232
  FleetboUI: typeof FleetboUI;
242
233
  }
243
234
  }
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}
235
+ `),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=`
236
+ VITE_FLEETBO_DB_KEY=${a.fleetboDBKey}
237
+ VITE_FLEETBO_ENTERPRISE_ID=${a.enterpriseId}
238
+ VITE_FLEETBO_KEY_APP=${l}
248
239
  ${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=`{
240
+ `:""}`;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)+`
241
+ `),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
242
  name: 'fleetbo-schema-sync-middleware',
252
243
  configureServer(server) {
253
244
  server.middlewares.use('/__fleetbo_sync_schema', (req, res) => {
@@ -290,24 +281,24 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
290
281
  watch: {
291
282
  ignored: ['**/svro.schema.json', '**/src/auto-imports.d.ts']
292
283
  }
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=`
284
+ },`))),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
285
  AutoImport({
295
- imports: [{ '${d}': ['Fleetbo', 'FleetboUI'] }],
286
+ imports: [{ '${b}': ['Fleetbo', 'FleetboUI'] }],
296
287
  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(`
288
+ }),`;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';
289
+ `;if(T){let p=T.index+T[0].length;e=e.slice(0,p)+`
290
+ `+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)+`
291
+ `+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)+`
292
+ `),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(`
293
+ `).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(`
294
+ [Fleetbo] Initializing and configuring Fleetbo...`),await Y(t,I),K(t,n),u(`
304
295
  [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
296
+ `),u(`
297
+ Next step:`),u(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
298
+ `);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)+`
299
+ `),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
300
 
310
- export type FleetboTables = ${v};
301
+ export type FleetboTables = ${T};
311
302
 
312
303
  declare global {
313
304
  interface ImportMetaEnv {
@@ -479,71 +470,61 @@ declare global {
479
470
  FleetboUI: typeof FleetboUI;
480
471
  }
481
472
  }
482
- `;if(p.writeFileSync(d,T),p.existsSync(y.dirname(e))){let m=`/* eslint-disable */
473
+ `;if(m.writeFileSync(b,v),m.existsSync(y.dirname(e))){let p=`/* eslint-disable */
483
474
  /* prettier-ignore */
484
475
  // @ts-nocheck
485
476
  // Generated by fleetbo-svro \u2014 Updated via fleetbo sync
486
477
  export {}
478
+
479
+ type FleetboTextProps = { value?: any; fallback?: string; class?: string; className?: string; children?: any; [key: string]: any };
480
+ type FleetboNumberProps = { value?: any; 'invalid-fallback'?: string; currency?: string; class?: string; className?: string; [key: string]: any };
481
+ type FleetboToggleProps = { value?: any; 'label-true'?: string; 'label-false'?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
482
+ type FleetboDateProps = { value?: any; locale?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
483
+ type FleetboEnumProps = { value?: any; allowed?: string; 'invalid-fallback'?: string; class?: string; className?: string; [key: string]: any };
484
+ type FleetboMediaProps = { value?: any; alt?: string; fallback?: string; class?: string; className?: string; [key: string]: any };
485
+ type FleetboRefProps = { table: any; id?: string; field?: string; 'orphan-fallback'?: string; 'loading-fallback'?: string; 'malformed-fallback'?: string; class?: string; className?: string; [key: string]: any };
486
+
487
487
  declare global {
488
- type FleetboTables = ${v};
488
+ type FleetboTables = ${T};
489
489
  const Fleetbo: typeof import('fleetbo-svro')['Fleetbo'];
490
490
  const FleetboUI: typeof import('fleetbo-svro')['FleetboUI'];
491
491
 
492
492
  namespace JSX {
493
493
  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
- };
494
+ 'fleetbo-text': FleetboTextProps;
495
+ 'fleetbo-number': FleetboNumberProps;
496
+ 'fleetbo-toggle': FleetboToggleProps;
497
+ 'fleetbo-date': FleetboDateProps;
498
+ 'fleetbo-enum': FleetboEnumProps;
499
+ 'fleetbo-media': FleetboMediaProps;
500
+ 'fleetbo-reference': FleetboRefProps;
501
+ }
502
+ }
503
+
504
+ namespace React.JSX {
505
+ interface IntrinsicElements {
506
+ 'fleetbo-text': FleetboTextProps;
507
+ 'fleetbo-number': FleetboNumberProps;
508
+ 'fleetbo-toggle': FleetboToggleProps;
509
+ 'fleetbo-date': FleetboDateProps;
510
+ 'fleetbo-enum': FleetboEnumProps;
511
+ 'fleetbo-media': FleetboMediaProps;
512
+ 'fleetbo-reference': FleetboRefProps;
513
+ }
514
+ }
515
+ }
516
+
517
+ declare module 'react' {
518
+ namespace JSX {
519
+ interface IntrinsicElements {
520
+ 'fleetbo-text': FleetboTextProps;
521
+ 'fleetbo-number': FleetboNumberProps;
522
+ 'fleetbo-toggle': FleetboToggleProps;
523
+ 'fleetbo-date': FleetboDateProps;
524
+ 'fleetbo-enum': FleetboEnumProps;
525
+ 'fleetbo-media': FleetboMediaProps;
526
+ 'fleetbo-reference': FleetboRefProps;
546
527
  }
547
528
  }
548
529
  }
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)});
530
+ `;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.7",
3
+ "version": "1.0.9",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "types": "index.d.ts",