@tthr/vue 0.0.24 → 0.0.26

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.
@@ -217,7 +217,7 @@ useTetherSubscription('comments.list', undefined, (data) => {
217
217
  if (!grouped[comment.postId]) {
218
218
  grouped[comment.postId] = [];
219
219
  }
220
- grouped[comment.postId].push(comment);
220
+ grouped[comment.postId]!.push(comment);
221
221
  }
222
222
  postComments.value = grouped;
223
223
  }
@@ -251,11 +251,8 @@ async function handleCreateComment(postId: string) {
251
251
 
252
252
  try {
253
253
  await createComment.mutate({
254
- id: crypto.randomUUID(),
255
254
  postId,
256
255
  content: newCommentText.value.trim(),
257
- authorId: 'demo-user',
258
- createdAt: new Date().toISOString(),
259
256
  });
260
257
  newCommentText.value = '';
261
258
  // Refresh comments for this post
@@ -298,12 +295,8 @@ async function handleCreatePost() {
298
295
 
299
296
  try {
300
297
  await createPost.mutate({
301
- id: crypto.randomUUID(),
302
298
  title: newPostTitle.value.trim(),
303
299
  content: '',
304
- authorId: 'demo-user',
305
- createdAt: new Date().toISOString(),
306
- updatedAt: new Date().toISOString(),
307
300
  });
308
301
  newPostTitle.value = '';
309
302
  await posts.refetch();
@@ -21,12 +21,18 @@ async function loadFunctionRegistry() {
21
21
  try {
22
22
  // Try to import the user's functions index
23
23
  // This path is relative to the Nuxt app's server runtime
24
- const functions = await import('~~/tether/functions/index.ts').catch(() => null);
24
+ console.log('[Tether] Loading custom functions from ~~/tether/functions/index.ts');
25
+ const functions = await import('~~/tether/functions/index.ts').catch((err) => {
26
+ console.warn('[Tether] Failed to import functions:', err.message);
27
+ return null;
28
+ });
25
29
 
26
30
  if (functions) {
31
+ console.log('[Tether] Loaded function modules:', Object.keys(functions));
27
32
  functionRegistry = functions;
28
33
  } else {
29
34
  // No custom functions found - that's OK, we'll proxy everything
35
+ console.log('[Tether] No custom functions found, will proxy all requests');
30
36
  functionRegistry = {};
31
37
  }
32
38
  } catch (error) {
@@ -117,7 +123,18 @@ function createDatabaseProxy(apiKey, url, projectId) {
117
123
  if (options?.where) args.where = options.where;
118
124
  if (options?.limit) args.limit = options.limit;
119
125
  if (options?.offset) args.offset = options.offset;
120
- if (options?.orderBy) args.orderBy = options.orderBy;
126
+ // Handle orderBy as either a string or an object { column: 'asc'|'desc' }
127
+ if (options?.orderBy) {
128
+ if (typeof options.orderBy === 'string') {
129
+ args.orderBy = options.orderBy;
130
+ } else if (typeof options.orderBy === 'object') {
131
+ const [column, dir] = Object.entries(options.orderBy)[0] || [];
132
+ if (column) {
133
+ args.orderBy = column;
134
+ args.orderDir = dir?.toUpperCase?.() || 'ASC';
135
+ }
136
+ }
137
+ }
121
138
  if (options?.orderDir) args.orderDir = options.orderDir;
122
139
  return makeRequest('list', args);
123
140
  },
@@ -234,10 +251,12 @@ export default defineEventHandler(async (event) => {
234
251
 
235
252
  // Try to find a custom function
236
253
  const customFn = lookupFunction(body.function);
254
+ console.log(`[Tether] Mutation: ${body.function}, custom function found: ${!!customFn}`);
237
255
 
238
256
  if (customFn) {
239
257
  // Execute locally with database proxy
240
258
  try {
259
+ console.log(`[Tether] Executing custom mutation: ${body.function}`);
241
260
  const db = createDatabaseProxy(apiKey, url, projectId);
242
261
 
243
262
  // Create auth context - try to get user identity from request
@@ -296,9 +315,11 @@ export default defineEventHandler(async (event) => {
296
315
 
297
316
  return { data: result };
298
317
  } catch (error) {
318
+ console.error(`[Tether] Mutation ${body.function} failed:`, error);
299
319
  throw createError({
300
320
  statusCode: 500,
301
321
  message: error.message || 'Mutation execution failed',
322
+ data: { function: body.function, error: String(error) },
302
323
  });
303
324
  }
304
325
  }
@@ -123,7 +123,18 @@ function createDatabaseProxy(apiKey, url, projectId) {
123
123
  if (options?.where) args.where = options.where;
124
124
  if (options?.limit) args.limit = options.limit;
125
125
  if (options?.offset) args.offset = options.offset;
126
- if (options?.orderBy) args.orderBy = options.orderBy;
126
+ // Handle orderBy as either a string or an object { column: 'asc'|'desc' }
127
+ if (options?.orderBy) {
128
+ if (typeof options.orderBy === 'string') {
129
+ args.orderBy = options.orderBy;
130
+ } else if (typeof options.orderBy === 'object') {
131
+ const [column, dir] = Object.entries(options.orderBy)[0] || [];
132
+ if (column) {
133
+ args.orderBy = column;
134
+ args.orderDir = dir?.toUpperCase?.() || 'ASC';
135
+ }
136
+ }
137
+ }
127
138
  if (options?.orderDir) args.orderDir = options.orderDir;
128
139
  return makeRequest('list', args);
129
140
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tthr/vue",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "Tether Vue/Nuxt SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",