@drawbridge/drawbridge-utils 0.0.31 → 0.0.33

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/ai.cjs CHANGED
@@ -84,7 +84,6 @@ var circuit = ({
84
84
  var insertTransaction = async ({
85
85
  db,
86
86
  user,
87
- userId,
88
87
  type,
89
88
  category,
90
89
  source,
@@ -103,7 +102,7 @@ var insertTransaction = async ({
103
102
  collection: "transaction",
104
103
  data: {
105
104
  ..._id && { _id },
106
- userId,
105
+ userId: user == null ? void 0 : user.id,
107
106
  type,
108
107
  category,
109
108
  source,
@@ -119,7 +118,6 @@ var insertTransaction = async ({
119
118
  var debit = async ({
120
119
  db,
121
120
  user,
122
- userId,
123
121
  amount,
124
122
  type,
125
123
  category,
@@ -141,7 +139,6 @@ var debit = async ({
141
139
  await insertTransaction({
142
140
  db,
143
141
  user,
144
- userId,
145
142
  type,
146
143
  category,
147
144
  source,
@@ -175,7 +172,7 @@ var cost = {
175
172
  "gemini-2.5-flash-image": {
176
173
  cached: 3,
177
174
  input: 30,
178
- output: 250
175
+ output: 3e3
179
176
  }
180
177
  };
181
178
  var MARKUP = 1.3;
@@ -213,8 +210,7 @@ var tokensFromMetadata = (metadata) => ({
213
210
  });
214
211
  var billRequest = async ({
215
212
  db,
216
- authenticated,
217
- userId,
213
+ user,
218
214
  model,
219
215
  usage
220
216
  }) => {
@@ -222,8 +218,7 @@ var billRequest = async ({
222
218
  const cogs = costForRequest(model, usage);
223
219
  await debit({
224
220
  db,
225
- authenticated,
226
- userId,
221
+ user,
227
222
  amount: gross,
228
223
  type: "ai",
229
224
  category: "usage",
@@ -251,8 +246,7 @@ var google = {
251
246
  reference = null
252
247
  }, {
253
248
  db,
254
- authenticated,
255
- userId
249
+ user
256
250
  }) => {
257
251
  var _a, _b, _c, _d, _e, _f;
258
252
  const model = models.image;
@@ -260,68 +254,57 @@ var google = {
260
254
  ...reference ? [{ inlineData: { data: reference.data, mimeType: reference.mimeType } }] : [],
261
255
  { text: prompt.join("\n") }
262
256
  ];
263
- try {
264
- const response = await googleCircuit(() => google_client.models.generateContent({
265
- model,
266
- contents: { parts },
267
- config: {
268
- ...config,
269
- responseModalities: ["Image"]
270
- }
271
- }));
272
- const content = (_f = (_e = (_d = (_c = (_b = (_a = response == null ? void 0 : response.candidates) == null ? void 0 : _a[0]) == null ? void 0 : _b.content) == null ? void 0 : _c.parts) == null ? void 0 : _d[0]) == null ? void 0 : _e.inlineData) == null ? void 0 : _f.data;
273
- if (!content) {
274
- throw new Error("Could not generate from prompt. Please try again with a different prompt.");
275
- }
276
- if (userId) {
277
- await billRequest({
278
- db,
279
- authenticated,
280
- userId,
281
- model,
282
- usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata)
283
- });
257
+ const response = await googleCircuit(() => google_client.models.generateContent({
258
+ model,
259
+ contents: { parts },
260
+ config: {
261
+ ...config,
262
+ responseModalities: ["Image"]
284
263
  }
285
- return { content };
286
- } catch (error) {
287
- throw new Error((error == null ? void 0 : error.message) || "AI error, please try again");
264
+ }));
265
+ const content = (_f = (_e = (_d = (_c = (_b = (_a = response == null ? void 0 : response.candidates) == null ? void 0 : _a[0]) == null ? void 0 : _b.content) == null ? void 0 : _c.parts) == null ? void 0 : _d[0]) == null ? void 0 : _e.inlineData) == null ? void 0 : _f.data;
266
+ if (!content) {
267
+ throw new Error("Could not generate from prompt. Please try again with a different prompt.");
288
268
  }
269
+ if (user == null ? void 0 : user.id) {
270
+ await billRequest({
271
+ db,
272
+ user,
273
+ model,
274
+ usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata)
275
+ });
276
+ }
277
+ return { content };
289
278
  },
290
279
  text: async ({
291
280
  config = {},
292
281
  prompt = []
293
282
  }, {
294
283
  db,
295
- authenticated,
296
- userId
284
+ user
297
285
  }) => {
298
286
  const model = models.text;
299
- try {
300
- const response = await googleCircuit(() => google_client.models.generateContent({
301
- config: {
302
- ...config,
303
- responseModalities: ["Text"]
304
- },
305
- contents: prompt.join("\n"),
306
- model
307
- }));
308
- const content = response == null ? void 0 : response.text;
309
- if (!content) {
310
- throw new Error("Could not generate from prompt. Please try again with a different prompt.");
311
- }
312
- if (userId) {
313
- await billRequest({
314
- db,
315
- authenticated,
316
- userId,
317
- model,
318
- usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata)
319
- });
320
- }
321
- return { content };
322
- } catch (error) {
323
- throw new Error((error == null ? void 0 : error.message) || "AI error, please try again");
287
+ const response = await googleCircuit(() => google_client.models.generateContent({
288
+ config: {
289
+ ...config,
290
+ responseModalities: ["Text"]
291
+ },
292
+ contents: prompt.join("\n"),
293
+ model
294
+ }));
295
+ const content = response == null ? void 0 : response.text;
296
+ if (!content) {
297
+ throw new Error("Could not generate from prompt. Please try again with a different prompt.");
298
+ }
299
+ if (user == null ? void 0 : user.id) {
300
+ await billRequest({
301
+ db,
302
+ user,
303
+ model,
304
+ usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata)
305
+ });
324
306
  }
307
+ return { content };
325
308
  }
326
309
  };
327
310
  // Annotate the CommonJS export names for ESM import in node:
package/dist/ai.d.cts CHANGED
@@ -50,7 +50,7 @@ const cost = {
50
50
  'gemini-2.5-flash-image' : {
51
51
  cached : 3,
52
52
  input : 30,
53
- output : 250
53
+ output : 3000
54
54
  }
55
55
  };
56
56
 
@@ -129,8 +129,7 @@ const tokensFromMetadata = ( metadata ) => ({
129
129
  // is a single $sum: '$ai.net'.
130
130
  const billRequest = async ({
131
131
  db,
132
- authenticated,
133
- userId,
132
+ user,
134
133
  model,
135
134
  usage
136
135
  }) => {
@@ -140,8 +139,7 @@ const billRequest = async ({
140
139
 
141
140
  await debit({
142
141
  db,
143
- authenticated,
144
- userId,
142
+ user,
145
143
  amount : gross,
146
144
  type : 'ai',
147
145
  category : 'usage',
@@ -174,8 +172,7 @@ const google = {
174
172
  },
175
173
  {
176
174
  db,
177
- authenticated,
178
- userId
175
+ user
179
176
  }
180
177
  ) => {
181
178
 
@@ -186,45 +183,36 @@ const google = {
186
183
  { text : prompt.join( '\n' ) }
187
184
  ];
188
185
 
189
- try {
190
-
191
- const response = await googleCircuit( () => google_client.models.generateContent({
192
- model,
193
- contents : { parts },
194
- config : {
195
- ...config,
196
- responseModalities : [ 'Image' ]
197
- }
198
- }) );
199
-
200
- const content = response?.candidates?.[ 0 ]?.content?.parts?.[ 0 ]?.inlineData?.data;
201
-
202
- if( !content ){
203
-
204
- throw new Error( 'Could not generate from prompt. Please try again with a different prompt.' );
205
-
186
+ const response = await googleCircuit( () => google_client.models.generateContent({
187
+ model,
188
+ contents : { parts },
189
+ config : {
190
+ ...config,
191
+ responseModalities : [ 'Image' ]
206
192
  }
193
+ }) );
207
194
 
208
- if( userId ){
195
+ const content = response?.candidates?.[ 0 ]?.content?.parts?.[ 0 ]?.inlineData?.data;
209
196
 
210
- await billRequest({
211
- db,
212
- authenticated,
213
- userId,
214
- model,
215
- usage : tokensFromMetadata( response?.usageMetadata )
216
- });
197
+ if( !content ){
217
198
 
218
- }
199
+ throw new Error( 'Could not generate from prompt. Please try again with a different prompt.' );
219
200
 
220
- return { content };
201
+ }
221
202
 
222
- } catch ( error ) {
203
+ if( user?.id ){
223
204
 
224
- throw new Error( error?.message || 'AI error, please try again' );
205
+ await billRequest({
206
+ db,
207
+ user,
208
+ model,
209
+ usage : tokensFromMetadata( response?.usageMetadata )
210
+ });
225
211
 
226
212
  }
227
213
 
214
+ return { content };
215
+
228
216
  },
229
217
 
230
218
  text : async (
@@ -234,52 +222,42 @@ const google = {
234
222
  },
235
223
  {
236
224
  db,
237
- authenticated,
238
- userId
225
+ user
239
226
  }
240
227
  ) => {
241
228
 
242
229
  const model = models.text;
243
230
 
244
- try {
245
-
246
- const response = await googleCircuit( () => google_client.models.generateContent({
247
- config : {
248
- ...config,
249
- responseModalities : [ 'Text' ]
250
- },
251
- contents : prompt.join( '\n' ),
252
- model
253
- }) );
254
-
255
- const content = response?.text;
256
-
257
- if( !content ){
258
-
259
- throw new Error( 'Could not generate from prompt. Please try again with a different prompt.' );
260
-
261
- }
231
+ const response = await googleCircuit( () => google_client.models.generateContent({
232
+ config : {
233
+ ...config,
234
+ responseModalities : [ 'Text' ]
235
+ },
236
+ contents : prompt.join( '\n' ),
237
+ model
238
+ }) );
262
239
 
263
- if( userId ){
240
+ const content = response?.text;
264
241
 
265
- await billRequest({
266
- db,
267
- authenticated,
268
- userId,
269
- model,
270
- usage : tokensFromMetadata( response?.usageMetadata )
271
- });
242
+ if( !content ){
272
243
 
273
- }
244
+ throw new Error( 'Could not generate from prompt. Please try again with a different prompt.' );
274
245
 
275
- return { content };
246
+ }
276
247
 
277
- } catch ( error ) {
248
+ if( user?.id ){
278
249
 
279
- throw new Error( error?.message || 'AI error, please try again' );
250
+ await billRequest({
251
+ db,
252
+ user,
253
+ model,
254
+ usage : tokensFromMetadata( response?.usageMetadata )
255
+ });
280
256
 
281
257
  }
282
258
 
259
+ return { content };
260
+
283
261
  }
284
262
 
285
263
  };
package/dist/ai.d.ts CHANGED
@@ -50,7 +50,7 @@ const cost = {
50
50
  'gemini-2.5-flash-image' : {
51
51
  cached : 3,
52
52
  input : 30,
53
- output : 250
53
+ output : 3000
54
54
  }
55
55
  };
56
56
 
@@ -129,8 +129,7 @@ const tokensFromMetadata = ( metadata ) => ({
129
129
  // is a single $sum: '$ai.net'.
130
130
  const billRequest = async ({
131
131
  db,
132
- authenticated,
133
- userId,
132
+ user,
134
133
  model,
135
134
  usage
136
135
  }) => {
@@ -140,8 +139,7 @@ const billRequest = async ({
140
139
 
141
140
  await debit({
142
141
  db,
143
- authenticated,
144
- userId,
142
+ user,
145
143
  amount : gross,
146
144
  type : 'ai',
147
145
  category : 'usage',
@@ -174,8 +172,7 @@ const google = {
174
172
  },
175
173
  {
176
174
  db,
177
- authenticated,
178
- userId
175
+ user
179
176
  }
180
177
  ) => {
181
178
 
@@ -186,45 +183,36 @@ const google = {
186
183
  { text : prompt.join( '\n' ) }
187
184
  ];
188
185
 
189
- try {
190
-
191
- const response = await googleCircuit( () => google_client.models.generateContent({
192
- model,
193
- contents : { parts },
194
- config : {
195
- ...config,
196
- responseModalities : [ 'Image' ]
197
- }
198
- }) );
199
-
200
- const content = response?.candidates?.[ 0 ]?.content?.parts?.[ 0 ]?.inlineData?.data;
201
-
202
- if( !content ){
203
-
204
- throw new Error( 'Could not generate from prompt. Please try again with a different prompt.' );
205
-
186
+ const response = await googleCircuit( () => google_client.models.generateContent({
187
+ model,
188
+ contents : { parts },
189
+ config : {
190
+ ...config,
191
+ responseModalities : [ 'Image' ]
206
192
  }
193
+ }) );
207
194
 
208
- if( userId ){
195
+ const content = response?.candidates?.[ 0 ]?.content?.parts?.[ 0 ]?.inlineData?.data;
209
196
 
210
- await billRequest({
211
- db,
212
- authenticated,
213
- userId,
214
- model,
215
- usage : tokensFromMetadata( response?.usageMetadata )
216
- });
197
+ if( !content ){
217
198
 
218
- }
199
+ throw new Error( 'Could not generate from prompt. Please try again with a different prompt.' );
219
200
 
220
- return { content };
201
+ }
221
202
 
222
- } catch ( error ) {
203
+ if( user?.id ){
223
204
 
224
- throw new Error( error?.message || 'AI error, please try again' );
205
+ await billRequest({
206
+ db,
207
+ user,
208
+ model,
209
+ usage : tokensFromMetadata( response?.usageMetadata )
210
+ });
225
211
 
226
212
  }
227
213
 
214
+ return { content };
215
+
228
216
  },
229
217
 
230
218
  text : async (
@@ -234,52 +222,42 @@ const google = {
234
222
  },
235
223
  {
236
224
  db,
237
- authenticated,
238
- userId
225
+ user
239
226
  }
240
227
  ) => {
241
228
 
242
229
  const model = models.text;
243
230
 
244
- try {
245
-
246
- const response = await googleCircuit( () => google_client.models.generateContent({
247
- config : {
248
- ...config,
249
- responseModalities : [ 'Text' ]
250
- },
251
- contents : prompt.join( '\n' ),
252
- model
253
- }) );
254
-
255
- const content = response?.text;
256
-
257
- if( !content ){
258
-
259
- throw new Error( 'Could not generate from prompt. Please try again with a different prompt.' );
260
-
261
- }
231
+ const response = await googleCircuit( () => google_client.models.generateContent({
232
+ config : {
233
+ ...config,
234
+ responseModalities : [ 'Text' ]
235
+ },
236
+ contents : prompt.join( '\n' ),
237
+ model
238
+ }) );
262
239
 
263
- if( userId ){
240
+ const content = response?.text;
264
241
 
265
- await billRequest({
266
- db,
267
- authenticated,
268
- userId,
269
- model,
270
- usage : tokensFromMetadata( response?.usageMetadata )
271
- });
242
+ if( !content ){
272
243
 
273
- }
244
+ throw new Error( 'Could not generate from prompt. Please try again with a different prompt.' );
274
245
 
275
- return { content };
246
+ }
276
247
 
277
- } catch ( error ) {
248
+ if( user?.id ){
278
249
 
279
- throw new Error( error?.message || 'AI error, please try again' );
250
+ await billRequest({
251
+ db,
252
+ user,
253
+ model,
254
+ usage : tokensFromMetadata( response?.usageMetadata )
255
+ });
280
256
 
281
257
  }
282
258
 
259
+ return { content };
260
+
283
261
  }
284
262
 
285
263
  };
package/dist/ai.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debit
3
- } from "./chunk-6S43OFA7.js";
3
+ } from "./chunk-RW2FJVIV.js";
4
4
  import {
5
5
  circuit
6
6
  } from "./chunk-6HH36OK6.js";
@@ -28,7 +28,7 @@ var cost = {
28
28
  "gemini-2.5-flash-image": {
29
29
  cached: 3,
30
30
  input: 30,
31
- output: 250
31
+ output: 3e3
32
32
  }
33
33
  };
34
34
  var MARKUP = 1.3;
@@ -66,8 +66,7 @@ var tokensFromMetadata = (metadata) => ({
66
66
  });
67
67
  var billRequest = async ({
68
68
  db,
69
- authenticated,
70
- userId,
69
+ user,
71
70
  model,
72
71
  usage
73
72
  }) => {
@@ -75,8 +74,7 @@ var billRequest = async ({
75
74
  const cogs = costForRequest(model, usage);
76
75
  await debit({
77
76
  db,
78
- authenticated,
79
- userId,
77
+ user,
80
78
  amount: gross,
81
79
  type: "ai",
82
80
  category: "usage",
@@ -104,8 +102,7 @@ var google = {
104
102
  reference = null
105
103
  }, {
106
104
  db,
107
- authenticated,
108
- userId
105
+ user
109
106
  }) => {
110
107
  var _a, _b, _c, _d, _e, _f;
111
108
  const model = models.image;
@@ -113,68 +110,57 @@ var google = {
113
110
  ...reference ? [{ inlineData: { data: reference.data, mimeType: reference.mimeType } }] : [],
114
111
  { text: prompt.join("\n") }
115
112
  ];
116
- try {
117
- const response = await googleCircuit(() => google_client.models.generateContent({
118
- model,
119
- contents: { parts },
120
- config: {
121
- ...config,
122
- responseModalities: ["Image"]
123
- }
124
- }));
125
- const content = (_f = (_e = (_d = (_c = (_b = (_a = response == null ? void 0 : response.candidates) == null ? void 0 : _a[0]) == null ? void 0 : _b.content) == null ? void 0 : _c.parts) == null ? void 0 : _d[0]) == null ? void 0 : _e.inlineData) == null ? void 0 : _f.data;
126
- if (!content) {
127
- throw new Error("Could not generate from prompt. Please try again with a different prompt.");
128
- }
129
- if (userId) {
130
- await billRequest({
131
- db,
132
- authenticated,
133
- userId,
134
- model,
135
- usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata)
136
- });
113
+ const response = await googleCircuit(() => google_client.models.generateContent({
114
+ model,
115
+ contents: { parts },
116
+ config: {
117
+ ...config,
118
+ responseModalities: ["Image"]
137
119
  }
138
- return { content };
139
- } catch (error) {
140
- throw new Error((error == null ? void 0 : error.message) || "AI error, please try again");
120
+ }));
121
+ const content = (_f = (_e = (_d = (_c = (_b = (_a = response == null ? void 0 : response.candidates) == null ? void 0 : _a[0]) == null ? void 0 : _b.content) == null ? void 0 : _c.parts) == null ? void 0 : _d[0]) == null ? void 0 : _e.inlineData) == null ? void 0 : _f.data;
122
+ if (!content) {
123
+ throw new Error("Could not generate from prompt. Please try again with a different prompt.");
124
+ }
125
+ if (user == null ? void 0 : user.id) {
126
+ await billRequest({
127
+ db,
128
+ user,
129
+ model,
130
+ usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata)
131
+ });
141
132
  }
133
+ return { content };
142
134
  },
143
135
  text: async ({
144
136
  config = {},
145
137
  prompt = []
146
138
  }, {
147
139
  db,
148
- authenticated,
149
- userId
140
+ user
150
141
  }) => {
151
142
  const model = models.text;
152
- try {
153
- const response = await googleCircuit(() => google_client.models.generateContent({
154
- config: {
155
- ...config,
156
- responseModalities: ["Text"]
157
- },
158
- contents: prompt.join("\n"),
159
- model
160
- }));
161
- const content = response == null ? void 0 : response.text;
162
- if (!content) {
163
- throw new Error("Could not generate from prompt. Please try again with a different prompt.");
164
- }
165
- if (userId) {
166
- await billRequest({
167
- db,
168
- authenticated,
169
- userId,
170
- model,
171
- usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata)
172
- });
173
- }
174
- return { content };
175
- } catch (error) {
176
- throw new Error((error == null ? void 0 : error.message) || "AI error, please try again");
143
+ const response = await googleCircuit(() => google_client.models.generateContent({
144
+ config: {
145
+ ...config,
146
+ responseModalities: ["Text"]
147
+ },
148
+ contents: prompt.join("\n"),
149
+ model
150
+ }));
151
+ const content = response == null ? void 0 : response.text;
152
+ if (!content) {
153
+ throw new Error("Could not generate from prompt. Please try again with a different prompt.");
154
+ }
155
+ if (user == null ? void 0 : user.id) {
156
+ await billRequest({
157
+ db,
158
+ user,
159
+ model,
160
+ usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata)
161
+ });
177
162
  }
163
+ return { content };
178
164
  }
179
165
  };
180
166
  export {
@@ -2,7 +2,6 @@
2
2
  var insertTransaction = async ({
3
3
  db,
4
4
  user,
5
- userId,
6
5
  type,
7
6
  category,
8
7
  source,
@@ -21,7 +20,7 @@ var insertTransaction = async ({
21
20
  collection: "transaction",
22
21
  data: {
23
22
  ..._id && { _id },
24
- userId,
23
+ userId: user == null ? void 0 : user.id,
25
24
  type,
26
25
  category,
27
26
  source,
@@ -37,7 +36,6 @@ var insertTransaction = async ({
37
36
  var credit = async ({
38
37
  db,
39
38
  user,
40
- userId,
41
39
  amount,
42
40
  type,
43
41
  category,
@@ -60,7 +58,6 @@ var credit = async ({
60
58
  await insertTransaction({
61
59
  db,
62
60
  user,
63
- userId,
64
61
  type,
65
62
  category,
66
63
  source,
@@ -75,7 +72,6 @@ var credit = async ({
75
72
  var debit = async ({
76
73
  db,
77
74
  user,
78
- userId,
79
75
  amount,
80
76
  type,
81
77
  category,
@@ -97,7 +93,6 @@ var debit = async ({
97
93
  await insertTransaction({
98
94
  db,
99
95
  user,
100
- userId,
101
96
  type,
102
97
  category,
103
98
  source,
@@ -26,7 +26,6 @@ module.exports = __toCommonJS(transactions_exports);
26
26
  var insertTransaction = async ({
27
27
  db,
28
28
  user,
29
- userId,
30
29
  type,
31
30
  category,
32
31
  source,
@@ -45,7 +44,7 @@ var insertTransaction = async ({
45
44
  collection: "transaction",
46
45
  data: {
47
46
  ..._id && { _id },
48
- userId,
47
+ userId: user == null ? void 0 : user.id,
49
48
  type,
50
49
  category,
51
50
  source,
@@ -61,7 +60,6 @@ var insertTransaction = async ({
61
60
  var credit = async ({
62
61
  db,
63
62
  user,
64
- userId,
65
63
  amount,
66
64
  type,
67
65
  category,
@@ -84,7 +82,6 @@ var credit = async ({
84
82
  await insertTransaction({
85
83
  db,
86
84
  user,
87
- userId,
88
85
  type,
89
86
  category,
90
87
  source,
@@ -99,7 +96,6 @@ var credit = async ({
99
96
  var debit = async ({
100
97
  db,
101
98
  user,
102
- userId,
103
99
  amount,
104
100
  type,
105
101
  category,
@@ -121,7 +117,6 @@ var debit = async ({
121
117
  await insertTransaction({
122
118
  db,
123
119
  user,
124
- userId,
125
120
  type,
126
121
  category,
127
122
  source,
@@ -29,7 +29,6 @@
29
29
  const insertTransaction = async ({
30
30
  db,
31
31
  user,
32
- userId,
33
32
  type,
34
33
  category,
35
34
  source,
@@ -51,7 +50,7 @@ const insertTransaction = async ({
51
50
  collection : 'transaction',
52
51
  data : {
53
52
  ...( _id && { _id }),
54
- userId,
53
+ userId : user?.id,
55
54
  type,
56
55
  category,
57
56
  source,
@@ -73,7 +72,6 @@ const insertTransaction = async ({
73
72
  const credit = async ({
74
73
  db,
75
74
  user,
76
- userId,
77
75
  amount,
78
76
  type,
79
77
  category,
@@ -106,7 +104,6 @@ const credit = async ({
106
104
  await insertTransaction({
107
105
  db,
108
106
  user,
109
- userId,
110
107
  type,
111
108
  category,
112
109
  source,
@@ -134,7 +131,6 @@ const credit = async ({
134
131
  const debit = async ({
135
132
  db,
136
133
  user,
137
- userId,
138
134
  amount,
139
135
  type,
140
136
  category,
@@ -166,7 +162,6 @@ const debit = async ({
166
162
  await insertTransaction({
167
163
  db,
168
164
  user,
169
- userId,
170
165
  type,
171
166
  category,
172
167
  source,
@@ -29,7 +29,6 @@
29
29
  const insertTransaction = async ({
30
30
  db,
31
31
  user,
32
- userId,
33
32
  type,
34
33
  category,
35
34
  source,
@@ -51,7 +50,7 @@ const insertTransaction = async ({
51
50
  collection : 'transaction',
52
51
  data : {
53
52
  ...( _id && { _id }),
54
- userId,
53
+ userId : user?.id,
55
54
  type,
56
55
  category,
57
56
  source,
@@ -73,7 +72,6 @@ const insertTransaction = async ({
73
72
  const credit = async ({
74
73
  db,
75
74
  user,
76
- userId,
77
75
  amount,
78
76
  type,
79
77
  category,
@@ -106,7 +104,6 @@ const credit = async ({
106
104
  await insertTransaction({
107
105
  db,
108
106
  user,
109
- userId,
110
107
  type,
111
108
  category,
112
109
  source,
@@ -134,7 +131,6 @@ const credit = async ({
134
131
  const debit = async ({
135
132
  db,
136
133
  user,
137
- userId,
138
134
  amount,
139
135
  type,
140
136
  category,
@@ -166,7 +162,6 @@ const debit = async ({
166
162
  await insertTransaction({
167
163
  db,
168
164
  user,
169
- userId,
170
165
  type,
171
166
  category,
172
167
  source,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  credit,
3
3
  debit
4
- } from "./chunk-6S43OFA7.js";
4
+ } from "./chunk-RW2FJVIV.js";
5
5
  export {
6
6
  credit,
7
7
  debit
package/package.json CHANGED
@@ -103,5 +103,5 @@
103
103
  "build": "tsup && npm publish"
104
104
  },
105
105
  "types": "dist/index.d.ts",
106
- "version": "0.0.31"
106
+ "version": "0.0.33"
107
107
  }