Skip to content

Commit

Permalink
fix type/compilation issues after package updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fforbeck committed Oct 24, 2024
1 parent 68f0a49 commit 5fd8afb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions billing/data/egress.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const egressSchema = Schema.struct({
space: Schema.did({ method: 'key' }),
customer: Schema.did({ method: 'mailto' }),
resource: Schema.link(),
bytes: Schema.bigint(),
bytes: Schema.number(),
servedAt: Schema.date(),
cause: Schema.link(),
})
Expand All @@ -26,7 +26,7 @@ export const encode = input => {
space: input.space.toString(),
customer: input.customer.toString(),
resource: input.resource.toString(),
bytes: input.bytes.toString(),
bytes: Number(input.bytes),
servedAt: input.servedAt.toISOString(),
cause: input.cause.toString(),
}
Expand Down Expand Up @@ -59,7 +59,7 @@ export const decode = input => {
space: Schema.did({ method: 'key' }).from(input.space),
customer: Schema.did({ method: 'mailto' }).from(input.customer),
resource: Link.parse(/** @type {string} */(input.resource)),
bytes: BigInt(input.bytes),
bytes: Number(input.bytes),
servedAt: new Date(input.servedAt),
cause: Link.parse(/** @type {string} */(input.cause)),
}
Expand Down
2 changes: 1 addition & 1 deletion billing/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export interface EgressTrafficData {
/** Resource that was served. */
resource: UnknownLink
/** Number of bytes that were served. */
bytes: bigint
bytes: number
/** Time the egress traffic was served at. */
servedAt: Date
/** UCAN invocation IDthat caused the egress traffic. */
Expand Down
2 changes: 1 addition & 1 deletion billing/test/helpers/egress.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const randomEgressEvent = async (customer) => ({
space: await randomDID(),
customer: customer.customer,
resource: randomLink(),
bytes: BigInt(Math.floor(Math.random() * 1000000)),
bytes: Math.floor(Math.random() * 1000000),
// Random timestamp within the last 1 hour
servedAt: new Date(Date.now() - Math.floor(Math.random() * 60 * 60 * 1000)),
cause: randomLink()
Expand Down
2 changes: 1 addition & 1 deletion billing/test/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface UCANStreamTestContext {
export interface EgressTrafficTestContext extends Context {
egressTrafficQueue: EgressTrafficQueue & QueueRemover<EgressTrafficData>
egressTrafficQueueUrl: string
egressTrafficHandler: Handler<SQSEvent, { statusCode: number, body: string }>
egressTrafficHandler: Handler<SQSEvent, any>
accountId: string
region: string
customerTable: string
Expand Down
16 changes: 8 additions & 8 deletions upload-api/stores/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ export function useUsageStore({ spaceSnapshotStore, spaceDiffStore, egressTraffi
/**
* Handle egress traffic data and enqueues it, so the billing system can process it and update the Stripe Billing Meter API.
*
* @param {import('@web3-storage/upload-api').SpaceDID} space
* @param {import('@web3-storage/upload-api').AccountDID} customer
* @param {import('@web3-storage/upload-api').UnknownLink} resource
* @param {bigint} bytes
* @param {Date} servedAt
* @param {import('@web3-storage/upload-api').UnknownLink} cause
* @returns {Promise<import('@ucanto/interface').Result<import('@ucanto/interface').Unit, import('@ucanto/interface').Failure>>}
* @param {import('@web3-storage/upload-api').SpaceDID} space - The space that the egress traffic is associated with.
* @param {import('@web3-storage/upload-api').AccountDID} customer - The customer that will be billed for the egress traffic.
* @param {import('@web3-storage/upload-api').UnknownLink} resource - The resource that was served.
* @param {number} bytes - The number of bytes that were served.
* @param {Date} servedAt - The date and time when the egress traffic was served.
* @param {import('@web3-storage/upload-api').UnknownLink} cause - The UCAN invocation ID that caused the egress traffic.
* @returns {Promise<import('@ucanto/interface').Result<import('@web3-storage/upload-api').EgressData, import('@ucanto/interface').Failure>>}
*/
async record(space, customer, resource, bytes, servedAt, cause) {
const record = {
Expand All @@ -84,7 +84,7 @@ export function useUsageStore({ spaceSnapshotStore, spaceDiffStore, egressTraffi
const result = await egressTrafficQueue.add(record)
if (result.error) return result

return { ok: record }
return { ok: { ...record, servedAt: servedAt.toISOString() } }
}
}
}

0 comments on commit 5fd8afb

Please sign in to comment.