@vaiftech/client 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 VAIF Technologies
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,202 @@
1
+ # @vaif/client
2
+
3
+ The official TypeScript SDK for VAIF Studio - a Backend-as-a-Service platform.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @vaif/client
9
+ # or
10
+ pnpm add @vaif/client
11
+ # or
12
+ yarn add @vaif/client
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { createVaifClient } from '@vaif/client';
19
+
20
+ const vaif = createVaifClient({
21
+ baseUrl: 'https://api.myproject.vaif.io',
22
+ apiKey: 'vaif_pk_xxx',
23
+ });
24
+ ```
25
+
26
+ ## Features
27
+
28
+ ### Authentication
29
+
30
+ ```typescript
31
+ // Sign up
32
+ const { user, session } = await vaif.auth.signUp({
33
+ email: 'user@example.com',
34
+ password: 'securepassword',
35
+ });
36
+
37
+ // Sign in
38
+ const { user, session } = await vaif.auth.signIn({
39
+ email: 'user@example.com',
40
+ password: 'securepassword',
41
+ });
42
+
43
+ // OAuth
44
+ const { url } = await vaif.auth.signInWithOAuth({
45
+ provider: 'google',
46
+ redirectTo: 'https://myapp.com/callback',
47
+ });
48
+
49
+ // Get current user
50
+ const user = await vaif.auth.getUser();
51
+
52
+ // Sign out
53
+ await vaif.auth.signOut();
54
+ ```
55
+
56
+ ### Database Operations
57
+
58
+ ```typescript
59
+ // Define your types
60
+ interface User {
61
+ id: string;
62
+ email: string;
63
+ name: string;
64
+ createdAt: string;
65
+ }
66
+
67
+ // List with filters
68
+ const users = await vaif.from<User>('users')
69
+ .select('id', 'name', 'email')
70
+ .eq('active', true)
71
+ .orderBy('createdAt', 'desc')
72
+ .limit(10)
73
+ .list();
74
+
75
+ // Get single record
76
+ const user = await vaif.from<User>('users')
77
+ .eq('id', 'user-123')
78
+ .single();
79
+
80
+ // Create
81
+ const newUser = await vaif.from<User>('users').create({
82
+ email: 'new@example.com',
83
+ name: 'New User',
84
+ });
85
+
86
+ // Update
87
+ const updated = await vaif.from<User>('users')
88
+ .eq('id', 'user-123')
89
+ .update({ name: 'Updated Name' });
90
+
91
+ // Delete
92
+ await vaif.from<User>('users')
93
+ .eq('id', 'user-123')
94
+ .delete();
95
+
96
+ // Pagination
97
+ const { data, total, page, pageSize } = await vaif.from<User>('users')
98
+ .paginate({ page: 1, pageSize: 20 });
99
+ ```
100
+
101
+ ### Realtime Subscriptions
102
+
103
+ ```typescript
104
+ const realtime = vaif.realtime();
105
+ await realtime.connect();
106
+
107
+ // Subscribe to table changes
108
+ realtime.subscribe(
109
+ { table: 'messages', event: 'INSERT' },
110
+ (event) => {
111
+ console.log('New message:', event.new);
112
+ }
113
+ );
114
+
115
+ // Channel messaging
116
+ const channel = realtime.channel('room-1');
117
+
118
+ // Presence
119
+ channel.presence.track({ userId: 'user-123', status: 'online' });
120
+ channel.presence.onSync((state) => {
121
+ console.log('Online users:', Object.keys(state));
122
+ });
123
+
124
+ // Broadcast
125
+ channel.broadcast.send('typing', { userId: 'user-123' });
126
+ channel.broadcast.on('typing', (payload) => {
127
+ console.log('User typing:', payload.userId);
128
+ });
129
+
130
+ // Cleanup
131
+ realtime.unsubscribe({ table: 'messages' });
132
+ await realtime.disconnect();
133
+ ```
134
+
135
+ ### Storage
136
+
137
+ ```typescript
138
+ // Upload file
139
+ const result = await vaif.storage.upload('avatars/user-123.jpg', file, {
140
+ contentType: 'image/jpeg',
141
+ isPublic: true,
142
+ });
143
+
144
+ // Download file
145
+ const blob = await vaif.storage.download('avatars/user-123.jpg');
146
+
147
+ // Get public URL
148
+ const url = vaif.storage.getPublicUrl('avatars/user-123.jpg');
149
+
150
+ // Get signed URL (temporary access)
151
+ const signedUrl = await vaif.storage.getSignedUrl('private/doc.pdf', {
152
+ expiresIn: 3600,
153
+ });
154
+
155
+ // List files
156
+ const { files } = await vaif.storage.list({ prefix: 'avatars/' });
157
+
158
+ // Delete file
159
+ await vaif.storage.delete('avatars/old-avatar.jpg');
160
+ ```
161
+
162
+ ### Edge Functions
163
+
164
+ ```typescript
165
+ // Invoke a function
166
+ const result = await vaif.functions.invoke('send-email', {
167
+ to: 'user@example.com',
168
+ subject: 'Hello',
169
+ body: 'Welcome to VAIF!',
170
+ });
171
+
172
+ // List functions
173
+ const functions = await vaif.functions.list({ projectId: 'proj-123' });
174
+ ```
175
+
176
+ ## TypeScript Support
177
+
178
+ The SDK is fully typed. Use generics for type-safe database operations:
179
+
180
+ ```typescript
181
+ interface Post {
182
+ id: string;
183
+ title: string;
184
+ content: string;
185
+ authorId: string;
186
+ createdAt: string;
187
+ }
188
+
189
+ // Full type inference
190
+ const posts = await vaif.from<Post>('posts').list();
191
+ // posts is Post[]
192
+ ```
193
+
194
+ ## Related Packages
195
+
196
+ - [@vaif/react](https://www.npmjs.com/package/@vaif/react) - React hooks
197
+ - [@vaif/sdk-expo](https://www.npmjs.com/package/@vaif/sdk-expo) - React Native/Expo SDK
198
+ - [@vaif/cli](https://www.npmjs.com/package/@vaif/cli) - CLI tools
199
+
200
+ ## License
201
+
202
+ MIT