Skip to content

Commit

Permalink
Add bsync scanPurchaseOperations route
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelbsky committed Dec 11, 2024
1 parent c919743 commit 6a39b89
Show file tree
Hide file tree
Showing 7 changed files with 518 additions and 122 deletions.
31 changes: 24 additions & 7 deletions packages/bsync/proto/bsync.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ message ScanNotifOperationsResponse {
string cursor = 2;
}

message RefreshPurchasesRequest {
string actor_did = 1;
}

message RefreshPurchasesResponse {}

message Subscription {
string status = 1;
string renewalStatus = 2;
Expand Down Expand Up @@ -108,6 +102,28 @@ message GetSubscriptionGroupResponse {
repeated SubscriptionOffering offerings = 1;
}

message RefreshPurchasesRequest {
string actor_did = 1;
}

message RefreshPurchasesResponse {}

message PurchaseOperation {
string id = 1;
string actor_did = 2;
repeated string entitlements = 3;
}

message ScanPurchaseOperationsRequest {
string cursor = 1;
int32 limit = 2;
}

message ScanPurchaseOperationsResponse {
repeated PurchaseOperation operations = 1;
string cursor = 2;
}

// Ping
message PingRequest {}
message PingResponse {}
Expand All @@ -120,9 +136,10 @@ service Service {
rpc AddNotifOperation(AddNotifOperationRequest) returns (AddNotifOperationResponse);
rpc ScanNotifOperations(ScanNotifOperationsRequest) returns (ScanNotifOperationsResponse);
// Purchase
rpc RefreshPurchases(RefreshPurchasesRequest) returns (RefreshPurchasesResponse);
rpc GetSubscriptions(GetSubscriptionsRequest) returns (GetSubscriptionsResponse);
rpc GetSubscriptionGroup(GetSubscriptionGroupRequest) returns (GetSubscriptionGroupResponse);
rpc RefreshPurchases(RefreshPurchasesRequest) returns (RefreshPurchasesResponse);
rpc ScanPurchaseOperations(ScanPurchaseOperationsRequest) returns (ScanPurchaseOperationsResponse);
// Ping
rpc Ping(PingRequest) returns (PingResponse);
}
1 change: 1 addition & 0 deletions packages/bsync/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class BsyncService {
// if these error, unhandled rejection should cause process to exit
conn.query(`listen ${createMuteOpChannel}`)
conn.query(`listen ${createNotifOpChannel}`)
conn.query(`listen ${createPurchaseOpChannel}`)
conn.on('notification', (notif) => {
if (notif.channel === createMuteOpChannel) {
this.ctx.events.emit(createMuteOpChannel)
Expand Down
29 changes: 20 additions & 9 deletions packages/bsync/src/proto/bsync_connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
ScanMuteOperationsResponse,
ScanNotifOperationsRequest,
ScanNotifOperationsResponse,
ScanPurchaseOperationsRequest,
ScanPurchaseOperationsResponse,
} from './bsync_pb'
import { MethodKind } from '@bufbuild/protobuf'

Expand Down Expand Up @@ -70,15 +72,6 @@ export const Service = {
/**
* Purchase
*
* @generated from rpc bsync.Service.RefreshPurchases
*/
refreshPurchases: {
name: 'RefreshPurchases',
I: RefreshPurchasesRequest,
O: RefreshPurchasesResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc bsync.Service.GetSubscriptions
*/
getSubscriptions: {
Expand All @@ -96,6 +89,24 @@ export const Service = {
O: GetSubscriptionGroupResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc bsync.Service.RefreshPurchases
*/
refreshPurchases: {
name: 'RefreshPurchases',
I: RefreshPurchasesRequest,
O: RefreshPurchasesResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc bsync.Service.ScanPurchaseOperations
*/
scanPurchaseOperations: {
name: 'ScanPurchaseOperations',
I: ScanPurchaseOperationsRequest,
O: ScanPurchaseOperationsResponse,
kind: MethodKind.Unary,
},
/**
* Ping
*
Expand Down
Loading

0 comments on commit 6a39b89

Please sign in to comment.