@revealui/services 0.3.2 → 0.3.4

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 (70) hide show
  1. package/dist/stripe/payment-intent.d.ts.map +1 -1
  2. package/dist/stripe/payment-intent.js +6 -1
  3. package/dist/stripe/payment-intent.js.map +1 -1
  4. package/dist/supabase/types.d.ts.map +1 -1
  5. package/package.json +6 -6
  6. package/LICENSE.commercial +0 -111
  7. package/dist/api/create-checkout-session/index.d.ts +0 -2
  8. package/dist/api/create-checkout-session/index.d.ts.map +0 -1
  9. package/dist/api/create-checkout-session/index.js +0 -61
  10. package/dist/api/create-checkout-session/index.js.map +0 -1
  11. package/dist/api/create-portal-link/index.d.ts +0 -2
  12. package/dist/api/create-portal-link/index.d.ts.map +0 -1
  13. package/dist/api/create-portal-link/index.js +0 -37
  14. package/dist/api/create-portal-link/index.js.map +0 -1
  15. package/dist/api/handlers/customer-handlers.d.ts +0 -27
  16. package/dist/api/handlers/customer-handlers.d.ts.map +0 -1
  17. package/dist/api/handlers/customer-handlers.js +0 -82
  18. package/dist/api/handlers/customer-handlers.js.map +0 -1
  19. package/dist/api/handlers/index.d.ts +0 -18
  20. package/dist/api/handlers/index.d.ts.map +0 -1
  21. package/dist/api/handlers/index.js +0 -18
  22. package/dist/api/handlers/index.js.map +0 -1
  23. package/dist/api/handlers/invoice-handlers.d.ts +0 -9
  24. package/dist/api/handlers/invoice-handlers.d.ts.map +0 -1
  25. package/dist/api/handlers/invoice-handlers.js +0 -52
  26. package/dist/api/handlers/invoice-handlers.js.map +0 -1
  27. package/dist/api/handlers/payment-handlers.d.ts +0 -13
  28. package/dist/api/handlers/payment-handlers.d.ts.map +0 -1
  29. package/dist/api/handlers/payment-handlers.js +0 -133
  30. package/dist/api/handlers/payment-handlers.js.map +0 -1
  31. package/dist/api/handlers/payment-intent.d.ts +0 -21
  32. package/dist/api/handlers/payment-intent.d.ts.map +0 -1
  33. package/dist/api/handlers/payment-intent.js +0 -87
  34. package/dist/api/handlers/payment-intent.js.map +0 -1
  35. package/dist/api/handlers/product-handlers.d.ts +0 -11
  36. package/dist/api/handlers/product-handlers.d.ts.map +0 -1
  37. package/dist/api/handlers/product-handlers.js +0 -43
  38. package/dist/api/handlers/product-handlers.js.map +0 -1
  39. package/dist/api/handlers/subscription-handlers.d.ts +0 -17
  40. package/dist/api/handlers/subscription-handlers.d.ts.map +0 -1
  41. package/dist/api/handlers/subscription-handlers.js +0 -119
  42. package/dist/api/handlers/subscription-handlers.js.map +0 -1
  43. package/dist/api/index.d.ts +0 -7
  44. package/dist/api/index.d.ts.map +0 -1
  45. package/dist/api/index.js +0 -7
  46. package/dist/api/index.js.map +0 -1
  47. package/dist/api/types/stripe.d.ts +0 -42
  48. package/dist/api/types/stripe.d.ts.map +0 -1
  49. package/dist/api/types/stripe.js +0 -72
  50. package/dist/api/types/stripe.js.map +0 -1
  51. package/dist/api/update-price/index.d.ts +0 -42
  52. package/dist/api/update-price/index.d.ts.map +0 -1
  53. package/dist/api/update-price/index.js +0 -78
  54. package/dist/api/update-price/index.js.map +0 -1
  55. package/dist/api/update-product/index.d.ts +0 -44
  56. package/dist/api/update-product/index.d.ts.map +0 -1
  57. package/dist/api/update-product/index.js +0 -85
  58. package/dist/api/update-product/index.js.map +0 -1
  59. package/dist/api/utils.d.ts +0 -34
  60. package/dist/api/utils.d.ts.map +0 -1
  61. package/dist/api/utils.js +0 -66
  62. package/dist/api/utils.js.map +0 -1
  63. package/dist/api/webhooks/index.d.ts +0 -12
  64. package/dist/api/webhooks/index.d.ts.map +0 -1
  65. package/dist/api/webhooks/index.js +0 -280
  66. package/dist/api/webhooks/index.js.map +0 -1
  67. package/dist/stripe/billing.d.ts +0 -121
  68. package/dist/stripe/billing.d.ts.map +0 -1
  69. package/dist/stripe/billing.js +0 -157
  70. package/dist/stripe/billing.js.map +0 -1
@@ -1,42 +0,0 @@
1
- import type { VercelRequest, VercelResponse } from '@vercel/node';
2
- import type Stripe from 'stripe';
3
- interface RevealUIQueryResult {
4
- docs?: Array<{
5
- id: string | number;
6
- }>;
7
- }
8
- interface RevealUIInstance {
9
- find(arg0: {
10
- collection: string;
11
- where: {
12
- stripeProductID: {
13
- equals: string;
14
- };
15
- };
16
- }): Promise<RevealUIQueryResult>;
17
- update(arg0: {
18
- collection: string;
19
- id: string | number;
20
- data: {
21
- priceJSON: string;
22
- skipSync: boolean;
23
- };
24
- }): Promise<unknown>;
25
- logger: {
26
- info: (message: string) => void;
27
- error: (message: string) => void;
28
- };
29
- }
30
- export type StripeWebhookHandler<T> = (args: {
31
- event: Stripe.Event & T;
32
- revealui: RevealUIInstance;
33
- stripe: Stripe;
34
- }) => Promise<void>;
35
- export declare const updatePrice: StripeWebhookHandler<{
36
- data: {
37
- object: Stripe.Price;
38
- };
39
- }>;
40
- export declare function POST(req: VercelRequest, res: VercelResponse): Promise<void>;
41
- export {};
42
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/update-price/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,UAAU,mBAAmB;IAC3B,IAAI,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC,CAAC;CACvC;AAED,UAAU,gBAAgB;IACxB,IAAI,CAAC,IAAI,EAAE;QACT,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE;YAAE,eAAe,EAAE;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAC;KAChD,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACjC,MAAM,CAAC,IAAI,EAAE;QACX,UAAU,EAAE,MAAM,CAAC;QACnB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,IAAI,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAC;KAChD,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACrB,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;QAChC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;KAClC,CAAC;CACH;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE;IAC3C,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IACxB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAIpB,eAAO,MAAM,WAAW,EAAE,oBAAoB,CAAC;IAC7C,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;KACtB,CAAC;CACH,CAuEA,CAAC;AAQF,wBAAsB,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBjF"}
@@ -1,78 +0,0 @@
1
- import { logger } from '@revealui/core/utils/logger';
2
- const logs = false;
3
- export const updatePrice = async (args) => {
4
- const { event, revealui, stripe } = args;
5
- const priceObject = event.data.object;
6
- if (typeof priceObject !== 'object' ||
7
- priceObject === null ||
8
- !('product' in priceObject) ||
9
- !('id' in priceObject)) {
10
- revealui.logger.error('Invalid price object in Stripe event');
11
- return;
12
- }
13
- const stripeProduct = priceObject.product;
14
- const stripeProductID = typeof stripeProduct === 'string' ? stripeProduct : stripeProduct.id;
15
- if (logs)
16
- revealui.logger.info(`🪝 A price was created or updated in Stripe on product ID: ${stripeProductID}, syncing to RevealUI...`);
17
- let revealuiProductID;
18
- // First lookup the product in RevealUI
19
- try {
20
- if (logs)
21
- revealui.logger.info(`- Looking up existing RevealUI product...`);
22
- const productQuery = await revealui.find({
23
- collection: 'products',
24
- where: {
25
- stripeProductID: {
26
- equals: stripeProductID,
27
- },
28
- },
29
- });
30
- revealuiProductID = productQuery.docs?.[0]?.id;
31
- if (revealuiProductID) {
32
- if (logs)
33
- revealui.logger.info(`- Found existing product with Stripe ID: ${stripeProductID}, saving price...`);
34
- }
35
- }
36
- catch (err) {
37
- const msg = err instanceof Error ? err.message : 'Unknown error';
38
- revealui.logger.error(`Error finding product ${msg}`);
39
- }
40
- try {
41
- // Find all stripe prices that are assigned to "revealuiProductID"
42
- const stripePrices = await stripe.prices.list({
43
- product: stripeProductID,
44
- limit: 100,
45
- });
46
- await revealui.update({
47
- collection: 'products',
48
- id: revealuiProductID || '',
49
- data: {
50
- priceJSON: JSON.stringify(stripePrices),
51
- skipSync: true,
52
- },
53
- });
54
- if (logs)
55
- revealui.logger.info(`✅ Successfully updated product price.`);
56
- }
57
- catch (error) {
58
- const errorMessage = error instanceof Error ? error.message : String(error);
59
- revealui.logger.error(`- Error updating product price: ${errorMessage}`);
60
- }
61
- };
62
- export async function POST(req, res) {
63
- if (req.method !== 'POST') {
64
- res.status(405).send('Method Not Allowed');
65
- return;
66
- }
67
- const { event, revealui, stripe } = req.body;
68
- try {
69
- await updatePrice({ event, revealui, stripe });
70
- res.status(200).send('Product updated successfully');
71
- }
72
- catch (error) {
73
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
74
- logger.error('Error updating product', { error: errorMessage });
75
- res.status(500).send('Internal Server Error');
76
- }
77
- }
78
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/update-price/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AA8BrD,MAAM,IAAI,GAAG,KAAK,CAAC;AAEnB,MAAM,CAAC,MAAM,WAAW,GAInB,KAAK,EAAE,IAAI,EAAE,EAAE;IAClB,M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AAI,CAAC;QACH,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QAC9E,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;QAChE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
@@ -1,44 +0,0 @@
1
- import type { VercelRequest, VercelResponse } from '@vercel/node';
2
- import type Stripe from 'stripe';
3
- interface RevealUIQueryResult {
4
- docs?: Array<{
5
- id: string | number;
6
- }>;
7
- }
8
- interface RevealUIInstance {
9
- find(arg0: {
10
- collection: string;
11
- where: {
12
- stripeProductID: {
13
- equals: string;
14
- };
15
- };
16
- }): Promise<RevealUIQueryResult>;
17
- update(arg0: {
18
- collection: string;
19
- id: string | number;
20
- data: {
21
- priceJSON: string;
22
- skipSync: boolean;
23
- name: string;
24
- description: string | null;
25
- };
26
- }): Promise<unknown>;
27
- logger: {
28
- info: (message: string) => void;
29
- error: (message: string) => void;
30
- };
31
- }
32
- export type StripeWebhookHandler<T> = (args: {
33
- event: Stripe.Event & T;
34
- revealui: RevealUIInstance;
35
- stripe: Stripe;
36
- }) => Promise<void>;
37
- export declare const updateProduct: StripeWebhookHandler<{
38
- data: {
39
- object: Stripe.Product;
40
- };
41
- }>;
42
- export declare function POST(req: VercelRequest, res: VercelResponse): Promise<void>;
43
- export {};
44
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts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/C,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC;KACxB,CAAC;CACH,CA8EA,CAAC;AAQF,wBAAsB,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBjF"}
@@ -1,85 +0,0 @@
1
- // api/update-product.ts
2
- import { logger } from '@revealui/core/utils/logger';
3
- const logs = false;
4
- export const updateProduct = async (args) => {
5
- const { event, revealui, stripe } = args;
6
- const { id: stripeProductID, name: stripeProductName, description: stripeDescription, } = event.data.object;
7
- if (logs)
8
- revealui.logger.info(`Syncing Stripe product with ID: ${stripeProductID} to RevealUI...
9
- Product name: ${stripeProductName}
10
- Product description: ${stripeDescription}`);
11
- let revealuiProductID;
12
- // First lookup the product in RevealUI
13
- try {
14
- if (logs)
15
- revealui.logger.info(`- Looking up existing RevealUI product...`);
16
- const productQuery = await revealui.find({
17
- collection: 'products',
18
- where: {
19
- stripeProductID: {
20
- equals: stripeProductID,
21
- },
22
- },
23
- });
24
- revealuiProductID = productQuery.docs?.[0]?.id;
25
- if (revealuiProductID) {
26
- if (logs)
27
- revealui.logger.info(`- Found existing product with Stripe ID: ${stripeProductID}, syncing now...`);
28
- }
29
- }
30
- catch (error) {
31
- const message = error instanceof Error ? error.message : 'Unknown error';
32
- revealui.logger.error(`Error finding product ${message}`);
33
- }
34
- let prices;
35
- try {
36
- if (logs)
37
- revealui.logger.info(`- Looking up all prices associated with this product...`);
38
- // Find all stripe prices that are assigned to "revealuiProductID"
39
- prices = await stripe.prices.list({
40
- product: stripeProductID,
41
- limit: 100,
42
- });
43
- }
44
- catch (error) {
45
- const errorMessage = error instanceof Error ? error.message : String(error);
46
- revealui.logger.error(`- Error looking up prices: ${errorMessage}`);
47
- }
48
- try {
49
- if (logs)
50
- revealui.logger.info(`- Updating document...`);
51
- await revealui.update({
52
- collection: 'products',
53
- id: revealuiProductID || '',
54
- data: {
55
- name: stripeProductName,
56
- description: stripeDescription,
57
- priceJSON: JSON.stringify(prices || { data: [], has_more: false }),
58
- skipSync: true,
59
- },
60
- });
61
- if (logs)
62
- revealui.logger.info(`✅ Successfully updated product.`);
63
- }
64
- catch (error) {
65
- const errorMessage = error instanceof Error ? error.message : String(error);
66
- revealui.logger.error(`- Error updating product: ${errorMessage}`);
67
- }
68
- };
69
- export async function POST(req, res) {
70
- if (req.method !== 'POST') {
71
- res.status(405).send('Method Not Allowed');
72
- return;
73
- }
74
- const { event, revealui, stripe } = req.body;
75
- try {
76
- await updateProduct({ event, revealui, stripe });
77
- res.status(200).send('Product updated successfully');
78
- }
79
- catch (error) {
80
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
81
- logger.error('Error updating product', { error: errorMessage });
82
- res.status(500).send('Internal Server Error');
83
- }
84
- }
85
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/update-product/index.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAIrD,MAAM,IAAI,GAAG,KAAK,CAAC;AAiCnB,MAAM,CAAC,MAAM,aAAa,GAIrB,KAAK,EAAE,IAAI,EAAE,EAAE;IAClB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAEzC,MAAM,EACJ,EAAE,EAAE,eAAe,EACnB,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,iBAAiB,GAC/B,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;IAEtB,IAAI,IAAI;QACN,QAAQ,CAAC,MAAM,CAAC,IAAI,CAClB,mCAAmC,eAAe;sBAClC,iBAAiB;6BACV,iBAAiB,EAAE,CAC3C,CAAC;IAEJ,IAAI,iBAA8C,CAAC;IAEnD,uCAAuC;IACvC,IAAI,CAAC;QACH,IAAI,IAAI;YAAE,QAAQ,CAAC,MAAM,CAAC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C;IACvD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QAC9E,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;QAChE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
@@ -1,34 +0,0 @@
1
- /**
2
- * API Utilities - Re-exports from focused handler modules
3
- *
4
- * This file preserves backward compatibility. New code should import
5
- * directly from the focused modules in ./handlers/ instead.
6
- *
7
- * @see ./handlers/subscription-handlers.ts
8
- * @see ./handlers/invoice-handlers.ts
9
- * @see ./handlers/product-handlers.ts
10
- * @see ./handlers/customer-handlers.ts
11
- * @see ./handlers/payment-handlers.ts
12
- * @see ./handlers/payment-intent.ts
13
- */
14
- import type { IncomingMessage, ServerResponse } from 'node:http';
15
- import { createServerClient } from '../supabase/index.js';
16
- interface Context {
17
- req: IncomingMessage;
18
- res: ServerResponse;
19
- }
20
- export declare function createClient(context: Context): ReturnType<typeof createServerClient>;
21
- export declare const getURL: () => string;
22
- export { copyBillingDetailsToCustomer, createOrRetrieveCustomer, createPaymentIntent, handleCheckoutSessionCompleted, handleCustomerCreated, handleCustomerSubscriptionCreated, handleCustomerSubscriptionDeleted, handleCustomerSubscriptionUpdated, handleCustomerUpdated, handleInvoicePaymentFailed, handleInvoicePaymentSucceeded, handlePaymentMethodAttached, handlePaymentMethodCreated, handlePaymentMethodDetached, handlePaymentMethodUpdated, handleSetupIntentFailed, handleSetupIntentSucceeded, handleSupabaseError, manageSubscriptionStatusChange, toDateTime, upsertPriceRecord, upsertProductRecord, upsertRecord, } from './handlers/index.js';
23
- import type { RevealRequest } from '@revealui/core';
24
- interface CreateStripeCustomerParams {
25
- req: RevealRequest;
26
- data: {
27
- email?: string;
28
- stripeCustomerID?: string;
29
- [key: string]: unknown;
30
- };
31
- operation: string;
32
- }
33
- export declare const createStripeCustomer: ({ req, data, operation, }: CreateStripeCustomerParams) => Promise<typeof data>;
34
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/api/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,UAAU,OAAO;IACf,GAAG,EAAE,eAAe,CAAC;IACrB,GAAG,EAAE,cAAc,CAAC;CACrB;AACD,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAEpF;AAED,eAAO,MAAM,MAAM,QAAO,MAOzB,CAAC;AAGF,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,mBAAmB,EACnB,8BAA8B,EAC9B,qBAAqB,EACrB,iCAAiC,EACjC,iCAAiC,EACjC,iCAAiC,EACjC,qBAAqB,EACrB,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,8BAA8B,EAC9B,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,GACb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD,UAAU,0BAA0B;IAClC,GAAG,EAAE,aAAa,CAAC;IACnB,IAAI,EAAE;QACJ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,oBAAoB,GAAU,2BAIxC,0BAA0B,KAAG,OAAO,CAAC,OAAO,IAAI,CAmClD,CAAC"}
package/dist/api/utils.js DELETED
@@ -1,66 +0,0 @@
1
- /**
2
- * API Utilities - Re-exports from focused handler modules
3
- *
4
- * This file preserves backward compatibility. New code should import
5
- * directly from the focused modules in ./handlers/ instead.
6
- *
7
- * @see ./handlers/subscription-handlers.ts
8
- * @see ./handlers/invoice-handlers.ts
9
- * @see ./handlers/product-handlers.ts
10
- * @see ./handlers/customer-handlers.ts
11
- * @see ./handlers/payment-handlers.ts
12
- * @see ./handlers/payment-intent.ts
13
- */
14
- import path from 'node:path';
15
- import { fileURLToPath } from 'node:url';
16
- import { createServerClient } from '../supabase/index.js';
17
- export function createClient(context) {
18
- return createServerClient(context);
19
- }
20
- export const getURL = () => {
21
- const filename = fileURLToPath(import.meta.url);
22
- const dirname = path.dirname(filename);
23
- let url = path.resolve(dirname);
24
- url = url.includes('http') ? url : `https://${url}`;
25
- url = url.charAt(url.length - 1) === '/' ? url : `${url}/`;
26
- return url;
27
- };
28
- // Re-export all handlers for backward compatibility
29
- export { copyBillingDetailsToCustomer, createOrRetrieveCustomer, createPaymentIntent, handleCheckoutSessionCompleted, handleCustomerCreated, handleCustomerSubscriptionCreated, handleCustomerSubscriptionDeleted, handleCustomerSubscriptionUpdated, handleCustomerUpdated, handleInvoicePaymentFailed, handleInvoicePaymentSucceeded, handlePaymentMethodAttached, handlePaymentMethodCreated, handlePaymentMethodDetached, handlePaymentMethodUpdated, handleSetupIntentFailed, handleSetupIntentSucceeded, handleSupabaseError, manageSubscriptionStatusChange, toDateTime, upsertPriceRecord, upsertProductRecord, upsertRecord, } from './handlers/index.js';
30
- import { logger } from '@revealui/core/utils/logger';
31
- import { protectedStripe } from '../stripe/stripeClient.js';
32
- export const createStripeCustomer = async ({ req, data, operation, }) => {
33
- const revealuiInstance = req.revealui;
34
- if (operation === 'create' && !data.stripeCustomerID && typeof data.email === 'string') {
35
- try {
36
- const existingCustomer = await protectedStripe.customers.list({
37
- email: data.email,
38
- limit: 1,
39
- });
40
- if (existingCustomer.data.length > 0 && existingCustomer.data[0]) {
41
- return {
42
- ...data,
43
- stripeCustomerID: existingCustomer.data[0].id,
44
- };
45
- }
46
- const customer = await protectedStripe.customers.create({
47
- email: data.email,
48
- });
49
- return {
50
- ...data,
51
- stripeCustomerID: customer.id,
52
- };
53
- }
54
- catch (err) {
55
- const errorMessage = err instanceof Error ? err.message : String(err);
56
- if (revealuiInstance?.logger) {
57
- revealuiInstance.logger.error(`Error creating Stripe customer: ${errorMessage}`);
58
- }
59
- else {
60
- logger.error('Error creating Stripe customer', { error: errorMessage });
61
- }
62
- }
63
- }
64
- return data;
65
- };
66
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/api/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAM1D,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE;IACjC,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,C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AAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjE,OAAO;oBACL,GAAG,IAAI;oBACP,gBAAgB,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;iBAC9C,CAAC;YACJ,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC;gBACtD,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAC,CAAC;YAEH,OAAO;gBACL,GAAG,IAAI;gBACP,gBAAgB,EAAE,QAAQ,CAAC,EAAE;aAC9B,CAAC;QACJ,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,MAAM,YAAY,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACtE,IAAI,gBAAgB,EAAE,MAAM,EAAE,CAAC;gBAC7B,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,YAAY,EAAE,CAAC,CAAC;YACnF,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- /**
2
- * @deprecated This Supabase-based webhook handler is legacy code.
3
- *
4
- * The production webhook handler is in apps/api/src/routes/webhooks.ts,
5
- * which uses NeonDB (Drizzle ORM) directly and handles all subscription
6
- * lifecycle events including disputes, refunds, and payment recovery.
7
- *
8
- * This file is retained for backward compatibility with any external
9
- * consumers of @revealui/services, but is NOT used by the API app.
10
- */
11
- export declare function POST(request: Request): Promise<Response>;
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/webhooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA+EH,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkN9D"}