@drawbridge/drawbridge-utils 0.0.44 → 0.0.46
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 +8 -20
- package/dist/ai.d.cts +13 -23
- package/dist/ai.d.ts +13 -23
- package/dist/ai.js +8 -20
- package/dist/oauth/index.cjs +13 -0
- package/dist/oauth/index.d.cts +21 -1
- package/dist/oauth/index.d.ts +21 -1
- package/dist/oauth/index.js +11 -0
- package/package.json +1 -1
package/dist/ai.cjs
CHANGED
|
@@ -293,16 +293,10 @@ var google = {
|
|
|
293
293
|
if (!content) {
|
|
294
294
|
throw new Error("Could not generate from prompt. Please try again with a different prompt.");
|
|
295
295
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
model,
|
|
301
|
-
usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata),
|
|
302
|
-
tools: toolsFromResponse(response)
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
return { content };
|
|
296
|
+
const usage = tokensFromMetadata(response == null ? void 0 : response.usageMetadata);
|
|
297
|
+
const tools = toolsFromResponse(response);
|
|
298
|
+
const bill = (user == null ? void 0 : user.id) ? () => billRequest({ db, user, model, usage, tools }) : () => Promise.resolve();
|
|
299
|
+
return { content, bill };
|
|
306
300
|
},
|
|
307
301
|
text: async ({
|
|
308
302
|
config = {},
|
|
@@ -324,16 +318,10 @@ var google = {
|
|
|
324
318
|
if (!content) {
|
|
325
319
|
throw new Error("Could not generate from prompt. Please try again with a different prompt.");
|
|
326
320
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
model,
|
|
332
|
-
usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata),
|
|
333
|
-
tools: toolsFromResponse(response)
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
return { content };
|
|
321
|
+
const usage = tokensFromMetadata(response == null ? void 0 : response.usageMetadata);
|
|
322
|
+
const tools = toolsFromResponse(response);
|
|
323
|
+
const bill = (user == null ? void 0 : user.id) ? () => billRequest({ db, user, model, usage, tools }) : () => Promise.resolve();
|
|
324
|
+
return { content, bill };
|
|
337
325
|
}
|
|
338
326
|
};
|
|
339
327
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/ai.d.cts
CHANGED
|
@@ -247,19 +247,14 @@ const google = {
|
|
|
247
247
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
const usage = tokensFromMetadata( response?.usageMetadata );
|
|
251
|
+
const tools = toolsFromResponse( response );
|
|
251
252
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
model,
|
|
256
|
-
usage : tokensFromMetadata( response?.usageMetadata ),
|
|
257
|
-
tools : toolsFromResponse( response )
|
|
258
|
-
});
|
|
253
|
+
const bill = user?.id
|
|
254
|
+
? () => billRequest({ db, user, model, usage, tools })
|
|
255
|
+
: () => Promise.resolve();
|
|
259
256
|
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return { content };
|
|
257
|
+
return { content, bill };
|
|
263
258
|
|
|
264
259
|
},
|
|
265
260
|
|
|
@@ -287,25 +282,20 @@ const google = {
|
|
|
287
282
|
|
|
288
283
|
const content = response?.text;
|
|
289
284
|
|
|
290
|
-
if( !content ){
|
|
285
|
+
if( ! content ){
|
|
291
286
|
|
|
292
287
|
throw new Error( 'Could not generate from prompt. Please try again with a different prompt.' );
|
|
293
288
|
|
|
294
289
|
}
|
|
295
290
|
|
|
296
|
-
|
|
291
|
+
const usage = tokensFromMetadata( response?.usageMetadata );
|
|
292
|
+
const tools = toolsFromResponse( response );
|
|
297
293
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
model,
|
|
302
|
-
usage : tokensFromMetadata( response?.usageMetadata ),
|
|
303
|
-
tools : toolsFromResponse( response )
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
}
|
|
294
|
+
const bill = user?.id
|
|
295
|
+
? () => billRequest({ db, user, model, usage, tools })
|
|
296
|
+
: () => Promise.resolve();
|
|
307
297
|
|
|
308
|
-
return { content };
|
|
298
|
+
return { content, bill };
|
|
309
299
|
|
|
310
300
|
}
|
|
311
301
|
|
package/dist/ai.d.ts
CHANGED
|
@@ -247,19 +247,14 @@ const google = {
|
|
|
247
247
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
const usage = tokensFromMetadata( response?.usageMetadata );
|
|
251
|
+
const tools = toolsFromResponse( response );
|
|
251
252
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
model,
|
|
256
|
-
usage : tokensFromMetadata( response?.usageMetadata ),
|
|
257
|
-
tools : toolsFromResponse( response )
|
|
258
|
-
});
|
|
253
|
+
const bill = user?.id
|
|
254
|
+
? () => billRequest({ db, user, model, usage, tools })
|
|
255
|
+
: () => Promise.resolve();
|
|
259
256
|
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return { content };
|
|
257
|
+
return { content, bill };
|
|
263
258
|
|
|
264
259
|
},
|
|
265
260
|
|
|
@@ -287,25 +282,20 @@ const google = {
|
|
|
287
282
|
|
|
288
283
|
const content = response?.text;
|
|
289
284
|
|
|
290
|
-
if( !content ){
|
|
285
|
+
if( ! content ){
|
|
291
286
|
|
|
292
287
|
throw new Error( 'Could not generate from prompt. Please try again with a different prompt.' );
|
|
293
288
|
|
|
294
289
|
}
|
|
295
290
|
|
|
296
|
-
|
|
291
|
+
const usage = tokensFromMetadata( response?.usageMetadata );
|
|
292
|
+
const tools = toolsFromResponse( response );
|
|
297
293
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
model,
|
|
302
|
-
usage : tokensFromMetadata( response?.usageMetadata ),
|
|
303
|
-
tools : toolsFromResponse( response )
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
}
|
|
294
|
+
const bill = user?.id
|
|
295
|
+
? () => billRequest({ db, user, model, usage, tools })
|
|
296
|
+
: () => Promise.resolve();
|
|
307
297
|
|
|
308
|
-
return { content };
|
|
298
|
+
return { content, bill };
|
|
309
299
|
|
|
310
300
|
}
|
|
311
301
|
|
package/dist/ai.js
CHANGED
|
@@ -263,16 +263,10 @@ var google = {
|
|
|
263
263
|
if (!content) {
|
|
264
264
|
throw new Error("Could not generate from prompt. Please try again with a different prompt.");
|
|
265
265
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
model,
|
|
271
|
-
usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata),
|
|
272
|
-
tools: toolsFromResponse(response)
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
return { content };
|
|
266
|
+
const usage = tokensFromMetadata(response == null ? void 0 : response.usageMetadata);
|
|
267
|
+
const tools = toolsFromResponse(response);
|
|
268
|
+
const bill = (user == null ? void 0 : user.id) ? () => billRequest({ db, user, model, usage, tools }) : () => Promise.resolve();
|
|
269
|
+
return { content, bill };
|
|
276
270
|
},
|
|
277
271
|
text: async ({
|
|
278
272
|
config = {},
|
|
@@ -294,16 +288,10 @@ var google = {
|
|
|
294
288
|
if (!content) {
|
|
295
289
|
throw new Error("Could not generate from prompt. Please try again with a different prompt.");
|
|
296
290
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
model,
|
|
302
|
-
usage: tokensFromMetadata(response == null ? void 0 : response.usageMetadata),
|
|
303
|
-
tools: toolsFromResponse(response)
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
return { content };
|
|
291
|
+
const usage = tokensFromMetadata(response == null ? void 0 : response.usageMetadata);
|
|
292
|
+
const tools = toolsFromResponse(response);
|
|
293
|
+
const bill = (user == null ? void 0 : user.id) ? () => billRequest({ db, user, model, usage, tools }) : () => Promise.resolve();
|
|
294
|
+
return { content, bill };
|
|
307
295
|
}
|
|
308
296
|
};
|
|
309
297
|
export {
|
package/dist/oauth/index.cjs
CHANGED
|
@@ -29,7 +29,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// lib/oauth/index.js
|
|
30
30
|
var oauth_exports = {};
|
|
31
31
|
__export(oauth_exports, {
|
|
32
|
+
clients: () => clients,
|
|
32
33
|
compare: () => compare,
|
|
34
|
+
cookies: () => cookies,
|
|
33
35
|
createOAuthClient: () => createOAuthClient,
|
|
34
36
|
developer: () => developer,
|
|
35
37
|
developerOptions: () => developerOptions,
|
|
@@ -68,6 +70,15 @@ var compare = (a, b) => {
|
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
// lib/oauth/index.js
|
|
73
|
+
var cookies = {
|
|
74
|
+
csrf: "drawbridge.csrf",
|
|
75
|
+
refresh: "drawbridge.refresh",
|
|
76
|
+
session: "drawbridge.session"
|
|
77
|
+
};
|
|
78
|
+
var clients = {
|
|
79
|
+
dashboard: "drawbridge-dashboard",
|
|
80
|
+
share: "drawbridge-share"
|
|
81
|
+
};
|
|
71
82
|
var scopes = [
|
|
72
83
|
"profile:read",
|
|
73
84
|
"profile:write",
|
|
@@ -209,7 +220,9 @@ var createOAuthClient = ({
|
|
|
209
220
|
};
|
|
210
221
|
// Annotate the CommonJS export names for ESM import in node:
|
|
211
222
|
0 && (module.exports = {
|
|
223
|
+
clients,
|
|
212
224
|
compare,
|
|
225
|
+
cookies,
|
|
213
226
|
createOAuthClient,
|
|
214
227
|
developer,
|
|
215
228
|
developerOptions,
|
package/dist/oauth/index.d.cts
CHANGED
|
@@ -10,8 +10,28 @@ import 'crypto';
|
|
|
10
10
|
// - parse, validate, intersect, isDeveloperAllowed: scope set operations
|
|
11
11
|
// - hashToken, generateToken, compare: opaque-token primitives
|
|
12
12
|
// - createOAuthClient: cached client_credentials access token getter
|
|
13
|
+
// - cookies, clients: shared identifier constants so cookie + first-party
|
|
14
|
+
// client names stay in lockstep across repos (api/middleware, api/auth,
|
|
15
|
+
// app-web BFF, sync WS handshake, seed scripts)
|
|
13
16
|
|
|
14
17
|
|
|
18
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
19
|
+
// Shared identifier constants — every repo reads from here so the strings
|
|
20
|
+
// stay aligned. Adding a new cookie or first-party client means one edit
|
|
21
|
+
// in this file followed by a utils bump downstream.
|
|
22
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
const cookies = {
|
|
25
|
+
csrf : 'drawbridge.csrf',
|
|
26
|
+
refresh : 'drawbridge.refresh',
|
|
27
|
+
session : 'drawbridge.session'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const clients = {
|
|
31
|
+
dashboard : 'drawbridge-dashboard',
|
|
32
|
+
share : 'drawbridge-share'
|
|
33
|
+
};
|
|
34
|
+
|
|
15
35
|
// ─────────────────────────────────────────────────────────────────────────
|
|
16
36
|
// Scope vocabulary (locked — 15 scopes, 10 in the developer-allowed subset)
|
|
17
37
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -260,4 +280,4 @@ const createOAuthClient = ({
|
|
|
260
280
|
|
|
261
281
|
};
|
|
262
282
|
|
|
263
|
-
export { createOAuthClient, developer, developerOptions, generateToken, hashToken, intersect, isDeveloperAllowed, parse, scopeLabels, scopeOptions, scopes, validate };
|
|
283
|
+
export { clients, cookies, createOAuthClient, developer, developerOptions, generateToken, hashToken, intersect, isDeveloperAllowed, parse, scopeLabels, scopeOptions, scopes, validate };
|
package/dist/oauth/index.d.ts
CHANGED
|
@@ -10,8 +10,28 @@ import 'crypto';
|
|
|
10
10
|
// - parse, validate, intersect, isDeveloperAllowed: scope set operations
|
|
11
11
|
// - hashToken, generateToken, compare: opaque-token primitives
|
|
12
12
|
// - createOAuthClient: cached client_credentials access token getter
|
|
13
|
+
// - cookies, clients: shared identifier constants so cookie + first-party
|
|
14
|
+
// client names stay in lockstep across repos (api/middleware, api/auth,
|
|
15
|
+
// app-web BFF, sync WS handshake, seed scripts)
|
|
13
16
|
|
|
14
17
|
|
|
18
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
19
|
+
// Shared identifier constants — every repo reads from here so the strings
|
|
20
|
+
// stay aligned. Adding a new cookie or first-party client means one edit
|
|
21
|
+
// in this file followed by a utils bump downstream.
|
|
22
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
const cookies = {
|
|
25
|
+
csrf : 'drawbridge.csrf',
|
|
26
|
+
refresh : 'drawbridge.refresh',
|
|
27
|
+
session : 'drawbridge.session'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const clients = {
|
|
31
|
+
dashboard : 'drawbridge-dashboard',
|
|
32
|
+
share : 'drawbridge-share'
|
|
33
|
+
};
|
|
34
|
+
|
|
15
35
|
// ─────────────────────────────────────────────────────────────────────────
|
|
16
36
|
// Scope vocabulary (locked — 15 scopes, 10 in the developer-allowed subset)
|
|
17
37
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -260,4 +280,4 @@ const createOAuthClient = ({
|
|
|
260
280
|
|
|
261
281
|
};
|
|
262
282
|
|
|
263
|
-
export { createOAuthClient, developer, developerOptions, generateToken, hashToken, intersect, isDeveloperAllowed, parse, scopeLabels, scopeOptions, scopes, validate };
|
|
283
|
+
export { clients, cookies, createOAuthClient, developer, developerOptions, generateToken, hashToken, intersect, isDeveloperAllowed, parse, scopeLabels, scopeOptions, scopes, validate };
|
package/dist/oauth/index.js
CHANGED
|
@@ -21,6 +21,15 @@ var compare = (a, b) => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
// lib/oauth/index.js
|
|
24
|
+
var cookies = {
|
|
25
|
+
csrf: "drawbridge.csrf",
|
|
26
|
+
refresh: "drawbridge.refresh",
|
|
27
|
+
session: "drawbridge.session"
|
|
28
|
+
};
|
|
29
|
+
var clients = {
|
|
30
|
+
dashboard: "drawbridge-dashboard",
|
|
31
|
+
share: "drawbridge-share"
|
|
32
|
+
};
|
|
24
33
|
var scopes = [
|
|
25
34
|
"profile:read",
|
|
26
35
|
"profile:write",
|
|
@@ -161,7 +170,9 @@ var createOAuthClient = ({
|
|
|
161
170
|
};
|
|
162
171
|
};
|
|
163
172
|
export {
|
|
173
|
+
clients,
|
|
164
174
|
compare,
|
|
175
|
+
cookies,
|
|
165
176
|
createOAuthClient,
|
|
166
177
|
developer,
|
|
167
178
|
developerOptions,
|
package/package.json
CHANGED