apogeoapi 1.0.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/EXAMPLES.md +666 -0
  3. package/README.md +532 -0
  4. package/dist/clients/account.client.d.ts +76 -0
  5. package/dist/clients/account.client.d.ts.map +1 -0
  6. package/dist/clients/account.client.js +85 -0
  7. package/dist/clients/account.client.js.map +1 -0
  8. package/dist/clients/api-keys.client.d.ts +90 -0
  9. package/dist/clients/api-keys.client.d.ts.map +1 -0
  10. package/dist/clients/api-keys.client.js +105 -0
  11. package/dist/clients/api-keys.client.js.map +1 -0
  12. package/dist/clients/auth.client.d.ts +63 -0
  13. package/dist/clients/auth.client.d.ts.map +1 -0
  14. package/dist/clients/auth.client.js +86 -0
  15. package/dist/clients/auth.client.js.map +1 -0
  16. package/dist/clients/billing.client.d.ts +79 -0
  17. package/dist/clients/billing.client.d.ts.map +1 -0
  18. package/dist/clients/billing.client.js +101 -0
  19. package/dist/clients/billing.client.js.map +1 -0
  20. package/dist/clients/geo.client.d.ts +105 -0
  21. package/dist/clients/geo.client.d.ts.map +1 -0
  22. package/dist/clients/geo.client.js +149 -0
  23. package/dist/clients/geo.client.js.map +1 -0
  24. package/dist/clients/webhooks.client.d.ts +110 -0
  25. package/dist/clients/webhooks.client.d.ts.map +1 -0
  26. package/dist/clients/webhooks.client.js +129 -0
  27. package/dist/clients/webhooks.client.js.map +1 -0
  28. package/dist/index.d.ts +137 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +157 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/types/index.d.ts +243 -0
  33. package/dist/types/index.d.ts.map +1 -0
  34. package/dist/types/index.js +16 -0
  35. package/dist/types/index.js.map +1 -0
  36. package/dist/utils/http-client.d.ts +43 -0
  37. package/dist/utils/http-client.d.ts.map +1 -0
  38. package/dist/utils/http-client.js +140 -0
  39. package/dist/utils/http-client.js.map +1 -0
  40. package/package.json +44 -0
@@ -0,0 +1,90 @@
1
+ import { HttpClient } from '../utils/http-client';
2
+ import { ApiKey, CreateApiKeyDto, UpdateApiKeyDto } from '../types';
3
+ /**
4
+ * ApiKeysClient - Handles API key management
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const apiKeys = new ApiKeysClient(httpClient);
9
+ *
10
+ * // Create new API key
11
+ * const newKey = await apiKeys.create({
12
+ * name: 'Production Key',
13
+ * expiresAt: new Date('2025-12-31')
14
+ * });
15
+ * console.log('Your API key:', newKey.key); // Save this!
16
+ *
17
+ * // List all keys
18
+ * const keys = await apiKeys.list();
19
+ *
20
+ * // Revoke a key
21
+ * await apiKeys.update(keyId, { isActive: false });
22
+ * ```
23
+ */
24
+ export declare class ApiKeysClient {
25
+ private http;
26
+ constructor(http: HttpClient);
27
+ /**
28
+ * List all API keys for the current user
29
+ *
30
+ * Note: The actual key value is only shown once during creation
31
+ *
32
+ * @returns Array of API keys (without key values)
33
+ */
34
+ list(): Promise<ApiKey[]>;
35
+ /**
36
+ * Get specific API key by ID
37
+ *
38
+ * @param id - API key ID
39
+ * @returns API key data
40
+ */
41
+ get(id: string): Promise<ApiKey>;
42
+ /**
43
+ * Create a new API key
44
+ *
45
+ * **Important:** The full key value is only returned once.
46
+ * Save it immediately!
47
+ *
48
+ * @param data - API key creation data (name, expiresAt)
49
+ * @returns Newly created API key with full key value
50
+ */
51
+ create(data: CreateApiKeyDto): Promise<ApiKey>;
52
+ /**
53
+ * Update API key
54
+ *
55
+ * Can update name or activate/deactivate the key
56
+ *
57
+ * @param id - API key ID
58
+ * @param data - Update data (name, isActive)
59
+ * @returns Updated API key
60
+ */
61
+ update(id: string, data: UpdateApiKeyDto): Promise<ApiKey>;
62
+ /**
63
+ * Delete API key permanently
64
+ *
65
+ * **Warning:** This action is irreversible
66
+ *
67
+ * @param id - API key ID
68
+ * @returns Success response
69
+ */
70
+ delete(id: string): Promise<{
71
+ message: string;
72
+ }>;
73
+ /**
74
+ * Deactivate (revoke) an API key without deleting it
75
+ *
76
+ * This is safer than deletion as it can be reactivated later
77
+ *
78
+ * @param id - API key ID
79
+ * @returns Updated API key
80
+ */
81
+ revoke(id: string): Promise<ApiKey>;
82
+ /**
83
+ * Reactivate a previously revoked API key
84
+ *
85
+ * @param id - API key ID
86
+ * @returns Updated API key
87
+ */
88
+ activate(id: string): Promise<ApiKey>;
89
+ }
90
+ //# sourceMappingURL=api-keys.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.client.d.ts","sourceRoot":"","sources":["../../src/clients/api-keys.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEpC;;;;;;OAMG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI/B;;;;;OAKG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAItC;;;;;;;;OAQG;IACG,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpD;;;;;;;;OAQG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAIhE;;;;;;;OAOG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAItD;;;;;;;OAOG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIzC;;;;;OAKG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG5C"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiKeysClient = void 0;
4
+ /**
5
+ * ApiKeysClient - Handles API key management
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const apiKeys = new ApiKeysClient(httpClient);
10
+ *
11
+ * // Create new API key
12
+ * const newKey = await apiKeys.create({
13
+ * name: 'Production Key',
14
+ * expiresAt: new Date('2025-12-31')
15
+ * });
16
+ * console.log('Your API key:', newKey.key); // Save this!
17
+ *
18
+ * // List all keys
19
+ * const keys = await apiKeys.list();
20
+ *
21
+ * // Revoke a key
22
+ * await apiKeys.update(keyId, { isActive: false });
23
+ * ```
24
+ */
25
+ class ApiKeysClient {
26
+ constructor(http) {
27
+ this.http = http;
28
+ }
29
+ /**
30
+ * List all API keys for the current user
31
+ *
32
+ * Note: The actual key value is only shown once during creation
33
+ *
34
+ * @returns Array of API keys (without key values)
35
+ */
36
+ async list() {
37
+ return this.http.get('/api-keys');
38
+ }
39
+ /**
40
+ * Get specific API key by ID
41
+ *
42
+ * @param id - API key ID
43
+ * @returns API key data
44
+ */
45
+ async get(id) {
46
+ return this.http.get(`/api-keys/${id}`);
47
+ }
48
+ /**
49
+ * Create a new API key
50
+ *
51
+ * **Important:** The full key value is only returned once.
52
+ * Save it immediately!
53
+ *
54
+ * @param data - API key creation data (name, expiresAt)
55
+ * @returns Newly created API key with full key value
56
+ */
57
+ async create(data) {
58
+ return this.http.post('/api-keys', data);
59
+ }
60
+ /**
61
+ * Update API key
62
+ *
63
+ * Can update name or activate/deactivate the key
64
+ *
65
+ * @param id - API key ID
66
+ * @param data - Update data (name, isActive)
67
+ * @returns Updated API key
68
+ */
69
+ async update(id, data) {
70
+ return this.http.put(`/api-keys/${id}`, data);
71
+ }
72
+ /**
73
+ * Delete API key permanently
74
+ *
75
+ * **Warning:** This action is irreversible
76
+ *
77
+ * @param id - API key ID
78
+ * @returns Success response
79
+ */
80
+ async delete(id) {
81
+ return this.http.delete(`/api-keys/${id}`);
82
+ }
83
+ /**
84
+ * Deactivate (revoke) an API key without deleting it
85
+ *
86
+ * This is safer than deletion as it can be reactivated later
87
+ *
88
+ * @param id - API key ID
89
+ * @returns Updated API key
90
+ */
91
+ async revoke(id) {
92
+ return this.update(id, { isActive: false });
93
+ }
94
+ /**
95
+ * Reactivate a previously revoked API key
96
+ *
97
+ * @param id - API key ID
98
+ * @returns Updated API key
99
+ */
100
+ async activate(id) {
101
+ return this.update(id, { isActive: true });
102
+ }
103
+ }
104
+ exports.ApiKeysClient = ApiKeysClient;
105
+ //# sourceMappingURL=api-keys.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.client.js","sourceRoot":"","sources":["../../src/clients/api-keys.client.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,aAAa;IACxB,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC;;;;;;OAMG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAW,WAAW,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAS,aAAa,EAAE,EAAE,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,CAAC,IAAqB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAS,WAAW,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,IAAqB;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAS,aAAa,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAsB,aAAa,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF;AAnFD,sCAmFC"}
@@ -0,0 +1,63 @@
1
+ import { HttpClient } from '../utils/http-client';
2
+ import { RegisterDto, LoginDto, AuthResponse, RefreshTokenDto, User } from '../types';
3
+ /**
4
+ * AuthClient - Handles authentication operations
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const auth = new AuthClient(httpClient);
9
+ *
10
+ * // Register new user
11
+ * const { user, access_token } = await auth.register({
12
+ * email: 'user@example.com',
13
+ * password: 'securePassword123',
14
+ * username: 'johndoe'
15
+ * });
16
+ *
17
+ * // Login
18
+ * const tokens = await auth.login({
19
+ * email: 'user@example.com',
20
+ * password: 'securePassword123'
21
+ * });
22
+ *
23
+ * // Refresh token
24
+ * const newTokens = await auth.refreshToken({ refresh_token: 'xxx' });
25
+ * ```
26
+ */
27
+ export declare class AuthClient {
28
+ private http;
29
+ constructor(http: HttpClient);
30
+ /**
31
+ * Register a new user
32
+ *
33
+ * @param data - Registration data (email, password, username)
34
+ * @returns Auth response with user data and tokens
35
+ */
36
+ register(data: RegisterDto): Promise<AuthResponse>;
37
+ /**
38
+ * Login with email and password
39
+ *
40
+ * @param data - Login credentials (email, password)
41
+ * @returns Auth response with user data and tokens
42
+ */
43
+ login(data: LoginDto): Promise<AuthResponse>;
44
+ /**
45
+ * Refresh access token using refresh token
46
+ *
47
+ * @param data - Refresh token data
48
+ * @returns New auth tokens
49
+ */
50
+ refreshToken(data: RefreshTokenDto): Promise<AuthResponse>;
51
+ /**
52
+ * Get current user profile
53
+ *
54
+ * @returns Current user data
55
+ */
56
+ getProfile(): Promise<User>;
57
+ /**
58
+ * Logout (client-side token removal)
59
+ * Note: Backend doesn't have logout endpoint (JWT is stateless)
60
+ */
61
+ logout(): void;
62
+ }
63
+ //# sourceMappingURL=auth.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.client.d.ts","sourceRoot":"","sources":["../../src/clients/auth.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,IAAI,EACL,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,UAAU;IACT,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEpC;;;;;OAKG;IACG,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAIxD;;;;;OAKG;IACG,KAAK,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAWlD;;;;;OAKG;IACG,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IAWhE;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC;;;OAGG;IACH,MAAM,IAAI,IAAI;CAGf"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthClient = void 0;
4
+ /**
5
+ * AuthClient - Handles authentication operations
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const auth = new AuthClient(httpClient);
10
+ *
11
+ * // Register new user
12
+ * const { user, access_token } = await auth.register({
13
+ * email: 'user@example.com',
14
+ * password: 'securePassword123',
15
+ * username: 'johndoe'
16
+ * });
17
+ *
18
+ * // Login
19
+ * const tokens = await auth.login({
20
+ * email: 'user@example.com',
21
+ * password: 'securePassword123'
22
+ * });
23
+ *
24
+ * // Refresh token
25
+ * const newTokens = await auth.refreshToken({ refresh_token: 'xxx' });
26
+ * ```
27
+ */
28
+ class AuthClient {
29
+ constructor(http) {
30
+ this.http = http;
31
+ }
32
+ /**
33
+ * Register a new user
34
+ *
35
+ * @param data - Registration data (email, password, username)
36
+ * @returns Auth response with user data and tokens
37
+ */
38
+ async register(data) {
39
+ return this.http.post('/auth/register', data);
40
+ }
41
+ /**
42
+ * Login with email and password
43
+ *
44
+ * @param data - Login credentials (email, password)
45
+ * @returns Auth response with user data and tokens
46
+ */
47
+ async login(data) {
48
+ const response = await this.http.post('/auth/login', data);
49
+ // Auto-update token in http client
50
+ if (response.access_token) {
51
+ this.http.setToken(response.access_token);
52
+ }
53
+ return response;
54
+ }
55
+ /**
56
+ * Refresh access token using refresh token
57
+ *
58
+ * @param data - Refresh token data
59
+ * @returns New auth tokens
60
+ */
61
+ async refreshToken(data) {
62
+ const response = await this.http.post('/auth/refresh', data);
63
+ // Auto-update token in http client
64
+ if (response.access_token) {
65
+ this.http.setToken(response.access_token);
66
+ }
67
+ return response;
68
+ }
69
+ /**
70
+ * Get current user profile
71
+ *
72
+ * @returns Current user data
73
+ */
74
+ async getProfile() {
75
+ return this.http.get('/auth/profile');
76
+ }
77
+ /**
78
+ * Logout (client-side token removal)
79
+ * Note: Backend doesn't have logout endpoint (JWT is stateless)
80
+ */
81
+ logout() {
82
+ this.http.setToken('');
83
+ }
84
+ }
85
+ exports.AuthClient = AuthClient;
86
+ //# sourceMappingURL=auth.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.client.js","sourceRoot":"","sources":["../../src/clients/auth.client.ts"],"names":[],"mappings":";;;AASA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,UAAU;IACrB,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,IAAiB;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAe,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CAAC,IAAc;QACxB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAe,aAAa,EAAE,IAAI,CAAC,CAAC;QAEzE,mCAAmC;QACnC,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,IAAqB;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAe,eAAe,EAAE,IAAI,CAAC,CAAC;QAE3E,mCAAmC;QACnC,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAO,eAAe,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;CACF;AA/DD,gCA+DC"}
@@ -0,0 +1,79 @@
1
+ import { HttpClient } from '../utils/http-client';
2
+ import { BillingPortalResponse, CheckoutSessionResponse, Invoice, Tier } from '../types';
3
+ /**
4
+ * BillingClient - Handles subscription and billing operations
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const billing = new BillingClient(httpClient);
9
+ *
10
+ * // Upgrade to Professional tier
11
+ * const checkout = await billing.createCheckoutSession('professional');
12
+ * window.location.href = checkout.url; // Redirect to Stripe
13
+ *
14
+ * // Access billing portal
15
+ * const portal = await billing.createPortalSession();
16
+ * window.location.href = portal.url; // Manage subscription
17
+ *
18
+ * // Get invoices
19
+ * const invoices = await billing.getInvoices();
20
+ * ```
21
+ */
22
+ export declare class BillingClient {
23
+ private http;
24
+ constructor(http: HttpClient);
25
+ /**
26
+ * Create Stripe Checkout session for subscription upgrade
27
+ *
28
+ * Returns a URL to redirect the user to Stripe Checkout
29
+ *
30
+ * @param tier - Target tier ('starter', 'professional', 'enterprise')
31
+ * @param successUrl - URL to redirect after successful payment (optional)
32
+ * @param cancelUrl - URL to redirect if user cancels (optional)
33
+ * @returns Checkout session with redirect URL
34
+ */
35
+ createCheckoutSession(tier: Exclude<Tier, 'free'>, successUrl?: string, cancelUrl?: string): Promise<CheckoutSessionResponse>;
36
+ /**
37
+ * Create Stripe Customer Portal session
38
+ *
39
+ * Returns a URL to redirect the user to Stripe Customer Portal
40
+ * where they can manage their subscription, payment methods, and view invoices
41
+ *
42
+ * @param returnUrl - URL to return to after portal session (optional)
43
+ * @returns Portal session with redirect URL
44
+ */
45
+ createPortalSession(returnUrl?: string): Promise<BillingPortalResponse>;
46
+ /**
47
+ * Get all invoices for the current user
48
+ *
49
+ * @param limit - Maximum number of invoices to return (optional)
50
+ * @returns Array of invoices
51
+ */
52
+ getInvoices(limit?: number): Promise<Invoice[]>;
53
+ /**
54
+ * Get specific invoice by ID
55
+ *
56
+ * @param invoiceId - Stripe invoice ID
57
+ * @returns Invoice data
58
+ */
59
+ getInvoice(invoiceId: string): Promise<Invoice>;
60
+ /**
61
+ * Cancel subscription at end of current billing period
62
+ *
63
+ * User will keep access until period ends, then downgrade to free tier
64
+ *
65
+ * @returns Success response
66
+ */
67
+ cancelSubscription(): Promise<{
68
+ message: string;
69
+ }>;
70
+ /**
71
+ * Reactivate a canceled subscription before period ends
72
+ *
73
+ * @returns Success response
74
+ */
75
+ reactivateSubscription(): Promise<{
76
+ message: string;
77
+ }>;
78
+ }
79
+ //# sourceMappingURL=billing.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.client.d.ts","sourceRoot":"","sources":["../../src/clients/billing.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,OAAO,EACP,IAAI,EACL,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEpC;;;;;;;;;OASG;IACG,qBAAqB,CACzB,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,EAC3B,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,uBAAuB,CAAC;IAWnC;;;;;;;;OAQG;IACG,mBAAmB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAU7E;;;;;OAKG;IACG,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAOrD;;;;;OAKG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrD;;;;;;OAMG;IACG,kBAAkB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAIxD;;;;OAIG;IACG,sBAAsB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAK7D"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingClient = void 0;
4
+ /**
5
+ * BillingClient - Handles subscription and billing operations
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const billing = new BillingClient(httpClient);
10
+ *
11
+ * // Upgrade to Professional tier
12
+ * const checkout = await billing.createCheckoutSession('professional');
13
+ * window.location.href = checkout.url; // Redirect to Stripe
14
+ *
15
+ * // Access billing portal
16
+ * const portal = await billing.createPortalSession();
17
+ * window.location.href = portal.url; // Manage subscription
18
+ *
19
+ * // Get invoices
20
+ * const invoices = await billing.getInvoices();
21
+ * ```
22
+ */
23
+ class BillingClient {
24
+ constructor(http) {
25
+ this.http = http;
26
+ }
27
+ /**
28
+ * Create Stripe Checkout session for subscription upgrade
29
+ *
30
+ * Returns a URL to redirect the user to Stripe Checkout
31
+ *
32
+ * @param tier - Target tier ('starter', 'professional', 'enterprise')
33
+ * @param successUrl - URL to redirect after successful payment (optional)
34
+ * @param cancelUrl - URL to redirect if user cancels (optional)
35
+ * @returns Checkout session with redirect URL
36
+ */
37
+ async createCheckoutSession(tier, successUrl, cancelUrl) {
38
+ const body = { tier };
39
+ if (successUrl)
40
+ body.successUrl = successUrl;
41
+ if (cancelUrl)
42
+ body.cancelUrl = cancelUrl;
43
+ return this.http.post('/billing/create-checkout-session', body);
44
+ }
45
+ /**
46
+ * Create Stripe Customer Portal session
47
+ *
48
+ * Returns a URL to redirect the user to Stripe Customer Portal
49
+ * where they can manage their subscription, payment methods, and view invoices
50
+ *
51
+ * @param returnUrl - URL to return to after portal session (optional)
52
+ * @returns Portal session with redirect URL
53
+ */
54
+ async createPortalSession(returnUrl) {
55
+ const body = {};
56
+ if (returnUrl)
57
+ body.returnUrl = returnUrl;
58
+ return this.http.post('/billing/create-portal-session', body);
59
+ }
60
+ /**
61
+ * Get all invoices for the current user
62
+ *
63
+ * @param limit - Maximum number of invoices to return (optional)
64
+ * @returns Array of invoices
65
+ */
66
+ async getInvoices(limit) {
67
+ const params = {};
68
+ if (limit)
69
+ params.limit = limit;
70
+ return this.http.get('/billing/invoices', { params });
71
+ }
72
+ /**
73
+ * Get specific invoice by ID
74
+ *
75
+ * @param invoiceId - Stripe invoice ID
76
+ * @returns Invoice data
77
+ */
78
+ async getInvoice(invoiceId) {
79
+ return this.http.get(`/billing/invoices/${invoiceId}`);
80
+ }
81
+ /**
82
+ * Cancel subscription at end of current billing period
83
+ *
84
+ * User will keep access until period ends, then downgrade to free tier
85
+ *
86
+ * @returns Success response
87
+ */
88
+ async cancelSubscription() {
89
+ return this.http.post('/billing/cancel-subscription');
90
+ }
91
+ /**
92
+ * Reactivate a canceled subscription before period ends
93
+ *
94
+ * @returns Success response
95
+ */
96
+ async reactivateSubscription() {
97
+ return this.http.post('/billing/reactivate-subscription');
98
+ }
99
+ }
100
+ exports.BillingClient = BillingClient;
101
+ //# sourceMappingURL=billing.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.client.js","sourceRoot":"","sources":["../../src/clients/billing.client.ts"],"names":[],"mappings":";;;AAQA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,aAAa;IACxB,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC;;;;;;;;;OASG;IACH,KAAK,CAAC,qBAAqB,CACzB,IAA2B,EAC3B,UAAmB,EACnB,SAAkB;QAElB,MAAM,IAAI,GAAQ,EAAE,IAAI,EAAE,CAAC;QAC3B,IAAI,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7C,IAAI,SAAS;YAAE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE1C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CACnB,kCAAkC,EAClC,IAAI,CACL,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,mBAAmB,CAAC,SAAkB;QAC1C,MAAM,IAAI,GAAQ,EAAE,CAAC;QACrB,IAAI,SAAS;YAAE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE1C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CACnB,gCAAgC,EAChC,IAAI,CACL,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,KAAc;QAC9B,MAAM,MAAM,GAAQ,EAAE,CAAC;QACvB,IAAI,KAAK;YAAE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QAEhC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAY,mBAAmB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CAAC,SAAiB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAU,qBAAqB,SAAS,EAAE,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,kBAAkB;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAsB,8BAA8B,CAAC,CAAC;IAC7E,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,sBAAsB;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CACnB,kCAAkC,CACnC,CAAC;IACJ,CAAC;CACF;AA3FD,sCA2FC"}
@@ -0,0 +1,105 @@
1
+ import { HttpClient } from '../utils/http-client';
2
+ import { Country, State, City, GeoSearchParams, PaginatedResponse } from '../types';
3
+ /**
4
+ * GeoClient - Handles geography data queries
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const geo = new GeoClient(httpClient);
9
+ *
10
+ * // Get all countries
11
+ * const countries = await geo.getCountries();
12
+ *
13
+ * // Get country by ISO code
14
+ * const usa = await geo.getCountryByIso('US');
15
+ *
16
+ * // Get states of a country
17
+ * const usStates = await geo.getStates('US');
18
+ *
19
+ * // Search for cities
20
+ * const cities = await geo.searchCities({ query: 'New York', limit: 10 });
21
+ * ```
22
+ */
23
+ export declare class GeoClient {
24
+ private http;
25
+ constructor(http: HttpClient);
26
+ /**
27
+ * Get all countries
28
+ *
29
+ * @param limit - Maximum number of results (optional)
30
+ * @param offset - Pagination offset (optional)
31
+ * @returns Array of countries
32
+ */
33
+ getCountries(limit?: number, offset?: number): Promise<Country[]>;
34
+ /**
35
+ * Get country by ISO2 code
36
+ *
37
+ * @param iso2 - ISO2 country code (e.g., 'US', 'CA', 'MX')
38
+ * @returns Country data
39
+ */
40
+ getCountryByIso(iso2: string): Promise<Country>;
41
+ /**
42
+ * Get states/provinces of a country
43
+ *
44
+ * @param countryIso2 - ISO2 country code
45
+ * @param limit - Maximum number of results (optional)
46
+ * @param offset - Pagination offset (optional)
47
+ * @returns Array of states
48
+ */
49
+ getStates(countryIso2: string, limit?: number, offset?: number): Promise<State[]>;
50
+ /**
51
+ * Get state by ID
52
+ *
53
+ * @param stateId - State ID
54
+ * @returns State data
55
+ */
56
+ getStateById(stateId: number): Promise<State>;
57
+ /**
58
+ * Get cities of a state
59
+ *
60
+ * @param stateId - State ID
61
+ * @param limit - Maximum number of results (optional)
62
+ * @param offset - Pagination offset (optional)
63
+ * @returns Array of cities
64
+ */
65
+ getCities(stateId: number, limit?: number, offset?: number): Promise<City[]>;
66
+ /**
67
+ * Get city by ID
68
+ *
69
+ * @param cityId - City ID
70
+ * @returns City data
71
+ */
72
+ getCityById(cityId: number): Promise<City>;
73
+ /**
74
+ * Search for countries, states, or cities
75
+ *
76
+ * @param params - Search parameters (query, limit, offset, type)
77
+ * @returns Paginated search results
78
+ */
79
+ search(params: GeoSearchParams): Promise<PaginatedResponse<any>>;
80
+ /**
81
+ * Search specifically for countries
82
+ *
83
+ * @param query - Search query
84
+ * @param limit - Maximum number of results (optional)
85
+ * @returns Array of matching countries
86
+ */
87
+ searchCountries(query: string, limit?: number): Promise<Country[]>;
88
+ /**
89
+ * Search specifically for states
90
+ *
91
+ * @param query - Search query
92
+ * @param limit - Maximum number of results (optional)
93
+ * @returns Array of matching states
94
+ */
95
+ searchStates(query: string, limit?: number): Promise<State[]>;
96
+ /**
97
+ * Search specifically for cities
98
+ *
99
+ * @param query - Search query
100
+ * @param limit - Maximum number of results (optional)
101
+ * @returns Array of matching cities
102
+ */
103
+ searchCities(query: string, limit?: number): Promise<City[]>;
104
+ }
105
+ //# sourceMappingURL=geo.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo.client.d.ts","sourceRoot":"","sources":["../../src/clients/geo.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,OAAO,EACP,KAAK,EACL,IAAI,EACJ,eAAe,EACf,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,SAAS;IACR,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEpC;;;;;;OAMG;IACG,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAQvE;;;;;OAKG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrD;;;;;;;OAOG;IACG,SAAS,CACb,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,KAAK,EAAE,CAAC;IAWnB;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAInD;;;;;;;OAOG;IACG,SAAS,CACb,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,EAAE,CAAC;IAQlB;;;;;OAKG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD;;;;;OAKG;IACG,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAItE;;;;;;OAMG;IACG,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAMxE;;;;;;OAMG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAMnE;;;;;;OAMG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAKnE"}