@tthr/vue 0.0.68 → 0.0.70

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.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,KAAK,EAAgC,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGtG,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAKlF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI,CAE9E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,IAAI,kBAAkB,CAQpD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CAEzF;AAMD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,eAAe,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;CACtD;AAoGD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,OAAO,EAClD,EAAE,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G;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,OAAO,EAClD,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,EACxE,IAAI,EAAE,KAAK,EACX,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,OAAO,CAAC,CA4ClB"}
package/dist/server.js CHANGED
@@ -152,12 +152,17 @@ function createDatabaseProxy(client) {
152
152
  },
153
153
  upsert: async (options) => {
154
154
  const whereObj = options.where;
155
- const id = whereObj.id;
156
- // Try to find existing
157
- const existing = id
158
- ? await client.query(`${tableName}.get`, { id }).catch(() => null)
159
- : null;
155
+ // Try to find existing record using the where clause
156
+ // This allows upserting on any field (e.g. clip_id, email, etc.)
157
+ // Use list with limit: 1 since findFirst doesn't exist on the server
158
+ const results = await client.query(`${tableName}.list`, { where: whereObj, limit: 1 }).catch(() => []);
159
+ const existing = results?.[0] ?? null;
160
160
  if (existing) {
161
+ // Use _id from the found record for the update
162
+ const id = existing._id ?? existing.id;
163
+ if (!id) {
164
+ throw new Error('Found record has no _id or id field for update');
165
+ }
161
166
  await client.mutation(`${tableName}.update`, { id, data: options.update });
162
167
  return { ...existing, ...options.update };
163
168
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAkC,MAAM,cAAc,CAAC;AAGlF,wDAAwD;AACxD,OAAO,EAAE,kBAAkB,EAAkC,MAAM,cAAc,CAAC;AAElF,4BAA4B;AAC5B,IAAI,YAAY,GAA8B,IAAI,CAAC;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAkC;IACtE,YAAY,GAAG,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eA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e,EAAE,CAAC;IAC9C,IAAI,QAAQ,EAAE,CAAC;QACb,GAAG,CAAC,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC9B,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC;QACnC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,wBAAwB;IACxB,MAAM,cAAc,GAAG;QACrB,EAAE;QACF,GAAG;QACH,IAAI;QACJ,IAAI;KACL,CAAC;IAEF,+BAA+B;IAC/B,yEAAyE;IACzE,8DAA8D;IAC9D,OAAO,EAAE,CAAC,OAAO,CAAC,cAAqB,CAAC,CAAC;AAC3C,CAAC"}
@@ -185,9 +185,10 @@ function createDatabaseProxy(apiKey, url, projectId) {
185
185
  },
186
186
  update: async (options) => {
187
187
  const whereObj = options.where;
188
- const id = whereObj?.id;
188
+ // Support both _id (standard) and id (legacy) in where clause
189
+ const id = whereObj?._id ?? whereObj?.id;
189
190
  if (!id) {
190
- throw new Error('Update requires an id in the where clause');
191
+ throw new Error('Update requires an _id in the where clause');
191
192
  }
192
193
  const result = await makeMutation('update', { id, data: options.data });
193
194
  return result?.rowsAffected ?? 0;
@@ -197,7 +198,9 @@ function createDatabaseProxy(apiKey, url, projectId) {
197
198
 
198
199
  // Try to find existing record using the where clause
199
200
  // This allows upserting on any field (e.g. clip_id, email, etc.)
200
- const existing = await makeRequest('findFirst', { where: whereObj }).catch(() => null);
201
+ // Use list with limit: 1 since findFirst doesn't exist on the server
202
+ const results = await makeRequest('list', { where: whereObj, limit: 1 }).catch(() => []);
203
+ const existing = results?.[0] ?? null;
201
204
 
202
205
  if (existing) {
203
206
  // Use _id from the found record for the update
@@ -213,9 +216,10 @@ function createDatabaseProxy(apiKey, url, projectId) {
213
216
  },
214
217
  delete: async (options) => {
215
218
  const whereObj = options.where;
216
- const id = whereObj?.id;
219
+ // Support both _id (standard) and id (legacy) in where clause
220
+ const id = whereObj?._id ?? whereObj?.id;
217
221
  if (!id) {
218
- throw new Error('Delete requires an id in the where clause');
222
+ throw new Error('Delete requires an _id in the where clause');
219
223
  }
220
224
  const result = await makeMutation('delete', { id });
221
225
  return result?.rowsAffected ?? 0;
@@ -244,9 +244,16 @@ function createDatabaseProxy(apiKey, url, projectId, environment) {
244
244
  return result?.rowsAffected ?? 0;
245
245
  },
246
246
  upsert: async (options) => {
247
- const id = options.where?.id;
248
- const existing = id ? await makeRequest('get', { id }).catch(() => null) : null;
247
+ // Try to find existing record using the where clause
248
+ // This allows upserting on any field (e.g. clip_id, email, etc.)
249
+ // Use list with limit: 1 since findFirst doesn't exist on the server
250
+ const results = await makeRequest('list', { where: options.where, limit: 1 }).catch(() => []);
251
+ const existing = results?.[0] ?? null;
249
252
  if (existing) {
253
+ // Use _id from the found record for the update
254
+ const id = existing._id ?? existing.id;
255
+ if (!id)
256
+ throw new Error('Found record has no _id or id field for update');
250
257
  await makeMutation('update', { id, data: options.update });
251
258
  return { ...existing, ...options.update };
252
259
  }
@@ -185,22 +185,29 @@ function createDatabaseProxy(apiKey, url, projectId) {
185
185
  },
186
186
  update: async (options) => {
187
187
  const whereObj = options.where;
188
- const id = whereObj?.id;
188
+ // Support both _id (standard) and id (legacy) in where clause
189
+ const id = whereObj?._id ?? whereObj?.id;
189
190
  if (!id) {
190
- throw new Error('Update requires an id in the where clause');
191
+ throw new Error('Update requires an _id in the where clause');
191
192
  }
192
193
  const result = await makeMutation('update', { id, data: options.data });
193
194
  return result?.rowsAffected ?? 0;
194
195
  },
195
196
  upsert: async (options) => {
196
197
  const whereObj = options.where;
197
- const id = whereObj?.id;
198
198
 
199
- const existing = id
200
- ? await makeRequest('get', { id }).catch(() => null)
201
- : null;
199
+ // Try to find existing record using the where clause
200
+ // This allows upserting on any field (e.g. clip_id, email, etc.)
201
+ // Use list with limit: 1 since findFirst doesn't exist on the server
202
+ const results = await makeRequest('list', { where: whereObj, limit: 1 }).catch(() => []);
203
+ const existing = results?.[0] ?? null;
202
204
 
203
205
  if (existing) {
206
+ // Use _id from the found record for the update
207
+ const id = existing._id ?? existing.id;
208
+ if (!id) {
209
+ throw new Error('Found record has no _id or id field for update');
210
+ }
204
211
  await makeMutation('update', { id, data: options.update });
205
212
  return { ...existing, ...options.update };
206
213
  } else {
@@ -209,9 +216,10 @@ function createDatabaseProxy(apiKey, url, projectId) {
209
216
  },
210
217
  delete: async (options) => {
211
218
  const whereObj = options.where;
212
- const id = whereObj?.id;
219
+ // Support both _id (standard) and id (legacy) in where clause
220
+ const id = whereObj?._id ?? whereObj?.id;
213
221
  if (!id) {
214
- throw new Error('Delete requires an id in the where clause');
222
+ throw new Error('Delete requires an _id in the where clause');
215
223
  }
216
224
  const result = await makeMutation('delete', { id });
217
225
  return result?.rowsAffected ?? 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tthr/vue",
3
- "version": "0.0.68",
3
+ "version": "0.0.70",
4
4
  "description": "Tether Vue/Nuxt SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,87 +0,0 @@
1
- /**
2
- * Nuxt composables for Tether
3
- *
4
- * These are auto-imported when using the Tether Nuxt module.
5
- * Queries and mutations are executed server-side to keep API keys secure.
6
- * WebSocket subscriptions run client-side for realtime updates.
7
- */
8
- import { type Ref } from 'vue';
9
- /**
10
- * Query state returned by useQuery
11
- */
12
- export interface QueryState<T> {
13
- data: Ref<T | undefined>;
14
- error: Ref<Error | null>;
15
- isLoading: Ref<boolean>;
16
- refetch: () => Promise<void>;
17
- /** Update data directly (used for hot-swapping from WebSocket) */
18
- setData: (newData: T) => void;
19
- }
20
- /**
21
- * Query function reference
22
- */
23
- export interface QueryFunction<TArgs = void, TResult = unknown> {
24
- _name: string;
25
- _args?: TArgs;
26
- _result?: TResult;
27
- }
28
- /**
29
- * Reactive query composable with auto-refresh on subscription updates
30
- *
31
- * @example
32
- * ```vue
33
- * <script setup>
34
- * const { data: posts, isLoading } = useQuery(api.posts.list);
35
- * </script>
36
- * ```
37
- */
38
- export declare function useQuery<TArgs, TResult>(query: QueryFunction<TArgs, TResult> | string, args?: TArgs): QueryState<TResult>;
39
- /**
40
- * Mutation state returned by useMutation
41
- */
42
- export interface MutationState<TArgs, TResult> {
43
- data: Ref<TResult | undefined>;
44
- error: Ref<Error | null>;
45
- isPending: Ref<boolean>;
46
- mutate: (args: TArgs) => Promise<TResult>;
47
- reset: () => void;
48
- }
49
- /**
50
- * Mutation function reference
51
- */
52
- export interface MutationFunction<TArgs = void, TResult = unknown> {
53
- _name: string;
54
- _args?: TArgs;
55
- _result?: TResult;
56
- }
57
- /**
58
- * Mutation composable
59
- *
60
- * @example
61
- * ```vue
62
- * <script setup>
63
- * const { mutate: createPost, isPending } = useMutation(api.posts.create);
64
- *
65
- * async function handleSubmit() {
66
- * await createPost({ title: 'Hello', content: '...' });
67
- * }
68
- * </script>
69
- * ```
70
- */
71
- export declare function useMutation<TArgs, TResult>(mutation: MutationFunction<TArgs, TResult> | string): MutationState<TArgs, TResult>;
72
- /**
73
- * WebSocket subscription composable for realtime updates
74
- * This runs client-side only and calls refetch when updates are received
75
- *
76
- * @example
77
- * ```vue
78
- * <script setup>
79
- * const { data: posts, refetch } = useQuery('posts.list');
80
- * useTetherSubscription('posts.list', {}, refetch);
81
- * </script>
82
- * ```
83
- */
84
- export declare function useTetherSubscription(queryName: string, args: Record<string, unknown> | undefined, onUpdate: (data?: unknown) => void): {
85
- isConnected: Ref<boolean>;
86
- };
87
- //# sourceMappingURL=composables.d.ts.map
@@ -1,275 +0,0 @@
1
- /**
2
- * Nuxt composables for Tether
3
- *
4
- * These are auto-imported when using the Tether Nuxt module.
5
- * Queries and mutations are executed server-side to keep API keys secure.
6
- * WebSocket subscriptions run client-side for realtime updates.
7
- */
8
- import { ref, onMounted, onUnmounted } from 'vue';
9
- /**
10
- * Reactive query composable with auto-refresh on subscription updates
11
- *
12
- * @example
13
- * ```vue
14
- * <script setup>
15
- * const { data: posts, isLoading } = useQuery(api.posts.list);
16
- * </script>
17
- * ```
18
- */
19
- export function useQuery(query, args) {
20
- const queryName = typeof query === 'string' ? query : query._name;
21
- const data = ref();
22
- const error = ref(null);
23
- const isLoading = ref(true);
24
- const fetchData = async () => {
25
- try {
26
- isLoading.value = true;
27
- error.value = null;
28
- const response = await $fetch('/api/_tether/query', {
29
- method: 'POST',
30
- body: {
31
- function: queryName,
32
- args,
33
- },
34
- });
35
- data.value = response.data;
36
- }
37
- catch (e) {
38
- error.value = e instanceof Error ? e : new Error(String(e));
39
- }
40
- finally {
41
- isLoading.value = false;
42
- }
43
- };
44
- // Fetch on mount (client-side)
45
- onMounted(() => {
46
- fetchData();
47
- });
48
- // Also fetch immediately for SSR
49
- if (import.meta.server) {
50
- fetchData();
51
- }
52
- // Direct data setter for hot-swapping from WebSocket
53
- const setData = (newData) => {
54
- data.value = newData;
55
- };
56
- return {
57
- data: data,
58
- error,
59
- isLoading,
60
- refetch: fetchData,
61
- setData,
62
- };
63
- }
64
- /**
65
- * Mutation composable
66
- *
67
- * @example
68
- * ```vue
69
- * <script setup>
70
- * const { mutate: createPost, isPending } = useMutation(api.posts.create);
71
- *
72
- * async function handleSubmit() {
73
- * await createPost({ title: 'Hello', content: '...' });
74
- * }
75
- * </script>
76
- * ```
77
- */
78
- export function useMutation(mutation) {
79
- const mutationName = typeof mutation === 'string' ? mutation : mutation._name;
80
- const data = ref();
81
- const error = ref(null);
82
- const isPending = ref(false);
83
- const mutate = async (args) => {
84
- try {
85
- isPending.value = true;
86
- error.value = null;
87
- const response = await $fetch('/api/_tether/mutation', {
88
- method: 'POST',
89
- body: {
90
- function: mutationName,
91
- args,
92
- },
93
- });
94
- data.value = response.data;
95
- return response.data;
96
- }
97
- catch (e) {
98
- error.value = e instanceof Error ? e : new Error(String(e));
99
- throw e;
100
- }
101
- finally {
102
- isPending.value = false;
103
- }
104
- };
105
- const reset = () => {
106
- data.value = undefined;
107
- error.value = null;
108
- isPending.value = false;
109
- };
110
- return {
111
- data: data,
112
- error,
113
- isPending,
114
- mutate,
115
- reset,
116
- };
117
- }
118
- /**
119
- * WebSocket subscription composable for realtime updates
120
- * This runs client-side only and calls refetch when updates are received
121
- *
122
- * @example
123
- * ```vue
124
- * <script setup>
125
- * const { data: posts, refetch } = useQuery('posts.list');
126
- * useTetherSubscription('posts.list', {}, refetch);
127
- * </script>
128
- * ```
129
- */
130
- export function useTetherSubscription(queryName, args, onUpdate) {
131
- const isConnected = ref(false);
132
- if (import.meta.client) {
133
- let ws = null;
134
- let reconnectTimeout = null;
135
- let heartbeatInterval = null;
136
- let heartbeatTimeout = null;
137
- let awaitingPong = false;
138
- let isConnecting = false;
139
- let isMounted = false;
140
- // Heartbeat configuration
141
- const HEARTBEAT_INTERVAL = 25000; // 25 seconds (well under server's 90s timeout)
142
- const HEARTBEAT_TIMEOUT = 15000; // 15 seconds to receive pong (generous for slow networks)
143
- // Generate a unique subscription ID
144
- const subscriptionId = `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
145
- const startHeartbeat = () => {
146
- stopHeartbeat();
147
- heartbeatInterval = setInterval(() => {
148
- if (ws?.readyState === WebSocket.OPEN) {
149
- awaitingPong = true;
150
- ws.send(JSON.stringify({ type: 'ping' }));
151
- heartbeatTimeout = setTimeout(() => {
152
- if (awaitingPong && isMounted) {
153
- console.warn('[Tether] Heartbeat timeout - forcing reconnect');
154
- ws?.close();
155
- }
156
- }, HEARTBEAT_TIMEOUT);
157
- }
158
- }, HEARTBEAT_INTERVAL);
159
- };
160
- const stopHeartbeat = () => {
161
- if (heartbeatInterval) {
162
- clearInterval(heartbeatInterval);
163
- heartbeatInterval = null;
164
- }
165
- if (heartbeatTimeout) {
166
- clearTimeout(heartbeatTimeout);
167
- heartbeatTimeout = null;
168
- }
169
- awaitingPong = false;
170
- };
171
- const connect = () => {
172
- // Don't connect if unmounted or already connecting/connected
173
- if (!isMounted)
174
- return;
175
- if (isConnecting)
176
- return;
177
- if (ws && (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING)) {
178
- return;
179
- }
180
- // Get config from window (set by plugin)
181
- const config = window.__TETHER_CONFIG__;
182
- if (!config?.wsUrl || !config?.projectId) {
183
- console.warn('[Tether] WebSocket config not available');
184
- return;
185
- }
186
- isConnecting = true;
187
- const wsUrl = `${config.wsUrl}/ws/${config.projectId}`;
188
- ws = new WebSocket(wsUrl);
189
- ws.onopen = () => {
190
- isConnecting = false;
191
- // Wait for connected message before subscribing
192
- };
193
- ws.onmessage = (event) => {
194
- try {
195
- const message = JSON.parse(event.data);
196
- if (message.type === 'connected') {
197
- isConnected.value = true;
198
- startHeartbeat();
199
- // Subscribe to the query with our ID
200
- ws?.send(JSON.stringify({
201
- type: 'subscribe',
202
- id: subscriptionId,
203
- query: queryName,
204
- args,
205
- }));
206
- }
207
- else if (message.type === 'data' && message.id === subscriptionId) {
208
- // Call onUpdate with the fresh data
209
- onUpdate(message.data);
210
- }
211
- else if (message.type === 'pong') {
212
- // Heartbeat acknowledged
213
- awaitingPong = false;
214
- if (heartbeatTimeout) {
215
- clearTimeout(heartbeatTimeout);
216
- heartbeatTimeout = null;
217
- }
218
- }
219
- }
220
- catch {
221
- // Ignore parse errors
222
- }
223
- };
224
- ws.onclose = () => {
225
- isConnected.value = false;
226
- isConnecting = false;
227
- stopHeartbeat();
228
- // Only reconnect if still mounted
229
- if (isMounted) {
230
- reconnectTimeout = setTimeout(connect, 3000);
231
- }
232
- };
233
- ws.onerror = () => {
234
- isConnecting = false;
235
- ws?.close();
236
- };
237
- };
238
- // Handle page visibility changes - reconnect when tab becomes visible
239
- const handleVisibilityChange = () => {
240
- if (!isMounted)
241
- return;
242
- if (document.visibilityState === 'visible') {
243
- // Tab became visible - check connection health
244
- if (!ws || ws.readyState === WebSocket.CLOSED) {
245
- // Clear any pending reconnect and connect immediately
246
- if (reconnectTimeout) {
247
- clearTimeout(reconnectTimeout);
248
- reconnectTimeout = null;
249
- }
250
- connect();
251
- }
252
- }
253
- };
254
- onMounted(() => {
255
- isMounted = true;
256
- connect();
257
- document.addEventListener('visibilitychange', handleVisibilityChange);
258
- });
259
- onUnmounted(() => {
260
- isMounted = false;
261
- document.removeEventListener('visibilitychange', handleVisibilityChange);
262
- stopHeartbeat();
263
- if (reconnectTimeout) {
264
- clearTimeout(reconnectTimeout);
265
- reconnectTimeout = null;
266
- }
267
- if (ws) {
268
- ws.close();
269
- ws = null;
270
- }
271
- });
272
- }
273
- return { isConnected };
274
- }
275
- //# sourceMappingURL=composables.js.map