@djangocfg/api 1.0.4 → 1.0.6

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 (134) hide show
  1. package/dist/index.cjs +15856 -34128
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +15274 -34396
  4. package/dist/index.d.ts +15274 -34396
  5. package/dist/index.mjs +15853 -33956
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +2 -2
  8. package/src/cfg/contexts/payments/ApiKeysContext.tsx +21 -58
  9. package/src/cfg/contexts/payments/BalancesContext.tsx +19 -72
  10. package/src/cfg/contexts/payments/CurrenciesContext.tsx +5 -18
  11. package/src/cfg/contexts/payments/OverviewContext.tsx +78 -124
  12. package/src/cfg/contexts/payments/PaymentsContext.tsx +37 -36
  13. package/src/cfg/contexts/payments/RootPaymentsContext.tsx +7 -76
  14. package/src/cfg/contexts/payments/index.ts +5 -24
  15. package/src/cfg/generated/_utils/fetchers/cfg__payments.ts +38 -2380
  16. package/src/cfg/generated/_utils/fetchers/index.ts +0 -1
  17. package/src/cfg/generated/_utils/hooks/cfg__payments.ts +41 -2615
  18. package/src/cfg/generated/_utils/hooks/index.ts +0 -1
  19. package/src/cfg/generated/_utils/schemas/ArchiveItem.schema.ts +1 -1
  20. package/src/cfg/generated/_utils/schemas/ArchiveItemChunk.schema.ts +1 -1
  21. package/src/cfg/generated/_utils/schemas/ArchiveItemChunkDetail.schema.ts +1 -1
  22. package/src/cfg/generated/_utils/schemas/ArchiveItemChunkRequest.schema.ts +1 -1
  23. package/src/cfg/generated/_utils/schemas/ArchiveItemDetail.schema.ts +1 -1
  24. package/src/cfg/generated/_utils/schemas/ArchiveItemRequest.schema.ts +1 -1
  25. package/src/cfg/generated/_utils/schemas/ChatMessage.schema.ts +2 -2
  26. package/src/cfg/generated/_utils/schemas/ChatSession.schema.ts +3 -3
  27. package/src/cfg/generated/_utils/schemas/ChatSessionRequest.schema.ts +3 -3
  28. package/src/cfg/generated/_utils/schemas/Document.schema.ts +1 -1
  29. package/src/cfg/generated/_utils/schemas/DocumentRequest.schema.ts +1 -1
  30. package/src/cfg/generated/_utils/schemas/PatchedArchiveItemChunkRequest.schema.ts +1 -1
  31. package/src/cfg/generated/_utils/schemas/PatchedArchiveItemRequest.schema.ts +1 -1
  32. package/src/cfg/generated/_utils/schemas/PatchedChatSessionRequest.schema.ts +3 -3
  33. package/src/cfg/generated/_utils/schemas/PatchedDocumentRequest.schema.ts +1 -1
  34. package/src/cfg/generated/_utils/schemas/PaymentDetail.schema.ts +44 -0
  35. package/src/cfg/generated/_utils/schemas/PaymentList.schema.ts +7 -11
  36. package/src/cfg/generated/_utils/schemas/index.ts +1 -81
  37. package/src/cfg/generated/cfg__payments/client.ts +40 -1732
  38. package/src/cfg/generated/cfg__payments/models.ts +50 -1795
  39. package/src/cfg/generated/client.ts +0 -3
  40. package/src/cfg/generated/enums.ts +5 -347
  41. package/src/cfg/generated/index.ts +0 -5
  42. package/src/cfg/generated/schema.ts +5918 -18352
  43. package/src/cfg/services/payments/ApiKeysService.ts +34 -116
  44. package/src/cfg/services/payments/DashboardService.ts +37 -122
  45. package/src/cfg/services/payments/PaymentsService.ts +36 -69
  46. package/src/cfg/services/payments/SubscriptionsService.ts +35 -136
  47. package/src/cfg/services/webhooks/WebhooksService.ts +24 -66
  48. package/src/index.ts +1 -6
  49. package/src/cfg/generated/_utils/fetchers/cfg__payments__webhooks.ts +0 -109
  50. package/src/cfg/generated/_utils/hooks/cfg__payments__webhooks.ts +0 -100
  51. package/src/cfg/generated/_utils/schemas/APIKeyCreate.schema.ts +0 -24
  52. package/src/cfg/generated/_utils/schemas/APIKeyCreateRequest.schema.ts +0 -24
  53. package/src/cfg/generated/_utils/schemas/APIKeyDetail.schema.ts +0 -35
  54. package/src/cfg/generated/_utils/schemas/APIKeyList.schema.ts +0 -32
  55. package/src/cfg/generated/_utils/schemas/APIKeyUpdate.schema.ts +0 -24
  56. package/src/cfg/generated/_utils/schemas/APIKeyUpdateRequest.schema.ts +0 -24
  57. package/src/cfg/generated/_utils/schemas/APIKeyValidationRequest.schema.ts +0 -23
  58. package/src/cfg/generated/_utils/schemas/APIKeyValidationResponse.schema.ts +0 -29
  59. package/src/cfg/generated/_utils/schemas/APIKeysOverview.schema.ts +0 -26
  60. package/src/cfg/generated/_utils/schemas/AdminPaymentCreate.schema.ts +0 -26
  61. package/src/cfg/generated/_utils/schemas/AdminPaymentCreateRequest.schema.ts +0 -27
  62. package/src/cfg/generated/_utils/schemas/AdminPaymentDetail.schema.ts +0 -50
  63. package/src/cfg/generated/_utils/schemas/AdminPaymentList.schema.ts +0 -38
  64. package/src/cfg/generated/_utils/schemas/AdminPaymentStats.schema.ts +0 -29
  65. package/src/cfg/generated/_utils/schemas/AdminPaymentUpdate.schema.ts +0 -25
  66. package/src/cfg/generated/_utils/schemas/AdminPaymentUpdateRequest.schema.ts +0 -25
  67. package/src/cfg/generated/_utils/schemas/AdminUser.schema.ts +0 -24
  68. package/src/cfg/generated/_utils/schemas/BalanceOverview.schema.ts +0 -25
  69. package/src/cfg/generated/_utils/schemas/ChartDataPoint.schema.ts +0 -20
  70. package/src/cfg/generated/_utils/schemas/ChartSeries.schema.ts +0 -22
  71. package/src/cfg/generated/_utils/schemas/Currency.schema.ts +0 -35
  72. package/src/cfg/generated/_utils/schemas/CurrencyAnalyticsItem.schema.ts +0 -25
  73. package/src/cfg/generated/_utils/schemas/CurrencyList.schema.ts +0 -32
  74. package/src/cfg/generated/_utils/schemas/CurrencyRates.schema.ts +0 -26
  75. package/src/cfg/generated/_utils/schemas/EndpointGroup.schema.ts +0 -28
  76. package/src/cfg/generated/_utils/schemas/Network.schema.ts +0 -30
  77. package/src/cfg/generated/_utils/schemas/PaginatedAPIKeyListList.schema.ts +0 -24
  78. package/src/cfg/generated/_utils/schemas/PaginatedAdminPaymentListList.schema.ts +0 -24
  79. package/src/cfg/generated/_utils/schemas/PaginatedAdminPaymentStatsList.schema.ts +0 -24
  80. package/src/cfg/generated/_utils/schemas/PaginatedAdminUserList.schema.ts +0 -24
  81. package/src/cfg/generated/_utils/schemas/PaginatedCurrencyListList.schema.ts +0 -24
  82. package/src/cfg/generated/_utils/schemas/PaginatedEndpointGroupList.schema.ts +0 -24
  83. package/src/cfg/generated/_utils/schemas/PaginatedNetworkList.schema.ts +0 -24
  84. package/src/cfg/generated/_utils/schemas/PaginatedProviderCurrencyList.schema.ts +0 -24
  85. package/src/cfg/generated/_utils/schemas/PaginatedRecentPaymentList.schema.ts +0 -24
  86. package/src/cfg/generated/_utils/schemas/PaginatedRecentTransactionList.schema.ts +0 -24
  87. package/src/cfg/generated/_utils/schemas/PaginatedSubscriptionListList.schema.ts +0 -24
  88. package/src/cfg/generated/_utils/schemas/PaginatedTariffList.schema.ts +0 -24
  89. package/src/cfg/generated/_utils/schemas/PaginatedTransactionList.schema.ts +0 -24
  90. package/src/cfg/generated/_utils/schemas/PaginatedUserBalanceList.schema.ts +0 -24
  91. package/src/cfg/generated/_utils/schemas/PaginatedWebhookEventListList.schema.ts +0 -24
  92. package/src/cfg/generated/_utils/schemas/PaginatedWebhookStatsList.schema.ts +0 -24
  93. package/src/cfg/generated/_utils/schemas/PatchedAPIKeyUpdateRequest.schema.ts +0 -24
  94. package/src/cfg/generated/_utils/schemas/PatchedAdminPaymentUpdateRequest.schema.ts +0 -25
  95. package/src/cfg/generated/_utils/schemas/PatchedPaymentRequest.schema.ts +0 -30
  96. package/src/cfg/generated/_utils/schemas/PatchedSubscriptionRequest.schema.ts +0 -26
  97. package/src/cfg/generated/_utils/schemas/Payment.schema.ts +0 -49
  98. package/src/cfg/generated/_utils/schemas/PaymentAnalyticsResponse.schema.ts +0 -22
  99. package/src/cfg/generated/_utils/schemas/PaymentCreate.schema.ts +0 -28
  100. package/src/cfg/generated/_utils/schemas/PaymentCreateRequest.schema.ts +0 -28
  101. package/src/cfg/generated/_utils/schemas/PaymentOverview.schema.ts +0 -31
  102. package/src/cfg/generated/_utils/schemas/PaymentRequest.schema.ts +0 -30
  103. package/src/cfg/generated/_utils/schemas/PaymentsChartResponse.schema.ts +0 -24
  104. package/src/cfg/generated/_utils/schemas/PaymentsDashboardOverview.schema.ts +0 -26
  105. package/src/cfg/generated/_utils/schemas/PaymentsMetrics.schema.ts +0 -26
  106. package/src/cfg/generated/_utils/schemas/ProviderAnalyticsItem.schema.ts +0 -24
  107. package/src/cfg/generated/_utils/schemas/ProviderCurrency.schema.ts +0 -36
  108. package/src/cfg/generated/_utils/schemas/RecentPayment.schema.ts +0 -32
  109. package/src/cfg/generated/_utils/schemas/RecentTransaction.schema.ts +0 -29
  110. package/src/cfg/generated/_utils/schemas/Subscription.schema.ts +0 -41
  111. package/src/cfg/generated/_utils/schemas/SubscriptionCreate.schema.ts +0 -25
  112. package/src/cfg/generated/_utils/schemas/SubscriptionCreateRequest.schema.ts +0 -25
  113. package/src/cfg/generated/_utils/schemas/SubscriptionList.schema.ts +0 -32
  114. package/src/cfg/generated/_utils/schemas/SubscriptionOverview.schema.ts +0 -37
  115. package/src/cfg/generated/_utils/schemas/SubscriptionRequest.schema.ts +0 -26
  116. package/src/cfg/generated/_utils/schemas/SupportedCurrencies.schema.ts +0 -25
  117. package/src/cfg/generated/_utils/schemas/SupportedProviders.schema.ts +0 -22
  118. package/src/cfg/generated/_utils/schemas/Tariff.schema.ts +0 -34
  119. package/src/cfg/generated/_utils/schemas/Transaction.schema.ts +0 -35
  120. package/src/cfg/generated/_utils/schemas/UserBalance.schema.ts +0 -29
  121. package/src/cfg/generated/_utils/schemas/WebhookEvent.schema.ts +0 -31
  122. package/src/cfg/generated/_utils/schemas/WebhookEventList.schema.ts +0 -25
  123. package/src/cfg/generated/_utils/schemas/WebhookEventListRequest.schema.ts +0 -25
  124. package/src/cfg/generated/_utils/schemas/WebhookEventRequest.schema.ts +0 -30
  125. package/src/cfg/generated/_utils/schemas/WebhookHealth.schema.ts +0 -21
  126. package/src/cfg/generated/_utils/schemas/WebhookProviderStats.schema.ts +0 -23
  127. package/src/cfg/generated/_utils/schemas/WebhookProviderStatsRequest.schema.ts +0 -23
  128. package/src/cfg/generated/_utils/schemas/WebhookResponse.schema.ts +0 -27
  129. package/src/cfg/generated/_utils/schemas/WebhookResponseRequest.schema.ts +0 -27
  130. package/src/cfg/generated/_utils/schemas/WebhookStats.schema.ts +0 -27
  131. package/src/cfg/generated/_utils/schemas/WebhookStatsRequest.schema.ts +0 -27
  132. package/src/cfg/generated/cfg__payments__webhooks/client.ts +0 -75
  133. package/src/cfg/generated/cfg__payments__webhooks/index.ts +0 -2
  134. package/src/cfg/generated/cfg__payments__webhooks/models.ts +0 -87
@@ -1,202 +1,101 @@
1
1
  /**
2
- * Subscriptions Service
2
+ * Subscriptions Service (DEPRECATED)
3
3
  *
4
- * Manages user subscriptions and tariffs
4
+ * Subscriptions functionality has been removed in Payments v2.0
5
+ * This service is kept as a stub for backward compatibility
5
6
  */
6
7
 
7
8
  import { BaseClient } from '../../BaseClient';
8
- import { APIError, CfgPaymentsTypes } from '../../generated';
9
+
10
+ const DEPRECATED_ERROR = 'Subscriptions feature has been removed in Payments v2.0';
9
11
 
10
12
  export class SubscriptionsService extends BaseClient {
11
13
  /**
12
- * List subscriptions (admin)
14
+ * @deprecated Subscriptions removed in v2.0
13
15
  */
14
- static async list(params?: {
15
- ordering?: string;
16
- page?: number;
17
- page_size?: number;
18
- search?: string;
19
- status?: string;
20
- tier?: string;
21
- user?: number;
22
- }): Promise<{
16
+ static async list(): Promise<{
23
17
  success: boolean;
24
- subscriptions?: CfgPaymentsTypes.PaginatedSubscriptionListList;
18
+ subscriptions?: never;
25
19
  error?: string;
26
20
  }> {
27
- try {
28
- const response = await this.api.cfg_payments.subscriptionsList(
29
- params?.ordering,
30
- params?.page,
31
- params?.page_size,
32
- params?.search,
33
- params?.status,
34
- params?.tier,
35
- params?.user
36
- );
37
- return { success: true, subscriptions: response };
38
- } catch (error) {
39
- if (error instanceof APIError) {
40
- return { success: false, error: error.errorMessage };
41
- }
42
- return { success: false, error: 'Network error' };
43
- }
21
+ return { success: false, error: DEPRECATED_ERROR };
44
22
  }
45
23
 
46
24
  /**
47
- * Create subscription
25
+ * @deprecated Subscriptions removed in v2.0
48
26
  */
49
- static async create(
50
- data: CfgPaymentsTypes.SubscriptionCreateRequest
51
- ): Promise<{
27
+ static async create(): Promise<{
52
28
  success: boolean;
53
- subscription?: CfgPaymentsTypes.SubscriptionCreate;
29
+ subscription?: never;
54
30
  error?: string;
55
31
  fieldErrors?: Record<string, string[]>;
56
32
  }> {
57
- try {
58
- const subscription = await this.api.cfg_payments.subscriptionsCreate(data);
59
- return { success: true, subscription };
60
- } catch (error) {
61
- if (error instanceof APIError) {
62
- if (error.isValidationError && error.fieldErrors) {
63
- return { success: false, fieldErrors: error.fieldErrors };
64
- }
65
- return { success: false, error: error.errorMessage };
66
- }
67
- return { success: false, error: 'Network error' };
68
- }
33
+ return { success: false, error: DEPRECATED_ERROR };
69
34
  }
70
35
 
71
36
  /**
72
- * Get subscription details
37
+ * @deprecated Subscriptions removed in v2.0
73
38
  */
74
- static async get(id: string): Promise<{
39
+ static async get(): Promise<{
75
40
  success: boolean;
76
- subscription?: CfgPaymentsTypes.Subscription;
41
+ subscription?: never;
77
42
  error?: string;
78
43
  }> {
79
- try {
80
- const subscription = await this.api.cfg_payments.subscriptionsRetrieve(id);
81
- return { success: true, subscription };
82
- } catch (error) {
83
- if (error instanceof APIError) {
84
- return { success: false, error: error.errorMessage };
85
- }
86
- return { success: false, error: 'Network error' };
87
- }
44
+ return { success: false, error: DEPRECATED_ERROR };
88
45
  }
89
46
 
90
47
  /**
91
- * Update subscription
48
+ * @deprecated Subscriptions removed in v2.0
92
49
  */
93
- static async update(
94
- id: string,
95
- data: CfgPaymentsTypes.PatchedSubscriptionRequest
96
- ): Promise<{
50
+ static async update(): Promise<{
97
51
  success: boolean;
98
- subscription?: CfgPaymentsTypes.Subscription;
52
+ subscription?: never;
99
53
  error?: string;
100
54
  fieldErrors?: Record<string, string[]>;
101
55
  }> {
102
- try {
103
- const subscription = await this.api.cfg_payments.subscriptionsPartialUpdate(id, data);
104
- return { success: true, subscription };
105
- } catch (error) {
106
- if (error instanceof APIError) {
107
- if (error.isValidationError && error.fieldErrors) {
108
- return { success: false, fieldErrors: error.fieldErrors };
109
- }
110
- return { success: false, error: error.errorMessage };
111
- }
112
- return { success: false, error: 'Network error' };
113
- }
56
+ return { success: false, error: DEPRECATED_ERROR };
114
57
  }
115
58
 
116
59
  /**
117
- * Delete subscription
60
+ * @deprecated Subscriptions removed in v2.0
118
61
  */
119
- static async delete(id: string): Promise<{
62
+ static async delete(): Promise<{
120
63
  success: boolean;
121
64
  error?: string;
122
65
  }> {
123
- try {
124
- await this.api.cfg_payments.subscriptionsDestroy(id);
125
- return { success: true };
126
- } catch (error) {
127
- if (error instanceof APIError) {
128
- return { success: false, error: error.errorMessage };
129
- }
130
- return { success: false, error: 'Network error' };
131
- }
66
+ return { success: false, error: DEPRECATED_ERROR };
132
67
  }
133
68
 
134
69
  /**
135
- * Get subscriptions analytics
70
+ * @deprecated Subscriptions removed in v2.0
136
71
  */
137
72
  static async getAnalytics(): Promise<{
138
73
  success: boolean;
139
- analytics?: CfgPaymentsTypes.Subscription;
74
+ analytics?: never;
140
75
  error?: string;
141
76
  }> {
142
- try {
143
- const analytics = await this.api.cfg_payments.subscriptionsAnalyticsRetrieve();
144
- return { success: true, analytics };
145
- } catch (error) {
146
- if (error instanceof APIError) {
147
- return { success: false, error: error.errorMessage };
148
- }
149
- return { success: false, error: 'Network error' };
150
- }
77
+ return { success: false, error: DEPRECATED_ERROR };
151
78
  }
152
79
 
153
80
  /**
154
- * List tariffs
81
+ * @deprecated Subscriptions removed in v2.0
155
82
  */
156
- static async listTariffs(params?: {
157
- is_active?: boolean;
158
- ordering?: string;
159
- page?: number;
160
- page_size?: number;
161
- search?: string;
162
- }): Promise<{
83
+ static async listTariffs(): Promise<{
163
84
  success: boolean;
164
- tariffs?: CfgPaymentsTypes.PaginatedTariffList;
85
+ tariffs?: never;
165
86
  error?: string;
166
87
  }> {
167
- try {
168
- const response = await this.api.cfg_payments.tariffsList(
169
- params?.is_active,
170
- params?.ordering,
171
- params?.page,
172
- params?.page_size,
173
- params?.search
174
- );
175
- return { success: true, tariffs: response };
176
- } catch (error) {
177
- if (error instanceof APIError) {
178
- return { success: false, error: error.errorMessage };
179
- }
180
- return { success: false, error: 'Network error' };
181
- }
88
+ return { success: false, error: DEPRECATED_ERROR };
182
89
  }
183
90
 
184
91
  /**
185
- * Get tariff details
92
+ * @deprecated Subscriptions removed in v2.0
186
93
  */
187
- static async getTariff(id: number): Promise<{
94
+ static async getTariff(): Promise<{
188
95
  success: boolean;
189
- tariff?: CfgPaymentsTypes.Tariff;
96
+ tariff?: never;
190
97
  error?: string;
191
98
  }> {
192
- try {
193
- const tariff = await this.api.cfg_payments.tariffsRetrieve(id);
194
- return { success: true, tariff };
195
- } catch (error) {
196
- if (error instanceof APIError) {
197
- return { success: false, error: error.errorMessage };
198
- }
199
- return { success: false, error: 'Network error' };
200
- }
99
+ return { success: false, error: DEPRECATED_ERROR };
201
100
  }
202
101
  }
@@ -1,108 +1,66 @@
1
1
  /**
2
- * Webhooks Service
2
+ * Webhooks Service (DEPRECATED)
3
3
  *
4
- * Manages payment webhooks
4
+ * Webhooks functionality has been integrated into main Payments API in v2.0
5
+ * This service is kept as a stub for backward compatibility
5
6
  */
6
7
 
7
8
  import { BaseClient } from '../../BaseClient';
8
- import { APIError, CfgWebhooksTypes } from '../../generated';
9
+
10
+ const DEPRECATED_ERROR = 'Webhooks feature has been integrated into Payments API in v2.0';
9
11
 
10
12
  export class WebhooksService extends BaseClient {
11
13
  /**
12
- * Get webhook info
14
+ * @deprecated Webhooks integrated into Payments API in v2.0
13
15
  */
14
- static async getInfo(provider: string): Promise<{
16
+ static async list(): Promise<{
15
17
  success: boolean;
16
- webhook?: CfgWebhooksTypes.WebhookResponse;
18
+ events?: never;
17
19
  error?: string;
18
20
  }> {
19
- try {
20
- const webhook = await this.api.cfg_webhooks.paymentsWebhooksRetrieve(provider);
21
- return { success: true, webhook };
22
- } catch (error) {
23
- if (error instanceof APIError) {
24
- return { success: false, error: error.errorMessage };
25
- }
26
- return { success: false, error: 'Network error' };
27
- }
21
+ return { success: false, error: DEPRECATED_ERROR };
28
22
  }
29
23
 
30
24
  /**
31
- * Process webhook
25
+ * @deprecated Webhooks integrated into Payments API in v2.0
32
26
  */
33
- static async process(
34
- provider: string,
35
- data: CfgWebhooksTypes.WebhookResponseRequest
36
- ): Promise<{
27
+ static async get(): Promise<{
37
28
  success: boolean;
38
- response?: CfgWebhooksTypes.WebhookResponse;
29
+ event?: never;
39
30
  error?: string;
40
31
  }> {
41
- try {
42
- const response = await this.api.cfg_webhooks.paymentsWebhooksCreate(provider, data);
43
- return { success: true, response };
44
- } catch (error) {
45
- if (error instanceof APIError) {
46
- return { success: false, error: error.errorMessage };
47
- }
48
- return { success: false, error: 'Network error' };
49
- }
32
+ return { success: false, error: DEPRECATED_ERROR };
50
33
  }
51
34
 
52
35
  /**
53
- * Get webhook health
36
+ * @deprecated Webhooks integrated into Payments API in v2.0
54
37
  */
55
- static async getHealth(): Promise<{
38
+ static async getStats(): Promise<{
56
39
  success: boolean;
57
- health?: CfgWebhooksTypes.WebhookHealth;
40
+ stats?: never;
58
41
  error?: string;
59
42
  }> {
60
- try {
61
- const health = await this.api.cfg_webhooks.paymentsWebhooksHealthRetrieve();
62
- return { success: true, health };
63
- } catch (error) {
64
- if (error instanceof APIError) {
65
- return { success: false, error: error.errorMessage };
66
- }
67
- return { success: false, error: 'Network error' };
68
- }
43
+ return { success: false, error: DEPRECATED_ERROR };
69
44
  }
70
45
 
71
46
  /**
72
- * Get supported providers
47
+ * @deprecated Webhooks integrated into Payments API in v2.0
73
48
  */
74
- static async getProviders(): Promise<{
49
+ static async getHealth(): Promise<{
75
50
  success: boolean;
76
- providers?: CfgWebhooksTypes.SupportedProviders;
51
+ health?: never;
77
52
  error?: string;
78
53
  }> {
79
- try {
80
- const providers = await this.api.cfg_webhooks.paymentsWebhooksProvidersRetrieve();
81
- return { success: true, providers };
82
- } catch (error) {
83
- if (error instanceof APIError) {
84
- return { success: false, error: error.errorMessage };
85
- }
86
- return { success: false, error: 'Network error' };
87
- }
54
+ return { success: false, error: DEPRECATED_ERROR };
88
55
  }
89
56
 
90
57
  /**
91
- * Get webhook stats
58
+ * @deprecated Webhooks integrated into Payments API in v2.0
92
59
  */
93
- static async getStats(days?: number): Promise<{
60
+ static async retry(): Promise<{
94
61
  success: boolean;
95
- stats?: CfgWebhooksTypes.WebhookStats;
96
62
  error?: string;
97
63
  }> {
98
- try {
99
- const stats = await this.api.cfg_webhooks.paymentsWebhooksStatsRetrieve({ days });
100
- return { success: true, stats };
101
- } catch (error) {
102
- if (error instanceof APIError) {
103
- return { success: false, error: error.errorMessage };
104
- }
105
- return { success: false, error: 'Network error' };
106
- }
64
+ return { success: false, error: DEPRECATED_ERROR };
107
65
  }
108
66
  }
package/src/index.ts CHANGED
@@ -42,13 +42,8 @@ export * from './cfg/contexts';
42
42
  export { Schemas, Fetchers } from './cfg/generated';
43
43
 
44
44
  // Re-export commonly used types directly for convenience
45
- // Usage: import type { APIKeyList } from '@djangocfg/api'
45
+ // Usage: import type { User } from '@djangocfg/api'
46
46
  export type {
47
- // API Keys
48
- APIKeyList,
49
- APIKeyDetail,
50
- APIKeyCreate,
51
- PaginatedAPIKeyListList,
52
47
  // Auth
53
48
  OTPRequestResponse,
54
49
  OTPVerifyResponse,
@@ -1,109 +0,0 @@
1
- /**
2
- * Typed fetchers for Webhooks
3
- *
4
- * Universal functions that work in any environment:
5
- * - Next.js (App Router / Pages Router / Server Components)
6
- * - React Native
7
- * - Node.js backend
8
- *
9
- * These fetchers use Zod schemas for runtime validation.
10
- *
11
- * Usage:
12
- * ```typescript
13
- * // Configure API once (in your app entry point)
14
- * import { configureAPI } from '../../api-instance'
15
- * configureAPI({ baseUrl: 'https://api.example.com' })
16
- *
17
- * // Then use fetchers anywhere
18
- * const users = await getUsers({ page: 1 })
19
- *
20
- * // With SWR
21
- * const { data } = useSWR(['users', params], () => getUsers(params))
22
- *
23
- * // With React Query
24
- * const { data } = useQuery(['users', params], () => getUsers(params))
25
- *
26
- * // In Server Component or SSR (pass custom client)
27
- * import { API } from '../../index'
28
- * const api = new API('https://api.example.com')
29
- * const users = await getUsers({ page: 1 }, api)
30
- * ```
31
- */
32
- import { SupportedProvidersSchema, type SupportedProviders } from '../schemas/SupportedProviders.schema'
33
- import { WebhookHealthSchema, type WebhookHealth } from '../schemas/WebhookHealth.schema'
34
- import { WebhookResponseSchema, type WebhookResponse } from '../schemas/WebhookResponse.schema'
35
- import { WebhookResponseRequestSchema, type WebhookResponseRequest } from '../schemas/WebhookResponseRequest.schema'
36
- import { WebhookStatsSchema, type WebhookStats } from '../schemas/WebhookStats.schema'
37
- import { getAPIInstance } from '../../api-instance'
38
- import type { API } from '../../index'
39
-
40
- /**
41
- * Webhook Endpoint Info
42
- *
43
- * @method GET
44
- * @path /cfg/payments/webhooks/{provider}/
45
- */
46
- export async function getPaymentsWebhooksRetrieve( provider: string, client?
47
- ): Promise<WebhookResponse> {
48
- const api = client || getAPIInstance()
49
- const response = await api.cfg_webhooks.paymentsWebhooksRetrieve(provider)
50
- return WebhookResponseSchema.parse(response)
51
- }
52
-
53
-
54
- /**
55
- * Process Webhook
56
- *
57
- * @method POST
58
- * @path /cfg/payments/webhooks/{provider}/
59
- */
60
- export async function createPaymentsWebhooksCreate( provider: string, data: WebhookResponseRequest, client?
61
- ): Promise<WebhookResponse> {
62
- const api = client || getAPIInstance()
63
- const response = await api.cfg_webhooks.paymentsWebhooksCreate(provider, data)
64
- return WebhookResponseSchema.parse(response)
65
- }
66
-
67
-
68
- /**
69
- * Webhook Health Check
70
- *
71
- * @method GET
72
- * @path /cfg/payments/webhooks/health/
73
- */
74
- export async function getPaymentsWebhooksHealthRetrieve( client?
75
- ): Promise<WebhookHealth> {
76
- const api = client || getAPIInstance()
77
- const response = await api.cfg_webhooks.paymentsWebhooksHealthRetrieve()
78
- return WebhookHealthSchema.parse(response)
79
- }
80
-
81
-
82
- /**
83
- * Supported Webhook Providers
84
- *
85
- * @method GET
86
- * @path /cfg/payments/webhooks/providers/
87
- */
88
- export async function getPaymentsWebhooksProvidersRetrieve( client?
89
- ): Promise<SupportedProviders> {
90
- const api = client || getAPIInstance()
91
- const response = await api.cfg_webhooks.paymentsWebhooksProvidersRetrieve()
92
- return SupportedProvidersSchema.parse(response)
93
- }
94
-
95
-
96
- /**
97
- * Webhook Statistics
98
- *
99
- * @method GET
100
- * @path /cfg/payments/webhooks/stats/
101
- */
102
- export async function getPaymentsWebhooksStatsRetrieve( params?: { days?: number }, client?
103
- ): Promise<WebhookStats> {
104
- const api = client || getAPIInstance()
105
- const response = await api.cfg_webhooks.paymentsWebhooksStatsRetrieve(params?.days)
106
- return WebhookStatsSchema.parse(response)
107
- }
108
-
109
-
@@ -1,100 +0,0 @@
1
- /**
2
- * SWR Hooks for Webhooks
3
- *
4
- * React hooks powered by SWR for data fetching with automatic caching,
5
- * revalidation, and optimistic updates.
6
- *
7
- * Usage:
8
- * ```typescript
9
- * // Query hooks (GET)
10
- * const { data, error, isLoading } = useUsers({ page: 1 })
11
- *
12
- * // Mutation hooks (POST/PUT/PATCH/DELETE)
13
- * const createUser = useCreateUser()
14
- * await createUser({ name: 'John', email: 'john@example.com' })
15
- * ```
16
- */
17
- import useSWR from 'swr'
18
- import { useSWRConfig } from 'swr'
19
- import * as Fetchers from '../fetchers/cfg__payments__webhooks'
20
- import type { API } from '../../index'
21
- import type { SupportedProviders } from '../schemas/SupportedProviders.schema'
22
- import type { WebhookHealth } from '../schemas/WebhookHealth.schema'
23
- import type { WebhookResponse } from '../schemas/WebhookResponse.schema'
24
- import type { WebhookResponseRequest } from '../schemas/WebhookResponseRequest.schema'
25
- import type { WebhookStats } from '../schemas/WebhookStats.schema'
26
-
27
- /**
28
- * Webhook Endpoint Info
29
- *
30
- * @method GET
31
- * @path /cfg/payments/webhooks/{provider}/
32
- */
33
- export function usePaymentsWebhooksRetrieve(provider: string, client?: API): ReturnType<typeof useSWR<WebhookResponse>> {
34
- return useSWR<WebhookResponse>(
35
- ['cfg-payments-webhook', provider],
36
- () => Fetchers.getPaymentsWebhooksRetrieve(provider, client)
37
- )
38
- }
39
-
40
-
41
- /**
42
- * Process Webhook
43
- *
44
- * @method POST
45
- * @path /cfg/payments/webhooks/{provider}/
46
- */
47
- export function useCreatePaymentsWebhooksCreate() {
48
- const { mutate } = useSWRConfig()
49
-
50
- return async (provider: string, data: WebhookResponseRequest, client?: API): Promise<WebhookResponse> => {
51
- const result = await Fetchers.createPaymentsWebhooksCreate(provider, data, client)
52
- // Revalidate related queries
53
- mutate('cfg-payments-webhooks')
54
- return result
55
- }
56
- }
57
-
58
-
59
- /**
60
- * Webhook Health Check
61
- *
62
- * @method GET
63
- * @path /cfg/payments/webhooks/health/
64
- */
65
- export function usePaymentsWebhooksHealthRetrieve(client?: API): ReturnType<typeof useSWR<WebhookHealth>> {
66
- return useSWR<WebhookHealth>(
67
- 'cfg-payments-webhooks-health',
68
- () => Fetchers.getPaymentsWebhooksHealthRetrieve(client)
69
- )
70
- }
71
-
72
-
73
- /**
74
- * Supported Webhook Providers
75
- *
76
- * @method GET
77
- * @path /cfg/payments/webhooks/providers/
78
- */
79
- export function usePaymentsWebhooksProvidersRetrieve(client?: API): ReturnType<typeof useSWR<SupportedProviders>> {
80
- return useSWR<SupportedProviders>(
81
- 'cfg-payments-webhooks-provider',
82
- () => Fetchers.getPaymentsWebhooksProvidersRetrieve(client)
83
- )
84
- }
85
-
86
-
87
- /**
88
- * Webhook Statistics
89
- *
90
- * @method GET
91
- * @path /cfg/payments/webhooks/stats/
92
- */
93
- export function usePaymentsWebhooksStatsRetrieve(params?: { days?: number }, client?: API): ReturnType<typeof useSWR<WebhookStats>> {
94
- return useSWR<WebhookStats>(
95
- params ? ['cfg-payments-webhooks-stat', params] : 'cfg-payments-webhooks-stat',
96
- () => Fetchers.getPaymentsWebhooksStatsRetrieve(params, client)
97
- )
98
- }
99
-
100
-
@@ -1,24 +0,0 @@
1
- /**
2
- * Zod schema for APIKeyCreate
3
- *
4
- * This schema provides runtime validation and type inference.
5
- * * API key creation serializer with service integration.
6
-
7
- Creates new API keys and returns the full key value (only once).
8
- * */
9
- import { z } from 'zod'
10
-
11
- /**
12
- * API key creation serializer with service integration.
13
-
14
- Creates new API keys and returns the full key value (only once).
15
- */
16
- export const APIKeyCreateSchema = z.object({
17
- name: z.string().max(100),
18
- expires_in_days: z.int().min(1.0).max(365.0).nullable().optional(),
19
- })
20
-
21
- /**
22
- * Infer TypeScript type from Zod schema
23
- */
24
- export type APIKeyCreate = z.infer<typeof APIKeyCreateSchema>
@@ -1,24 +0,0 @@
1
- /**
2
- * Zod schema for APIKeyCreateRequest
3
- *
4
- * This schema provides runtime validation and type inference.
5
- * * API key creation serializer with service integration.
6
-
7
- Creates new API keys and returns the full key value (only once).
8
- * */
9
- import { z } from 'zod'
10
-
11
- /**
12
- * API key creation serializer with service integration.
13
-
14
- Creates new API keys and returns the full key value (only once).
15
- */
16
- export const APIKeyCreateRequestSchema = z.object({
17
- name: z.string().min(1).max(100),
18
- expires_in_days: z.int().min(1.0).max(365.0).nullable().optional(),
19
- })
20
-
21
- /**
22
- * Infer TypeScript type from Zod schema
23
- */
24
- export type APIKeyCreateRequest = z.infer<typeof APIKeyCreateRequestSchema>
@@ -1,35 +0,0 @@
1
- /**
2
- * Zod schema for APIKeyDetail
3
- *
4
- * This schema provides runtime validation and type inference.
5
- * * Complete API key serializer with full details.
6
-
7
- Used for API key detail views (no key value for security).
8
- * */
9
- import { z } from 'zod'
10
-
11
- /**
12
- * Complete API key serializer with full details.
13
-
14
- Used for API key detail views (no key value for security).
15
- */
16
- export const APIKeyDetailSchema = z.object({
17
- id: z.uuid(),
18
- user: z.string(),
19
- name: z.string(),
20
- key_preview: z.string(),
21
- is_active: z.boolean(),
22
- is_expired: z.boolean(),
23
- is_valid: z.boolean(),
24
- days_until_expiry: z.int(),
25
- total_requests: z.int(),
26
- last_used_at: z.iso.datetime().nullable(),
27
- expires_at: z.iso.datetime().nullable(),
28
- created_at: z.iso.datetime(),
29
- updated_at: z.iso.datetime(),
30
- })
31
-
32
- /**
33
- * Infer TypeScript type from Zod schema
34
- */
35
- export type APIKeyDetail = z.infer<typeof APIKeyDetailSchema>