onehook-api-client 1.0.19 → 1.0.21

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.
@@ -0,0 +1,50 @@
1
+ import { SubscriptionTier } from '../models/models_0';
2
+ export { SubscriptionTier };
3
+ export const SUBSCRIPTION_TIERS = Object.freeze([
4
+ { wire: 'MUST', displayName: 'Must', maxConnections: 1 },
5
+ { wire: 'SUPER', displayName: 'Super', maxConnections: 1 },
6
+ { wire: 'INFINITY', displayName: 'Infinity', maxConnections: 3 },
7
+ ]);
8
+ export const SUBSCRIPTION_TIER_ORDER = Object.freeze(SUBSCRIPTION_TIERS.map((t) => t.wire));
9
+ export const DEFAULT_SUBSCRIPTION_TIER = SUBSCRIPTION_TIER_ORDER[0];
10
+ export const PAID_SUBSCRIPTION_TIERS = Object.freeze(SUBSCRIPTION_TIERS.slice(1));
11
+ const BY_WIRE = Object.freeze(Object.fromEntries(SUBSCRIPTION_TIERS.map((t) => [t.wire, t])));
12
+ export function subscriptionTierInfo(tier) {
13
+ return BY_WIRE[tier];
14
+ }
15
+ export function subscriptionTierDisplayName(tier) {
16
+ return BY_WIRE[tier].displayName;
17
+ }
18
+ export function parseSubscriptionTier(raw) {
19
+ if (typeof raw !== 'string')
20
+ return undefined;
21
+ const key = raw.trim().toUpperCase();
22
+ return SUBSCRIPTION_TIERS.find((t) => t.wire === key)?.wire;
23
+ }
24
+ let unknownTierHandler = () => { };
25
+ export function onUnknownSubscriptionTier(handler) {
26
+ unknownTierHandler = handler;
27
+ }
28
+ export function resolveSubscriptionTier(raw) {
29
+ const tier = parseSubscriptionTier(raw);
30
+ if (tier)
31
+ return tier;
32
+ if (typeof raw === 'string' ? raw.trim() !== '' : raw != null) {
33
+ try {
34
+ unknownTierHandler(String(raw));
35
+ }
36
+ catch {
37
+ }
38
+ }
39
+ return DEFAULT_SUBSCRIPTION_TIER;
40
+ }
41
+ export function subscriptionTierRank(tier) {
42
+ return SUBSCRIPTION_TIER_ORDER.indexOf(tier);
43
+ }
44
+ export function isPaidSubscriptionTier(tier) {
45
+ const parsed = parseSubscriptionTier(tier);
46
+ return parsed !== undefined && parsed !== DEFAULT_SUBSCRIPTION_TIER;
47
+ }
48
+ export function maxConnectionsForTier(raw) {
49
+ return BY_WIRE[resolveSubscriptionTier(raw)].maxConnections;
50
+ }
@@ -91,3 +91,8 @@ export const CredentialGap = {
91
91
  USERNAME_MISMATCHED_IN_COGNITO: "USERNAME_MISMATCHED_IN_COGNITO",
92
92
  USERNAME_NOT_SYNCED_TO_COGNITO: "USERNAME_NOT_SYNCED_TO_COGNITO",
93
93
  };
94
+ export const SubscriptionTier = {
95
+ INFINITY: "INFINITY",
96
+ MUST: "MUST",
97
+ SUPER: "SUPER",
98
+ };