fleetbo-svro 1.0.22 → 1.0.24

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 +13 -52
  2. package/package.json +4 -4
package/dist/cli.cjs CHANGED
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  var J=(t,o)=>()=>{try{return o||t((o={exports:{}}).exports,o),o.exports}catch(n){throw o=0,n}};var _=J((le,w)=>{var c=require("fs"),p=require("path"),L=require("https"),{execSync:A}=require("child_process"),$="\x1B[38;2;231;233;237m",N="\x1B[31m",T="\x1B[0m";function f(t){console.log(` ${$}${t}${T}`)}function u(t){console.error(` ${N}${t}${T}`)}function D(t){let o={};return t.forEach(n=>{if(n.startsWith("--")){let[r,s]=n.slice(2).split("=");r&&s&&(o[r]=s)}}),o}function E(t,o){try{let n=JSON.parse(c.readFileSync(t,"utf8"));return!!(n.dependencies&&n.dependencies[o]||n.devDependencies&&n.devDependencies[o])}catch{return!1}}function U(t,o){if(!E(o,"fleetbo-svro")){f("\u2192 Installing fleetbo-svro into the project...");try{A("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 B(t){let o=p.join(t,"svro.schema.json");if(c.existsSync(o))return;let n=new Date().toISOString(),r={createdAt:n,patchedAt:n,schemaVersion:1,collections:{}};c.writeFileSync(o,JSON.stringify(r,null,2)+`
3
- `),f("\u2192 Created svro.schema.json at project root.")}function M(t){let o=p.join(t,"src");if(!c.existsSync(o))return;let n=p.join(o,"auto-imports.d.ts");if(c.existsSync(n))return;let r=`/* eslint-disable */
3
+ `),f("\u2192 Created svro.schema.json at project root.")}function M(t){let o=p.join(t,"src");if(!c.existsSync(o))return;let n=p.join(o,"fleetbo.d.ts");if(c.existsSync(n))return;let r=`/* eslint-disable */
4
4
  /* prettier-ignore */
5
5
  // @ts-nocheck
6
- // Generated by fleetbo-svro setup
7
6
  export {}
8
7
 
9
8
  type FleetboProp = {
@@ -72,45 +71,7 @@ declare module 'react' {
72
71
  }
73
72
  }
74
73
  }
75
-
76
- declare module '@vue/runtime-core' {
77
- export interface GlobalComponents {
78
- 'fleetbo-text': FleetboProp;
79
- 'fleetbo-number': FleetboProp;
80
- 'fleetbo-toggle': FleetboProp;
81
- 'fleetbo-date': FleetboProp;
82
- 'fleetbo-enum': FleetboProp;
83
- 'fleetbo-media': FleetboProp;
84
- 'fleetbo-reference': FleetboProp;
85
- }
86
- }
87
-
88
- declare module 'preact' {
89
- namespace JSX {
90
- interface IntrinsicElements {
91
- 'fleetbo-text': FleetboProp;
92
- 'fleetbo-number': FleetboProp;
93
- 'fleetbo-toggle': FleetboProp;
94
- 'fleetbo-date': FleetboProp;
95
- 'fleetbo-enum': FleetboProp;
96
- 'fleetbo-media': FleetboProp;
97
- 'fleetbo-reference': FleetboProp;
98
- }
99
- }
100
- }
101
-
102
- declare module 'svelte/elements' {
103
- export interface SvelteHTMLElements {
104
- 'fleetbo-text': FleetboProp;
105
- 'fleetbo-number': FleetboProp;
106
- 'fleetbo-toggle': FleetboProp;
107
- 'fleetbo-date': FleetboProp;
108
- 'fleetbo-enum': FleetboProp;
109
- 'fleetbo-media': FleetboProp;
110
- 'fleetbo-reference': FleetboProp;
111
- }
112
- }
113
- `;try{c.writeFileSync(n,r),f("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(s){u(`\u26A0\uFE0F Unable to create src/auto-imports.d.ts: ${s.message}`)}}function q(t){let o=p.join(t,"index.d.ts");c.existsSync(o)||f("\u2192 Verified index.d.ts presence.")}function V(t){let o=["tsconfig.json","jsconfig.json"];for(let n of o){let r=p.join(t,n);if(c.existsSync(r)){let s=new Date;c.utimesSync(r,s,s);break}}}function H(t){return new Promise((o,n)=>{let r=JSON.stringify({token:t}),s={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},b=L.request(s,e=>{let i="";e.on("data",l=>{i+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{o(JSON.parse(i))}catch{n(new Error("Invalid response received from Fleetbo server."))}else try{let l=JSON.parse(i);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(r),b.end()})}async function W(t,o=[]){let n=p.join(t,".env");if(c.existsSync(n)&&c.readFileSync(n,"utf8").includes("VITE_FLEETBO_DB_KEY")){f("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let r=D(o),s=r.keyApp,b=r.token||r.bootstrapToken,e=r.email||"";(!s||!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 i;try{i=await H(b)}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)}(!i.enterpriseId||!i.fleetboDBKey)&&(u("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let l=`
74
+ `;try{c.writeFileSync(n,r),f("\u2192 Created src/fleetbo.d.ts stub for instant IDE auto-completion.")}catch(s){u(`\u26A0\uFE0F Unable to create src/fleetbo.d.ts: ${s.message}`)}}function q(t){let o=p.join(t,"index.d.ts");c.existsSync(o)||f("\u2192 Verified index.d.ts presence.")}function V(t){let o=["tsconfig.json","jsconfig.json"];for(let n of o){let r=p.join(t,n);if(c.existsSync(r)){let s=new Date;c.utimesSync(r,s,s);break}}}function H(t){return new Promise((o,n)=>{let r=JSON.stringify({token:t}),s={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},b=L.request(s,e=>{let i="";e.on("data",l=>{i+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{o(JSON.parse(i))}catch{n(new Error("Invalid response received from Fleetbo server."))}else try{let l=JSON.parse(i);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(r),b.end()})}async function W(t,o=[]){let n=p.join(t,".env");if(c.existsSync(n)&&c.readFileSync(n,"utf8").includes("VITE_FLEETBO_DB_KEY")){f("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let r=D(o),s=r.keyApp,b=r.token||r.bootstrapToken,e=r.email||"";(!s||!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 i;try{i=await H(b)}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)}(!i.enterpriseId||!i.fleetboDBKey)&&(u("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let l=`
114
75
  VITE_FLEETBO_DB_KEY=${i.fleetboDBKey}
115
76
  VITE_FLEETBO_ENTERPRISE_ID=${i.enterpriseId}
116
77
  VITE_FLEETBO_KEY_APP=${s}
@@ -170,23 +131,23 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
170
131
  watch: {
171
132
  ignored: ['**/svro.schema.json', '**/src/auto-imports.d.ts']
172
133
  }
173
- },`))),!e.includes("unplugin-auto-import")){let l=e.match(/plugins\s*:\s*\[/);if(l){let a=l.index+l[0].length,y=`
134
+ },`))),!e.includes("unplugin-auto-import")){let l=e.match(/plugins\s*:\s*\[/);if(l){let a=l.index+l[0].length,h=`
174
135
  AutoImport({
175
136
  imports: [{ '${b}': ['Fleetbo', 'FleetboUI'] }],
176
137
  dts: 'src/auto-imports.d.ts'
177
- }),`;if(e=e.slice(0,a)+y+e.slice(a),!e.includes("import AutoImport")){let h=[...e.matchAll(/^import .+;?$/gm)].pop(),v=`import AutoImport from 'unplugin-auto-import/vite';
178
- `;if(h){let m=h.index+h[0].length;e=e.slice(0,m)+`
138
+ }),`;if(e=e.slice(0,a)+h+e.slice(a),!e.includes("import AutoImport")){let P=[...e.matchAll(/^import .+;?$/gm)].pop(),v=`import AutoImport from 'unplugin-auto-import/vite';
139
+ `;if(P){let m=P.index+P[0].length;e=e.slice(0,m)+`
179
140
  `+v+e.slice(m)}else e=v+e}}}if(!e.includes("fleetbo-auto-runtime")){let l=e.match(/plugins\s*:\s*\[/);if(l){let a=l.index+l[0].length;e=e.slice(0,a)+`
180
- `+i+e.slice(a)}}e!==s&&c.writeFileSync(r,e)}function X(t,o,n={}){let{skipSelfInstall:r=!1}=n,s=p.join(__dirname,"..");r||U(t,o),B(t),q(s),M(t),O(t),I(t,o),k(t,o),j(t)}w.exports={touchTsConfig:V,log:f,logError:u,handleAuthAndEnv:W,detectDependency:E,cleanupLegacyRootDts:O,patchJsOrTsConfig:I,attemptViteAutoImportPatch:k,injectUniversalRuntime:j,runFullSetup:X}});var g=require("fs"),F=require("path"),R=require("https"),{runFullSetup:K,handleAuthAndEnv:G,touchTsConfig:Y,attemptViteAutoImportPatch:z,injectUniversalRuntime:Q}=_(),Z="\x1B[34m",ee="\x1B[31m",C="\x1B[0m";function d(t){console.log(`${Z}${t}${C}`)}function P(t){console.error(`${ee}${t}${C}`)}function te(t,o){return new Promise((n,r)=>{let s=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(s)}},e=R.request(b,i=>{let l="";i.on("data",a=>{l+=a}),i.on("end",()=>{i.statusCode>=200&&i.statusCode<300?n(JSON.parse(l)):r(new Error(`Edge sync failed with HTTP ${i.statusCode}`))})});e.on("error",i=>r(i)),e.write(s),e.end()})}function oe(t){let o=F.join(t,".env");if(!g.existsSync(o))return{};let n=g.readFileSync(o,"utf8"),r={};return n.split(`
181
- `).forEach(s=>{let[b,...e]=s.split("=");b&&e.length>0&&(r[b.trim()]=e.join("=").trim())}),r}function ne(t){return new Promise((o,n)=>{let r=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),s={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},b=R.request(s,e=>{let i="";e.on("data",l=>{i+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let l=JSON.parse(i);if(l.success&&l.found&&l.module){let a=l.module.code||l.module.mockCode;o(typeof a=="string"?JSON.parse(a):a)}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(r),b.end()})}var S=process.argv.slice(2),x=S[0];async function re(){let t=process.cwd(),o=F.join(t,"package.json");if(x==="init"||x==="doctor")d(`
182
- [Fleetbo] Initializing and configuring Fleetbo...`),await G(t,S),K(t,o),d(`
141
+ `+i+e.slice(a)}}e!==s&&c.writeFileSync(r,e)}function K(t,o,n={}){let{skipSelfInstall:r=!1}=n,s=p.join(__dirname,"..");r||U(t,o),B(t),q(s),M(t),O(t),I(t,o),k(t,o),j(t)}w.exports={touchTsConfig:V,log:f,logError:u,handleAuthAndEnv:W,detectDependency:E,cleanupLegacyRootDts:O,patchJsOrTsConfig:I,attemptViteAutoImportPatch:k,injectUniversalRuntime:j,runFullSetup:K}});var g=require("fs"),F=require("path"),R=require("https"),{runFullSetup:X,handleAuthAndEnv:Y,touchTsConfig:G,attemptViteAutoImportPatch:z,injectUniversalRuntime:Q}=_(),Z="\x1B[34m",ee="\x1B[31m",C="\x1B[0m";function d(t){console.log(`${Z}${t}${C}`)}function y(t){console.error(`${ee}${t}${C}`)}function te(t,o){return new Promise((n,r)=>{let s=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(s)}},e=R.request(b,i=>{let l="";i.on("data",a=>{l+=a}),i.on("end",()=>{i.statusCode>=200&&i.statusCode<300?n(JSON.parse(l)):r(new Error(`Edge sync failed with HTTP ${i.statusCode}`))})});e.on("error",i=>r(i)),e.write(s),e.end()})}function oe(t){let o=F.join(t,".env");if(!g.existsSync(o))return{};let n=g.readFileSync(o,"utf8"),r={};return n.split(`
142
+ `).forEach(s=>{let[b,...e]=s.split("=");b&&e.length>0&&(r[b.trim()]=e.join("=").trim())}),r}function ne(t){return new Promise((o,n)=>{let r=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),s={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},b=R.request(s,e=>{let i="";e.on("data",l=>{i+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let l=JSON.parse(i);if(l.success&&l.found&&l.module){let a=l.module.code||l.module.mockCode;o(typeof a=="string"?JSON.parse(a):a)}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(r),b.end()})}var x=process.argv.slice(2),S=x[0];async function re(){let t=process.cwd(),o=F.join(t,"package.json");if(S==="init"||S==="doctor")d(`
143
+ [Fleetbo] Initializing and configuring Fleetbo...`),await Y(t,x),X(t,o),d(`
183
144
  [Fleetbo] Configuration completed successfully!
184
145
  `),d(`
185
146
  Next step:`),d(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
186
- `);else if(x==="sync"){let n=S.includes("--dry-run");d(`[Fleetbo] Syncing schema...${n?" (dry-run)":""}`);let r=F.join(t,"svro.schema.json"),s=F.join(__dirname,".."),b=F.join(s,"index.d.ts"),e=F.join(t,"src","auto-imports.d.ts"),l=oe(t).VITE_FLEETBO_ENTERPRISE_ID;if(l)try{d("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let a=await ne(l);g.writeFileSync(r,JSON.stringify(a,null,2)+`
187
- `),d("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(a){P(`\u26A0\uFE0F Cloud fetch bypassed: ${a.message}. Using local file fallback.`)}else P("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");g.existsSync(r)||(P("Error: svro.schema.json not found."),process.exit(1));try{let a=JSON.parse(g.readFileSync(r,"utf8")),y=Object.keys(a.collections||{});if(l)try{await te(l,a),d("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(m){P(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${m.message}`)}let h=y.length>0?y.map(m=>`'${m}'`).join(" | "):"string",v=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
147
+ `);else if(S==="sync"){let n=x.includes("--dry-run");d(`[Fleetbo] Syncing schema...${n?" (dry-run)":""}`);let r=F.join(t,"svro.schema.json"),s=F.join(__dirname,".."),b=F.join(s,"index.d.ts"),e=F.join(t,"src","fleetbo.d.ts"),l=oe(t).VITE_FLEETBO_ENTERPRISE_ID;if(l)try{d("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let a=await ne(l);g.writeFileSync(r,JSON.stringify(a,null,2)+`
148
+ `),d("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(a){y(`\u26A0\uFE0F Cloud fetch bypassed: ${a.message}. Using local file fallback.`)}else y("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");g.existsSync(r)||(y("Error: svro.schema.json not found."),process.exit(1));try{let a=JSON.parse(g.readFileSync(r,"utf8")),h=Object.keys(a.collections||{});if(l)try{await te(l,a),d("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(m){y(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${m.message}`)}let P=h.length>0?h.map(m=>`'${m}'`).join(" | "):"string",v=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
188
149
 
189
- export type FleetboTables = ${h};
150
+ export type FleetboTables = ${P};
190
151
 
191
152
  declare global {
192
153
  interface ImportMetaEnv {
@@ -418,7 +379,7 @@ type FleetboProp = {
418
379
  };
419
380
 
420
381
  declare global {
421
- type FleetboTables = ${h};
382
+ type FleetboTables = ${P};
422
383
  const Fleetbo: typeof import('fleetbo-svro')['Fleetbo'];
423
384
 
424
385
  namespace JSX {
@@ -499,4 +460,4 @@ declare module 'svelte/elements' {
499
460
  'fleetbo-reference': FleetboProp;
500
461
  }
501
462
  }
502
- `;g.writeFileSync(e,m)}Y(t),z(t,o),Q(t),d(`[Fleetbo] Schema synced successfully (${y.length} collection(s)).`),n&&d("\u2192 [Dry-run] Schema is valid.")}catch(a){P(`Error during synchronization: ${a.message}`),process.exit(1)}}else P('Unknown command. Usage: "npx fleetbo-svro init" or "npx fleetbo-svro sync"'),process.exit(1)}re().catch(t=>{P(`Fleetbo CLI Error: ${t.message}`),process.exit(1)});
463
+ `;g.writeFileSync(e,m)}G(t),z(t,o),Q(t),d(`[Fleetbo] Schema synced successfully (${h.length} collection(s)).`),n&&d("\u2192 [Dry-run] Schema is valid.")}catch(a){y(`Error during synchronization: ${a.message}`),process.exit(1)}}else y('Unknown command. Usage: "npx fleetbo-svro init" or "npx fleetbo-svro sync"'),process.exit(1)}re().catch(t=>{y(`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.22",
3
+ "version": "1.0.24",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -8,9 +8,9 @@
8
8
  },
9
9
  "types": "index.d.ts",
10
10
  "bin": {
11
- "fleetbo-svro": "./dist/cli.cjs",
12
- "fleetbo": "./dist/cli.cjs",
13
- "svro": "./dist/cli.cjs"
11
+ "fleetbo-svro": "dist/cli.cjs",
12
+ "fleetbo": "dist/cli.cjs",
13
+ "svro": "dist/cli.cjs"
14
14
  },
15
15
  "scripts": {
16
16
  "build:pkg": "node package-build.js",