@chanomhub/sdk 1.2.4 → 1.2.5

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/index.d.ts CHANGED
@@ -31,7 +31,7 @@
31
31
  * ```
32
32
  */
33
33
  import { type GraphQLFetcher } from './client';
34
- import { type ArticleRepository, type FavoritesRepository, type UsersRepository, type SearchRepository, type AuthRepository, type DownloadsRepository } from './repositories';
34
+ import { type ArticleRepository, type FavoritesRepository, type UsersRepository, type SearchRepository, type AuthRepository, type DownloadsRepository, type SubscriptionsRepository } from './repositories';
35
35
  import { type ChanomhubConfig } from './config';
36
36
  export * from './types';
37
37
  export * from './config';
@@ -51,6 +51,8 @@ export interface ChanomhubClient {
51
51
  auth: AuthRepository;
52
52
  /** Downloads management operations */
53
53
  downloads: DownloadsRepository;
54
+ /** Subscriptions operations */
55
+ subscriptions: SubscriptionsRepository;
54
56
  /** Raw GraphQL fetcher for custom queries */
55
57
  graphql: GraphQLFetcher;
56
58
  /** SDK configuration */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAyC,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AACtF,OAAO,EAOH,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAGhE,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,qCAAqC;AACrC,MAAM,WAAW,eAAe;IAC5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AW,eAAe;IAC5B,yBAAyB;IACzB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,2BAA2B;IAC3B,SAAS,EAAE,mBAAmB,CAAC;IAC/B,8BAA8B;IAC9B,KAAK,EAAE,eAAe,CAAC;IACvB,wBAAwB;IACxB,MAAM,EAAE,gBAAgB,CAAC;IACzB,qEAAqE;IACrE,IAAI,EAAE,cAAc,CAAC;IACrB,sCAAsC;IACtC,SAAS,EAAE,mBAAmB,CAAC;IAC/B,+BAA+B;IAC/B,aAAa,EAAE,uBAAuB,CAAC;IACvC,6CAA6C;IAC7C,OAAO,EAAE,cAAc,CAAC;IACxB,wBAAwB;IACxB,MAAM,EAAE,eAAe,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,GAAG,eAAe,CA2B5F;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACrC,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,GACtC,eAAe,CAMjB;AAGD,eAAe,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -95,6 +95,7 @@ function createChanomhubClient(config = {}) {
95
95
  const search = (0, repositories_1.createSearchRepository)(graphql);
96
96
  const auth = (0, repositories_1.createAuthRepository)(rest, fullConfig);
97
97
  const downloads = (0, repositories_1.createDownloadsRepository)(rest, fullConfig);
98
+ const subscriptions = (0, repositories_1.createSubscriptionsRepository)(rest, fullConfig);
98
99
  return {
99
100
  articles,
100
101
  favorites,
@@ -102,6 +103,7 @@ function createChanomhubClient(config = {}) {
102
103
  search,
103
104
  auth,
104
105
  downloads,
106
+ subscriptions,
105
107
  graphql,
106
108
  config: fullConfig,
107
109
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;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CAAC,CAAC;IAEtE,OAAO;QACH,QAAQ;QACR,SAAS;QACT,KAAK;QACL,MAAM;QACN,IAAI;QACJ,SAAS;QACT,aAAa;QACb,OAAO;QACP,MAAM,EAAE,UAAU;KACrB,CAAC;AACN,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CACrC,KAAa,EACb,SAAmC,EAAE;IAErC,OAAO,qBAAqB,CAAC;QACzB,GAAG,MAAM;QACT,KAAK;QACL,mBAAmB,EAAE,CAAC,EAAE,2CAA2C;KACtE,CAAC,CAAC;AACP,CAAC;AAED,iBAAiB;AACjB,kBAAe,qBAAqB,CAAC"}
@@ -7,4 +7,5 @@ export { createUsersRepository, type UsersRepository } from './usersRepository';
7
7
  export { createSearchRepository, type SearchRepository, type SearchOptions, } from './searchRepository';
8
8
  export { createAuthRepository, type AuthRepository } from './authRepository';
9
9
  export { createDownloadsRepository, type DownloadsRepository } from './downloadsRepository';
10
+ export { createSubscriptionsRepository, type SubscriptionsRepository, } from './subscriptionsRepository';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../repositories/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EACH,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EACH,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../repositories/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EACH,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EACH,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EACH,6BAA6B,EAC7B,KAAK,uBAAuB,GAC/B,MAAM,2BAA2B,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * Chanomhub SDK - Repositories Index
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createDownloadsRepository = exports.createAuthRepository = exports.createSearchRepository = exports.createUsersRepository = exports.createFavoritesRepository = exports.createArticleRepository = void 0;
6
+ exports.createSubscriptionsRepository = exports.createDownloadsRepository = exports.createAuthRepository = exports.createSearchRepository = exports.createUsersRepository = exports.createFavoritesRepository = exports.createArticleRepository = void 0;
7
7
  var articleRepository_1 = require("./articleRepository");
8
8
  Object.defineProperty(exports, "createArticleRepository", { enumerable: true, get: function () { return articleRepository_1.createArticleRepository; } });
9
9
  var favoritesRepository_1 = require("./favoritesRepository");
@@ -16,4 +16,6 @@ var authRepository_1 = require("./authRepository");
16
16
  Object.defineProperty(exports, "createAuthRepository", { enumerable: true, get: function () { return authRepository_1.createAuthRepository; } });
17
17
  var downloadsRepository_1 = require("./downloadsRepository");
18
18
  Object.defineProperty(exports, "createDownloadsRepository", { enumerable: true, get: function () { return downloadsRepository_1.createDownloadsRepository; } });
19
+ var subscriptionsRepository_1 = require("./subscriptionsRepository");
20
+ Object.defineProperty(exports, "createSubscriptionsRepository", { enumerable: true, get: function () { return subscriptionsRepository_1.createSubscriptionsRepository; } });
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../repositories/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yDAAsF;AAA7E,4HAAA,uBAAuB,OAAA;AAChC,6DAI+B;AAH3B,gIAAA,yBAAyB,OAAA;AAI7B,qDAAgF;AAAvE,wHAAA,qBAAqB,OAAA;AAC9B,uDAI4B;AAHxB,0HAAA,sBAAsB,OAAA;AAI1B,mDAA6E;AAApE,sHAAA,oBAAoB,OAAA;AAC7B,6DAA4F;AAAnF,gIAAA,yBAAyB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../repositories/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yDAAsF;AAA7E,4HAAA,uBAAuB,OAAA;AAChC,6DAI+B;AAH3B,gIAAA,yBAAyB,OAAA;AAI7B,qDAAgF;AAAvE,wHAAA,qBAAqB,OAAA;AAC9B,uDAI4B;AAHxB,0HAAA,sBAAsB,OAAA;AAI1B,mDAA6E;AAApE,sHAAA,oBAAoB,OAAA;AAC7B,6DAA4F;AAAnF,gIAAA,yBAAyB,OAAA;AAClC,qEAGmC;AAF/B,wIAAA,6BAA6B,OAAA"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Chanomhub SDK - Subscriptions Repository
3
+ *
4
+ * Provides API methods for managing subscriptions and plans.
5
+ */
6
+ import type { RestFetcher } from '../client';
7
+ import type { ChanomhubConfig } from '../config';
8
+ import type { Subscription, SubscriptionPlan, CreateSubscriptionRequest, CreateSubscriptionPlanRequest } from '../types/subscription';
9
+ export interface SubscriptionsRepository {
10
+ /**
11
+ * Create a new subscription
12
+ * @param data - Subscription data
13
+ * @returns Created subscription
14
+ */
15
+ create(data: CreateSubscriptionRequest): Promise<Subscription | null>;
16
+ /**
17
+ * Get all user subscriptions
18
+ * @returns List of subscriptions
19
+ */
20
+ getAll(): Promise<Subscription[]>;
21
+ /**
22
+ * Cancel a subscription
23
+ * @param id - Subscription ID
24
+ * @returns Cancelled subscription
25
+ */
26
+ cancel(id: number): Promise<Subscription | null>;
27
+ /**
28
+ * Create a new subscription plan (Admin only)
29
+ * @param data - Subscription plan data
30
+ * @returns Created subscription plan
31
+ */
32
+ createPlan(data: CreateSubscriptionPlanRequest): Promise<SubscriptionPlan | null>;
33
+ /**
34
+ * Get all available subscription plans
35
+ * @param refresh - Force refresh (optional)
36
+ * @returns List of subscription plans
37
+ */
38
+ getPlans(refresh?: boolean): Promise<SubscriptionPlan[]>;
39
+ }
40
+ /**
41
+ * Creates a subscriptions repository with the given REST client
42
+ */
43
+ export declare function createSubscriptionsRepository(fetcher: RestFetcher, config: ChanomhubConfig): SubscriptionsRepository;
44
+ //# sourceMappingURL=subscriptionsRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptionsRepository.d.ts","sourceRoot":"","sources":["../../repositories/subscriptionsRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,KAAK,EACR,YAAY,EACZ,gBAAgB,EAChB,yBAAyB,EACzB,6BAA6B,EAChC,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,uBAAuB;IACpC;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAEtE;;;OAGG;IACH,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAElC;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAEjD;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAElF;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;CAC5D;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CACzC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,eAAe,GACxB,uBAAuB,CAkGzB"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /**
3
+ * Chanomhub SDK - Subscriptions Repository
4
+ *
5
+ * Provides API methods for managing subscriptions and plans.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.createSubscriptionsRepository = createSubscriptionsRepository;
9
+ const errors_1 = require("../errors");
10
+ /**
11
+ * Creates a subscriptions repository with the given REST client
12
+ */
13
+ function createSubscriptionsRepository(fetcher, config) {
14
+ function requireAuth() {
15
+ if (!config.token) {
16
+ throw new errors_1.AuthenticationError('Authentication required for subscriptions management. Use createAuthenticatedClient() or provide a token.');
17
+ }
18
+ }
19
+ async function create(data) {
20
+ requireAuth();
21
+ const { data: response, error } = await fetcher('/api/subscriptions', { method: 'POST', body: data });
22
+ if (error) {
23
+ console.error('Failed to create subscription:', error);
24
+ return null;
25
+ }
26
+ return response;
27
+ }
28
+ async function getAll() {
29
+ requireAuth();
30
+ const { data, error } = await fetcher('/api/subscriptions', { method: 'GET' });
31
+ if (error) {
32
+ console.error('Failed to get subscriptions:', error);
33
+ return [];
34
+ }
35
+ return data !== null && data !== void 0 ? data : [];
36
+ }
37
+ async function cancel(id) {
38
+ requireAuth();
39
+ const { data: response, error } = await fetcher(`/api/subscriptions/${id}`, { method: 'DELETE' });
40
+ if (error) {
41
+ console.error('Failed to cancel subscription:', error);
42
+ return null;
43
+ }
44
+ return response;
45
+ }
46
+ async function createPlan(data) {
47
+ requireAuth();
48
+ const { data: response, error } = await fetcher('/api/subscriptions/plans', { method: 'POST', body: data });
49
+ if (error) {
50
+ console.error('Failed to create subscription plan:', error);
51
+ return null;
52
+ }
53
+ return response;
54
+ }
55
+ async function getPlans(refresh) {
56
+ const url = refresh
57
+ ? '/api/subscriptions/plans?refresh=true'
58
+ : '/api/subscriptions/plans';
59
+ const { data, error } = await fetcher(url, { method: 'GET' });
60
+ if (error) {
61
+ console.error('Failed to get subscription plans:', error);
62
+ return [];
63
+ }
64
+ return data !== null && data !== void 0 ? data : [];
65
+ }
66
+ return {
67
+ create,
68
+ getAll,
69
+ cancel,
70
+ createPlan,
71
+ getPlans,
72
+ };
73
+ }
74
+ //# sourceMappingURL=subscriptionsRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptionsRepository.js","sourceRoot":"","sources":["../../repositories/subscriptionsRepository.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAmDH,sEAqGC;AApJD,sCAAgD;AA4ChD;;GAEG;AACH,SAAgB,6BAA6B,CACzC,OAAoB,EACpB,MAAuB;IAEvB,SAAS,WAAW;QAChB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,4BAAmB,CACzB,2GAA2G,CAC9G,CAAC;QACN,CAAC;IACL,CAAC;IAED,KAAK,UAAU,MAAM,CAAC,IAA+B;QACjD,WAAW,EAAE,CAAC;QAEd,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAC3C,oBAAoB,EACpB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAA0C,EAAE,CACvE,CAAC;QAEF,IAAI,KAAK,EAAE,CAAC;YACR,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,QAAQ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AAC,uCAAuC;YACzC,CAAC,CAAC,0BAA0B,CAAC;QAEjC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CACjC,GAAG,EACH,EAAE,MAAM,EAAE,KAAK,EAAE,CACpB,CAAC;QAEF,IAAI,KAAK,EAAE,CAAC;YACR,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;YAC1D,OAAO,EAAE,CAAC;QACd,CAAC;QAED,OAAO,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC;IACtB,CAAC;IAED,OAAO;QACH,MAAM;QACN,MAAM;QACN,MAAM;QACN,UAAU;QACV,QAAQ;KACX,CAAC;AACN,CAAC"}
@@ -7,4 +7,5 @@ export * from './user';
7
7
  export type { SocialMediaLink } from './user';
8
8
  export * from './auth';
9
9
  export * from './download';
10
+ export * from './subscription';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,YAAY,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,YAAY,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
@@ -22,4 +22,5 @@ __exportStar(require("./article"), exports);
22
22
  __exportStar(require("./user"), exports);
23
23
  __exportStar(require("./auth"), exports);
24
24
  __exportStar(require("./download"), exports);
25
+ __exportStar(require("./subscription"), exports);
25
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AAEvB,yCAAuB;AACvB,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AAEvB,yCAAuB;AACvB,6CAA2B;AAC3B,iDAA+B"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Chanomhub SDK - Subscription Types
3
+ */
4
+ /** Subscription status */
5
+ export type SubscriptionStatus = 'ACTIVE' | 'CANCELED' | 'SUSPENDED' | 'PAST_DUE' | 'UNPAID';
6
+ /** Payment method */
7
+ export type PaymentMethod = 'POINTS' | 'TRUEMONEY' | 'SLIP2GO';
8
+ /** Subscription entity */
9
+ export interface Subscription {
10
+ id: number;
11
+ userId: number;
12
+ planId: string;
13
+ status: SubscriptionStatus;
14
+ currentPeriodStart: string;
15
+ currentPeriodEnd: string;
16
+ cancelAtPeriodEnd: boolean;
17
+ startDate: string;
18
+ endDate?: string | null;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ }
22
+ /** Subscription plan entity */
23
+ export interface SubscriptionPlan {
24
+ planId: string;
25
+ name: string;
26
+ description?: string | null;
27
+ pointsCost: number;
28
+ durationDays: number;
29
+ roleId: number;
30
+ isActive: boolean;
31
+ }
32
+ /** Request to create a new subscription */
33
+ export interface CreateSubscriptionRequest {
34
+ planId: string;
35
+ paymentMethod?: PaymentMethod;
36
+ }
37
+ /** Request to create a new subscription plan */
38
+ export interface CreateSubscriptionPlanRequest {
39
+ planId: string;
40
+ name: string;
41
+ description?: string;
42
+ pointsCost: number;
43
+ durationDays: number;
44
+ roleId: number;
45
+ isActive?: boolean;
46
+ }
47
+ /** Response for subscription plan creation */
48
+ export interface SubscriptionPlanResponse {
49
+ plan: SubscriptionPlan;
50
+ }
51
+ /** Response for subscription creation */
52
+ export interface SubscriptionResponse {
53
+ subscription: Subscription;
54
+ }
55
+ /** List of user subscriptions */
56
+ export interface SubscriptionsListResponse {
57
+ subscriptions: Subscription[];
58
+ }
59
+ /** List of subscription plans */
60
+ export interface SubscriptionPlansListResponse {
61
+ plans: SubscriptionPlan[];
62
+ }
63
+ //# sourceMappingURL=subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../types/subscription.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0BAA0B;AAC1B,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE7F,qBAAqB;AACrB,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AAE/D,0BAA0B;AAC1B,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,kBAAkB,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,+BAA+B;AAC/B,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,2CAA2C;AAC3C,MAAM,WAAW,yBAAyB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,aAAa,CAAC;CACjC;AAED,gDAAgD;AAChD,MAAM,WAAW,6BAA6B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,8CAA8C;AAC9C,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,gBAAgB,CAAC;CAC1B;AAED,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACjC,YAAY,EAAE,YAAY,CAAC;CAC9B;AAED,iCAAiC;AACjC,MAAM,WAAW,yBAAyB;IACtC,aAAa,EAAE,YAAY,EAAE,CAAC;CACjC;AAED,iCAAiC;AACjC,MAAM,WAAW,6BAA6B;IAC1C,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC7B"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Chanomhub SDK - Subscription Types
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../types/subscription.ts"],"names":[],"mappings":";AAAA;;GAEG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chanomhub/sdk",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "ChanomHub SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",