onehook-api-client 1.0.20 → 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.
- package/dist-cjs/membership/index.js +61 -0
- package/dist-cjs/models/models_0.js +6 -1
- package/dist-es/membership/index.js +50 -0
- package/dist-es/models/models_0.js +5 -0
- package/dist-types/commands/GetMyProfileCommand.d.ts +1 -1
- package/dist-types/commands/GetProfileCommand.d.ts +1 -1
- package/dist-types/commands/GetStateCommand.d.ts +1 -1
- package/dist-types/commands/UpdateEntitlementsCommand.d.ts +2 -2
- package/dist-types/commands/UpgradeUserCommand.d.ts +1 -1
- package/dist-types/membership/index.d.ts +47 -0
- package/dist-types/models/models_0.d.ts +45 -4
- package/membership/SubscriptionTierCatalog.kt +30 -0
- package/membership/SubscriptionTierCatalog.swift +31 -0
- package/membership/membership-catalog.json +20 -0
- package/package.json +11 -2
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.maxConnectionsForTier = exports.isPaidSubscriptionTier = exports.subscriptionTierRank = exports.resolveSubscriptionTier = exports.onUnknownSubscriptionTier = exports.parseSubscriptionTier = exports.subscriptionTierDisplayName = exports.subscriptionTierInfo = exports.PAID_SUBSCRIPTION_TIERS = exports.DEFAULT_SUBSCRIPTION_TIER = exports.SUBSCRIPTION_TIER_ORDER = exports.SUBSCRIPTION_TIERS = exports.SubscriptionTier = void 0;
|
|
4
|
+
const models_0_1 = require("../models/models_0");
|
|
5
|
+
Object.defineProperty(exports, "SubscriptionTier", { enumerable: true, get: function () { return models_0_1.SubscriptionTier; } });
|
|
6
|
+
exports.SUBSCRIPTION_TIERS = Object.freeze([
|
|
7
|
+
{ wire: 'MUST', displayName: 'Must', maxConnections: 1 },
|
|
8
|
+
{ wire: 'SUPER', displayName: 'Super', maxConnections: 1 },
|
|
9
|
+
{ wire: 'INFINITY', displayName: 'Infinity', maxConnections: 3 },
|
|
10
|
+
]);
|
|
11
|
+
exports.SUBSCRIPTION_TIER_ORDER = Object.freeze(exports.SUBSCRIPTION_TIERS.map((t) => t.wire));
|
|
12
|
+
exports.DEFAULT_SUBSCRIPTION_TIER = exports.SUBSCRIPTION_TIER_ORDER[0];
|
|
13
|
+
exports.PAID_SUBSCRIPTION_TIERS = Object.freeze(exports.SUBSCRIPTION_TIERS.slice(1));
|
|
14
|
+
const BY_WIRE = Object.freeze(Object.fromEntries(exports.SUBSCRIPTION_TIERS.map((t) => [t.wire, t])));
|
|
15
|
+
function subscriptionTierInfo(tier) {
|
|
16
|
+
return BY_WIRE[tier];
|
|
17
|
+
}
|
|
18
|
+
exports.subscriptionTierInfo = subscriptionTierInfo;
|
|
19
|
+
function subscriptionTierDisplayName(tier) {
|
|
20
|
+
return BY_WIRE[tier].displayName;
|
|
21
|
+
}
|
|
22
|
+
exports.subscriptionTierDisplayName = subscriptionTierDisplayName;
|
|
23
|
+
function parseSubscriptionTier(raw) {
|
|
24
|
+
if (typeof raw !== 'string')
|
|
25
|
+
return undefined;
|
|
26
|
+
const key = raw.trim().toUpperCase();
|
|
27
|
+
return exports.SUBSCRIPTION_TIERS.find((t) => t.wire === key)?.wire;
|
|
28
|
+
}
|
|
29
|
+
exports.parseSubscriptionTier = parseSubscriptionTier;
|
|
30
|
+
let unknownTierHandler = () => { };
|
|
31
|
+
function onUnknownSubscriptionTier(handler) {
|
|
32
|
+
unknownTierHandler = handler;
|
|
33
|
+
}
|
|
34
|
+
exports.onUnknownSubscriptionTier = onUnknownSubscriptionTier;
|
|
35
|
+
function resolveSubscriptionTier(raw) {
|
|
36
|
+
const tier = parseSubscriptionTier(raw);
|
|
37
|
+
if (tier)
|
|
38
|
+
return tier;
|
|
39
|
+
if (typeof raw === 'string' ? raw.trim() !== '' : raw != null) {
|
|
40
|
+
try {
|
|
41
|
+
unknownTierHandler(String(raw));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return exports.DEFAULT_SUBSCRIPTION_TIER;
|
|
47
|
+
}
|
|
48
|
+
exports.resolveSubscriptionTier = resolveSubscriptionTier;
|
|
49
|
+
function subscriptionTierRank(tier) {
|
|
50
|
+
return exports.SUBSCRIPTION_TIER_ORDER.indexOf(tier);
|
|
51
|
+
}
|
|
52
|
+
exports.subscriptionTierRank = subscriptionTierRank;
|
|
53
|
+
function isPaidSubscriptionTier(tier) {
|
|
54
|
+
const parsed = parseSubscriptionTier(tier);
|
|
55
|
+
return parsed !== undefined && parsed !== exports.DEFAULT_SUBSCRIPTION_TIER;
|
|
56
|
+
}
|
|
57
|
+
exports.isPaidSubscriptionTier = isPaidSubscriptionTier;
|
|
58
|
+
function maxConnectionsForTier(raw) {
|
|
59
|
+
return BY_WIRE[resolveSubscriptionTier(raw)].maxConnections;
|
|
60
|
+
}
|
|
61
|
+
exports.maxConnectionsForTier = maxConnectionsForTier;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CredentialGap = exports.DeviceLimitError = exports.Platform = exports.LastSeenVisibility = exports.MediaKind = exports.ForbiddenError = exports.NotFoundError = exports.InternalServerError = exports.BadRequestError = void 0;
|
|
3
|
+
exports.SubscriptionTier = exports.CredentialGap = exports.DeviceLimitError = exports.Platform = exports.LastSeenVisibility = exports.MediaKind = exports.ForbiddenError = exports.NotFoundError = exports.InternalServerError = exports.BadRequestError = void 0;
|
|
4
4
|
const OneHookServiceException_1 = require("./OneHookServiceException");
|
|
5
5
|
class BadRequestError extends OneHookServiceException_1.OneHookServiceException {
|
|
6
6
|
name = "BadRequestError";
|
|
@@ -99,3 +99,8 @@ exports.CredentialGap = {
|
|
|
99
99
|
USERNAME_MISMATCHED_IN_COGNITO: "USERNAME_MISMATCHED_IN_COGNITO",
|
|
100
100
|
USERNAME_NOT_SYNCED_TO_COGNITO: "USERNAME_NOT_SYNCED_TO_COGNITO",
|
|
101
101
|
};
|
|
102
|
+
exports.SubscriptionTier = {
|
|
103
|
+
INFINITY: "INFINITY",
|
|
104
|
+
MUST: "MUST",
|
|
105
|
+
SUPER: "SUPER",
|
|
106
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -61,7 +61,7 @@ declare const GetMyProfileCommand_base: {
|
|
|
61
61
|
* // ],
|
|
62
62
|
* // starSign: "STRING_VALUE",
|
|
63
63
|
* // verified: true || false,
|
|
64
|
-
* // subscriptionTier: "
|
|
64
|
+
* // subscriptionTier: "MUST" || "SUPER" || "INFINITY",
|
|
65
65
|
* // pictures: [
|
|
66
66
|
* // "STRING_VALUE",
|
|
67
67
|
* // ],
|
|
@@ -62,7 +62,7 @@ declare const GetProfileCommand_base: {
|
|
|
62
62
|
* // ],
|
|
63
63
|
* // starSign: "STRING_VALUE",
|
|
64
64
|
* // verified: true || false,
|
|
65
|
-
* // subscriptionTier: "
|
|
65
|
+
* // subscriptionTier: "MUST" || "SUPER" || "INFINITY",
|
|
66
66
|
* // pictures: [
|
|
67
67
|
* // "STRING_VALUE",
|
|
68
68
|
* // ],
|
|
@@ -47,7 +47,7 @@ declare const GetStateCommand_base: {
|
|
|
47
47
|
* // matchIds: [ // StringList // required
|
|
48
48
|
* // "STRING_VALUE",
|
|
49
49
|
* // ],
|
|
50
|
-
* // subscriptionTier: "
|
|
50
|
+
* // subscriptionTier: "MUST" || "SUPER" || "INFINITY", // required
|
|
51
51
|
* // };
|
|
52
52
|
*
|
|
53
53
|
* ```
|
|
@@ -41,7 +41,7 @@ declare const UpdateEntitlementsCommand_base: {
|
|
|
41
41
|
* const client = new OneHookClient(config);
|
|
42
42
|
* const input = { // UpdateEntitlementsRequest
|
|
43
43
|
* userId: "STRING_VALUE", // required
|
|
44
|
-
* subscriptionTier: "
|
|
44
|
+
* subscriptionTier: "MUST" || "SUPER" || "INFINITY", // required
|
|
45
45
|
* source: "STRING_VALUE",
|
|
46
46
|
* purchaseRef: "STRING_VALUE",
|
|
47
47
|
* effectiveAt: Number("long"),
|
|
@@ -50,7 +50,7 @@ declare const UpdateEntitlementsCommand_base: {
|
|
|
50
50
|
* const response = await client.send(command);
|
|
51
51
|
* // { // UpdateEntitlementsResponse
|
|
52
52
|
* // status: "STRING_VALUE", // required
|
|
53
|
-
* // subscriptionTier: "
|
|
53
|
+
* // subscriptionTier: "MUST" || "SUPER" || "INFINITY", // required
|
|
54
54
|
* // };
|
|
55
55
|
*
|
|
56
56
|
* ```
|
|
@@ -45,7 +45,7 @@ declare const UpgradeUserCommand_base: {
|
|
|
45
45
|
* // matchIds: [ // StringList // required
|
|
46
46
|
* // "STRING_VALUE",
|
|
47
47
|
* // ],
|
|
48
|
-
* // subscriptionTier: "
|
|
48
|
+
* // subscriptionTier: "MUST" || "SUPER" || "INFINITY", // required
|
|
49
49
|
* // };
|
|
50
50
|
*
|
|
51
51
|
* ```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SubscriptionTier } from '../models/models_0';
|
|
2
|
+
export { SubscriptionTier };
|
|
3
|
+
/** Customer-facing brand name of a tier. */
|
|
4
|
+
export type SubscriptionTierDisplayName = 'Must' | 'Super' | 'Infinity';
|
|
5
|
+
export interface SubscriptionTierInfo {
|
|
6
|
+
/** Wire value — the ONLY form that is persisted or sent to the backend. */
|
|
7
|
+
readonly wire: SubscriptionTier;
|
|
8
|
+
/** Presentation-only brand name. */
|
|
9
|
+
readonly displayName: SubscriptionTierDisplayName;
|
|
10
|
+
/** Default concurrent-connection (hook) ceiling. */
|
|
11
|
+
readonly maxConnections: number;
|
|
12
|
+
}
|
|
13
|
+
/** Every tier, lowest first. */
|
|
14
|
+
export declare const SUBSCRIPTION_TIERS: readonly SubscriptionTierInfo[];
|
|
15
|
+
/** Tier wire values, lowest first. */
|
|
16
|
+
export declare const SUBSCRIPTION_TIER_ORDER: readonly SubscriptionTier[];
|
|
17
|
+
/** The lowest tier — what an unknown / missing tier fails closed to. */
|
|
18
|
+
export declare const DEFAULT_SUBSCRIPTION_TIER: SubscriptionTier;
|
|
19
|
+
/** Paid tiers (every tier above the lowest), lowest first. */
|
|
20
|
+
export declare const PAID_SUBSCRIPTION_TIERS: readonly SubscriptionTierInfo[];
|
|
21
|
+
/** Metadata for a wire value. */
|
|
22
|
+
export declare function subscriptionTierInfo(tier: SubscriptionTier): SubscriptionTierInfo;
|
|
23
|
+
/** Customer-facing name for a wire value. */
|
|
24
|
+
export declare function subscriptionTierDisplayName(tier: SubscriptionTier): SubscriptionTierDisplayName;
|
|
25
|
+
/**
|
|
26
|
+
* Strict parser for an UNTRUSTED tier string (token claim, stored row, config key). Accepts a tier
|
|
27
|
+
* name (wire value or display name), case-insensitively and trimmed. Returns undefined otherwise.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseSubscriptionTier(raw: unknown): SubscriptionTier | undefined;
|
|
30
|
+
/** Called with the raw value whenever {@link resolveSubscriptionTier} meets a non-empty unknown tier. */
|
|
31
|
+
export type UnknownSubscriptionTierHandler = (raw: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Registers the process-wide handler for unknown tiers (e.g. log an error / page a developer).
|
|
34
|
+
* The tier still resolves to {@link DEFAULT_SUBSCRIPTION_TIER}; the handler is for investigation.
|
|
35
|
+
*/
|
|
36
|
+
export declare function onUnknownSubscriptionTier(handler: UnknownSubscriptionTierHandler): void;
|
|
37
|
+
/**
|
|
38
|
+
* Like {@link parseSubscriptionTier} but fails closed to {@link DEFAULT_SUBSCRIPTION_TIER}. A missing
|
|
39
|
+
* value is normal (new account); a non-empty unknown value is reported to the registered handler.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveSubscriptionTier(raw: unknown): SubscriptionTier;
|
|
42
|
+
/** Zero-based rank of a tier (lowest = 0). */
|
|
43
|
+
export declare function subscriptionTierRank(tier: SubscriptionTier): number;
|
|
44
|
+
/** True for any tier above the lowest tier. */
|
|
45
|
+
export declare function isPaidSubscriptionTier(tier: unknown): boolean;
|
|
46
|
+
/** Default connection ceiling for a (possibly unknown) tier; unknown fails closed to the lowest tier. */
|
|
47
|
+
export declare function maxConnectionsForTier(raw: unknown): number;
|
|
@@ -784,12 +784,32 @@ export interface UnlinkSocialRequest {
|
|
|
784
784
|
export interface UnlinkSocialResponse {
|
|
785
785
|
status: string | undefined;
|
|
786
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* @public
|
|
789
|
+
* @enum
|
|
790
|
+
*/
|
|
791
|
+
export declare const SubscriptionTier: {
|
|
792
|
+
readonly INFINITY: "INFINITY";
|
|
793
|
+
readonly MUST: "MUST";
|
|
794
|
+
readonly SUPER: "SUPER";
|
|
795
|
+
};
|
|
796
|
+
/**
|
|
797
|
+
* @public
|
|
798
|
+
*/
|
|
799
|
+
export type SubscriptionTier = typeof SubscriptionTier[keyof typeof SubscriptionTier];
|
|
787
800
|
/**
|
|
788
801
|
* @public
|
|
789
802
|
*/
|
|
790
803
|
export interface UpdateEntitlementsRequest {
|
|
791
804
|
userId: string | undefined;
|
|
792
|
-
|
|
805
|
+
/**
|
|
806
|
+
* A OneHook membership tier. The member values are the wire values persisted in Cognito
|
|
807
|
+
* (`custom:subscriptionTier`), DynamoDB and Postgres. Members are declared in ascending order
|
|
808
|
+
* (lowest tier first); consumers rely on that order. A stored value that is not one of these is
|
|
809
|
+
* treated as the lowest tier (Must) and raises the UnknownSubscriptionTier alarm.
|
|
810
|
+
* @public
|
|
811
|
+
*/
|
|
812
|
+
subscriptionTier: SubscriptionTier | undefined;
|
|
793
813
|
/**
|
|
794
814
|
* Provenance of the entitlement decision (e.g. stripe / apple / google / sync). Advisory/audit.
|
|
795
815
|
* @public
|
|
@@ -811,7 +831,14 @@ export interface UpdateEntitlementsRequest {
|
|
|
811
831
|
*/
|
|
812
832
|
export interface UpdateEntitlementsResponse {
|
|
813
833
|
status: string | undefined;
|
|
814
|
-
|
|
834
|
+
/**
|
|
835
|
+
* A OneHook membership tier. The member values are the wire values persisted in Cognito
|
|
836
|
+
* (`custom:subscriptionTier`), DynamoDB and Postgres. Members are declared in ascending order
|
|
837
|
+
* (lowest tier first); consumers rely on that order. A stored value that is not one of these is
|
|
838
|
+
* treated as the lowest tier (Must) and raises the UnknownSubscriptionTier alarm.
|
|
839
|
+
* @public
|
|
840
|
+
*/
|
|
841
|
+
subscriptionTier: SubscriptionTier | undefined;
|
|
815
842
|
}
|
|
816
843
|
/**
|
|
817
844
|
* @public
|
|
@@ -1421,7 +1448,14 @@ export interface ProfileResponse {
|
|
|
1421
1448
|
* @public
|
|
1422
1449
|
*/
|
|
1423
1450
|
verified?: boolean | undefined;
|
|
1424
|
-
|
|
1451
|
+
/**
|
|
1452
|
+
* A OneHook membership tier. The member values are the wire values persisted in Cognito
|
|
1453
|
+
* (`custom:subscriptionTier`), DynamoDB and Postgres. Members are declared in ascending order
|
|
1454
|
+
* (lowest tier first); consumers rely on that order. A stored value that is not one of these is
|
|
1455
|
+
* treated as the lowest tier (Must) and raises the UnknownSubscriptionTier alarm.
|
|
1456
|
+
* @public
|
|
1457
|
+
*/
|
|
1458
|
+
subscriptionTier?: SubscriptionTier | undefined;
|
|
1425
1459
|
pictures?: (string)[] | undefined;
|
|
1426
1460
|
/**
|
|
1427
1461
|
* Display-only preview transforms keyed by picture object key. Values use `v1:x,y,zoom`.
|
|
@@ -1547,7 +1581,14 @@ export interface UserStateResponse {
|
|
|
1547
1581
|
state: string | undefined;
|
|
1548
1582
|
activeConnections: number | undefined;
|
|
1549
1583
|
matchIds: (string)[] | undefined;
|
|
1550
|
-
|
|
1584
|
+
/**
|
|
1585
|
+
* A OneHook membership tier. The member values are the wire values persisted in Cognito
|
|
1586
|
+
* (`custom:subscriptionTier`), DynamoDB and Postgres. Members are declared in ascending order
|
|
1587
|
+
* (lowest tier first); consumers rely on that order. A stored value that is not one of these is
|
|
1588
|
+
* treated as the lowest tier (Must) and raises the UnknownSubscriptionTier alarm.
|
|
1589
|
+
* @public
|
|
1590
|
+
*/
|
|
1591
|
+
subscriptionTier: SubscriptionTier | undefined;
|
|
1551
1592
|
}
|
|
1552
1593
|
/**
|
|
1553
1594
|
* @public
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// GENERATED from OneHookBackend packages/api-models/model/smithy/common.smithy (SubscriptionTier).
|
|
2
|
+
// DO NOT EDIT. Regenerate: (OneHookBackend) npm run generate && npm run membership:sync
|
|
3
|
+
|
|
4
|
+
package club.onehook.membership
|
|
5
|
+
|
|
6
|
+
/** Backend-owned membership catalogue (wire value, display name, connection ceiling), lowest first. */
|
|
7
|
+
object SubscriptionTierCatalog {
|
|
8
|
+
data class Entry(val wire: String, val displayName: String, val maxConnections: Int)
|
|
9
|
+
|
|
10
|
+
val tiers: List<Entry> = listOf(
|
|
11
|
+
Entry(wire = "MUST", displayName = "Must", maxConnections = 1),
|
|
12
|
+
Entry(wire = "SUPER", displayName = "Super", maxConnections = 1),
|
|
13
|
+
Entry(wire = "INFINITY", displayName = "Infinity", maxConnections = 3),
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
/** The lowest tier wire value — what an unknown tier fails closed to. */
|
|
17
|
+
val defaultWire: String = tiers.first().wire
|
|
18
|
+
|
|
19
|
+
/** Parser: tier name (wire value or display name), case-insensitive + trimmed; null if unknown. */
|
|
20
|
+
fun parse(raw: String?): Entry? {
|
|
21
|
+
val key = raw?.trim()?.uppercase().orEmpty()
|
|
22
|
+
return tiers.firstOrNull { it.wire == key }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Parses [raw], failing closed to the lowest tier (Must). The server alarms on unknown stored tiers. */
|
|
26
|
+
fun resolve(raw: String?): Entry = parse(raw) ?: tiers.first()
|
|
27
|
+
|
|
28
|
+
/** True for any known tier above the lowest tier. */
|
|
29
|
+
fun isPaid(raw: String?): Boolean = parse(raw)?.let { it.wire != defaultWire } ?: false
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// GENERATED from OneHookBackend packages/api-models/model/smithy/common.smithy (SubscriptionTier).
|
|
2
|
+
// DO NOT EDIT. Regenerate: (OneHookBackend) npm run generate && npm run membership:sync
|
|
3
|
+
|
|
4
|
+
import Foundation
|
|
5
|
+
|
|
6
|
+
/// Backend-owned membership catalogue (wire value, display name, connection ceiling), lowest first.
|
|
7
|
+
enum SubscriptionTierCatalog {
|
|
8
|
+
struct Entry: Equatable, Sendable {
|
|
9
|
+
let wire: String
|
|
10
|
+
let displayName: String
|
|
11
|
+
let maxConnections: Int
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static let tiers: [Entry] = [
|
|
15
|
+
.init(wire: "MUST", displayName: "Must", maxConnections: 1),
|
|
16
|
+
.init(wire: "SUPER", displayName: "Super", maxConnections: 1),
|
|
17
|
+
.init(wire: "INFINITY", displayName: "Infinity", maxConnections: 3),
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
/// The lowest tier wire value — what an unknown tier fails closed to.
|
|
21
|
+
static let defaultWire: String = tiers[0].wire
|
|
22
|
+
|
|
23
|
+
static func entry(wire: String) -> Entry? { tiers.first { $0.wire == wire } }
|
|
24
|
+
|
|
25
|
+
/// Parser: tier name (wire value or display name), case-insensitive + trimmed; nil if unknown.
|
|
26
|
+
/// Callers treat nil as the lowest tier (Must) — the server alarms on unknown stored tiers.
|
|
27
|
+
static func parse(_ raw: String?) -> Entry? {
|
|
28
|
+
guard let key = raw?.trimmingCharacters(in: .whitespacesAndNewlines).uppercased() else { return nil }
|
|
29
|
+
return entry(wire: key)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "club.onehook.common#SubscriptionTier",
|
|
3
|
+
"tiers": [
|
|
4
|
+
{
|
|
5
|
+
"wire": "MUST",
|
|
6
|
+
"displayName": "Must",
|
|
7
|
+
"maxConnections": 1
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"wire": "SUPER",
|
|
11
|
+
"displayName": "Super",
|
|
12
|
+
"maxConnections": 1
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"wire": "INFINITY",
|
|
16
|
+
"displayName": "Infinity",
|
|
17
|
+
"maxConnections": 3
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onehook-api-client",
|
|
3
3
|
"description": "OneHook API Client",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.21",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
7
7
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
@@ -73,7 +73,8 @@
|
|
|
73
73
|
},
|
|
74
74
|
"files": [
|
|
75
75
|
"dist-*/**",
|
|
76
|
-
"telemetry/**"
|
|
76
|
+
"telemetry/**",
|
|
77
|
+
"membership/**"
|
|
77
78
|
],
|
|
78
79
|
"browser": {
|
|
79
80
|
"./dist-es/runtimeConfig": "./dist-es/runtimeConfig.browser"
|
|
@@ -98,6 +99,14 @@
|
|
|
98
99
|
"import": "./dist-es/telemetry/index.js",
|
|
99
100
|
"require": "./dist-cjs/telemetry/index.js"
|
|
100
101
|
},
|
|
102
|
+
"./membership": {
|
|
103
|
+
"types": "./dist-types/membership/index.d.ts",
|
|
104
|
+
"import": "./dist-es/membership/index.js",
|
|
105
|
+
"require": "./dist-cjs/membership/index.js"
|
|
106
|
+
},
|
|
107
|
+
"./membership/SubscriptionTierCatalog.swift": "./membership/SubscriptionTierCatalog.swift",
|
|
108
|
+
"./membership/SubscriptionTierCatalog.kt": "./membership/SubscriptionTierCatalog.kt",
|
|
109
|
+
"./membership/membership-catalog.json": "./membership/membership-catalog.json",
|
|
101
110
|
"./telemetry/TelemetryCatalog.swift": "./telemetry/TelemetryCatalog.swift",
|
|
102
111
|
"./telemetry/TelemetryCatalog.kt": "./telemetry/TelemetryCatalog.kt",
|
|
103
112
|
"./telemetry/telemetry-catalog.json": "./telemetry/telemetry-catalog.json",
|