@tthr/vue 0.0.47 → 0.0.48

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/nuxt/module.js CHANGED
@@ -133,83 +133,80 @@ export default defineNuxtModule({
133
133
  });
134
134
  // Generate a server plugin to auto-register cron handlers from tether/functions
135
135
  // This runs at build time and creates a plugin that imports user's functions
136
+ // NOTE: Must be .js file (not .ts) to avoid Rollup parse errors during Nitro build
136
137
  addTemplate({
137
- filename: 'server/plugins/tether-functions.ts',
138
+ filename: 'server/plugins/tether-functions.js',
138
139
  write: true,
139
140
  getContents: () => `
140
141
  /**
141
142
  * Auto-generated plugin to register Tether functions as cron handlers
142
143
  * This file is generated by @tthr/vue/nuxt module
143
144
  */
144
- import { defineNitroPlugin } from 'nitropack/runtime';
145
- import { registerCronHandler } from '@tthr/vue/nuxt/runtime/server/plugins/cron.js';
145
+ import { defineNitroPlugin, registerCronHandler } from '@tthr/vue/nuxt/runtime/server/plugins/cron.js';
146
146
  import { useTetherServer } from '@tthr/vue/nuxt/runtime/server/utils/tether.js';
147
147
 
148
148
  // Import all functions from tether/functions (using ~~ for rootDir)
149
- // @ts-ignore - user's functions may not exist yet
150
149
  import * as tetherFunctions from '~~/tether/functions';
151
150
 
152
151
  /**
153
152
  * Create a simple logger for function execution
154
153
  */
155
- function createLogger(functionName: string) {
154
+ function createLogger(functionName) {
156
155
  const prefix = \`[Tether] \${functionName}\`;
157
156
  return {
158
- log: (msg: string, data?: unknown) => console.log(prefix, msg, data !== undefined ? data : ''),
159
- info: (msg: string, data?: unknown) => console.log(prefix, msg, data !== undefined ? data : ''),
160
- warn: (msg: string, data?: unknown) => console.warn(prefix, msg, data !== undefined ? data : ''),
161
- error: (msg: string, data?: unknown) => console.error(prefix, msg, data !== undefined ? data : ''),
162
- debug: (msg: string, data?: unknown) => console.debug(prefix, msg, data !== undefined ? data : ''),
157
+ log: (msg, data) => console.log(prefix, msg, data !== undefined ? data : ''),
158
+ info: (msg, data) => console.log(prefix, msg, data !== undefined ? data : ''),
159
+ warn: (msg, data) => console.warn(prefix, msg, data !== undefined ? data : ''),
160
+ error: (msg, data) => console.error(prefix, msg, data !== undefined ? data : ''),
161
+ debug: (msg, data) => console.debug(prefix, msg, data !== undefined ? data : ''),
163
162
  };
164
163
  }
165
164
 
166
165
  /**
167
166
  * Create the handler context for a function
168
167
  */
169
- function createHandlerContext(functionName: string, args: unknown) {
170
- const tether = useTetherServer(null as any);
168
+ function createHandlerContext(functionName, args) {
169
+ const tether = useTetherServer(null);
171
170
  const log = createLogger(functionName);
172
171
 
173
172
  // Create db proxy that uses tether server client
174
- // TODO: This is a placeholder - proper db operations need to be implemented
175
173
  const db = new Proxy({}, {
176
- get(_, tableName: string) {
174
+ get(_, tableName) {
177
175
  return {
178
- findMany: async (options?: any) => {
179
- // Call Tether API for db operations
176
+ findMany: async (options) => {
180
177
  return tether.query(\`_db.\${tableName}.findMany\`, options);
181
178
  },
182
- findFirst: async (options?: any) => {
179
+ findFirst: async (options) => {
183
180
  return tether.query(\`_db.\${tableName}.findFirst\`, options);
184
181
  },
185
- findUnique: async (options?: any) => {
182
+ findUnique: async (options) => {
186
183
  return tether.query(\`_db.\${tableName}.findUnique\`, options);
187
184
  },
188
- findById: async (id: unknown) => {
185
+ findById: async (id) => {
189
186
  return tether.query(\`_db.\${tableName}.findById\`, { id });
190
187
  },
191
- count: async (options?: any) => {
188
+ count: async (options) => {
192
189
  return tether.query(\`_db.\${tableName}.count\`, options);
193
190
  },
194
- create: async (options: any) => {
191
+ create: async (options) => {
195
192
  return tether.mutation(\`_db.\${tableName}.create\`, options);
196
193
  },
197
- insert: async (data: any) => {
194
+ insert: async (data) => {
198
195
  return tether.mutation(\`_db.\${tableName}.insert\`, { data });
199
196
  },
200
- insertMany: async (data: any[]) => {
197
+ insertMany: async (data) => {
201
198
  return tether.mutation(\`_db.\${tableName}.insertMany\`, { data });
202
199
  },
203
- update: async (options: any) => {
200
+ update: async (options) => {
204
201
  return tether.mutation(\`_db.\${tableName}.update\`, options);
205
202
  },
206
- upsert: async (options: any) => {
203
+ upsert: async (options) => {
207
204
  return tether.mutation(\`_db.\${tableName}.upsert\`, options);
208
205
  },
209
- delete: async (options: any) => {
206
+ delete: async (options) => {
210
207
  return tether.mutation(\`_db.\${tableName}.delete\`, options);
211
208
  },
212
- deleteById: async (id: unknown) => {
209
+ deleteById: async (id) => {
213
210
  return tether.mutation(\`_db.\${tableName}.deleteById\`, { id });
214
211
  },
215
212
  };
@@ -221,7 +218,7 @@ function createHandlerContext(functionName: string, args: unknown) {
221
218
  query: tether.query.bind(tether),
222
219
  mutation: tether.mutation.bind(tether),
223
220
  env: new Proxy({}, {
224
- get(_, key: string) {
221
+ get(_, key) {
225
222
  return process.env[key];
226
223
  },
227
224
  }),
@@ -244,14 +241,14 @@ export default defineNitroPlugin(() => {
244
241
  if (!moduleExports || typeof moduleExports !== 'object') continue;
245
242
 
246
243
  // Iterate through all exports in each module
247
- for (const [fnName, fnDef] of Object.entries(moduleExports as Record<string, any>)) {
244
+ for (const [fnName, fnDef] of Object.entries(moduleExports)) {
248
245
  // Check if it's a Tether function definition (has handler property)
249
246
  if (!fnDef || typeof fnDef !== 'object' || typeof fnDef.handler !== 'function') continue;
250
247
 
251
248
  const fullName = \`\${moduleName}.\${fnName}\`;
252
249
 
253
250
  // Register the cron handler
254
- registerCronHandler(fullName, async (args: unknown) => {
251
+ registerCronHandler(fullName, async (args) => {
255
252
  const context = createHandlerContext(fullName, args);
256
253
  return fnDef.handler(context);
257
254
  });
@@ -268,7 +265,7 @@ export default defineNitroPlugin(() => {
268
265
  nuxt.hook('nitro:config', (nitroConfig) => {
269
266
  nitroConfig.plugins = nitroConfig.plugins || [];
270
267
  // Add our generated plugin after the cron plugin
271
- nitroConfig.plugins.push('#build/server/plugins/tether-functions');
268
+ nitroConfig.plugins.push('#build/server/plugins/tether-functions.js');
272
269
  });
273
270
  },
274
271
  });
package/nuxt/module.ts CHANGED
@@ -167,8 +167,7 @@ export default defineNuxtModule<TetherModuleOptions>({
167
167
  * Auto-generated plugin to register Tether functions as cron handlers
168
168
  * This file is generated by @tthr/vue/nuxt module
169
169
  */
170
- import { defineNitroPlugin } from 'nitropack/runtime';
171
- import { registerCronHandler } from '@tthr/vue/nuxt/runtime/server/plugins/cron.js';
170
+ import { defineNitroPlugin, registerCronHandler } from '@tthr/vue/nuxt/runtime/server/plugins/cron.js';
172
171
  import { useTetherServer } from '@tthr/vue/nuxt/runtime/server/utils/tether.js';
173
172
 
174
173
  // Import all functions from tether/functions (using ~~ for rootDir)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tthr/vue",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "description": "Tether Vue/Nuxt SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",