fleetbo-svro 1.0.0 → 1.0.2

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 +194 -73
  2. package/package.json +2 -2
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- var _=(t,s)=>()=>{try{return s||t((s={exports:{}}).exports,s),s.exports}catch(n){throw s=0,n}};var C=_((se,P)=>{var d=require("fs"),u=require("path"),U=require("https"),{execSync:j}=require("child_process"),A="\x1B[38;2;231;233;237m",D="\x1B[31m",I="\x1B[0m";function b(t){console.log(` ${A}${t}${I}`)}function p(t){console.error(` ${D}${t}${I}`)}function $(t){let s={};return t.forEach(n=>{if(n.startsWith("--")){let[r,a]=n.slice(2).split("=");r&&a&&(s[r]=a)}}),s}function T(t,s){try{let n=JSON.parse(d.readFileSync(t,"utf8"));return!!(n.dependencies&&n.dependencies[s]||n.devDependencies&&n.devDependencies[s])}catch{return!1}}function J(t,s){if(!T(s,"fleetbo-svro")){b("\u2192 Installing fleetbo-svro into the project...");try{j("npm install fleetbo-svro",{cwd:t,stdio:"inherit"}),b("fleetbo-svro installed successfully!")}catch{p("\u26A0\uFE0F Automatic installation failed. Please run 'npm install fleetbo-svro' manually.")}}}function L(t){let s=u.join(t,"svro.schema.json");if(d.existsSync(s))return;let n=new Date().toISOString(),r={createdAt:n,patchedAt:n,schemaVersion:1,collections:{}};d.writeFileSync(s,JSON.stringify(r,null,2)+`
3
- `),b("\u2192 Created svro.schema.json at project root.")}function q(t){let s=u.join(t,"src");if(!d.existsSync(s))return;let n=u.join(s,"auto-imports.d.ts");if(d.existsSync(n))return;let r=`/* eslint-disable */
2
+ var C=(t,n)=>()=>{try{return n||t((n={exports:{}}).exports,n),n.exports}catch(o){throw n=0,o}};var k=C((ne,w)=>{var d=require("fs"),u=require("path"),N=require("https"),{execSync:j}=require("child_process"),L="\x1B[38;2;231;233;237m",A="\x1B[31m",x="\x1B[0m";function b(t){console.log(` ${L}${t}${x}`)}function g(t){console.error(` ${A}${t}${x}`)}function D(t){let n={};return t.forEach(o=>{if(o.startsWith("--")){let[r,i]=o.slice(2).split("=");r&&i&&(n[r]=i)}}),n}function E(t,n){try{let o=JSON.parse(d.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{j("npm install fleetbo-svro",{cwd:t,stdio:"inherit"}),b("fleetbo-svro installed successfully!")}catch{g("\u26A0\uFE0F Automatic installation failed. Please run 'npm install fleetbo-svro' manually.")}}}function J(t){let n=u.join(t,"svro.schema.json");if(d.existsSync(n))return;let o=new Date().toISOString(),r={createdAt:o,patchedAt:o,schemaVersion:1,collections:{}};d.writeFileSync(n,JSON.stringify(r,null,2)+`
3
+ `),b("\u2192 Created svro.schema.json at project root.")}function M(t){let n=u.join(t,"src");if(!d.existsSync(n))return;let o=u.join(n,"auto-imports.d.ts");if(d.existsSync(o))return;let r=`/* eslint-disable */
4
4
  /* prettier-ignore */
5
5
  // @ts-nocheck
6
6
  // Generated by fleetbo-svro setup
@@ -9,8 +9,7 @@ declare global {
9
9
  const Fleetbo: typeof import('fleetbo-svro')['Fleetbo']
10
10
  const FleetboUI: typeof import('fleetbo-svro')['FleetboUI']
11
11
  }
12
- `;try{d.writeFileSync(n,r),b("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(a){p(`\u26A0\uFE0F Unable to create src/auto-imports.d.ts: ${a.message}`)}}function B(t){let s=["tsconfig.json","jsconfig.json"];for(let n of s){let r=u.join(t,n);if(d.existsSync(r)){let a=new Date;d.utimesSync(r,a,a);break}}}function W(t){let s=u.join(t,"index.d.ts");if(d.existsSync(s))return;d.writeFileSync(s,`// File generated/synchronized by fleetbo-svro \u2014 do not edit manually
13
- import type React from 'react';
12
+ `;try{d.writeFileSync(o,r),b("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(i){g(`\u26A0\uFE0F Unable to create src/auto-imports.d.ts: ${i.message}`)}}function q(t){let n=["tsconfig.json","jsconfig.json"];for(let o of n){let r=u.join(t,o);if(d.existsSync(r)){let i=new Date;d.utimesSync(r,i,i);break}}}function B(t){let n=u.join(t,"index.d.ts");if(d.existsSync(n))return;d.writeFileSync(n,`// File generated/synchronized by fleetbo-svro \u2014 do not edit manually
14
13
 
15
14
  export type FleetboTables = string;
16
15
 
@@ -26,8 +25,18 @@ declare global {
26
25
  }
27
26
  }
28
27
 
29
- export interface FleetboWriteResult { success: boolean; documentId?: string; error?: string; }
30
- export interface FleetboReadResult<T = any> { success: boolean; data?: T; notFound?: boolean; message?: string; }
28
+ export interface FleetboWriteResult {
29
+ success: boolean;
30
+ documentId?: string;
31
+ mediaUrl?: string;
32
+ error?: string;
33
+ }
34
+
35
+ export interface FleetboCallResult<T = any> {
36
+ success: boolean;
37
+ data?: T;
38
+ error?: string;
39
+ }
31
40
 
32
41
  export interface FleetboAuthUser {
33
42
  uid: string;
@@ -42,24 +51,13 @@ export interface FleetboAuthResult {
42
51
  }
43
52
 
44
53
  export declare const FleetboUI: {
45
- Text: React.FC<{ value?: any; fallback?: string; className?: string }>;
46
- Number: React.FC<{ value?: any; fallback?: React.ReactNode; invalidFallback?: React.ReactNode; className?: string; format?: Intl.NumberFormatOptions }>;
47
- Toggle: React.FC<{ value?: any; className?: string; labels?: { true: string; false: string }; invalidFallback?: React.ReactNode }>;
48
- Date: React.FC<{ value?: any; className?: string; locale?: string; invalidFallback?: React.ReactNode }>;
49
- Enum: React.FC<{ value?: any; allowed?: any[]; className?: string; invalidFallback?: React.ReactNode }>;
50
- Reference: React.FC<{
51
- table: FleetboTables;
52
- id?: string;
53
- render?: (doc: any) => React.ReactNode;
54
- orphanFallback?: React.ReactNode;
55
- malformedFallback?: React.ReactNode;
56
- loadingFallback?: React.ReactNode;
57
- className?: string;
58
- }>;
59
- List: React.FC<{ value?: any[]; render?: (item: any, index: number) => React.ReactNode; className?: string }>;
60
- Media: React.FC<{ value?: any; alt?: string; className?: string; fallback?: React.ReactNode }>;
61
- Geo: React.FC<{ value?: any; className?: string; render?: (coords: { lat: number; lng: number }) => React.ReactNode }>;
62
- Smart: React.FC<any>;
54
+ Text: string;
55
+ Number: string;
56
+ Toggle: string;
57
+ Date: string;
58
+ Enum: string;
59
+ Media: string;
60
+ Reference: string;
63
61
  };
64
62
 
65
63
  export interface FleetboAclResult {
@@ -79,10 +77,11 @@ export interface FleetboJoinOptions {
79
77
  export declare const Fleetbo: typeof FleetboUI & {
80
78
  call: {
81
79
  [key: string]: <T = any>(payload?: Record<string, any>) => Promise<FleetboCallResult<T>>;
82
- };
80
+ };
83
81
  add(table: FleetboTables, data: Record<string, any>): Promise<FleetboWriteResult>;
84
82
  addWithId(table: FleetboTables, data: Record<string, any>, customId: string): Promise<FleetboWriteResult>;
85
83
  addWithUserId(table: FleetboTables, data: Record<string, any>): Promise<FleetboWriteResult>;
84
+ addWithMedia(table: FleetboTables, data: Record<string, any>, fileBase64?: string, fileName?: string): Promise<FleetboWriteResult>;
86
85
 
87
86
  getDocsG<T = any>(table: FleetboTables): Promise<T[]>;
88
87
  getDocsU<T = any>(table: FleetboTables): Promise<T[]>;
@@ -109,6 +108,73 @@ export declare const Fleetbo: typeof FleetboUI & {
109
108
  };
110
109
 
111
110
  declare global {
111
+ namespace JSX {
112
+ interface IntrinsicElements {
113
+ 'fleetbo-text': {
114
+ value?: any;
115
+ fallback?: string;
116
+ class?: string;
117
+ className?: string;
118
+ };
119
+ 'fleetbo-number': {
120
+ value?: any;
121
+ 'invalid-fallback'?: string;
122
+ currency?: string;
123
+ class?: string;
124
+ className?: string;
125
+ };
126
+ 'fleetbo-toggle': {
127
+ value?: any;
128
+ 'label-true'?: string;
129
+ 'label-false'?: string;
130
+ 'invalid-fallback'?: string;
131
+ class?: string;
132
+ className?: string;
133
+ };
134
+ 'fleetbo-date': {
135
+ value?: any;
136
+ locale?: string;
137
+ 'invalid-fallback'?: string;
138
+ class?: string;
139
+ className?: string;
140
+ };
141
+ 'fleetbo-enum': {
142
+ value?: any;
143
+ allowed?: string;
144
+ 'invalid-fallback'?: string;
145
+ class?: string;
146
+ className?: string;
147
+ };
148
+ 'fleetbo-media': {
149
+ value?: any;
150
+ alt?: string;
151
+ fallback?: string;
152
+ class?: string;
153
+ className?: string;
154
+ };
155
+ 'fleetbo-reference': {
156
+ table: FleetboTables;
157
+ id?: string;
158
+ field?: string;
159
+ 'orphan-fallback'?: string;
160
+ 'loading-fallback'?: string;
161
+ 'malformed-fallback'?: string;
162
+ class?: string;
163
+ className?: string;
164
+ };
165
+ }
166
+ }
167
+
168
+ interface HTMLElementTagNameMap {
169
+ 'fleetbo-text': HTMLElement;
170
+ 'fleetbo-number': HTMLElement;
171
+ 'fleetbo-toggle': HTMLElement;
172
+ 'fleetbo-date': HTMLElement;
173
+ 'fleetbo-enum': HTMLElement;
174
+ 'fleetbo-media': HTMLElement;
175
+ 'fleetbo-reference': HTMLElement;
176
+ }
177
+
112
178
  const Fleetbo: typeof import('./index').Fleetbo;
113
179
  const FleetboUI: typeof import('./index').FleetboUI;
114
180
 
@@ -117,13 +183,13 @@ declare global {
117
183
  FleetboUI: typeof FleetboUI;
118
184
  }
119
185
  }
120
- `),b("\u2192 Initialized index.d.ts.")}function M(t){return new Promise((s,n)=>{let r=JSON.stringify({token:t}),a={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},l=U.request(a,e=>{let i="";e.on("data",o=>{i+=o}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{s(JSON.parse(i))}catch{n(new Error("Invalid response received from Fleetbo server."))}else try{let o=JSON.parse(i);n(new Error(o.error||`Server error ${e.statusCode}`))}catch{n(new Error(`Server error ${e.statusCode}`))}})});l.on("error",e=>n(e)),l.write(r),l.end()})}async function V(t,s=[]){let n=u.join(t,".env");if(d.existsSync(n)&&d.readFileSync(n,"utf8").includes("VITE_FLEETBO_DB_KEY")){b("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let r=$(s),a=r.keyApp,l=r.token||r.bootstrapToken,e=r.email||"";(!a||!l)&&(p("\u26A0\uFE0F Missing required parameters."),p("\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 i;try{i=await M(l)}catch(c){p(`\u26A0\uFE0F Token exchange failed: ${c.message}`),p("\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)&&(p("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let o=`
121
- VITE_FLEETBO_DB_KEY=${i.fleetboDBKey}
122
- VITE_FLEETBO_ENTERPRISE_ID=${i.enterpriseId}
123
- VITE_FLEETBO_KEY_APP=${a}
186
+ `),b("\u2192 Initialized index.d.ts.")}function W(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)}},a=N.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}`))}})});a.on("error",e=>o(e)),a.write(r),a.end()})}async function H(t,n=[]){let o=u.join(t,".env");if(d.existsSync(o)&&d.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,a=r.token||r.bootstrapToken,e=r.email||"";(!i||!a)&&(g("\u26A0\uFE0F Missing required parameters."),g("\u{1F449} Usage: npx fleetbo-svro init --keyApp=YOUR_KEY --token=YOUR_TOKEN"),process.exit(1)),b("\u2192 Exchanging bootstrap token for project keys...");let l;try{l=await W(a)}catch(c){g(`\u26A0\uFE0F Token exchange failed: ${c.message}`),g("\u{1F449} The token may have expired (15 min limit) or was already used. Please regenerate one from the Fleetbo dashboard."),process.exit(1)}(!l.enterpriseId||!l.fleetboDBKey)&&(g("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let s=`
187
+ VITE_FLEETBO_DB_KEY=${l.fleetboDBKey}
188
+ VITE_FLEETBO_ENTERPRISE_ID=${l.enterpriseId}
189
+ VITE_FLEETBO_KEY_APP=${i}
124
190
  ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
125
- `:""}`;d.appendFileSync(n,o),b(".env file updated successfully with Fleetbo keys!")}function x(t){let s=u.join(t,"svro.d.ts");if(d.existsSync(s))try{d.unlinkSync(s),b("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function O(t,s){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let n=u.join(t,"tsconfig.json"),r=u.join(t,"jsconfig.json"),a=d.existsSync(n)?n:r,l=!d.existsSync(a),e={};if(!l)try{e=JSON.parse(d.readFileSync(a,"utf8"))}catch{p(`\u26A0\uFE0F Unable to read ${u.basename(a)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let i=!1,o=T(s,"react"),c=T(s,"vite");l?(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"],i=!0):(e.compilerOptions.checkJs===void 0&&(e.compilerOptions.checkJs=!0,i=!0),e.compilerOptions.allowJs===void 0&&(e.compilerOptions.allowJs=!0,i=!0)),o&&e.compilerOptions.jsx===void 0&&(e.compilerOptions.jsx="react-jsx",i=!0),c&&e.compilerOptions.types===void 0&&(e.compilerOptions.types=["vite/client"],i=!0),i&&(d.writeFileSync(a,JSON.stringify(e,null,2)+`
126
- `),b(`\u2192 Updated ${u.basename(a)}.`))}function N(t,s){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let r=["vite.config.ts","vite.config.js","vite.config.mjs"].map(o=>u.join(t,o)).find(o=>d.existsSync(o));if(!r)return;let a;try{a=d.readFileSync(r,"utf8")}catch{return}let l="fleetbo-svro",e=a,i=`{
191
+ `:""}`;d.appendFileSync(o,s),b(".env file updated successfully with Fleetbo keys!")}function O(t){let n=u.join(t,"svro.d.ts");if(d.existsSync(n))try{d.unlinkSync(n),b("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function P(t,n){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let o=u.join(t,"tsconfig.json"),r=u.join(t,"jsconfig.json"),i=d.existsSync(o)?o:r,a=!d.existsSync(i),e={};if(!a)try{e=JSON.parse(d.readFileSync(i,"utf8"))}catch{g(`\u26A0\uFE0F Unable to read ${u.basename(i)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let l=!1,s=E(n,"react"),c=E(n,"vite");a?(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),c&&e.compilerOptions.types===void 0&&(e.compilerOptions.types=["vite/client"],l=!0),l&&(d.writeFileSync(i,JSON.stringify(e,null,2)+`
192
+ `),b(`\u2192 Updated ${u.basename(i)}.`))}function R(t,n){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let r=["vite.config.ts","vite.config.js","vite.config.mjs"].map(s=>u.join(t,s)).find(s=>d.existsSync(s));if(!r)return;let i;try{i=d.readFileSync(r,"utf8")}catch{return}let a="fleetbo-svro",e=i,l=`{
127
193
  name: 'fleetbo-schema-sync-middleware',
128
194
  configureServer(server) {
129
195
  server.middlewares.use('/__fleetbo_sync_schema', (req, res) => {
@@ -166,23 +232,22 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
166
232
  watch: {
167
233
  ignored: ['**/svro.schema.json', '**/src/auto-imports.d.ts']
168
234
  }
169
- },`))),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: [{ '${l}': ['Fleetbo', 'FleetboUI'] }]`));else{let o=e.match(/plugins\s*:\s*\[/);if(o){let c=o.index+o[0].length,h=`
235
+ },`))),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: [{ '${a}': ['Fleetbo', 'FleetboUI'] }]`));else{let s=e.match(/plugins\s*:\s*\[/);if(s){let c=s.index+s[0].length,F=`
170
236
  AutoImport({
171
- imports: [{ '${l}': ['Fleetbo', 'FleetboUI'] }],
237
+ imports: [{ '${a}': ['Fleetbo', 'FleetboUI'] }],
172
238
  dts: 'src/auto-imports.d.ts'
173
- }),`;if(e=e.slice(0,c)+h+e.slice(c),!e.includes("import AutoImport")){let R=[...e.matchAll(/^import .+;?$/gm)].pop(),v=`import AutoImport from 'unplugin-auto-import/vite';
174
- `;if(R){let g=R.index+R[0].length;e=e.slice(0,g)+`
175
- `+v+e.slice(g)}else e=v+e}}}if(e.includes("__fleetbo_sync_schema")){if(e.includes("require('fs')")||e.includes('require("fs")')){let o=/\{\s*name:\s*['"]fleetbo-schema-sync-middleware['"][\s\S]*?\},/g;o.test(e)&&(e=e.replace(o,i),b("\u2192 Updated legacy Fleetbo middleware to modern ESM version."))}}else{let o=e.match(/plugins\s*:\s*\[/);if(o){let c=o.index+o[0].length;e=e.slice(0,c)+`
176
- `+i+e.slice(c)}}if(e!==a)try{d.writeFileSync(r,e),b(`\u2192 Updated ${u.basename(r)} with Watcher and AutoImport configuration.`)}catch(o){p(`\u26A0\uFE0F Failed to write to ${u.basename(r)}: ${o.message}`)}try{let o=JSON.parse(d.readFileSync(s,"utf8"));o.devDependencies=o.devDependencies||{},o.devDependencies["unplugin-auto-import"]||(o.devDependencies["unplugin-auto-import"]="^0.18.0",d.writeFileSync(s,JSON.stringify(o,null,2)+`
177
- `),b("\u2192 Added unplugin-auto-import to devDependencies."))}catch(o){p(`\u26A0\uFE0F Failed to update ${u.basename(s)}: ${o.message}`)}}function K(t,s,n={}){let{skipSelfInstall:r=!1}=n,a=u.join(__dirname,"..");r||J(t,s),L(t),W(a),q(t),x(t),O(t,s),N(t,s)}P.exports={touchTsConfig:B,log:b,logError:p,handleAuthAndEnv:V,detectDependency:T,cleanupLegacyRootDts:x,patchJsOrTsConfig:O,attemptViteAutoImportPatch:N,runFullSetup:K}});var m=require("fs"),y=require("path"),k=require("https"),{runFullSetup:Y,handleAuthAndEnv:G,touchTsConfig:H}=C(),z="\x1B[34m",Q="\x1B[31m",w="\x1B[0m";function f(t){console.log(`${z}${t}${w}`)}function F(t){console.error(`${Q}${t}${w}`)}function X(t,s){return new Promise((n,r)=>{let a=JSON.stringify({enterpriseID:t,schema:s}),l={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(a)}},e=k.request(l,i=>{let o="";i.on("data",c=>{o+=c}),i.on("end",()=>{i.statusCode>=200&&i.statusCode<300?n(JSON.parse(o)):r(new Error(`Edge sync failed with HTTP ${i.statusCode}`))})});e.on("error",i=>r(i)),e.write(a),e.end()})}function Z(t){let s=y.join(t,".env");if(!m.existsSync(s))return{};let n=m.readFileSync(s,"utf8"),r={};return n.split(`
178
- `).forEach(a=>{let[l,...e]=a.split("=");l&&e.length>0&&(r[l.trim()]=e.join("=").trim())}),r}function ee(t){return new Promise((s,n)=>{let r=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),a={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},l=k.request(a,e=>{let i="";e.on("data",o=>{i+=o}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let o=JSON.parse(i);if(o.success&&o.found&&o.module){let c=o.module.code||o.module.mockCode;s(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}`))})});l.on("error",e=>n(e)),l.write(r),l.end()})}var E=process.argv.slice(2),S=E[0];async function te(){let t=process.cwd(),s=y.join(t,"package.json");if(S==="init"||S==="doctor")f(`
179
- [Fleetbo] Initializing and configuring Fleetbo...`),await G(t,E),Y(t,s),f(`
239
+ }),`;if(e=e.slice(0,c)+F+e.slice(c),!e.includes("import AutoImport")){let T=[...e.matchAll(/^import .+;?$/gm)].pop(),v=`import AutoImport from 'unplugin-auto-import/vite';
240
+ `;if(T){let m=T.index+T[0].length;e=e.slice(0,m)+`
241
+ `+v+e.slice(m)}else e=v+e}}}if(e.includes("__fleetbo_sync_schema")){if(e.includes("require('fs')")||e.includes('require("fs")')){let s=/\{\s*name:\s*['"]fleetbo-schema-sync-middleware['"][\s\S]*?\},/g;s.test(e)&&(e=e.replace(s,l),b("\u2192 Updated legacy Fleetbo middleware to modern ESM version."))}}else{let s=e.match(/plugins\s*:\s*\[/);if(s){let c=s.index+s[0].length;e=e.slice(0,c)+`
242
+ `+l+e.slice(c)}}if(e!==i)try{d.writeFileSync(r,e),b(`\u2192 Updated ${u.basename(r)} with Watcher and AutoImport configuration.`)}catch(s){g(`\u26A0\uFE0F Failed to write to ${u.basename(r)}: ${s.message}`)}try{let s=JSON.parse(d.readFileSync(n,"utf8"));s.devDependencies=s.devDependencies||{},s.devDependencies["unplugin-auto-import"]||(s.devDependencies["unplugin-auto-import"]="^0.18.0",d.writeFileSync(n,JSON.stringify(s,null,2)+`
243
+ `),b("\u2192 Added unplugin-auto-import to devDependencies."))}catch(s){g(`\u26A0\uFE0F Failed to update ${u.basename(n)}: ${s.message}`)}}function V(t,n,o={}){let{skipSelfInstall:r=!1}=o,i=u.join(__dirname,"..");r||$(t,n),J(t),B(i),M(t),O(t),P(t,n),R(t,n)}w.exports={touchTsConfig:q,log:b,logError:g,handleAuthAndEnv:H,detectDependency:E,cleanupLegacyRootDts:O,patchJsOrTsConfig:P,attemptViteAutoImportPatch:R,runFullSetup:V}});var f=require("fs"),y=require("path"),_=require("https"),{runFullSetup:K,handleAuthAndEnv:Y,touchTsConfig:G}=k(),z="\x1B[34m",X="\x1B[31m",U="\x1B[0m";function p(t){console.log(`${z}${t}${U}`)}function h(t){console.error(`${X}${t}${U}`)}function Q(t,n){return new Promise((o,r)=>{let i=JSON.stringify({enterpriseID:t,schema:n}),a={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(i)}},e=_.request(a,l=>{let s="";l.on("data",c=>{s+=c}),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(!f.existsSync(n))return{};let o=f.readFileSync(n,"utf8"),r={};return o.split(`
244
+ `).forEach(i=>{let[a,...e]=i.split("=");a&&e.length>0&&(r[a.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)}},a=_.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 c=s.module.code||s.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}`))})});a.on("error",e=>o(e)),a.write(r),a.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")p(`
245
+ [Fleetbo] Initializing and configuring Fleetbo...`),await Y(t,S),K(t,n),p(`
180
246
  [Fleetbo] Configuration completed successfully!
181
- `);else if(S==="sql"&&E[1]==="sync"){let n=E.includes("--dry-run");f(`[Fleetbo] Syncing schema...${n?" (dry-run)":""}`);let r=y.join(t,"svro.schema.json"),a=y.join(__dirname,".."),l=y.join(a,"index.d.ts"),e=y.join(t,"src","auto-imports.d.ts"),o=Z(t).VITE_FLEETBO_ENTERPRISE_ID;if(o)try{f("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let c=await ee(o);m.writeFileSync(r,JSON.stringify(c,null,2)+`
182
- `),f("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(c){F(`\u26A0\uFE0F Cloud fetch bypassed: ${c.message}. Using local file fallback.`)}else F("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");(!m.existsSync(r)||!m.existsSync(l))&&(F("Error: Required system files not found."),process.exit(1));try{let c=JSON.parse(m.readFileSync(r,"utf8")),h=Object.keys(c.collections||{});if(o)try{await X(o,c),f("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(g){F(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${g.message}`)}let R=h.length>0?h.map(g=>`'${g}'`).join(" | "):"string",v=`// Generated by @fleetbo/svro \u2014 Updated via fleetbo sql sync
183
- import type React from 'react';
247
+ `);else if(I==="sql"&&S[1]==="sync"){let o=S.includes("--dry-run");p(`[Fleetbo] Syncing schema...${o?" (dry-run)":""}`);let r=y.join(t,"svro.schema.json"),i=y.join(__dirname,".."),a=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{p("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let c=await ee(s);f.writeFileSync(r,JSON.stringify(c,null,2)+`
248
+ `),p("\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.");(!f.existsSync(r)||!f.existsSync(a))&&(h("Error: Required system files not found."),process.exit(1));try{let c=JSON.parse(f.readFileSync(r,"utf8")),F=Object.keys(c.collections||{});if(s)try{await Q(s,c),p("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(m){h(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${m.message}`)}let T=F.length>0?F.map(m=>`'${m}'`).join(" | "):"string",v=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sql sync
184
249
 
185
- export type FleetboTables = ${R};
250
+ export type FleetboTables = ${T};
186
251
 
187
252
  declare global {
188
253
  interface ImportMetaEnv {
@@ -222,24 +287,13 @@ export interface FleetboAuthResult {
222
287
  }
223
288
 
224
289
  export declare const FleetboUI: {
225
- Text: React.FC<{ value?: any; fallback?: string; className?: string }>;
226
- Number: React.FC<{ value?: any; fallback?: React.ReactNode; invalidFallback?: React.ReactNode; className?: string; format?: Intl.NumberFormatOptions }>;
227
- Toggle: React.FC<{ value?: any; className?: string; labels?: { true: string; false: string }; invalidFallback?: React.ReactNode }>;
228
- Date: React.FC<{ value?: any; className?: string; locale?: string; invalidFallback?: React.ReactNode }>;
229
- Enum: React.FC<{ value?: any; allowed?: any[]; className?: string; invalidFallback?: React.ReactNode }>;
230
- Reference: React.FC<{
231
- table: FleetboTables;
232
- id?: string;
233
- render?: (doc: any) => React.ReactNode;
234
- orphanFallback?: React.ReactNode;
235
- malformedFallback?: React.ReactNode;
236
- loadingFallback?: React.ReactNode;
237
- className?: string;
238
- }>;
239
- List: React.FC<{ value?: any[]; render?: (item: any, index: number) => React.ReactNode; className?: string }>;
240
- Media: React.FC<{ value?: any; alt?: string; className?: string; fallback?: React.ReactNode }>;
241
- Geo: React.FC<{ value?: any; className?: string; render?: (coords: { lat: number; lng: number }) => React.ReactNode }>;
242
- Smart: React.FC<any>;
290
+ Text: string;
291
+ Number: string;
292
+ Toggle: string;
293
+ Date: string;
294
+ Enum: string;
295
+ Media: string;
296
+ Reference: string;
243
297
  };
244
298
 
245
299
  export interface FleetboAclResult {
@@ -290,6 +344,73 @@ export declare const Fleetbo: typeof FleetboUI & {
290
344
  };
291
345
 
292
346
  declare global {
347
+ namespace JSX {
348
+ interface IntrinsicElements {
349
+ 'fleetbo-text': {
350
+ value?: any;
351
+ fallback?: string;
352
+ class?: string;
353
+ className?: string;
354
+ };
355
+ 'fleetbo-number': {
356
+ value?: any;
357
+ 'invalid-fallback'?: string;
358
+ currency?: string;
359
+ class?: string;
360
+ className?: string;
361
+ };
362
+ 'fleetbo-toggle': {
363
+ value?: any;
364
+ 'label-true'?: string;
365
+ 'label-false'?: string;
366
+ 'invalid-fallback'?: string;
367
+ class?: string;
368
+ className?: string;
369
+ };
370
+ 'fleetbo-date': {
371
+ value?: any;
372
+ locale?: string;
373
+ 'invalid-fallback'?: string;
374
+ class?: string;
375
+ className?: string;
376
+ };
377
+ 'fleetbo-enum': {
378
+ value?: any;
379
+ allowed?: string;
380
+ 'invalid-fallback'?: string;
381
+ class?: string;
382
+ className?: string;
383
+ };
384
+ 'fleetbo-media': {
385
+ value?: any;
386
+ alt?: string;
387
+ fallback?: string;
388
+ class?: string;
389
+ className?: string;
390
+ };
391
+ 'fleetbo-reference': {
392
+ table: FleetboTables;
393
+ id?: string;
394
+ field?: string;
395
+ 'orphan-fallback'?: string;
396
+ 'loading-fallback'?: string;
397
+ 'malformed-fallback'?: string;
398
+ class?: string;
399
+ className?: string;
400
+ };
401
+ }
402
+ }
403
+
404
+ interface HTMLElementTagNameMap {
405
+ 'fleetbo-text': HTMLElement;
406
+ 'fleetbo-number': HTMLElement;
407
+ 'fleetbo-toggle': HTMLElement;
408
+ 'fleetbo-date': HTMLElement;
409
+ 'fleetbo-enum': HTMLElement;
410
+ 'fleetbo-media': HTMLElement;
411
+ 'fleetbo-reference': HTMLElement;
412
+ }
413
+
293
414
  const Fleetbo: typeof import('./index').Fleetbo;
294
415
  const FleetboUI: typeof import('./index').FleetboUI;
295
416
 
@@ -298,14 +419,14 @@ declare global {
298
419
  FleetboUI: typeof FleetboUI;
299
420
  }
300
421
  }
301
- `;if(m.writeFileSync(l,v),m.existsSync(y.dirname(e))){let g=`/* eslint-disable */
302
- /* prettier-ignore */
303
- // @ts-nocheck
304
- // Generated by @fleetbo/svro \u2014 Updated via fleetbo sql sync
305
- export {}
306
- declare global {
307
- type FleetboTables = ${R};
308
- const Fleetbo: typeof import('@fleetbo/svro')['Fleetbo'];
309
- const FleetboUI: typeof import('@fleetbo/svro')['FleetboUI'];
310
- }
311
- `;m.writeFileSync(e,g)}H(t),f(`[Fleetbo] Schema synced successfully (${h.length} collection(s)).`),n&&f("\u2192 [Dry-run] Schema is valid.")}catch(c){F(`Error during synchronization: ${c.message}`),process.exit(1)}}else F('Unknown command. Usage: "npx @fleetbo/svro init --keyApp=xxx --token=yyy"'),process.exit(1)}te().catch(t=>{F(`Fleetbo CLI Error: ${t.message}`),process.exit(1)});
422
+ `;if(f.writeFileSync(a,v),f.existsSync(y.dirname(e))){let m=`/* eslint-disable */
423
+ /* prettier-ignore */
424
+ // @ts-nocheck
425
+ // Generated by fleetbo-svro \u2014 Updated via fleetbo sql sync
426
+ export {}
427
+ declare global {
428
+ type FleetboTables = ${T};
429
+ const Fleetbo: typeof import('fleetbo-svro')['Fleetbo'];
430
+ const FleetboUI: typeof import('fleetbo-svro')['FleetboUI'];
431
+ }
432
+ `;f.writeFileSync(e,m)}G(t),p(`[Fleetbo] Schema synced successfully (${F.length} collection(s)).`),o&&p("\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 --keyApp=xxx --token=yyy"'),process.exit(1)}te().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.0",
3
+ "version": "1.0.2",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "types": "index.d.ts",
@@ -24,4 +24,4 @@
24
24
  "devDependencies": {
25
25
  "esbuild": "^0.28.1"
26
26
  }
27
- }
27
+ }