@juo/orion-core 0.16.0 → 0.17.0
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/core.js
CHANGED
|
@@ -792,6 +792,37 @@ function createMockSubscriptionAdapter() {
|
|
|
792
792
|
discounts: subscription.discounts.map((discount) => ({ ...discount }))
|
|
793
793
|
}
|
|
794
794
|
};
|
|
795
|
+
},
|
|
796
|
+
async getAvailablePlans() {
|
|
797
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
798
|
+
return {
|
|
799
|
+
_tag: "Success",
|
|
800
|
+
data: [
|
|
801
|
+
{
|
|
802
|
+
id: "plan_1",
|
|
803
|
+
name: "Monthly",
|
|
804
|
+
billingPolicy: { intervalCount: 1, interval: "MONTH" },
|
|
805
|
+
deliveryPolicy: { intervalCount: 1, interval: "MONTH" }
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
id: "plan_2",
|
|
809
|
+
name: "Every 2 months",
|
|
810
|
+
billingPolicy: { intervalCount: 2, interval: "MONTH" },
|
|
811
|
+
deliveryPolicy: { intervalCount: 2, interval: "MONTH" }
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
id: "plan_3",
|
|
815
|
+
name: "Every 3 months",
|
|
816
|
+
billingPolicy: { intervalCount: 3, interval: "MONTH" },
|
|
817
|
+
deliveryPolicy: { intervalCount: 3, interval: "MONTH" }
|
|
818
|
+
}
|
|
819
|
+
]
|
|
820
|
+
};
|
|
821
|
+
},
|
|
822
|
+
async getDefaultSubscriptionId() {
|
|
823
|
+
var _a;
|
|
824
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
825
|
+
return { _tag: "Success", data: ((_a = mockSubscriptions[0]) == null ? void 0 : _a.id) ?? null };
|
|
795
826
|
}
|
|
796
827
|
};
|
|
797
828
|
}
|
|
@@ -828,7 +859,9 @@ function createSubscriptionService(adapter) {
|
|
|
828
859
|
resume: (subscriptionId) => adapter.resume({ subscriptionId }),
|
|
829
860
|
pause: (subscriptionId) => adapter.pause({ subscriptionId }),
|
|
830
861
|
reactivate: (subscriptionId) => adapter.reactivate({ subscriptionId }),
|
|
831
|
-
cancel: (subscriptionId, reason) => adapter.cancel({ subscriptionId, reason })
|
|
862
|
+
cancel: (subscriptionId, reason) => adapter.cancel({ subscriptionId, reason }),
|
|
863
|
+
getAvailablePlans: (subscriptionId) => adapter.getAvailablePlans({ subscriptionId }),
|
|
864
|
+
getDefaultSubscriptionId: () => adapter.getDefaultSubscriptionId()
|
|
832
865
|
};
|
|
833
866
|
}
|
|
834
867
|
const MOCK_FLOWS = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Subscription, SearchOptions, PostableSubscriptionItem } from './types';
|
|
1
|
+
import { Subscription, SellingPlan, SearchOptions, PostableSubscriptionItem } from './types';
|
|
2
2
|
import { Result, PaginatedList } from '../../utils';
|
|
3
3
|
/**
|
|
4
4
|
* Adapter interface for subscription.
|
|
@@ -40,5 +40,9 @@ export interface SubscriptionAdapter {
|
|
|
40
40
|
subscriptionId: string;
|
|
41
41
|
reason?: string;
|
|
42
42
|
}): Promise<Result<Subscription>>;
|
|
43
|
+
getAvailablePlans(params: {
|
|
44
|
+
subscriptionId: string;
|
|
45
|
+
}): Promise<Result<SellingPlan[]>>;
|
|
46
|
+
getDefaultSubscriptionId(): Promise<Result<string | null>>;
|
|
43
47
|
}
|
|
44
48
|
export declare function createMockSubscriptionAdapter(): SubscriptionAdapter;
|
|
@@ -29,6 +29,16 @@ export interface Subscription {
|
|
|
29
29
|
updatedAt: string;
|
|
30
30
|
customerId: string;
|
|
31
31
|
}
|
|
32
|
+
export interface SellingPlanInterval {
|
|
33
|
+
intervalCount: number;
|
|
34
|
+
interval: string;
|
|
35
|
+
}
|
|
36
|
+
export interface SellingPlan {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
billingPolicy: SellingPlanInterval;
|
|
40
|
+
deliveryPolicy: SellingPlanInterval;
|
|
41
|
+
}
|
|
32
42
|
export interface SubscriptionFilter {
|
|
33
43
|
id?: string;
|
|
34
44
|
serial?: string;
|
|
@@ -60,4 +70,6 @@ export type SubscriptionService = {
|
|
|
60
70
|
pause(subscriptionId: string): Promise<Result<Subscription>>;
|
|
61
71
|
reactivate(subscriptionId: string): Promise<Result<Subscription>>;
|
|
62
72
|
cancel(subscriptionId: string, reason?: string): Promise<Result<Subscription>>;
|
|
73
|
+
getAvailablePlans(subscriptionId: string): Promise<Result<SellingPlan[]>>;
|
|
74
|
+
getDefaultSubscriptionId(): Promise<Result<string | null>>;
|
|
63
75
|
};
|