@drawbridge/drawbridge-utils 0.0.70 → 0.0.71
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/billing.cjs +26 -0
- package/dist/billing.d.cts +42 -0
- package/dist/billing.d.ts +42 -0
- package/dist/billing.js +26 -0
- package/package.json +1 -1
package/dist/billing.cjs
CHANGED
|
@@ -277,9 +277,35 @@ var scrapeFee = ({ provider, bytes, requests, url, cold }) => {
|
|
|
277
277
|
}
|
|
278
278
|
return LOCAL_FLAT_CENTS;
|
|
279
279
|
};
|
|
280
|
+
var scrapeBreakdown = ({ provider, bytes, requests, url }) => {
|
|
281
|
+
if (provider === "brightdata") {
|
|
282
|
+
return {
|
|
283
|
+
provider,
|
|
284
|
+
basis: "bytes",
|
|
285
|
+
units: bytes || 0,
|
|
286
|
+
rate: ratePerGB(url),
|
|
287
|
+
rateUnit: "GB",
|
|
288
|
+
cents: scrapeFee({ provider, bytes, url, cold: true })
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
if (provider === "brightdata-unlocker") {
|
|
292
|
+
return {
|
|
293
|
+
provider,
|
|
294
|
+
basis: "requests",
|
|
295
|
+
units: requests || 0,
|
|
296
|
+
// cpmCents is cents-per-request; ×10 expresses it as dollars per 1,000.
|
|
297
|
+
rate: cpmCents(url) * 10,
|
|
298
|
+
rateUnit: "1K requests",
|
|
299
|
+
cents: scrapeFee({ provider, requests, url, cold: true })
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return { provider: provider || "local", basis: "local", units: null, rate: null, rateUnit: null, cents: LOCAL_FLAT_CENTS };
|
|
303
|
+
};
|
|
280
304
|
var scrape = {
|
|
281
305
|
// Cents for a scrape given its provider/bytes/cold basis.
|
|
282
306
|
fee: scrapeFee,
|
|
307
|
+
// Itemized cold-fee breakdown (basis/units/rate/cents) for display + the scrape doc.
|
|
308
|
+
breakdown: scrapeBreakdown,
|
|
283
309
|
// Deferred bill(scrapeId) the scrape store's resolve() hands the generation
|
|
284
310
|
// flow. Atomically claims the cold (first-time) fee via the `charged` flag so
|
|
285
311
|
// a BrightData scrape's metered cost is recovered ONCE; later reuses pay the
|
package/dist/billing.d.cts
CHANGED
|
@@ -226,11 +226,53 @@ const scrapeFee = ({ provider, bytes, requests, url, cold }) => {
|
|
|
226
226
|
|
|
227
227
|
};
|
|
228
228
|
|
|
229
|
+
// Itemized cold-fee breakdown for the scrape doc / admin dashboard: the same cents
|
|
230
|
+
// scrapeFee charges on a COLD scrape, plus the basis, the metered units, and the
|
|
231
|
+
// wholesale provider rate behind it. Reuse hits aren't represented here — the doc
|
|
232
|
+
// records its cold acquisition cost. `rate` is the wholesale rate in dollars per
|
|
233
|
+
// `rateUnit` (pre-markup, i.e. the BrightData list price); `cents` is the retail fee
|
|
234
|
+
// billed (incl MARKUP). Local renders have no external cost — flat, no rate.
|
|
235
|
+
const scrapeBreakdown = ({ provider, bytes, requests, url }) => {
|
|
236
|
+
|
|
237
|
+
if( provider === 'brightdata' ){
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
provider,
|
|
241
|
+
basis : 'bytes',
|
|
242
|
+
units : bytes || 0,
|
|
243
|
+
rate : ratePerGB( url ),
|
|
244
|
+
rateUnit : 'GB',
|
|
245
|
+
cents : scrapeFee({ provider, bytes, url, cold : true })
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if( provider === 'brightdata-unlocker' ){
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
provider,
|
|
254
|
+
basis : 'requests',
|
|
255
|
+
units : requests || 0,
|
|
256
|
+
// cpmCents is cents-per-request; ×10 expresses it as dollars per 1,000.
|
|
257
|
+
rate : cpmCents( url ) * 10,
|
|
258
|
+
rateUnit : '1K requests',
|
|
259
|
+
cents : scrapeFee({ provider, requests, url, cold : true })
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return { provider : provider || 'local', basis : 'local', units : null, rate : null, rateUnit : null, cents : LOCAL_FLAT_CENTS };
|
|
265
|
+
|
|
266
|
+
};
|
|
267
|
+
|
|
229
268
|
const scrape = {
|
|
230
269
|
|
|
231
270
|
// Cents for a scrape given its provider/bytes/cold basis.
|
|
232
271
|
fee : scrapeFee,
|
|
233
272
|
|
|
273
|
+
// Itemized cold-fee breakdown (basis/units/rate/cents) for display + the scrape doc.
|
|
274
|
+
breakdown : scrapeBreakdown,
|
|
275
|
+
|
|
234
276
|
// Deferred bill(scrapeId) the scrape store's resolve() hands the generation
|
|
235
277
|
// flow. Atomically claims the cold (first-time) fee via the `charged` flag so
|
|
236
278
|
// a BrightData scrape's metered cost is recovered ONCE; later reuses pay the
|
package/dist/billing.d.ts
CHANGED
|
@@ -226,11 +226,53 @@ const scrapeFee = ({ provider, bytes, requests, url, cold }) => {
|
|
|
226
226
|
|
|
227
227
|
};
|
|
228
228
|
|
|
229
|
+
// Itemized cold-fee breakdown for the scrape doc / admin dashboard: the same cents
|
|
230
|
+
// scrapeFee charges on a COLD scrape, plus the basis, the metered units, and the
|
|
231
|
+
// wholesale provider rate behind it. Reuse hits aren't represented here — the doc
|
|
232
|
+
// records its cold acquisition cost. `rate` is the wholesale rate in dollars per
|
|
233
|
+
// `rateUnit` (pre-markup, i.e. the BrightData list price); `cents` is the retail fee
|
|
234
|
+
// billed (incl MARKUP). Local renders have no external cost — flat, no rate.
|
|
235
|
+
const scrapeBreakdown = ({ provider, bytes, requests, url }) => {
|
|
236
|
+
|
|
237
|
+
if( provider === 'brightdata' ){
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
provider,
|
|
241
|
+
basis : 'bytes',
|
|
242
|
+
units : bytes || 0,
|
|
243
|
+
rate : ratePerGB( url ),
|
|
244
|
+
rateUnit : 'GB',
|
|
245
|
+
cents : scrapeFee({ provider, bytes, url, cold : true })
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if( provider === 'brightdata-unlocker' ){
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
provider,
|
|
254
|
+
basis : 'requests',
|
|
255
|
+
units : requests || 0,
|
|
256
|
+
// cpmCents is cents-per-request; ×10 expresses it as dollars per 1,000.
|
|
257
|
+
rate : cpmCents( url ) * 10,
|
|
258
|
+
rateUnit : '1K requests',
|
|
259
|
+
cents : scrapeFee({ provider, requests, url, cold : true })
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return { provider : provider || 'local', basis : 'local', units : null, rate : null, rateUnit : null, cents : LOCAL_FLAT_CENTS };
|
|
265
|
+
|
|
266
|
+
};
|
|
267
|
+
|
|
229
268
|
const scrape = {
|
|
230
269
|
|
|
231
270
|
// Cents for a scrape given its provider/bytes/cold basis.
|
|
232
271
|
fee : scrapeFee,
|
|
233
272
|
|
|
273
|
+
// Itemized cold-fee breakdown (basis/units/rate/cents) for display + the scrape doc.
|
|
274
|
+
breakdown : scrapeBreakdown,
|
|
275
|
+
|
|
234
276
|
// Deferred bill(scrapeId) the scrape store's resolve() hands the generation
|
|
235
277
|
// flow. Atomically claims the cold (first-time) fee via the `charged` flag so
|
|
236
278
|
// a BrightData scrape's metered cost is recovered ONCE; later reuses pay the
|
package/dist/billing.js
CHANGED
|
@@ -248,9 +248,35 @@ var scrapeFee = ({ provider, bytes, requests, url, cold }) => {
|
|
|
248
248
|
}
|
|
249
249
|
return LOCAL_FLAT_CENTS;
|
|
250
250
|
};
|
|
251
|
+
var scrapeBreakdown = ({ provider, bytes, requests, url }) => {
|
|
252
|
+
if (provider === "brightdata") {
|
|
253
|
+
return {
|
|
254
|
+
provider,
|
|
255
|
+
basis: "bytes",
|
|
256
|
+
units: bytes || 0,
|
|
257
|
+
rate: ratePerGB(url),
|
|
258
|
+
rateUnit: "GB",
|
|
259
|
+
cents: scrapeFee({ provider, bytes, url, cold: true })
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
if (provider === "brightdata-unlocker") {
|
|
263
|
+
return {
|
|
264
|
+
provider,
|
|
265
|
+
basis: "requests",
|
|
266
|
+
units: requests || 0,
|
|
267
|
+
// cpmCents is cents-per-request; ×10 expresses it as dollars per 1,000.
|
|
268
|
+
rate: cpmCents(url) * 10,
|
|
269
|
+
rateUnit: "1K requests",
|
|
270
|
+
cents: scrapeFee({ provider, requests, url, cold: true })
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
return { provider: provider || "local", basis: "local", units: null, rate: null, rateUnit: null, cents: LOCAL_FLAT_CENTS };
|
|
274
|
+
};
|
|
251
275
|
var scrape = {
|
|
252
276
|
// Cents for a scrape given its provider/bytes/cold basis.
|
|
253
277
|
fee: scrapeFee,
|
|
278
|
+
// Itemized cold-fee breakdown (basis/units/rate/cents) for display + the scrape doc.
|
|
279
|
+
breakdown: scrapeBreakdown,
|
|
254
280
|
// Deferred bill(scrapeId) the scrape store's resolve() hands the generation
|
|
255
281
|
// flow. Atomically claims the cold (first-time) fee via the `charged` flag so
|
|
256
282
|
// a BrightData scrape's metered cost is recovered ONCE; later reuses pay the
|
package/package.json
CHANGED