@agentpaid/paid-nextjs-client 0.3.0-test.2 → 0.3.1

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 (72) hide show
  1. package/README.md +184 -79
  2. package/dist/api/api/handleBlocks.ts +144 -0
  3. package/dist/api/handleBlocks.d.ts +9 -0
  4. package/dist/api/handleBlocks.d.ts.map +1 -0
  5. package/dist/api/handleBlocks.js +107 -0
  6. package/dist/api/handleBlocks.js.map +1 -0
  7. package/dist/components/PaidActivityLog.d.ts +13 -26
  8. package/dist/components/PaidActivityLog.d.ts.map +1 -1
  9. package/dist/components/PaidActivityLog.js +70 -26
  10. package/dist/components/PaidActivityLog.js.map +1 -1
  11. package/dist/components/PaidContainer.d.ts +11 -24
  12. package/dist/components/PaidContainer.d.ts.map +1 -1
  13. package/dist/components/PaidContainer.js +18 -9
  14. package/dist/components/PaidContainer.js.map +1 -1
  15. package/dist/components/PaidInvoiceTable.d.ts +12 -25
  16. package/dist/components/PaidInvoiceTable.d.ts.map +1 -1
  17. package/dist/components/PaidInvoiceTable.js +78 -30
  18. package/dist/components/PaidInvoiceTable.js.map +1 -1
  19. package/dist/components/PaidPaymentsTable.d.ts +12 -25
  20. package/dist/components/PaidPaymentsTable.d.ts.map +1 -1
  21. package/dist/components/PaidPaymentsTable.js +63 -29
  22. package/dist/components/PaidPaymentsTable.js.map +1 -1
  23. package/dist/components/components/PaidActivityLog.js +115 -58
  24. package/dist/components/components/PaidContainer.js +42 -32
  25. package/dist/components/components/PaidInvoiceTable.js +126 -89
  26. package/dist/components/components/PaidPaymentsTable.js +111 -72
  27. package/dist/components/components/ui/Pagination.js +168 -0
  28. package/dist/components/ui/Pagination.d.ts +10 -0
  29. package/dist/components/ui/Pagination.d.ts.map +1 -0
  30. package/dist/components/ui/Pagination.js +111 -0
  31. package/dist/components/ui/Pagination.js.map +1 -0
  32. package/dist/hooks/useCache.d.ts +2 -2
  33. package/dist/hooks/useCache.d.ts.map +1 -1
  34. package/dist/hooks/useCache.js +10 -17
  35. package/dist/hooks/useCache.js.map +1 -1
  36. package/dist/index.d.ts +4 -4
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +4 -4
  39. package/dist/index.js.map +1 -1
  40. package/dist/styles/paid-activity-log.css +154 -0
  41. package/dist/styles/paid-container.css +25 -16
  42. package/dist/styles/paid-invoice-table.css +135 -120
  43. package/dist/styles/paid-payments-table.css +65 -109
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/dist/utils/apiClient.d.ts +17 -0
  46. package/dist/utils/apiClient.d.ts.map +1 -0
  47. package/dist/utils/apiClient.js +60 -0
  48. package/dist/utils/apiClient.js.map +1 -0
  49. package/dist/utils/cache.js +1 -1
  50. package/dist/utils/cache.js.map +1 -1
  51. package/package.json +1 -1
  52. package/dist/api/api/handlePaidInvoicePdf.ts +0 -79
  53. package/dist/api/api/handlePaidInvoices.ts +0 -77
  54. package/dist/api/api/handlePaidPayments.ts +0 -77
  55. package/dist/api/api/handlePaidUsage.ts +0 -52
  56. package/dist/api/handlePaidInvoicePdf.d.ts +0 -6
  57. package/dist/api/handlePaidInvoicePdf.d.ts.map +0 -1
  58. package/dist/api/handlePaidInvoicePdf.js +0 -60
  59. package/dist/api/handlePaidInvoicePdf.js.map +0 -1
  60. package/dist/api/handlePaidInvoices.d.ts +0 -6
  61. package/dist/api/handlePaidInvoices.d.ts.map +0 -1
  62. package/dist/api/handlePaidInvoices.js +0 -56
  63. package/dist/api/handlePaidInvoices.js.map +0 -1
  64. package/dist/api/handlePaidPayments.d.ts +0 -6
  65. package/dist/api/handlePaidPayments.d.ts.map +0 -1
  66. package/dist/api/handlePaidPayments.js +0 -56
  67. package/dist/api/handlePaidPayments.js.map +0 -1
  68. package/dist/api/handlePaidUsage.d.ts +0 -6
  69. package/dist/api/handlePaidUsage.d.ts.map +0 -1
  70. package/dist/api/handlePaidUsage.js +0 -35
  71. package/dist/api/handlePaidUsage.js.map +0 -1
  72. package/dist/styles/activity-log-table.css +0 -138
@@ -1,79 +0,0 @@
1
- export function handlePaidInvoicePdf(apiKey: string, apiBase?: string) {
2
- return async function GET(
3
- _: Request,
4
- { params }: { params: { invoiceId: string } }
5
- ) {
6
- try {
7
- if (!apiBase) {
8
- apiBase = 'https://api.agentpaid.io';
9
- }
10
-
11
- const { invoiceId } = params;
12
-
13
- if (!apiKey) {
14
- return new Response(
15
- JSON.stringify({ error: 'API key not configured' }),
16
- {
17
- status: 500,
18
- headers: { 'Content-Type': 'application/json' }
19
- }
20
- );
21
- }
22
-
23
- const url = `${apiBase}/api/organizations/org/invoices/${invoiceId}/pdf`;
24
-
25
- const response = await fetch(url, {
26
- headers: {
27
- 'Authorization': `Bearer ${apiKey}`,
28
- },
29
- }
30
- );
31
-
32
- if (!response.ok) {
33
- let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
34
- try {
35
- const errorData = await response.json();
36
- errorMessage = errorData.error || errorData.message || errorMessage;
37
- } catch (parseError) {
38
- try {
39
- const errorText = await response.text();
40
- if (errorText) {
41
- errorMessage = errorText;
42
- }
43
- } catch (textError) {
44
- console.log('handlePaidInvoicePdf - Could not parse error response');
45
- }
46
- }
47
-
48
- return new Response(
49
- JSON.stringify({ error: errorMessage }),
50
- {
51
- status: response.status,
52
- headers: { 'Content-Type': 'application/json' }
53
- }
54
- );
55
- }
56
-
57
- const data = await response.json();
58
- return new Response(
59
- JSON.stringify(data),
60
- {
61
- status: 200,
62
- headers: { 'Content-Type': 'application/json' }
63
- }
64
- );
65
- } catch (error) {
66
- console.error('Error fetching invoice PDF:', error);
67
- return new Response(
68
- JSON.stringify({
69
- error: 'Failed to fetch invoice PDF',
70
- details: error instanceof Error ? error.message : String(error)
71
- }),
72
- {
73
- status: 500,
74
- headers: { 'Content-Type': 'application/json' }
75
- }
76
- );
77
- }
78
- }
79
- }
@@ -1,77 +0,0 @@
1
- export function handlePaidInvoices(apiKey: string, apiBase?: string) {
2
- return async function GET(
3
- _: Request,
4
- { params }: { params: { accountExternalId: string } }
5
- ) {
6
- try {
7
-
8
- if (!apiBase) {
9
- apiBase = 'https://api.agentpaid.io';
10
- }
11
-
12
- const { accountExternalId } = params;
13
-
14
- if (!apiKey) {
15
- console.log('handlePaidInvoices - No API key provided');
16
- return new Response(
17
- JSON.stringify({ error: 'API key not configured' }),
18
- {
19
- status: 500,
20
- headers: { 'Content-Type': 'application/json' }
21
- }
22
- );
23
- }
24
-
25
- const url = `${apiBase}/api/organizations/org/customer/external/${accountExternalId}/invoices`;
26
-
27
- const response = await fetch(url, {
28
- headers: {
29
- 'Authorization': `Bearer ${apiKey}`,
30
- },
31
- }
32
- );
33
-
34
- if (!response.ok) {
35
- let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
36
- try {
37
- // Try to read as JSON first
38
- const errorData = await response.json();
39
- errorMessage = errorData.error || errorData.message || errorMessage;
40
- } catch (parseError) {
41
- // If JSON parsing fails, the body has been consumed, so we can't read it as text
42
- // Just use the HTTP status message
43
- console.log('handlePaidInvoices - Could not parse error response as JSON');
44
- }
45
-
46
- return new Response(
47
- JSON.stringify({ error: errorMessage }),
48
- {
49
- status: response.status,
50
- headers: { 'Content-Type': 'application/json' }
51
- }
52
- );
53
- }
54
-
55
- const data = await response.json();
56
- return new Response(
57
- JSON.stringify(data),
58
- {
59
- status: 200,
60
- headers: { 'Content-Type': 'application/json' }
61
- }
62
- );
63
- } catch (error) {
64
- console.error('Error fetching invoices:', error);
65
- return new Response(
66
- JSON.stringify({
67
- error: 'Failed to fetch invoices',
68
- details: error instanceof Error ? error.message : String(error)
69
- }),
70
- {
71
- status: 500,
72
- headers: { 'Content-Type': 'application/json' }
73
- }
74
- );
75
- }
76
- }
77
- }
@@ -1,77 +0,0 @@
1
- export function handlePaidPayments(apiKey: string, apiBase?: string) {
2
- return async function GET(
3
- _: Request,
4
- { params }: { params: { accountExternalId: string } }
5
- ) {
6
- try {
7
-
8
- if (!apiBase) {
9
- apiBase = 'https://api.agentpaid.io';
10
- }
11
-
12
- const { accountExternalId } = params;
13
-
14
- if (!apiKey) {
15
- console.log('handlePaidPayments - No API key provided');
16
- return new Response(
17
- JSON.stringify({ error: 'API key not configured' }),
18
- {
19
- status: 500,
20
- headers: { 'Content-Type': 'application/json' }
21
- }
22
- );
23
- }
24
-
25
- const url = `${apiBase}/api/organizations/org/customer/external/${accountExternalId}/payments`;
26
-
27
- const response = await fetch(url, {
28
- headers: {
29
- 'Authorization': `Bearer ${apiKey}`,
30
- },
31
- }
32
- );
33
-
34
- if (!response.ok) {
35
- let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
36
- try {
37
- // Try to read as JSON first
38
- const errorData = await response.json();
39
- errorMessage = errorData.error || errorData.message || errorMessage;
40
- } catch (parseError) {
41
- // If JSON parsing fails, the body has been consumed, so we can't read it as text
42
- // Just use the HTTP status message
43
- console.log('handlePaidPayments - Could not parse error response as JSON');
44
- }
45
-
46
- return new Response(
47
- JSON.stringify({ error: errorMessage }),
48
- {
49
- status: response.status,
50
- headers: { 'Content-Type': 'application/json' }
51
- }
52
- );
53
- }
54
-
55
- const data = await response.json();
56
- return new Response(
57
- JSON.stringify(data),
58
- {
59
- status: 200,
60
- headers: { 'Content-Type': 'application/json' }
61
- }
62
- );
63
- } catch (error) {
64
- console.error('Error fetching payments:', error);
65
- return new Response(
66
- JSON.stringify({
67
- error: 'Failed to fetch payments',
68
- details: error instanceof Error ? error.message : String(error)
69
- }),
70
- {
71
- status: 500,
72
- headers: { 'Content-Type': 'application/json' }
73
- }
74
- );
75
- }
76
- }
77
- }
@@ -1,52 +0,0 @@
1
- export function handlePaidUsage(apiKey: string) {
2
- return async function GET(
3
- _: Request,
4
- { params }: { params: { accountExternalId: string } }
5
- ) {
6
- try {
7
- const apiBase = 'https://api.agentpaid.io';
8
- const { accountExternalId } = params;
9
-
10
- if (!apiKey) {
11
- return new Response(
12
- JSON.stringify({ error: 'API key not configured' }),
13
- {
14
- status: 500,
15
- headers: { 'Content-Type': 'application/json' }
16
- }
17
- );
18
- }
19
-
20
- const response = await fetch(
21
- `${apiBase}/api/organizations/org/customer/external/${accountExternalId}`,
22
- {
23
- headers: {
24
- 'Authorization': `Bearer ${apiKey}`,
25
- },
26
- }
27
- );
28
-
29
- if (!response.ok) {
30
- throw new Error('Failed to fetch usage data');
31
- }
32
-
33
- const data = await response.json();
34
- return new Response(
35
- JSON.stringify(data),
36
- {
37
- status: 200,
38
- headers: { 'Content-Type': 'application/json' }
39
- }
40
- );
41
- } catch (error) {
42
- console.error('Error fetching usage data:', error);
43
- return new Response(
44
- JSON.stringify({ error: 'Failed to fetch usage data' }),
45
- {
46
- status: 500,
47
- headers: { 'Content-Type': 'application/json' }
48
- }
49
- );
50
- }
51
- }
52
- }
@@ -1,6 +0,0 @@
1
- export declare function handlePaidInvoicePdf(apiKey: string, apiBase?: string): (_: Request, { params }: {
2
- params: {
3
- invoiceId: string;
4
- };
5
- }) => Promise<Response>;
6
- //# sourceMappingURL=handlePaidInvoicePdf.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlePaidInvoicePdf.d.ts","sourceRoot":"","sources":["../../src/api/handlePaidInvoicePdf.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,OAE5D,OAAO;YACY;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE;wBA2E9C"}
@@ -1,60 +0,0 @@
1
- export function handlePaidInvoicePdf(apiKey, apiBase) {
2
- return async function GET(_, { params }) {
3
- try {
4
- if (!apiBase) {
5
- apiBase = 'https://api.agentpaid.io';
6
- }
7
- const { invoiceId } = params;
8
- if (!apiKey) {
9
- return new Response(JSON.stringify({ error: 'API key not configured' }), {
10
- status: 500,
11
- headers: { 'Content-Type': 'application/json' }
12
- });
13
- }
14
- const url = `${apiBase}/api/organizations/org/invoices/${invoiceId}/pdf`;
15
- const response = await fetch(url, {
16
- headers: {
17
- 'Authorization': `Bearer ${apiKey}`,
18
- },
19
- });
20
- if (!response.ok) {
21
- let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
22
- try {
23
- const errorData = await response.json();
24
- errorMessage = errorData.error || errorData.message || errorMessage;
25
- }
26
- catch (parseError) {
27
- try {
28
- const errorText = await response.text();
29
- if (errorText) {
30
- errorMessage = errorText;
31
- }
32
- }
33
- catch (textError) {
34
- console.log('handlePaidInvoicePdf - Could not parse error response');
35
- }
36
- }
37
- return new Response(JSON.stringify({ error: errorMessage }), {
38
- status: response.status,
39
- headers: { 'Content-Type': 'application/json' }
40
- });
41
- }
42
- const data = await response.json();
43
- return new Response(JSON.stringify(data), {
44
- status: 200,
45
- headers: { 'Content-Type': 'application/json' }
46
- });
47
- }
48
- catch (error) {
49
- console.error('Error fetching invoice PDF:', error);
50
- return new Response(JSON.stringify({
51
- error: 'Failed to fetch invoice PDF',
52
- details: error instanceof Error ? error.message : String(error)
53
- }), {
54
- status: 500,
55
- headers: { 'Content-Type': 'application/json' }
56
- });
57
- }
58
- };
59
- }
60
- //# sourceMappingURL=handlePaidInvoicePdf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlePaidInvoicePdf.js","sourceRoot":"","sources":["../../src/api/handlePaidInvoicePdf.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAAC,MAAc,EAAE,OAAgB;IACjE,OAAO,KAAK,UAAU,GAAG,CACvB,CAAU,EACV,EAAE,MAAM,EAAqC;QAE7C,IAAI,CAAC;YACH,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,OAAO,GAAG,0BAA0B,CAAC;YACzC,CAAC;YAED,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;YAE7B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAC,EACnD;oBACE,MAAM,EAAE,GAAG;oBACX,OAAO,EAAE,EAAE,cAAc,EAAE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AAG;gBACX,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;aAChD,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;YACpD,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC;gBACb,KAAK,EAAE,6BAA6B;gBACpC,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAChE,CAAC,EACF;gBACE,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;aAChD,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -1,6 +0,0 @@
1
- export declare function handlePaidInvoices(apiKey: string, apiBase?: string): (_: Request, { params }: {
2
- params: {
3
- accountExternalId: string;
4
- };
5
- }) => Promise<Response>;
6
- //# sourceMappingURL=handlePaidInvoices.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlePaidInvoices.d.ts","sourceRoot":"","sources":["../../src/api/handlePaidInvoices.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,OAE1D,OAAO;YACY;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE;wBAyEtD"}
@@ -1,56 +0,0 @@
1
- export function handlePaidInvoices(apiKey, apiBase) {
2
- return async function GET(_, { params }) {
3
- try {
4
- if (!apiBase) {
5
- apiBase = 'https://api.agentpaid.io';
6
- }
7
- const { accountExternalId } = params;
8
- if (!apiKey) {
9
- console.log('handlePaidInvoices - No API key provided');
10
- return new Response(JSON.stringify({ error: 'API key not configured' }), {
11
- status: 500,
12
- headers: { 'Content-Type': 'application/json' }
13
- });
14
- }
15
- const url = `${apiBase}/api/organizations/org/customer/external/${accountExternalId}/invoices`;
16
- const response = await fetch(url, {
17
- headers: {
18
- 'Authorization': `Bearer ${apiKey}`,
19
- },
20
- });
21
- if (!response.ok) {
22
- let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
23
- try {
24
- // Try to read as JSON first
25
- const errorData = await response.json();
26
- errorMessage = errorData.error || errorData.message || errorMessage;
27
- }
28
- catch (parseError) {
29
- // If JSON parsing fails, the body has been consumed, so we can't read it as text
30
- // Just use the HTTP status message
31
- console.log('handlePaidInvoices - Could not parse error response as JSON');
32
- }
33
- return new Response(JSON.stringify({ error: errorMessage }), {
34
- status: response.status,
35
- headers: { 'Content-Type': 'application/json' }
36
- });
37
- }
38
- const data = await response.json();
39
- return new Response(JSON.stringify(data), {
40
- status: 200,
41
- headers: { 'Content-Type': 'application/json' }
42
- });
43
- }
44
- catch (error) {
45
- console.error('Error fetching invoices:', error);
46
- return new Response(JSON.stringify({
47
- error: 'Failed to fetch invoices',
48
- details: error instanceof Error ? error.message : String(error)
49
- }), {
50
- status: 500,
51
- headers: { 'Content-Type': 'application/json' }
52
- });
53
- }
54
- };
55
- }
56
- //# sourceMappingURL=handlePaidInvoices.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlePaidInvoices.js","sourceRoot":"","sources":["../../src/api/handlePaidInvoices.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,OAAgB;IAC/D,OAAO,KAAK,UAAU,GAAG,CACvB,CAAU,EACV,EAAE,MAAM,EAA6C;QAErD,IAAI,CAAC;YAEH,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,OAAO,GAAG,0BAA0B,CAAC;YACzC,CAAC;YAED,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;YAErC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;gBACxD,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,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AkB,EAAE;aAChD,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;YACjD,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC;gBACb,KAAK,EAAE,0BAA0B;gBACjC,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAChE,CAAC,EACF;gBACE,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;aAChD,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -1,6 +0,0 @@
1
- export declare function handlePaidPayments(apiKey: string, apiBase?: string): (_: Request, { params }: {
2
- params: {
3
- accountExternalId: string;
4
- };
5
- }) => Promise<Response>;
6
- //# sourceMappingURL=handlePaidPayments.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlePaidPayments.d.ts","sourceRoot":"","sources":["../../src/api/handlePaidPayments.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,OAE1D,OAAO;YACY;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE;wBAyEtD"}
@@ -1,56 +0,0 @@
1
- export function handlePaidPayments(apiKey, apiBase) {
2
- return async function GET(_, { params }) {
3
- try {
4
- if (!apiBase) {
5
- apiBase = 'https://api.agentpaid.io';
6
- }
7
- const { accountExternalId } = params;
8
- if (!apiKey) {
9
- console.log('handlePaidPayments - No API key provided');
10
- return new Response(JSON.stringify({ error: 'API key not configured' }), {
11
- status: 500,
12
- headers: { 'Content-Type': 'application/json' }
13
- });
14
- }
15
- const url = `${apiBase}/api/organizations/org/customer/external/${accountExternalId}/payments`;
16
- const response = await fetch(url, {
17
- headers: {
18
- 'Authorization': `Bearer ${apiKey}`,
19
- },
20
- });
21
- if (!response.ok) {
22
- let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
23
- try {
24
- // Try to read as JSON first
25
- const errorData = await response.json();
26
- errorMessage = errorData.error || errorData.message || errorMessage;
27
- }
28
- catch (parseError) {
29
- // If JSON parsing fails, the body has been consumed, so we can't read it as text
30
- // Just use the HTTP status message
31
- console.log('handlePaidPayments - Could not parse error response as JSON');
32
- }
33
- return new Response(JSON.stringify({ error: errorMessage }), {
34
- status: response.status,
35
- headers: { 'Content-Type': 'application/json' }
36
- });
37
- }
38
- const data = await response.json();
39
- return new Response(JSON.stringify(data), {
40
- status: 200,
41
- headers: { 'Content-Type': 'application/json' }
42
- });
43
- }
44
- catch (error) {
45
- console.error('Error fetching payments:', error);
46
- return new Response(JSON.stringify({
47
- error: 'Failed to fetch payments',
48
- details: error instanceof Error ? error.message : String(error)
49
- }), {
50
- status: 500,
51
- headers: { 'Content-Type': 'application/json' }
52
- });
53
- }
54
- };
55
- }
56
- //# sourceMappingURL=handlePaidPayments.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlePaidPayments.js","sourceRoot":"","sources":["../../src/api/handlePaidPayments.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,OAAgB;IAC/D,OAAO,KAAK,UAAU,GAAG,CACvB,CAAU,EACV,EAAE,MAAM,EAA6C;QAErD,IAAI,CAAC;YAEH,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,OAAO,GAAG,0BAA0B,CAAC;YACzC,CAAC;YAED,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;YAErC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;gBACxD,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAC,EACnD;oBAC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AE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;YACjD,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC;gBACb,KAAK,EAAE,0BAA0B;gBACjC,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAChE,CAAC,EACF;gBACE,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;aAChD,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -1,6 +0,0 @@
1
- export declare function handlePaidUsage(apiKey: string): (_: Request, { params }: {
2
- params: {
3
- accountExternalId: string;
4
- };
5
- }) => Promise<Response>;
6
- //# sourceMappingURL=handlePaidUsage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlePaidUsage.d.ts","sourceRoot":"","sources":["../../src/api/handlePaidUsage.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,OAEvC,OAAO;YACY;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE;wBAgDtD"}
@@ -1,35 +0,0 @@
1
- export function handlePaidUsage(apiKey) {
2
- return async function GET(_, { params }) {
3
- try {
4
- const apiBase = 'https://api.agentpaid.io';
5
- const { accountExternalId } = params;
6
- if (!apiKey) {
7
- return new Response(JSON.stringify({ error: 'API key not configured' }), {
8
- status: 500,
9
- headers: { 'Content-Type': 'application/json' }
10
- });
11
- }
12
- const response = await fetch(`${apiBase}/api/organizations/org/customer/external/${accountExternalId}`, {
13
- headers: {
14
- 'Authorization': `Bearer ${apiKey}`,
15
- },
16
- });
17
- if (!response.ok) {
18
- throw new Error('Failed to fetch usage data');
19
- }
20
- const data = await response.json();
21
- return new Response(JSON.stringify(data), {
22
- status: 200,
23
- headers: { 'Content-Type': 'application/json' }
24
- });
25
- }
26
- catch (error) {
27
- console.error('Error fetching usage data:', error);
28
- return new Response(JSON.stringify({ error: 'Failed to fetch usage data' }), {
29
- status: 500,
30
- headers: { 'Content-Type': 'application/json' }
31
- });
32
- }
33
- };
34
- }
35
- //# sourceMappingURL=handlePaidUsage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlePaidUsage.js","sourceRoot":"","sources":["../../src/api/handlePaidUsage.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,KAAK,UAAU,GAAG,CACvB,CAAU,EACV,EAAE,MAAM,EAA6C;QAErD,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,0BAA0B,CAAC;YAC3C,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;YAErC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAC,EACnD;oBACE,MAAM,EAAE,GAAG;oBACX,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;iBAChD,CACF,CAAC;YACJ,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,GAAG,OAAO,4CAA4C,iBAAiB,EAAE,EACzE;gBACE,OAAO,EAAE;oBACP,eAAe,EAAE,UAAU,MAAM,EAAE;iBACpC;aACF,CACF,CAAC;YAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAChD,CAAC;YAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EACpB;gBACE,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;aAChD,CACF,CAA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