Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[subs 0] Feature - Subscriptions Backend #3240

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-and-push-bsky-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- bsky-bsync-subscription-endpoints
env:
REGISTRY: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_REGISTRY }}
USERNAME: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_USERNAME }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-push-bsky-ghcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- bsky-bsync-subscription-endpoints
env:
REGISTRY: ghcr.io
USERNAME: ${{ github.actor }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-push-bsync-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- bsky-bsync-subscription-endpoints
env:
REGISTRY: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_REGISTRY }}
USERNAME: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_USERNAME }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-push-bsync-ghcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- bsky-bsync-subscription-endpoints
env:
REGISTRY: ghcr.io
USERNAME: ${{ github.actor }}
Expand Down
29 changes: 29 additions & 0 deletions lexicons/app/bsky/purchase/createStripeBillingUrl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"lexicon": 1,
"id": "app.bsky.purchase.createStripeBillingUrl",
"defs": {
"main": {
"type": "procedure",
"description": "Creates a Stripe Billing Portal session and returns the URL to access it. Requires auth.",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["redirectUrl"],
"properties": {
"redirectUrl": { "type": "string", "format": "uri" }
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"properties": {
"billingUrl": { "type": "string", "format": "uri" }
}
}
}
}
}
}
31 changes: 31 additions & 0 deletions lexicons/app/bsky/purchase/createStripeCheckoutUrl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"lexicon": 1,
"id": "app.bsky.purchase.createStripeCheckoutUrl",
"defs": {
"main": {
"type": "procedure",
"description": "Creates a Stripe Checkout session and returns the URL to access it. Requires auth.",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["email", "priceId", "redirectUrl"],
"properties": {
"email": { "type": "string" },
"priceId": { "type": "string" },
"redirectUrl": { "type": "string", "format": "uri" }
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"properties": {
"checkoutUrl": { "type": "string", "format": "uri" }
}
}
}
}
}
}
33 changes: 33 additions & 0 deletions lexicons/app/bsky/purchase/getFeatures.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"lexicon": 1,
"id": "app.bsky.purchase.getFeatures",
"defs": {
"main": {
"type": "query",
"description": "Enumerate unlocked paid feature flags for the requesting account. Requires auth.",
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["features"],
"properties": {
"features": {
"type": "ref",
"ref": "#features"
}
}
}
}
},
"features": {
"type": "object",
"required": [],
"properties": {
"customProfileColor": {
"type": "boolean",
"description": "Indicates to client apps to allow the requesting account to customize the profile color."
}
}
}
}
}
53 changes: 53 additions & 0 deletions lexicons/app/bsky/purchase/getSubscriptionGroup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"lexicon": 1,
"id": "app.bsky.purchase.getSubscriptionGroup",
"defs": {
"main": {
"type": "query",
"description": "Gets a subscription group and its offerings for the target platform. Requires auth.",
"parameters": {
"type": "params",
"required": ["group", "platform"],
"properties": {
"group": { "type": "string", "knownValues": ["core"] },
"platform": {
"type": "string",
"knownValues": ["android", "ios", "web"]
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": [],
"properties": {
"group": { "type": "string", "knownValues": ["core"] },
"offerings": {
"type": "array",
"items": {
"type": "ref",
"ref": "#offering"
}
}
}
}
}
},
"offering": {
"type": "object",
"required": [],
"properties": {
"id": {
"type": "string",
"knownValues": ["core:annual", "core:monthly"]
},
"platform": {
"type": "string",
"knownValues": ["android", "ios", "web"]
},
"product": { "type": "string" }
}
}
}
}
58 changes: 58 additions & 0 deletions lexicons/app/bsky/purchase/getSubscriptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"lexicon": 1,
"id": "app.bsky.purchase.getSubscriptions",
"defs": {
"main": {
"type": "query",
"description": "Enumerate subscriptions for the requesting account, and the email used in the purchase. Requires auth.",
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["subscriptions"],
"properties": {
"email": { "type": "string" },
"subscriptions": {
"type": "array",
"items": {
"type": "ref",
"ref": "#subscription"
}
}
}
}
}
},
"subscription": {
"type": "object",
"required": [],
"properties": {
"status": {
"type": "string",
"knownValues": ["active", "expired", "paused", "unknown"]
},
"renewalStatus": {
"type": "string",
"knownValues": [
"unknown",
"will_not_renew",
"will_pause",
"will_renew"
]
},
"group": { "type": "string", "knownValues": ["core"] },
"platform": {
"type": "string",
"knownValues": ["android", "ios", "web"]
},
"offering": {
"type": "string",
"knownValues": ["core:annual", "core:monthly"]
},
"periodEndsAt": { "type": "string", "format": "datetime" },
"periodStartsAt": { "type": "string", "format": "datetime" },
"purchasedAt": { "type": "string", "format": "datetime" }
}
}
}
}
27 changes: 27 additions & 0 deletions lexicons/app/bsky/purchase/refreshCache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"lexicon": 1,
"id": "app.bsky.purchase.refreshCache",
"defs": {
"main": {
"type": "procedure",
"description": "Refresh the purchase cache for the requesting account or for another account if the role authorizes it. Requires auth.",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["did"],
"properties": {
"did": { "type": "string", "format": "did" }
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"properties": {}
}
}
}
}
}
94 changes: 94 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ import * as AppBskyNotificationListNotifications from './types/app/bsky/notifica
import * as AppBskyNotificationPutPreferences from './types/app/bsky/notification/putPreferences'
import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush'
import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
import * as AppBskyPurchaseCreateStripeBillingUrl from './types/app/bsky/purchase/createStripeBillingUrl'
import * as AppBskyPurchaseCreateStripeCheckoutUrl from './types/app/bsky/purchase/createStripeCheckoutUrl'
import * as AppBskyPurchaseGetFeatures from './types/app/bsky/purchase/getFeatures'
import * as AppBskyPurchaseGetSubscriptionGroup from './types/app/bsky/purchase/getSubscriptionGroup'
import * as AppBskyPurchaseGetSubscriptions from './types/app/bsky/purchase/getSubscriptions'
import * as AppBskyPurchaseRefreshCache from './types/app/bsky/purchase/refreshCache'
import * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
import * as AppBskyUnspeccedDefs from './types/app/bsky/unspecced/defs'
import * as AppBskyUnspeccedGetConfig from './types/app/bsky/unspecced/getConfig'
Expand Down Expand Up @@ -388,6 +394,12 @@ export * as AppBskyNotificationListNotifications from './types/app/bsky/notifica
export * as AppBskyNotificationPutPreferences from './types/app/bsky/notification/putPreferences'
export * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush'
export * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
export * as AppBskyPurchaseCreateStripeBillingUrl from './types/app/bsky/purchase/createStripeBillingUrl'
export * as AppBskyPurchaseCreateStripeCheckoutUrl from './types/app/bsky/purchase/createStripeCheckoutUrl'
export * as AppBskyPurchaseGetFeatures from './types/app/bsky/purchase/getFeatures'
export * as AppBskyPurchaseGetSubscriptionGroup from './types/app/bsky/purchase/getSubscriptionGroup'
export * as AppBskyPurchaseGetSubscriptions from './types/app/bsky/purchase/getSubscriptions'
export * as AppBskyPurchaseRefreshCache from './types/app/bsky/purchase/refreshCache'
export * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
export * as AppBskyUnspeccedDefs from './types/app/bsky/unspecced/defs'
export * as AppBskyUnspeccedGetConfig from './types/app/bsky/unspecced/getConfig'
Expand Down Expand Up @@ -1486,6 +1498,7 @@ export class AppBskyNS {
graph: AppBskyGraphNS
labeler: AppBskyLabelerNS
notification: AppBskyNotificationNS
purchase: AppBskyPurchaseNS
richtext: AppBskyRichtextNS
unspecced: AppBskyUnspeccedNS
video: AppBskyVideoNS
Expand All @@ -1498,6 +1511,7 @@ export class AppBskyNS {
this.graph = new AppBskyGraphNS(client)
this.labeler = new AppBskyLabelerNS(client)
this.notification = new AppBskyNotificationNS(client)
this.purchase = new AppBskyPurchaseNS(client)
this.richtext = new AppBskyRichtextNS(client)
this.unspecced = new AppBskyUnspeccedNS(client)
this.video = new AppBskyVideoNS(client)
Expand Down Expand Up @@ -3026,6 +3040,86 @@ export class AppBskyNotificationNS {
}
}

export class AppBskyPurchaseNS {
_client: XrpcClient

constructor(client: XrpcClient) {
this._client = client
}

createStripeBillingUrl(
data?: AppBskyPurchaseCreateStripeBillingUrl.InputSchema,
opts?: AppBskyPurchaseCreateStripeBillingUrl.CallOptions,
): Promise<AppBskyPurchaseCreateStripeBillingUrl.Response> {
return this._client.call(
'app.bsky.purchase.createStripeBillingUrl',
opts?.qp,
data,
opts,
)
}

createStripeCheckoutUrl(
data?: AppBskyPurchaseCreateStripeCheckoutUrl.InputSchema,
opts?: AppBskyPurchaseCreateStripeCheckoutUrl.CallOptions,
): Promise<AppBskyPurchaseCreateStripeCheckoutUrl.Response> {
return this._client.call(
'app.bsky.purchase.createStripeCheckoutUrl',
opts?.qp,
data,
opts,
)
}

getFeatures(
params?: AppBskyPurchaseGetFeatures.QueryParams,
opts?: AppBskyPurchaseGetFeatures.CallOptions,
): Promise<AppBskyPurchaseGetFeatures.Response> {
return this._client.call(
'app.bsky.purchase.getFeatures',
params,
undefined,
opts,
)
}

getSubscriptionGroup(
params?: AppBskyPurchaseGetSubscriptionGroup.QueryParams,
opts?: AppBskyPurchaseGetSubscriptionGroup.CallOptions,
): Promise<AppBskyPurchaseGetSubscriptionGroup.Response> {
return this._client.call(
'app.bsky.purchase.getSubscriptionGroup',
params,
undefined,
opts,
)
}

getSubscriptions(
params?: AppBskyPurchaseGetSubscriptions.QueryParams,
opts?: AppBskyPurchaseGetSubscriptions.CallOptions,
): Promise<AppBskyPurchaseGetSubscriptions.Response> {
return this._client.call(
'app.bsky.purchase.getSubscriptions',
params,
undefined,
opts,
)
}

refreshCache(
data?: AppBskyPurchaseRefreshCache.InputSchema,
opts?: AppBskyPurchaseRefreshCache.CallOptions,
): Promise<AppBskyPurchaseRefreshCache.Response> {
return this._client.call(
'app.bsky.purchase.refreshCache',
opts?.qp,
data,
opts,
)
}
}

export class AppBskyRichtextNS {
_client: XrpcClient

Expand Down
Loading
Loading