fleetbo-svro 1.0.12 → 1.0.13
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.
- package/dist/cli.cjs +283 -320
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,45 +1,60 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`),
|
|
2
|
+
var R=(t,n)=>()=>{try{return n||t((n={exports:{}}).exports,n),n.exports}catch(r){throw n=0,r}};var _=R((re,k)=>{var b=require("fs"),p=require("path"),J=require("https"),{execSync:L}=require("child_process"),$="\x1B[38;2;231;233;237m",D="\x1B[31m",x="\x1B[0m";function f(t){console.log(` ${$}${t}${x}`)}function d(t){console.error(` ${D}${t}${x}`)}function A(t){let n={};return t.forEach(r=>{if(r.startsWith("--")){let[s,l]=r.slice(2).split("=");s&&l&&(n[s]=l)}}),n}function E(t,n){try{let r=JSON.parse(b.readFileSync(t,"utf8"));return!!(r.dependencies&&r.dependencies[n]||r.devDependencies&&r.devDependencies[n])}catch{return!1}}function N(t,n){if(!E(n,"fleetbo-svro")){f("\u2192 Installing fleetbo-svro into the project...");try{L("npm install fleetbo-svro",{cwd:t,stdio:"inherit"}),f("fleetbo-svro installed successfully!")}catch{d("\u26A0\uFE0F Automatic installation failed. Please run 'npm install fleetbo-svro' manually.")}}}function U(t){let n=p.join(t,"svro.schema.json");if(b.existsSync(n))return;let r=new Date().toISOString(),s={createdAt:r,patchedAt:r,schemaVersion:1,collections:{}};b.writeFileSync(n,JSON.stringify(s,null,2)+`
|
|
3
|
+
`),f("\u2192 Created svro.schema.json at project root.")}function B(t){let n=p.join(t,"src");if(!b.existsSync(n))return;let r=p.join(n,"auto-imports.d.ts");if(b.existsSync(r))return;let s=`/* eslint-disable */
|
|
4
4
|
/* prettier-ignore */
|
|
5
5
|
// @ts-nocheck
|
|
6
6
|
// Generated by fleetbo-svro setup
|
|
7
7
|
export {}
|
|
8
8
|
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
type FleetboProp = {
|
|
10
|
+
value?: any;
|
|
11
|
+
fallback?: string;
|
|
12
|
+
'invalid-fallback'?: string;
|
|
13
|
+
currency?: string;
|
|
14
|
+
locale?: string;
|
|
15
|
+
allowed?: string;
|
|
16
|
+
alt?: string;
|
|
17
|
+
table?: any;
|
|
18
|
+
id?: string;
|
|
19
|
+
field?: string;
|
|
20
|
+
'label-true'?: string;
|
|
21
|
+
'label-false'?: string;
|
|
22
|
+
'orphan-fallback'?: string;
|
|
23
|
+
'loading-fallback'?: string;
|
|
24
|
+
'malformed-fallback'?: string;
|
|
25
|
+
class?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
children?: any;
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
16
30
|
|
|
17
31
|
declare global {
|
|
18
32
|
type FleetboTables = string;
|
|
19
33
|
const Fleetbo: typeof import('fleetbo-svro')['Fleetbo'];
|
|
20
|
-
const FleetboUI: typeof import('fleetbo-svro')['FleetboUI'];
|
|
21
34
|
|
|
22
35
|
namespace JSX {
|
|
23
36
|
interface IntrinsicElements {
|
|
24
|
-
'fleetbo-text':
|
|
25
|
-
'fleetbo-number':
|
|
26
|
-
'fleetbo-toggle':
|
|
27
|
-
'fleetbo-date':
|
|
28
|
-
'fleetbo-enum':
|
|
29
|
-
'fleetbo-media':
|
|
30
|
-
'fleetbo-reference':
|
|
37
|
+
'fleetbo-text': FleetboProp;
|
|
38
|
+
'fleetbo-number': FleetboProp;
|
|
39
|
+
'fleetbo-toggle': FleetboProp;
|
|
40
|
+
'fleetbo-date': FleetboProp;
|
|
41
|
+
'fleetbo-enum': FleetboProp;
|
|
42
|
+
'fleetbo-media': FleetboProp;
|
|
43
|
+
'fleetbo-reference': FleetboProp;
|
|
31
44
|
}
|
|
32
45
|
}
|
|
33
46
|
|
|
34
|
-
namespace React
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
namespace React {
|
|
48
|
+
namespace JSX {
|
|
49
|
+
interface IntrinsicElements {
|
|
50
|
+
'fleetbo-text': FleetboProp;
|
|
51
|
+
'fleetbo-number': FleetboProp;
|
|
52
|
+
'fleetbo-toggle': FleetboProp;
|
|
53
|
+
'fleetbo-date': FleetboProp;
|
|
54
|
+
'fleetbo-enum': FleetboProp;
|
|
55
|
+
'fleetbo-media': FleetboProp;
|
|
56
|
+
'fleetbo-reference': FleetboProp;
|
|
57
|
+
}
|
|
43
58
|
}
|
|
44
59
|
}
|
|
45
60
|
}
|
|
@@ -47,197 +62,61 @@ declare global {
|
|
|
47
62
|
declare module 'react' {
|
|
48
63
|
namespace JSX {
|
|
49
64
|
interface IntrinsicElements {
|
|
50
|
-
'fleetbo-text':
|
|
51
|
-
'fleetbo-number':
|
|
52
|
-
'fleetbo-toggle':
|
|
53
|
-
'fleetbo-date':
|
|
54
|
-
'fleetbo-enum':
|
|
55
|
-
'fleetbo-media':
|
|
56
|
-
'fleetbo-reference':
|
|
65
|
+
'fleetbo-text': FleetboProp;
|
|
66
|
+
'fleetbo-number': FleetboProp;
|
|
67
|
+
'fleetbo-toggle': FleetboProp;
|
|
68
|
+
'fleetbo-date': FleetboProp;
|
|
69
|
+
'fleetbo-enum': FleetboProp;
|
|
70
|
+
'fleetbo-media': FleetboProp;
|
|
71
|
+
'fleetbo-reference': FleetboProp;
|
|
57
72
|
}
|
|
58
73
|
}
|
|
59
74
|
}
|
|
60
|
-
`;try{c.writeFileSync(o,r),g("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(l){u(`\u26A0\uFE0F Unable to create src/auto-imports.d.ts: ${l.message}`)}}function B(t){let s=["tsconfig.json","jsconfig.json"];for(let o of s){let r=d.join(t,o);if(c.existsSync(r)){let l=new Date;c.utimesSync(r,l,l);break}}}function W(t){let s=d.join(t,"index.d.ts");if(c.existsSync(s))return;c.writeFileSync(s,`// File generated/synchronized by fleetbo-svro \u2014 do not edit manually
|
|
61
|
-
|
|
62
|
-
export type FleetboTables = string;
|
|
63
|
-
|
|
64
|
-
declare global {
|
|
65
|
-
interface ImportMetaEnv {
|
|
66
|
-
readonly VITE_FLEETBO_DB_KEY?: string;
|
|
67
|
-
readonly VITE_FLEETBO_ENTERPRISE_ID?: string;
|
|
68
|
-
readonly [key: string]: any;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface ImportMeta {
|
|
72
|
-
readonly env: ImportMetaEnv;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface FleetboWriteResult {
|
|
77
|
-
success: boolean;
|
|
78
|
-
documentId?: string;
|
|
79
|
-
mediaUrl?: string;
|
|
80
|
-
error?: string;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface FleetboCallResult<T = any> {
|
|
84
|
-
success: boolean;
|
|
85
|
-
data?: T;
|
|
86
|
-
error?: string;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface FleetboAuthUser {
|
|
90
|
-
uid: string;
|
|
91
|
-
email?: string | null;
|
|
92
|
-
isAnonymous: boolean;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface FleetboAuthResult {
|
|
96
|
-
success: boolean;
|
|
97
|
-
user?: FleetboAuthUser | null;
|
|
98
|
-
error?: string;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export declare const FleetboUI: {
|
|
102
|
-
Text: string;
|
|
103
|
-
Number: string;
|
|
104
|
-
Toggle: string;
|
|
105
|
-
Date: string;
|
|
106
|
-
Enum: string;
|
|
107
|
-
Media: string;
|
|
108
|
-
Reference: string;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export interface FleetboAclResult {
|
|
112
|
-
success: boolean;
|
|
113
|
-
error?: string;
|
|
114
|
-
}
|
|
115
75
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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;
|
|
122
85
|
}
|
|
123
86
|
}
|
|
124
87
|
|
|
125
|
-
|
|
126
|
-
call: {
|
|
127
|
-
[key: string]: <T = any>(payload?: Record<string, any>) => Promise<FleetboCallResult<T>>;
|
|
128
|
-
};
|
|
129
|
-
add(table: FleetboTables, data: Record<string, any>): Promise<FleetboWriteResult>;
|
|
130
|
-
addWithId(table: FleetboTables, data: Record<string, any>, customId: string): Promise<FleetboWriteResult>;
|
|
131
|
-
addWithUserId(table: FleetboTables, data: Record<string, any>): Promise<FleetboWriteResult>;
|
|
132
|
-
addWithMedia(table: FleetboTables, data: Record<string, any>, fileBase64?: string, fileName?: string): Promise<FleetboWriteResult>;
|
|
133
|
-
|
|
134
|
-
getDocsG<T = any>(table: FleetboTables): Promise<T[]>;
|
|
135
|
-
getDocsU<T = any>(table: FleetboTables): Promise<T[]>;
|
|
136
|
-
getDoc<T = any>(table: FleetboTables, docId: string): Promise<T | null>;
|
|
137
|
-
getAuthUser(): Promise<any>;
|
|
138
|
-
|
|
139
|
-
delete(table: FleetboTables, docId: string): Promise<FleetboWriteResult>;
|
|
140
|
-
update(table: FleetboTables, docId: string, data: Record<string, any>): Promise<FleetboWriteResult>;
|
|
141
|
-
|
|
142
|
-
join<T = any>(table: FleetboTables, options: FleetboJoinOptions): Promise<T[]>;
|
|
143
|
-
|
|
144
|
-
sendotpsvro(email: string): Promise<FleetboWriteResult>;
|
|
145
|
-
verifyotpsvro(email: string, code: string): Promise<FleetboAuthResult>;
|
|
146
|
-
|
|
147
|
-
isAuthenticated(forceRefresh?: boolean): Promise<boolean>;
|
|
148
|
-
logout(): Promise<{ success: boolean; error?: string }>;
|
|
149
|
-
getUser(): Promise<FleetboAuthUser | null>;
|
|
150
|
-
|
|
151
|
-
acl: {
|
|
152
|
-
grant(targetUserId: string, action: string, resourceTable: FleetboTables, resourceId?: string): Promise<FleetboAclResult>;
|
|
153
|
-
revoke(targetUserId: string, action: string, resourceTable: FleetboTables, resourceId?: string): Promise<FleetboAclResult>;
|
|
154
|
-
can(action: string, resourceTable: FleetboTables, resourceId?: string): Promise<boolean>;
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
declare global {
|
|
88
|
+
declare module 'preact' {
|
|
159
89
|
namespace JSX {
|
|
160
90
|
interface IntrinsicElements {
|
|
161
|
-
'fleetbo-text':
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
'fleetbo-
|
|
168
|
-
value?: any;
|
|
169
|
-
'invalid-fallback'?: string;
|
|
170
|
-
currency?: string;
|
|
171
|
-
class?: string;
|
|
172
|
-
className?: string;
|
|
173
|
-
};
|
|
174
|
-
'fleetbo-toggle': {
|
|
175
|
-
value?: any;
|
|
176
|
-
'label-true'?: string;
|
|
177
|
-
'label-false'?: string;
|
|
178
|
-
'invalid-fallback'?: string;
|
|
179
|
-
class?: string;
|
|
180
|
-
className?: string;
|
|
181
|
-
};
|
|
182
|
-
'fleetbo-date': {
|
|
183
|
-
value?: any;
|
|
184
|
-
locale?: string;
|
|
185
|
-
'invalid-fallback'?: string;
|
|
186
|
-
class?: string;
|
|
187
|
-
className?: string;
|
|
188
|
-
};
|
|
189
|
-
'fleetbo-enum': {
|
|
190
|
-
value?: any;
|
|
191
|
-
allowed?: string;
|
|
192
|
-
'invalid-fallback'?: string;
|
|
193
|
-
class?: string;
|
|
194
|
-
className?: string;
|
|
195
|
-
};
|
|
196
|
-
'fleetbo-media': {
|
|
197
|
-
value?: any;
|
|
198
|
-
alt?: string;
|
|
199
|
-
fallback?: string;
|
|
200
|
-
class?: string;
|
|
201
|
-
className?: string;
|
|
202
|
-
};
|
|
203
|
-
'fleetbo-reference': {
|
|
204
|
-
table: FleetboTables;
|
|
205
|
-
id?: string;
|
|
206
|
-
field?: string;
|
|
207
|
-
'orphan-fallback'?: string;
|
|
208
|
-
'loading-fallback'?: string;
|
|
209
|
-
'malformed-fallback'?: string;
|
|
210
|
-
class?: string;
|
|
211
|
-
className?: string;
|
|
212
|
-
};
|
|
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;
|
|
213
98
|
}
|
|
214
99
|
}
|
|
100
|
+
}
|
|
215
101
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
'fleetbo-
|
|
219
|
-
'fleetbo-
|
|
220
|
-
'fleetbo-
|
|
221
|
-
'fleetbo-
|
|
222
|
-
'fleetbo-
|
|
223
|
-
'fleetbo-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const Fleetbo: typeof import('./index').Fleetbo;
|
|
227
|
-
const FleetboUI: typeof import('./index').FleetboUI;
|
|
228
|
-
|
|
229
|
-
interface Window {
|
|
230
|
-
Fleetbo: typeof Fleetbo;
|
|
231
|
-
FleetboUI: typeof FleetboUI;
|
|
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;
|
|
232
111
|
}
|
|
233
112
|
}
|
|
234
|
-
`),
|
|
235
|
-
VITE_FLEETBO_DB_KEY=${
|
|
236
|
-
VITE_FLEETBO_ENTERPRISE_ID=${
|
|
113
|
+
`;try{b.writeFileSync(r,s),f("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(l){d(`\u26A0\uFE0F Unable to create src/auto-imports.d.ts: ${l.message}`)}}function M(t){let n=p.join(t,"index.d.ts");b.existsSync(n)||f("\u2192 Verified index.d.ts presence.")}function q(t){let n=["tsconfig.json","jsconfig.json"];for(let r of n){let s=p.join(t,r);if(b.existsSync(s)){let l=new Date;b.utimesSync(s,l,l);break}}}function H(t){return new Promise((n,r)=>{let s=JSON.stringify({token:t}),l={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},c=J.request(l,e=>{let i="";e.on("data",o=>{i+=o}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{n(JSON.parse(i))}catch{r(new Error("Invalid response received from Fleetbo server."))}else try{let o=JSON.parse(i);r(new Error(o.error||`Server error ${e.statusCode}`))}catch{r(new Error(`Server error ${e.statusCode}`))}})});c.on("error",e=>r(e)),c.write(s),c.end()})}async function V(t,n=[]){let r=p.join(t,".env");if(b.existsSync(r)&&b.readFileSync(r,"utf8").includes("VITE_FLEETBO_DB_KEY")){f("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let s=A(n),l=s.keyApp,c=s.token||s.bootstrapToken,e=s.email||"";(!l||!c)&&(d("\u26A0\uFE0F Missing required parameters."),d("\u{1F449} Usage: npx fleetbo-svro init --keyApp=YOUR_KEY --token=YOUR_TOKEN"),process.exit(1)),f("\u2192 Exchanging bootstrap token for project keys...");let i;try{i=await H(c)}catch(a){d(`\u26A0\uFE0F Token exchange failed: ${a.message}`),d("\u{1F449} The token may have expired (15 min limit) or was already used. Please regenerate one from the Fleetbo dashboard."),process.exit(1)}(!i.enterpriseId||!i.fleetboDBKey)&&(d("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let o=`
|
|
114
|
+
VITE_FLEETBO_DB_KEY=${i.fleetboDBKey}
|
|
115
|
+
VITE_FLEETBO_ENTERPRISE_ID=${i.enterpriseId}
|
|
237
116
|
VITE_FLEETBO_KEY_APP=${l}
|
|
238
117
|
${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
|
|
239
|
-
`:""}`;
|
|
240
|
-
`),
|
|
118
|
+
`:""}`;b.appendFileSync(r,o),f(".env file updated successfully with Fleetbo keys!")}function I(t){let n=p.join(t,"svro.d.ts");if(b.existsSync(n))try{b.unlinkSync(n),f("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function O(t,n){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let r=p.join(t,"tsconfig.json"),s=p.join(t,"jsconfig.json"),l=b.existsSync(r)?r:s,c=!b.existsSync(l),e={};if(!c)try{e=JSON.parse(b.readFileSync(l,"utf8"))}catch{d(`\u26A0\uFE0F Unable to read ${p.basename(l)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let i=!1,o=E(n,"react"),a=E(n,"vite");c?(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),a&&e.compilerOptions.types===void 0&&(e.compilerOptions.types=["vite/client"],i=!0),i&&(b.writeFileSync(l,JSON.stringify(e,null,2)+`
|
|
119
|
+
`),f(`\u2192 Updated ${p.basename(l)}.`))}function w(t,n){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let s=["vite.config.ts","vite.config.js","vite.config.mjs"].map(o=>p.join(t,o)).find(o=>b.existsSync(o));if(!s)return;let l;try{l=b.readFileSync(s,"utf8")}catch{return}let c="fleetbo-svro",e=l,i=`{
|
|
241
120
|
name: 'fleetbo-schema-sync-middleware',
|
|
242
121
|
transformIndexHtml() {
|
|
243
122
|
return [
|
|
@@ -290,24 +169,24 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
|
|
|
290
169
|
watch: {
|
|
291
170
|
ignored: ['**/svro.schema.json', '**/src/auto-imports.d.ts']
|
|
292
171
|
}
|
|
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: [{ '${
|
|
172
|
+
},`))),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: [{ '${c}': ['Fleetbo'] }]`));else{let o=e.match(/plugins\s*:\s*\[/);if(o){let a=o.index+o[0].length,P=`
|
|
294
173
|
AutoImport({
|
|
295
|
-
imports: [{ '${
|
|
174
|
+
imports: [{ '${c}': ['Fleetbo'] }],
|
|
296
175
|
dts: 'src/auto-imports.d.ts'
|
|
297
|
-
}),`;if(e=e.slice(0,
|
|
298
|
-
`;if(
|
|
299
|
-
`+v+e.slice(
|
|
300
|
-
`+
|
|
301
|
-
`),
|
|
302
|
-
`).forEach(l=>{let[
|
|
303
|
-
[Fleetbo] Initializing and configuring Fleetbo...`),await
|
|
176
|
+
}),`;if(e=e.slice(0,a)+P+e.slice(a),!e.includes("import AutoImport")){let h=[...e.matchAll(/^import .+;?$/gm)].pop(),v=`import AutoImport from 'unplugin-auto-import/vite';
|
|
177
|
+
`;if(h){let u=h.index+h[0].length;e=e.slice(0,u)+`
|
|
178
|
+
`+v+e.slice(u)}else e=v+e}}}if(e.includes("fleetbo-schema-sync-middleware")||e.includes("__fleetbo_sync_schema")){let o=/\{\s*name:\s*['"]fleetbo-schema-sync-middleware['"][\s\S]*?\},/g;!e.includes("transformIndexHtml")&&o.test(e)&&(e=e.replace(o,i),f("\u2192 Updated Fleetbo Vite plugin with universal runtime injection."))}else{let o=e.match(/plugins\s*:\s*\[/);if(o){let a=o.index+o[0].length;e=e.slice(0,a)+`
|
|
179
|
+
`+i+e.slice(a)}}if(e!==l)try{b.writeFileSync(s,e),f(`\u2192 Updated ${p.basename(s)} with Watcher and AutoImport configuration.`)}catch(o){d(`\u26A0\uFE0F Failed to write to ${p.basename(s)}: ${o.message}`)}try{let o=JSON.parse(b.readFileSync(n,"utf8"));o.devDependencies=o.devDependencies||{},o.devDependencies["unplugin-auto-import"]||(o.devDependencies["unplugin-auto-import"]="^0.18.0",b.writeFileSync(n,JSON.stringify(o,null,2)+`
|
|
180
|
+
`),f("\u2192 Added unplugin-auto-import to devDependencies."))}catch(o){d(`\u26A0\uFE0F Failed to update ${p.basename(n)}: ${o.message}`)}}function W(t,n,r={}){let{skipSelfInstall:s=!1}=r,l=p.join(__dirname,"..");s||N(t,n),U(t),M(l),B(t),I(t),O(t,n),w(t,n)}k.exports={touchTsConfig:q,log:f,logError:d,handleAuthAndEnv:V,detectDependency:E,cleanupLegacyRootDts:I,patchJsOrTsConfig:O,attemptViteAutoImportPatch:w,runFullSetup:W}});var g=require("fs"),F=require("path"),j=require("https"),{runFullSetup:X,handleAuthAndEnv:K,touchTsConfig:G,attemptViteAutoImportPatch:Y}=_(),z="\x1B[34m",Q="\x1B[31m",C="\x1B[0m";function m(t){console.log(`${z}${t}${C}`)}function y(t){console.error(`${Q}${t}${C}`)}function Z(t,n){return new Promise((r,s)=>{let l=JSON.stringify({enterpriseID:t,schema:n}),c={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l)}},e=j.request(c,i=>{let o="";i.on("data",a=>{o+=a}),i.on("end",()=>{i.statusCode>=200&&i.statusCode<300?r(JSON.parse(o)):s(new Error(`Edge sync failed with HTTP ${i.statusCode}`))})});e.on("error",i=>s(i)),e.write(l),e.end()})}function ee(t){let n=F.join(t,".env");if(!g.existsSync(n))return{};let r=g.readFileSync(n,"utf8"),s={};return r.split(`
|
|
181
|
+
`).forEach(l=>{let[c,...e]=l.split("=");c&&e.length>0&&(s[c.trim()]=e.join("=").trim())}),s}function te(t){return new Promise((n,r)=>{let s=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(s)}},c=j.request(l,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 a=o.module.code||o.module.mockCode;n(typeof a=="string"?JSON.parse(a):a)}else r(new Error("Schema not found in Fleetbo Cloud."))}catch{r(new Error("Invalid JSON response received from Fleetbo server."))}else r(new Error(`Server error ${e.statusCode}`))})});c.on("error",e=>r(e)),c.write(s),c.end()})}var T=process.argv.slice(2),S=T[0];async function oe(){let t=process.cwd(),n=F.join(t,"package.json");if(S==="init"||S==="doctor")m(`
|
|
182
|
+
[Fleetbo] Initializing and configuring Fleetbo...`),await K(t,T),X(t,n),m(`
|
|
304
183
|
[Fleetbo] Configuration completed successfully!
|
|
305
|
-
`),
|
|
306
|
-
Next step:`),
|
|
307
|
-
`);else if(
|
|
308
|
-
`),
|
|
184
|
+
`),m(`
|
|
185
|
+
Next step:`),m(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
|
|
186
|
+
`);else if(S==="sync"){let r=T.includes("--dry-run");m(`[Fleetbo] Syncing schema...${r?" (dry-run)":""}`);let s=F.join(t,"svro.schema.json"),l=F.join(__dirname,".."),c=F.join(l,"index.d.ts"),e=F.join(t,"src","auto-imports.d.ts"),o=ee(t).VITE_FLEETBO_ENTERPRISE_ID;if(o)try{m("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let a=await te(o);g.writeFileSync(s,JSON.stringify(a,null,2)+`
|
|
187
|
+
`),m("\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(s)||(y("Error: svro.schema.json not found."),process.exit(1));try{let a=JSON.parse(g.readFileSync(s,"utf8")),P=Object.keys(a.collections||{});if(o)try{await Z(o,a),m("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(u){y(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${u.message}`)}let h=P.length>0?P.map(u=>`'${u}'`).join(" | "):"string",v=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
|
|
309
188
|
|
|
310
|
-
export type FleetboTables = ${
|
|
189
|
+
export type FleetboTables = ${h};
|
|
311
190
|
|
|
312
191
|
declare global {
|
|
313
192
|
interface ImportMetaEnv {
|
|
@@ -346,16 +225,6 @@ export interface FleetboAuthResult {
|
|
|
346
225
|
error?: string;
|
|
347
226
|
}
|
|
348
227
|
|
|
349
|
-
export declare const FleetboUI: {
|
|
350
|
-
Text: string;
|
|
351
|
-
Number: string;
|
|
352
|
-
Toggle: string;
|
|
353
|
-
Date: string;
|
|
354
|
-
Enum: string;
|
|
355
|
-
Media: string;
|
|
356
|
-
Reference: string;
|
|
357
|
-
};
|
|
358
|
-
|
|
359
228
|
export interface FleetboAclResult {
|
|
360
229
|
success: boolean;
|
|
361
230
|
error?: string;
|
|
@@ -370,7 +239,7 @@ export interface FleetboJoinOptions {
|
|
|
370
239
|
}
|
|
371
240
|
}
|
|
372
241
|
|
|
373
|
-
export declare const Fleetbo:
|
|
242
|
+
export declare const Fleetbo: {
|
|
374
243
|
call: {
|
|
375
244
|
[key: string]: <T = any>(payload?: Record<string, any>) => Promise<FleetboCallResult<T>>;
|
|
376
245
|
};
|
|
@@ -403,62 +272,33 @@ export declare const Fleetbo: typeof FleetboUI & {
|
|
|
403
272
|
};
|
|
404
273
|
};
|
|
405
274
|
|
|
275
|
+
export type FleetboProp = {
|
|
276
|
+
value?: any;
|
|
277
|
+
fallback?: string;
|
|
278
|
+
'invalid-fallback'?: string;
|
|
279
|
+
currency?: string;
|
|
280
|
+
locale?: string;
|
|
281
|
+
allowed?: string;
|
|
282
|
+
alt?: string;
|
|
283
|
+
table?: FleetboTables | string;
|
|
284
|
+
id?: string;
|
|
285
|
+
field?: string;
|
|
286
|
+
'label-true'?: string;
|
|
287
|
+
'label-false'?: string;
|
|
288
|
+
'orphan-fallback'?: string;
|
|
289
|
+
'loading-fallback'?: string;
|
|
290
|
+
'malformed-fallback'?: string;
|
|
291
|
+
class?: string;
|
|
292
|
+
className?: string;
|
|
293
|
+
children?: any;
|
|
294
|
+
[key: string]: any;
|
|
295
|
+
};
|
|
296
|
+
|
|
406
297
|
declare global {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
fallback?: string;
|
|
412
|
-
class?: string;
|
|
413
|
-
className?: string;
|
|
414
|
-
};
|
|
415
|
-
'fleetbo-number': {
|
|
416
|
-
value?: any;
|
|
417
|
-
'invalid-fallback'?: string;
|
|
418
|
-
currency?: string;
|
|
419
|
-
class?: string;
|
|
420
|
-
className?: string;
|
|
421
|
-
};
|
|
422
|
-
'fleetbo-toggle': {
|
|
423
|
-
value?: any;
|
|
424
|
-
'label-true'?: string;
|
|
425
|
-
'label-false'?: string;
|
|
426
|
-
'invalid-fallback'?: string;
|
|
427
|
-
class?: string;
|
|
428
|
-
className?: string;
|
|
429
|
-
};
|
|
430
|
-
'fleetbo-date': {
|
|
431
|
-
value?: any;
|
|
432
|
-
locale?: string;
|
|
433
|
-
'invalid-fallback'?: string;
|
|
434
|
-
class?: string;
|
|
435
|
-
className?: string;
|
|
436
|
-
};
|
|
437
|
-
'fleetbo-enum': {
|
|
438
|
-
value?: any;
|
|
439
|
-
allowed?: string;
|
|
440
|
-
'invalid-fallback'?: string;
|
|
441
|
-
class?: string;
|
|
442
|
-
className?: string;
|
|
443
|
-
};
|
|
444
|
-
'fleetbo-media': {
|
|
445
|
-
value?: any;
|
|
446
|
-
alt?: string;
|
|
447
|
-
fallback?: string;
|
|
448
|
-
class?: string;
|
|
449
|
-
className?: string;
|
|
450
|
-
};
|
|
451
|
-
'fleetbo-reference': {
|
|
452
|
-
table: FleetboTables;
|
|
453
|
-
id?: string;
|
|
454
|
-
field?: string;
|
|
455
|
-
'orphan-fallback'?: string;
|
|
456
|
-
'loading-fallback'?: string;
|
|
457
|
-
'malformed-fallback'?: string;
|
|
458
|
-
class?: string;
|
|
459
|
-
className?: string;
|
|
460
|
-
};
|
|
461
|
-
}
|
|
298
|
+
const Fleetbo: typeof import('./index').Fleetbo;
|
|
299
|
+
|
|
300
|
+
interface Window {
|
|
301
|
+
Fleetbo: typeof Fleetbo;
|
|
462
302
|
}
|
|
463
303
|
|
|
464
304
|
interface HTMLElementTagNameMap {
|
|
@@ -471,54 +311,139 @@ declare global {
|
|
|
471
311
|
'fleetbo-reference': HTMLElement;
|
|
472
312
|
}
|
|
473
313
|
|
|
474
|
-
|
|
475
|
-
|
|
314
|
+
namespace JSX {
|
|
315
|
+
interface IntrinsicElements {
|
|
316
|
+
'fleetbo-text': FleetboProp;
|
|
317
|
+
'fleetbo-number': FleetboProp;
|
|
318
|
+
'fleetbo-toggle': FleetboProp;
|
|
319
|
+
'fleetbo-date': FleetboProp;
|
|
320
|
+
'fleetbo-enum': FleetboProp;
|
|
321
|
+
'fleetbo-media': FleetboProp;
|
|
322
|
+
'fleetbo-reference': FleetboProp;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
476
325
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
326
|
+
namespace React {
|
|
327
|
+
namespace JSX {
|
|
328
|
+
interface IntrinsicElements {
|
|
329
|
+
'fleetbo-text': FleetboProp;
|
|
330
|
+
'fleetbo-number': FleetboProp;
|
|
331
|
+
'fleetbo-toggle': FleetboProp;
|
|
332
|
+
'fleetbo-date': FleetboProp;
|
|
333
|
+
'fleetbo-enum': FleetboProp;
|
|
334
|
+
'fleetbo-media': FleetboProp;
|
|
335
|
+
'fleetbo-reference': FleetboProp;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
declare module 'react' {
|
|
342
|
+
namespace JSX {
|
|
343
|
+
interface IntrinsicElements {
|
|
344
|
+
'fleetbo-text': FleetboProp;
|
|
345
|
+
'fleetbo-number': FleetboProp;
|
|
346
|
+
'fleetbo-toggle': FleetboProp;
|
|
347
|
+
'fleetbo-date': FleetboProp;
|
|
348
|
+
'fleetbo-enum': FleetboProp;
|
|
349
|
+
'fleetbo-media': FleetboProp;
|
|
350
|
+
'fleetbo-reference': FleetboProp;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
declare module '@vue/runtime-core' {
|
|
356
|
+
export interface GlobalComponents {
|
|
357
|
+
'fleetbo-text': FleetboProp;
|
|
358
|
+
'fleetbo-number': FleetboProp;
|
|
359
|
+
'fleetbo-toggle': FleetboProp;
|
|
360
|
+
'fleetbo-date': FleetboProp;
|
|
361
|
+
'fleetbo-enum': FleetboProp;
|
|
362
|
+
'fleetbo-media': FleetboProp;
|
|
363
|
+
'fleetbo-reference': FleetboProp;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
declare module 'preact' {
|
|
368
|
+
namespace JSX {
|
|
369
|
+
interface IntrinsicElements {
|
|
370
|
+
'fleetbo-text': FleetboProp;
|
|
371
|
+
'fleetbo-number': FleetboProp;
|
|
372
|
+
'fleetbo-toggle': FleetboProp;
|
|
373
|
+
'fleetbo-date': FleetboProp;
|
|
374
|
+
'fleetbo-enum': FleetboProp;
|
|
375
|
+
'fleetbo-media': FleetboProp;
|
|
376
|
+
'fleetbo-reference': FleetboProp;
|
|
377
|
+
}
|
|
480
378
|
}
|
|
481
379
|
}
|
|
482
|
-
|
|
380
|
+
|
|
381
|
+
declare module 'svelte/elements' {
|
|
382
|
+
export interface SvelteHTMLElements {
|
|
383
|
+
'fleetbo-text': FleetboProp;
|
|
384
|
+
'fleetbo-number': FleetboProp;
|
|
385
|
+
'fleetbo-toggle': FleetboProp;
|
|
386
|
+
'fleetbo-date': FleetboProp;
|
|
387
|
+
'fleetbo-enum': FleetboProp;
|
|
388
|
+
'fleetbo-media': FleetboProp;
|
|
389
|
+
'fleetbo-reference': FleetboProp;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
`;if(g.writeFileSync(c,v),g.existsSync(F.dirname(e))){let u=`/* eslint-disable */
|
|
483
393
|
/* prettier-ignore */
|
|
484
394
|
// @ts-nocheck
|
|
485
395
|
// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
|
|
486
396
|
export {}
|
|
487
397
|
|
|
488
|
-
type
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
398
|
+
type FleetboProp = {
|
|
399
|
+
value?: any;
|
|
400
|
+
fallback?: string;
|
|
401
|
+
'invalid-fallback'?: string;
|
|
402
|
+
currency?: string;
|
|
403
|
+
locale?: string;
|
|
404
|
+
allowed?: string;
|
|
405
|
+
alt?: string;
|
|
406
|
+
table?: any;
|
|
407
|
+
id?: string;
|
|
408
|
+
field?: string;
|
|
409
|
+
'label-true'?: string;
|
|
410
|
+
'label-false'?: string;
|
|
411
|
+
'orphan-fallback'?: string;
|
|
412
|
+
'loading-fallback'?: string;
|
|
413
|
+
'malformed-fallback'?: string;
|
|
414
|
+
class?: string;
|
|
415
|
+
className?: string;
|
|
416
|
+
children?: any;
|
|
417
|
+
[key: string]: any;
|
|
418
|
+
};
|
|
495
419
|
|
|
496
420
|
declare global {
|
|
497
|
-
type FleetboTables = ${
|
|
421
|
+
type FleetboTables = ${h};
|
|
498
422
|
const Fleetbo: typeof import('fleetbo-svro')['Fleetbo'];
|
|
499
|
-
const FleetboUI: typeof import('fleetbo-svro')['FleetboUI'];
|
|
500
423
|
|
|
501
424
|
namespace JSX {
|
|
502
425
|
interface IntrinsicElements {
|
|
503
|
-
'fleetbo-text':
|
|
504
|
-
'fleetbo-number':
|
|
505
|
-
'fleetbo-toggle':
|
|
506
|
-
'fleetbo-date':
|
|
507
|
-
'fleetbo-enum':
|
|
508
|
-
'fleetbo-media':
|
|
509
|
-
'fleetbo-reference':
|
|
426
|
+
'fleetbo-text': FleetboProp;
|
|
427
|
+
'fleetbo-number': FleetboProp;
|
|
428
|
+
'fleetbo-toggle': FleetboProp;
|
|
429
|
+
'fleetbo-date': FleetboProp;
|
|
430
|
+
'fleetbo-enum': FleetboProp;
|
|
431
|
+
'fleetbo-media': FleetboProp;
|
|
432
|
+
'fleetbo-reference': FleetboProp;
|
|
510
433
|
}
|
|
511
434
|
}
|
|
512
435
|
|
|
513
|
-
namespace React
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
436
|
+
namespace React {
|
|
437
|
+
namespace JSX {
|
|
438
|
+
interface IntrinsicElements {
|
|
439
|
+
'fleetbo-text': FleetboProp;
|
|
440
|
+
'fleetbo-number': FleetboProp;
|
|
441
|
+
'fleetbo-toggle': FleetboProp;
|
|
442
|
+
'fleetbo-date': FleetboProp;
|
|
443
|
+
'fleetbo-enum': FleetboProp;
|
|
444
|
+
'fleetbo-media': FleetboProp;
|
|
445
|
+
'fleetbo-reference': FleetboProp;
|
|
446
|
+
}
|
|
522
447
|
}
|
|
523
448
|
}
|
|
524
449
|
}
|
|
@@ -526,14 +451,52 @@ declare global {
|
|
|
526
451
|
declare module 'react' {
|
|
527
452
|
namespace JSX {
|
|
528
453
|
interface IntrinsicElements {
|
|
529
|
-
'fleetbo-text':
|
|
530
|
-
'fleetbo-number':
|
|
531
|
-
'fleetbo-toggle':
|
|
532
|
-
'fleetbo-date':
|
|
533
|
-
'fleetbo-enum':
|
|
534
|
-
'fleetbo-media':
|
|
535
|
-
'fleetbo-reference':
|
|
454
|
+
'fleetbo-text': FleetboProp;
|
|
455
|
+
'fleetbo-number': FleetboProp;
|
|
456
|
+
'fleetbo-toggle': FleetboProp;
|
|
457
|
+
'fleetbo-date': FleetboProp;
|
|
458
|
+
'fleetbo-enum': FleetboProp;
|
|
459
|
+
'fleetbo-media': FleetboProp;
|
|
460
|
+
'fleetbo-reference': FleetboProp;
|
|
536
461
|
}
|
|
537
462
|
}
|
|
538
463
|
}
|
|
539
|
-
|
|
464
|
+
|
|
465
|
+
declare module '@vue/runtime-core' {
|
|
466
|
+
export interface GlobalComponents {
|
|
467
|
+
'fleetbo-text': FleetboProp;
|
|
468
|
+
'fleetbo-number': FleetboProp;
|
|
469
|
+
'fleetbo-toggle': FleetboProp;
|
|
470
|
+
'fleetbo-date': FleetboProp;
|
|
471
|
+
'fleetbo-enum': FleetboProp;
|
|
472
|
+
'fleetbo-media': FleetboProp;
|
|
473
|
+
'fleetbo-reference': FleetboProp;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
declare module 'preact' {
|
|
478
|
+
namespace JSX {
|
|
479
|
+
interface IntrinsicElements {
|
|
480
|
+
'fleetbo-text': FleetboProp;
|
|
481
|
+
'fleetbo-number': FleetboProp;
|
|
482
|
+
'fleetbo-toggle': FleetboProp;
|
|
483
|
+
'fleetbo-date': FleetboProp;
|
|
484
|
+
'fleetbo-enum': FleetboProp;
|
|
485
|
+
'fleetbo-media': FleetboProp;
|
|
486
|
+
'fleetbo-reference': FleetboProp;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
declare module 'svelte/elements' {
|
|
492
|
+
export interface SvelteHTMLElements {
|
|
493
|
+
'fleetbo-text': FleetboProp;
|
|
494
|
+
'fleetbo-number': FleetboProp;
|
|
495
|
+
'fleetbo-toggle': FleetboProp;
|
|
496
|
+
'fleetbo-date': FleetboProp;
|
|
497
|
+
'fleetbo-enum': FleetboProp;
|
|
498
|
+
'fleetbo-media': FleetboProp;
|
|
499
|
+
'fleetbo-reference': FleetboProp;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
`;g.writeFileSync(e,u)}G(t),Y(t,n),m(`[Fleetbo] Schema synced successfully (${P.length} collection(s)).`),r&&m("\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)}oe().catch(t=>{y(`Fleetbo CLI Error: ${t.message}`),process.exit(1)});
|