@donotdev/functions 0.1.42 → 0.2.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.
- package/README.md +25 -14
- package/lib/chunks/chunk-2JL3GDTO.js +151 -0
- package/lib/chunks/chunk-2JL3GDTO.js.map +7 -0
- package/lib/chunks/chunk-4TVLH2W2.js +22 -0
- package/lib/chunks/chunk-4TVLH2W2.js.map +7 -0
- package/lib/chunks/chunk-4U7QQWYG.js +22 -0
- package/lib/chunks/chunk-4U7QQWYG.js.map +7 -0
- package/lib/chunks/chunk-5DTPEM64.js +22 -0
- package/lib/chunks/chunk-5DTPEM64.js.map +7 -0
- package/lib/chunks/chunk-6CQXHNVL.js +22 -0
- package/lib/chunks/chunk-6CQXHNVL.js.map +7 -0
- package/lib/chunks/chunk-6DSCPZC6.js +22 -0
- package/lib/chunks/chunk-6DSCPZC6.js.map +7 -0
- package/lib/chunks/chunk-7E6TGWHU.js +22 -0
- package/lib/chunks/chunk-7E6TGWHU.js.map +7 -0
- package/lib/chunks/chunk-7LT32OWE.js +22 -0
- package/lib/chunks/chunk-7LT32OWE.js.map +7 -0
- package/lib/chunks/chunk-7VH2GJXT.js +151 -0
- package/lib/chunks/chunk-7VH2GJXT.js.map +7 -0
- package/lib/chunks/chunk-API5A4BV.js +22 -0
- package/lib/chunks/chunk-API5A4BV.js.map +7 -0
- package/lib/chunks/chunk-AYY7UXNI.js +22 -0
- package/lib/chunks/chunk-AYY7UXNI.js.map +7 -0
- package/lib/chunks/chunk-BUP7SXPV.js +23 -0
- package/lib/chunks/chunk-BUP7SXPV.js.map +7 -0
- package/lib/chunks/chunk-BXKRI3JJ.js +22 -0
- package/lib/chunks/chunk-BXKRI3JJ.js.map +7 -0
- package/lib/chunks/chunk-FSLGZD7A.js +21 -0
- package/lib/chunks/chunk-FSLGZD7A.js.map +7 -0
- package/lib/chunks/chunk-GVLSPWDD.js +151 -0
- package/lib/chunks/chunk-GVLSPWDD.js.map +7 -0
- package/lib/chunks/chunk-GXQVWEFT.js +22 -0
- package/lib/chunks/chunk-GXQVWEFT.js.map +7 -0
- package/lib/chunks/chunk-HB7EGXVI.js +22 -0
- package/lib/chunks/chunk-HB7EGXVI.js.map +7 -0
- package/lib/chunks/chunk-HLNYUAZH.js +22 -0
- package/lib/chunks/chunk-HLNYUAZH.js.map +7 -0
- package/lib/chunks/chunk-HM7XCMWW.js +22 -0
- package/lib/chunks/chunk-HM7XCMWW.js.map +7 -0
- package/lib/chunks/chunk-I7IOIL6U.js +151 -0
- package/lib/chunks/chunk-I7IOIL6U.js.map +7 -0
- package/lib/chunks/chunk-IFOYVSPU.js +22 -0
- package/lib/chunks/chunk-IFOYVSPU.js.map +7 -0
- package/lib/chunks/chunk-JTAGPPPL.js +22 -0
- package/lib/chunks/chunk-JTAGPPPL.js.map +7 -0
- package/lib/chunks/chunk-MZ232FUE.js +22 -0
- package/lib/chunks/chunk-MZ232FUE.js.map +7 -0
- package/lib/chunks/chunk-NE5ZTUUZ.js +22 -0
- package/lib/chunks/chunk-NE5ZTUUZ.js.map +7 -0
- package/lib/chunks/chunk-NP2AN2TV.js +22 -0
- package/lib/chunks/chunk-NP2AN2TV.js.map +7 -0
- package/lib/chunks/chunk-QJAU2MWV.js +22 -0
- package/lib/chunks/chunk-QJAU2MWV.js.map +7 -0
- package/lib/chunks/chunk-RM7DV6IQ.js +23 -0
- package/lib/chunks/chunk-RM7DV6IQ.js.map +7 -0
- package/lib/chunks/chunk-RQZGIZHD.js +151 -0
- package/lib/chunks/chunk-RQZGIZHD.js.map +7 -0
- package/lib/chunks/chunk-TBEDQLOB.js +23 -0
- package/lib/chunks/chunk-TBEDQLOB.js.map +7 -0
- package/lib/chunks/chunk-TMHBP3HB.js +22 -0
- package/lib/chunks/chunk-TMHBP3HB.js.map +7 -0
- package/lib/chunks/chunk-UH4L3EF3.js +151 -0
- package/lib/chunks/chunk-UH4L3EF3.js.map +7 -0
- package/lib/chunks/chunk-UJBIU6TL.js +22 -0
- package/lib/chunks/chunk-UJBIU6TL.js.map +7 -0
- package/lib/chunks/chunk-VKEYW3NT.js +22 -0
- package/lib/chunks/chunk-VKEYW3NT.js.map +7 -0
- package/lib/chunks/chunk-XGXBMXJ6.js +22 -0
- package/lib/chunks/chunk-XGXBMXJ6.js.map +7 -0
- package/lib/chunks/chunk-Y44NEQQG.js +22 -0
- package/lib/chunks/chunk-Y44NEQQG.js.map +7 -0
- package/lib/chunks/chunk-ZVU3KPXI.js +22 -0
- package/lib/chunks/chunk-ZVU3KPXI.js.map +7 -0
- package/lib/chunks/monitoring-AGCSU3FI.js +22 -0
- package/lib/chunks/monitoring-AGCSU3FI.js.map +7 -0
- package/lib/chunks/monitoring-PVQMFL34.js +22 -0
- package/lib/chunks/monitoring-PVQMFL34.js.map +7 -0
- package/lib/chunks/monitoring-V7FZXTTW.js +22 -0
- package/lib/chunks/monitoring-V7FZXTTW.js.map +7 -0
- package/lib/chunks/rateLimiter-6KO7AIZP.js +22 -0
- package/lib/chunks/rateLimiter-6KO7AIZP.js.map +7 -0
- package/lib/chunks/rateLimiter-OXVBFW5C.js +22 -0
- package/lib/chunks/rateLimiter-OXVBFW5C.js.map +7 -0
- package/lib/chunks/rateLimiter-U45OMTWR.js +22 -0
- package/lib/chunks/rateLimiter-U45OMTWR.js.map +7 -0
- package/lib/chunks/server-32A5RH4C.js +22 -0
- package/lib/chunks/server-32A5RH4C.js.map +7 -0
- package/lib/chunks/server-7HDAP5DL.js +22 -0
- package/lib/chunks/server-7HDAP5DL.js.map +7 -0
- package/lib/chunks/server-S2IMFOY7.js +22 -0
- package/lib/chunks/server-S2IMFOY7.js.map +7 -0
- package/lib/firebase/auth/getCustomClaims.d.ts +1 -1
- package/lib/firebase/auth/getUserAuthStatus.d.ts +1 -1
- package/lib/firebase/auth/removeCustomClaims.d.ts +1 -1
- package/lib/firebase/auth/setCustomClaims.d.ts +1 -1
- package/lib/firebase/baseFunction.d.ts +1 -1
- package/lib/firebase/billing/createCheckoutSession.d.ts +2 -2
- package/lib/firebase/billing/createCustomerPortal.d.ts +1 -1
- package/lib/firebase/billing/index.d.ts +2 -1
- package/lib/firebase/billing/refreshSubscriptionStatus.d.ts +0 -8
- package/lib/firebase/billing/webhookHandler.d.ts +17 -2
- package/lib/firebase/crud/aggregate.d.ts +0 -9
- package/lib/firebase/crud/bulk.d.ts +2 -2
- package/lib/firebase/crud/create.d.ts +1 -1
- package/lib/firebase/crud/delete.d.ts +1 -1
- package/lib/firebase/crud/get.d.ts +1 -1
- package/lib/firebase/crud/list.d.ts +1 -1
- package/lib/firebase/crud/update.d.ts +1 -9
- package/lib/firebase/index.js +1 -5
- package/lib/firebase/index.js.map +4 -4
- package/lib/firebase/oauth/githubAccess.d.ts +2 -2
- package/lib/firebase/registerCrudFunctions.d.ts +9 -1
- package/lib/shared/billing/apiVersion.d.ts +22 -0
- package/lib/shared/billing/checkoutPrice.d.ts +27 -0
- package/lib/shared/billing/checkoutValidation.d.ts +89 -0
- package/lib/shared/billing/createCheckout.d.ts +73 -24
- package/lib/shared/billing/helpers/index.d.ts +0 -1
- package/lib/shared/billing/helpers/subscriptionManagement.d.ts +4 -4
- package/lib/shared/billing/helpers/updateUserSubscription.d.ts +2 -29
- package/lib/shared/billing/idempotency.d.ts +32 -10
- package/lib/shared/billing/idempotencyContract.d.ts +121 -0
- package/lib/shared/billing/index.d.ts +2 -0
- package/lib/shared/billing/orderWebhook.d.ts +75 -0
- package/lib/shared/billing/supabaseIdempotency.d.ts +32 -0
- package/lib/shared/billing/tierWebhookEvents.d.ts +54 -0
- package/lib/shared/billing/webhookHandler.d.ts +28 -20
- package/lib/shared/index.js +1 -6
- package/lib/shared/index.js.map +4 -4
- package/lib/shared/utils/functionWrapper.d.ts +1 -1
- package/lib/shared/utils/internal/auth.d.ts +38 -1
- package/lib/shared/utils/internal/rateLimiter.d.ts +8 -0
- package/lib/shared/utils/schemaValidation.d.ts +1 -1
- package/lib/shared/utils/vercelHelpers.d.ts +8 -0
- package/lib/shared/utils.d.ts +4 -17
- package/lib/supabase/baseFunction.d.ts +1 -1
- package/lib/supabase/billing/stripeWebhook.d.ts +34 -0
- package/lib/supabase/crud/bulk.d.ts +1 -1
- package/lib/supabase/crud/entityStore.d.ts +71 -0
- package/lib/supabase/crud/index.d.ts +2 -0
- package/lib/supabase/helpers/authProvider.d.ts +5 -5
- package/lib/supabase/index.d.ts +10 -2
- package/lib/supabase/index.js +1 -3
- package/lib/supabase/index.js.map +4 -4
- package/lib/supabase/utils/rateLimiter.d.ts +1 -1
- package/lib/vercel/api/ai/chat.d.ts +0 -9
- package/lib/vercel/api/auth/get-custom-claims.d.ts +8 -0
- package/lib/vercel/api/auth/get-user-auth-status.d.ts +8 -0
- package/lib/vercel/api/auth/remove-custom-claims.d.ts +8 -0
- package/lib/vercel/api/auth/set-custom-claims.d.ts +8 -0
- package/lib/vercel/api/billing/backend.d.ts +39 -0
- package/lib/vercel/api/billing/cancel.d.ts +8 -0
- package/lib/vercel/api/billing/change-plan.d.ts +9 -1
- package/lib/vercel/api/billing/create-checkout-session.d.ts +25 -6
- package/lib/vercel/api/billing/customer-portal.d.ts +8 -0
- package/lib/vercel/api/billing/index.d.ts +4 -2
- package/lib/vercel/api/billing/refresh-subscription-status.d.ts +19 -3
- package/lib/vercel/api/billing/webhook-handler.d.ts +25 -4
- package/lib/vercel/api/config/firebase-admin.d.ts +8 -0
- package/lib/vercel/api/crud/bulk.d.ts +17 -0
- package/lib/vercel/api/crud/create.d.ts +8 -0
- package/lib/vercel/api/crud/delete.d.ts +8 -0
- package/lib/vercel/api/crud/get.d.ts +8 -0
- package/lib/vercel/api/crud/list.d.ts +8 -0
- package/lib/vercel/api/crud/update.d.ts +8 -0
- package/lib/vercel/api/index.js +1 -3
- package/lib/vercel/api/index.js.map +4 -4
- package/lib/vercel/api/oauth/check-github-access.d.ts +8 -0
- package/lib/vercel/api/oauth/exchange-token.d.ts +8 -0
- package/lib/vercel/api/oauth/grant-github-access.d.ts +8 -0
- package/lib/vercel/api/oauth/revoke-github-access.d.ts +1 -1
- package/lib/vercel/baseFunction.d.ts +4 -1
- package/lib/vercel/supabaseAdmin.d.ts +22 -0
- package/package.json +25 -26
- package/src/firebase/auth/getCustomClaims.ts +4 -5
- package/src/firebase/auth/getUserAuthStatus.ts +4 -5
- package/src/firebase/auth/removeCustomClaims.ts +4 -5
- package/src/firebase/auth/setCustomClaims.ts +4 -5
- package/src/firebase/baseFunction.ts +4 -5
- package/src/firebase/billing/cancelSubscription.ts +1 -2
- package/src/firebase/billing/changePlan.ts +2 -3
- package/src/firebase/billing/createCheckoutSession.ts +30 -56
- package/src/firebase/billing/createCustomerPortal.ts +4 -5
- package/src/firebase/billing/healthCheck.ts +0 -0
- package/src/firebase/billing/index.ts +8 -1
- package/src/firebase/billing/refreshSubscriptionStatus.ts +2 -3
- package/src/firebase/billing/webhookHandler.ts +20 -4
- package/src/firebase/crud/__tests__/bulk.test.ts +11 -1
- package/src/firebase/crud/aggregate.ts +1 -2
- package/src/firebase/crud/bulk.ts +5 -6
- package/src/firebase/crud/create.ts +5 -6
- package/src/firebase/crud/delete.ts +4 -5
- package/src/firebase/crud/get.ts +4 -5
- package/src/firebase/crud/list.ts +4 -5
- package/src/firebase/crud/update.ts +5 -6
- package/src/firebase/oauth/githubAccess.ts +2 -3
- package/src/firebase/registerCrudFunctions.ts +2 -2
- package/src/shared/__tests__/auth.test.ts +0 -3
- package/src/shared/__tests__/bulkCore.test.ts +3 -2
- package/src/shared/__tests__/errorHandling.test.ts +2 -2
- package/src/shared/__tests__/idempotency.test.ts +282 -55
- package/src/shared/__tests__/internalValidation.test.ts +3 -3
- package/src/shared/__tests__/rateLimiter.test.ts +2 -8
- package/src/shared/__tests__/schemaValidation.test.ts +1 -1
- package/src/shared/__tests__/utils.test.ts +2 -1
- package/src/shared/__tests__/validation-env.test.ts +0 -0
- package/src/shared/ai/createAIRoute.ts +53 -30
- package/src/shared/billing/__tests__/checkoutValidation.test.ts +219 -0
- package/src/shared/billing/__tests__/createCheckout.compat.test.ts +349 -0
- package/src/shared/billing/__tests__/createCheckout.test.ts +454 -411
- package/src/shared/billing/__tests__/firestoreIdempotency.emulator.test.ts +92 -0
- package/src/shared/billing/__tests__/webhookCorrectness.test.ts +387 -0
- package/src/shared/billing/__tests__/webhookHandler.test.ts +407 -23
- package/src/shared/billing/apiVersion.ts +25 -0
- package/src/shared/billing/checkoutPrice.ts +125 -0
- package/src/shared/billing/checkoutValidation.ts +284 -0
- package/src/shared/billing/createCheckout.ts +332 -196
- package/src/shared/billing/helpers/index.ts +0 -1
- package/src/shared/billing/helpers/subscriptionManagement.ts +7 -9
- package/src/shared/billing/helpers/updateUserSubscription.ts +3 -36
- package/src/shared/billing/idempotency.ts +253 -150
- package/src/shared/billing/idempotencyContract.ts +135 -0
- package/src/shared/billing/index.ts +2 -0
- package/src/shared/billing/orderWebhook.ts +269 -0
- package/src/shared/billing/supabaseIdempotency.ts +228 -0
- package/src/shared/billing/tierWebhookEvents.ts +432 -0
- package/src/shared/billing/webhookHandler.ts +188 -385
- package/src/shared/utils/external/subscription.ts +0 -0
- package/src/shared/utils/firebaseHelpers.ts +2 -3
- package/src/shared/utils/functionWrapper.ts +1 -2
- package/src/shared/utils/internal/auth.ts +55 -7
- package/src/shared/utils/internal/monitoring.ts +17 -9
- package/src/shared/utils/internal/rateLimiter.ts +14 -5
- package/src/shared/utils/schemaValidation.ts +1 -2
- package/src/shared/utils/vercelHelpers.ts +3 -3
- package/src/shared/utils.ts +14 -31
- package/src/shared/validation.ts +1 -1
- package/src/supabase/__tests__/bulk.test.ts +3 -1
- package/src/supabase/__tests__/entityStore.test.ts +90 -0
- package/src/supabase/baseFunction.ts +1 -2
- package/src/supabase/billing/createCheckoutSession.ts +10 -36
- package/src/supabase/billing/refreshSubscriptionStatus.ts +1 -2
- package/src/supabase/billing/stripeWebhook.ts +79 -0
- package/src/supabase/crud/aggregate.ts +1 -1
- package/src/supabase/crud/bulk.ts +3 -7
- package/src/supabase/crud/create.ts +1 -1
- package/src/supabase/crud/entityStore.ts +240 -0
- package/src/supabase/crud/index.ts +8 -0
- package/src/supabase/crud/update.ts +1 -1
- package/src/supabase/helpers/authProvider.ts +6 -5
- package/src/supabase/index.ts +26 -0
- package/src/supabase/utils/rateLimiter.ts +2 -2
- package/src/vercel/__tests__/bulk.test.ts +24 -21
- package/src/vercel/__tests__/firebaseOptional.test.ts +64 -0
- package/src/vercel/api/ai/chat.ts +2 -1
- package/src/vercel/api/auth/get-custom-claims.ts +2 -3
- package/src/vercel/api/auth/get-user-auth-status.ts +2 -3
- package/src/vercel/api/auth/remove-custom-claims.ts +2 -3
- package/src/vercel/api/auth/set-custom-claims.ts +3 -3
- package/src/vercel/api/billing/backend.ts +72 -0
- package/src/vercel/api/billing/cancel.ts +2 -4
- package/src/vercel/api/billing/change-plan.ts +3 -4
- package/src/vercel/api/billing/create-checkout-session.ts +42 -68
- package/src/vercel/api/billing/customer-portal.ts +2 -4
- package/src/vercel/api/billing/index.ts +4 -2
- package/src/vercel/api/billing/refresh-subscription-status.ts +21 -6
- package/src/vercel/api/billing/webhook-handler.ts +31 -25
- package/src/vercel/api/config/firebase-admin.ts +2 -2
- package/src/vercel/api/crud/bulk.ts +6 -9
- package/src/vercel/api/crud/create.ts +6 -5
- package/src/vercel/api/crud/delete.ts +4 -3
- package/src/vercel/api/crud/get.ts +6 -5
- package/src/vercel/api/crud/list.ts +6 -5
- package/src/vercel/api/crud/update.ts +6 -5
- package/src/vercel/api/oauth/check-github-access.ts +5 -5
- package/src/vercel/api/oauth/exchange-token.ts +3 -3
- package/src/vercel/api/oauth/grant-github-access.ts +5 -5
- package/src/vercel/api/oauth/revoke-github-access.ts +3 -4
- package/src/vercel/baseFunction.ts +23 -8
- package/src/vercel/supabaseAdmin.ts +45 -0
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Check GitHub access API handler
|
|
3
|
+
* @description Vercel API route for checking GitHub access status
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
1
9
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
2
10
|
import type * as v from 'valibot';
|
|
3
11
|
/**
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview OAuth token exchange API route
|
|
3
|
+
* @description Vercel API route for exchanging OAuth codes for tokens
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
1
9
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
2
10
|
import type * as v from 'valibot';
|
|
3
11
|
/**
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Grant GitHub access API handler
|
|
3
|
+
* @description Vercel API route for granting GitHub access
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
1
9
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
2
10
|
import type * as v from 'valibot';
|
|
3
11
|
/**
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* @since 0.0.1
|
|
7
7
|
* @author AMBROISE PARK Consulting
|
|
8
8
|
*/
|
|
9
|
-
import * as v from 'valibot';
|
|
10
9
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
10
|
+
import * as v from 'valibot';
|
|
11
11
|
export default function handler(req: NextApiRequest, res: NextApiResponse, customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>): Promise<void>;
|
|
@@ -6,14 +6,17 @@
|
|
|
6
6
|
* @since 0.0.1
|
|
7
7
|
* @author AMBROISE PARK Consulting
|
|
8
8
|
*/
|
|
9
|
+
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
9
10
|
import * as v from 'valibot';
|
|
10
11
|
import type { SecurityContext } from '@donotdev/core';
|
|
11
12
|
import type { AuthProvider } from '../shared/utils/internal/auth.js';
|
|
12
|
-
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
13
13
|
/**
|
|
14
14
|
* Base Vercel function that handles all common concerns
|
|
15
15
|
* Users just provide their business logic
|
|
16
16
|
*
|
|
17
|
+
* @throws DoNotDevError (`invalid-argument`) at construction when `provider` is
|
|
18
|
+
* neither `'firebase'` nor `'supabase'`
|
|
19
|
+
*
|
|
17
20
|
* @version 0.1.0
|
|
18
21
|
* @since 0.0.1
|
|
19
22
|
* @author AMBROISE PARK Consulting
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Supabase admin client for Vercel functions
|
|
3
|
+
* @description Lazily created service-role client for Vercel functions backed by
|
|
4
|
+
* Supabase. `@supabase/supabase-js` is imported on first use only, so
|
|
5
|
+
* Firebase-backed deployments never load it.
|
|
6
|
+
*
|
|
7
|
+
* @version 0.2.0
|
|
8
|
+
* @since 0.2.0
|
|
9
|
+
* @author AMBROISE PARK Consulting
|
|
10
|
+
*/
|
|
11
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
12
|
+
/**
|
|
13
|
+
* Get the service-role Supabase client (`SUPABASE_URL` + `SUPABASE_SECRET_KEY`
|
|
14
|
+
* or the legacy `SUPABASE_SERVICE_ROLE_KEY`).
|
|
15
|
+
*
|
|
16
|
+
* @throws When the environment variables are missing
|
|
17
|
+
*
|
|
18
|
+
* @version 0.2.0
|
|
19
|
+
* @since 0.2.0
|
|
20
|
+
* @author AMBROISE PARK Consulting
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSupabaseAdmin(): Promise<SupabaseClient>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/functions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Backend functions for DoNotDev Framework - Firebase, Vercel, and platform-agnostic implementations for auth, billing, CRUD, and OAuth",
|
|
6
6
|
"main": "./lib/firebase/index.js",
|
|
@@ -53,24 +53,23 @@
|
|
|
53
53
|
"serve": "firebase emulators:start --only functions"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@donotdev/core": "^0.
|
|
57
|
-
"@donotdev/
|
|
58
|
-
"@donotdev/supabase": "^0.1.42"
|
|
56
|
+
"@donotdev/core": "^0.2.0",
|
|
57
|
+
"@donotdev/supabase": "^0.2.0"
|
|
59
58
|
},
|
|
60
59
|
"peerDependencies": {
|
|
61
|
-
"@ai-sdk/anthropic": "^
|
|
62
|
-
"@ai-sdk/google": "^
|
|
63
|
-
"@ai-sdk/openai": "^
|
|
64
|
-
"@sentry/node": "^10.
|
|
65
|
-
"@supabase/supabase-js": "^2.
|
|
66
|
-
"ai": "^4.3.0",
|
|
67
|
-
"firebase-admin": "^13.6.1",
|
|
68
|
-
"firebase-functions": "^7.0.5",
|
|
69
|
-
"next": "^16.1.6",
|
|
70
|
-
"stripe": "^20.3.1",
|
|
71
|
-
"valibot": "^1.2.0",
|
|
60
|
+
"@ai-sdk/anthropic": "^4.0.99",
|
|
61
|
+
"@ai-sdk/google": "^4.0.114",
|
|
62
|
+
"@ai-sdk/openai": "^4.0.111",
|
|
63
|
+
"@sentry/node": "^10.78.0",
|
|
64
|
+
"@supabase/supabase-js": "^2.119.0",
|
|
72
65
|
"@upstash/ratelimit": "^2.0.8",
|
|
73
|
-
"@upstash/redis": "^1.37.0"
|
|
66
|
+
"@upstash/redis": "^1.37.0",
|
|
67
|
+
"ai": "^7.0.165",
|
|
68
|
+
"firebase-admin": "^14.5.0",
|
|
69
|
+
"firebase-functions": "^7.4.0",
|
|
70
|
+
"next": "^16.4.5",
|
|
71
|
+
"stripe": "^20.4.1",
|
|
72
|
+
"valibot": "^1.5.0"
|
|
74
73
|
},
|
|
75
74
|
"repository": {
|
|
76
75
|
"type": "git",
|
|
@@ -106,32 +105,32 @@
|
|
|
106
105
|
"@ai-sdk/openai": {
|
|
107
106
|
"optional": true
|
|
108
107
|
},
|
|
109
|
-
"ai": {
|
|
110
|
-
"optional": true
|
|
111
|
-
},
|
|
112
108
|
"@sentry/node": {
|
|
113
109
|
"optional": true
|
|
114
110
|
},
|
|
115
111
|
"@supabase/supabase-js": {
|
|
116
112
|
"optional": true
|
|
117
113
|
},
|
|
118
|
-
"
|
|
114
|
+
"@upstash/ratelimit": {
|
|
119
115
|
"optional": true
|
|
120
116
|
},
|
|
121
|
-
"
|
|
117
|
+
"@upstash/redis": {
|
|
122
118
|
"optional": true
|
|
123
119
|
},
|
|
124
|
-
"
|
|
120
|
+
"ai": {
|
|
125
121
|
"optional": true
|
|
126
122
|
},
|
|
127
|
-
"
|
|
123
|
+
"firebase-admin": {
|
|
128
124
|
"optional": true
|
|
129
125
|
},
|
|
130
|
-
"
|
|
126
|
+
"firebase-functions": {
|
|
131
127
|
"optional": true
|
|
132
128
|
},
|
|
133
|
-
"
|
|
129
|
+
"next": {
|
|
130
|
+
"optional": true
|
|
131
|
+
},
|
|
132
|
+
"stripe": {
|
|
134
133
|
"optional": true
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
|
-
}
|
|
136
|
+
}
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type {
|
|
13
|
+
CallableFunction,
|
|
14
|
+
CallableRequest,
|
|
15
|
+
} from 'firebase-functions/v2/https';
|
|
12
16
|
import * as v from 'valibot';
|
|
13
17
|
|
|
14
18
|
import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
|
|
@@ -16,11 +20,6 @@ import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
|
|
|
16
20
|
import { createBaseFunction } from '../baseFunction.js';
|
|
17
21
|
import { AUTH_CONFIG } from '../config/constants.js';
|
|
18
22
|
|
|
19
|
-
import type {
|
|
20
|
-
CallableFunction,
|
|
21
|
-
CallableRequest,
|
|
22
|
-
} from 'firebase-functions/v2/https';
|
|
23
|
-
|
|
24
23
|
const getCustomClaimsSchema = v.object({});
|
|
25
24
|
|
|
26
25
|
type GetCustomClaimsRequest = v.InferOutput<typeof getCustomClaimsSchema>;
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type {
|
|
13
|
+
CallableFunction,
|
|
14
|
+
CallableRequest,
|
|
15
|
+
} from 'firebase-functions/v2/https';
|
|
12
16
|
import * as v from 'valibot';
|
|
13
17
|
|
|
14
18
|
import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
|
|
@@ -16,11 +20,6 @@ import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
|
|
|
16
20
|
import { createBaseFunction } from '../baseFunction.js';
|
|
17
21
|
import { AUTH_CONFIG } from '../config/constants.js';
|
|
18
22
|
|
|
19
|
-
import type {
|
|
20
|
-
CallableFunction,
|
|
21
|
-
CallableRequest,
|
|
22
|
-
} from 'firebase-functions/v2/https';
|
|
23
|
-
|
|
24
23
|
const getUserAuthStatusSchema = v.object({});
|
|
25
24
|
|
|
26
25
|
export type GetUserAuthStatusRequest = v.InferOutput<
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type {
|
|
13
|
+
CallableFunction,
|
|
14
|
+
CallableRequest,
|
|
15
|
+
} from 'firebase-functions/v2/https';
|
|
12
16
|
import * as v from 'valibot';
|
|
13
17
|
|
|
14
18
|
import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
|
|
@@ -16,11 +20,6 @@ import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
|
|
|
16
20
|
import { createBaseFunction } from '../baseFunction.js';
|
|
17
21
|
import { AUTH_CONFIG } from '../config/constants.js';
|
|
18
22
|
|
|
19
|
-
import type {
|
|
20
|
-
CallableFunction,
|
|
21
|
-
CallableRequest,
|
|
22
|
-
} from 'firebase-functions/v2/https';
|
|
23
|
-
|
|
24
23
|
const removeCustomClaimsSchema = v.object({
|
|
25
24
|
claimsToRemove: v.pipe(
|
|
26
25
|
v.array(v.string()),
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type {
|
|
13
|
+
CallableFunction,
|
|
14
|
+
CallableRequest,
|
|
15
|
+
} from 'firebase-functions/v2/https';
|
|
12
16
|
import * as v from 'valibot';
|
|
13
17
|
|
|
14
18
|
import {
|
|
@@ -19,11 +23,6 @@ import {
|
|
|
19
23
|
import { createBaseFunction } from '../baseFunction.js';
|
|
20
24
|
import { AUTH_CONFIG } from '../config/constants.js';
|
|
21
25
|
|
|
22
|
-
import type {
|
|
23
|
-
CallableFunction,
|
|
24
|
-
CallableRequest,
|
|
25
|
-
} from 'firebase-functions/v2/https';
|
|
26
|
-
|
|
27
26
|
/**
|
|
28
27
|
* Claim keys that must NEVER be self-assignable — privilege escalation vectors.
|
|
29
28
|
*/
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
import { logger } from 'firebase-functions/v2';
|
|
13
13
|
import { onCall } from 'firebase-functions/v2/https';
|
|
14
|
+
import type {
|
|
15
|
+
CallableRequest,
|
|
16
|
+
CallableOptions,
|
|
17
|
+
} from 'firebase-functions/v2/https';
|
|
14
18
|
import * as v from 'valibot';
|
|
15
19
|
|
|
16
20
|
import type { SecurityContext } from '@donotdev/core';
|
|
@@ -21,11 +25,6 @@ import { FUNCTION_CONFIG } from './config/constants.js';
|
|
|
21
25
|
import { handleError, DoNotDevError } from '../shared/errorHandling.js';
|
|
22
26
|
import { assertAuthenticated, getUserRole } from '../shared/utils.js';
|
|
23
27
|
|
|
24
|
-
import type {
|
|
25
|
-
CallableRequest,
|
|
26
|
-
CallableOptions,
|
|
27
|
-
} from 'firebase-functions/v2/https';
|
|
28
|
-
|
|
29
28
|
// Optional monitoring imports - only used when enabled
|
|
30
29
|
// Lazy loaded to avoid unnecessary Firestore operations
|
|
31
30
|
let checkRateLimitWithFirestore:
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
12
13
|
import * as v from 'valibot';
|
|
13
14
|
|
|
14
15
|
import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
|
|
@@ -19,8 +20,6 @@ import { createBaseFunction } from '../baseFunction.js';
|
|
|
19
20
|
import { STRIPE_CONFIG } from '../config/constants.js';
|
|
20
21
|
import { stripeSecretKey } from '../config/secrets.js';
|
|
21
22
|
|
|
22
|
-
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
23
|
-
|
|
24
23
|
const cancelSubscriptionSchema = v.object({
|
|
25
24
|
userId: v.string(),
|
|
26
25
|
});
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
13
|
+
import type Stripe from 'stripe';
|
|
12
14
|
import * as v from 'valibot';
|
|
13
15
|
|
|
14
16
|
import type { StripeBackConfig } from '@donotdev/core/server';
|
|
@@ -25,9 +27,6 @@ import { createBaseFunction } from '../baseFunction.js';
|
|
|
25
27
|
import { STRIPE_CONFIG } from '../config/constants.js';
|
|
26
28
|
import { stripeSecretKey } from '../config/secrets.js';
|
|
27
29
|
|
|
28
|
-
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
29
|
-
import type Stripe from 'stripe';
|
|
30
|
-
|
|
31
30
|
const changePlanSchema = v.object({
|
|
32
31
|
userId: v.string(),
|
|
33
32
|
newPriceId: v.string(),
|
|
@@ -5,11 +5,17 @@
|
|
|
5
5
|
* @description Firebase callable function for creating Stripe checkout sessions.
|
|
6
6
|
* Delegates to shared createCheckoutAlgorithm (SSOT).
|
|
7
7
|
*
|
|
8
|
-
* @version 0.
|
|
8
|
+
* @version 0.3.0
|
|
9
9
|
* @since 0.0.1
|
|
10
10
|
* @author AMBROISE PARK Consulting
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import type {
|
|
14
|
+
CallableFunction,
|
|
15
|
+
CallableRequest,
|
|
16
|
+
} from 'firebase-functions/v2/https';
|
|
17
|
+
import type Stripe from 'stripe';
|
|
18
|
+
|
|
13
19
|
import type {
|
|
14
20
|
CreateCheckoutSessionRequest,
|
|
15
21
|
StripeBackConfig,
|
|
@@ -17,7 +23,9 @@ import type {
|
|
|
17
23
|
import { CreateCheckoutSessionRequestSchema } from '@donotdev/core/server';
|
|
18
24
|
import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
|
|
19
25
|
|
|
26
|
+
import { assertCheckoutSessionMetadata } from '../../shared/billing/checkoutValidation.js';
|
|
20
27
|
import { createCheckoutAlgorithm } from '../../shared/billing/createCheckout.js';
|
|
28
|
+
import type { StripeSessionProvider } from '../../shared/billing/createCheckout.js';
|
|
21
29
|
import {
|
|
22
30
|
initStripe,
|
|
23
31
|
stripe,
|
|
@@ -27,11 +35,6 @@ import { createBaseFunction } from '../baseFunction.js';
|
|
|
27
35
|
import { STRIPE_CONFIG } from '../config/constants.js';
|
|
28
36
|
import { stripeSecretKey } from '../config/secrets.js';
|
|
29
37
|
|
|
30
|
-
import type {
|
|
31
|
-
CallableFunction,
|
|
32
|
-
CallableRequest,
|
|
33
|
-
} from 'firebase-functions/v2/https';
|
|
34
|
-
|
|
35
38
|
/**
|
|
36
39
|
* Business logic for creating Stripe checkout session.
|
|
37
40
|
* Uses shared algorithm - same as Supabase and Vercel handlers.
|
|
@@ -48,53 +51,29 @@ async function createCheckoutSessionLogic(
|
|
|
48
51
|
initStripe(stripeSecretKey.value());
|
|
49
52
|
validateStripeEnvironment();
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
allowPromotionCodes: boolean;
|
|
61
|
-
successUrl: string;
|
|
62
|
-
cancelUrl: string;
|
|
63
|
-
mode?: 'payment' | 'subscription';
|
|
64
|
-
}) {
|
|
65
|
-
const session = await stripe.checkout.sessions.create({
|
|
66
|
-
line_items: [
|
|
67
|
-
params.priceId
|
|
68
|
-
? { price: params.priceId, quantity: 1 }
|
|
69
|
-
: {
|
|
70
|
-
price_data: {
|
|
71
|
-
currency: params.currency || 'eur',
|
|
72
|
-
unit_amount: params.unitAmount!,
|
|
73
|
-
product_data: { name: params.productName! },
|
|
74
|
-
},
|
|
75
|
-
quantity: 1,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
mode: params.mode || 'payment',
|
|
79
|
-
allow_promotion_codes: params.allowPromotionCodes,
|
|
80
|
-
success_url: params.successUrl,
|
|
81
|
-
cancel_url: params.cancelUrl,
|
|
82
|
-
customer_email: params.customerEmail,
|
|
83
|
-
metadata: {
|
|
84
|
-
...params.metadata,
|
|
85
|
-
firebaseUid: params.metadata.userId || '',
|
|
86
|
-
},
|
|
87
|
-
...(params.mode === 'subscription' && {
|
|
54
|
+
const stripeProvider: StripeSessionProvider = {
|
|
55
|
+
async createStripeSession(params) {
|
|
56
|
+
// 0.1.x Firebase sessions carry firebaseUid alongside userId
|
|
57
|
+
/** @grill-refuted Firebase-only by design (0.1.x parity); nothing reads firebaseUid, userId is the cross-provider key. */
|
|
58
|
+
const firebaseUid = context.uid;
|
|
59
|
+
const sessionParams: Stripe.Checkout.SessionCreateParams = {
|
|
60
|
+
...params,
|
|
61
|
+
metadata: { ...params.metadata, firebaseUid },
|
|
62
|
+
...(params.subscription_data && {
|
|
88
63
|
subscription_data: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
firebaseUid: params.metadata.userId || '',
|
|
92
|
-
},
|
|
64
|
+
...params.subscription_data,
|
|
65
|
+
metadata: { ...params.subscription_data.metadata, firebaseUid },
|
|
93
66
|
},
|
|
94
67
|
}),
|
|
95
|
-
}
|
|
68
|
+
};
|
|
69
|
+
assertCheckoutSessionMetadata(sessionParams);
|
|
70
|
+
const session = await stripe.checkout.sessions.create(sessionParams);
|
|
96
71
|
return { id: session.id, url: session.url };
|
|
97
72
|
},
|
|
73
|
+
async retrieveTaxRate(id) {
|
|
74
|
+
const rate = await stripe.taxRates.retrieve(id);
|
|
75
|
+
return { id: rate.id, inclusive: rate.inclusive };
|
|
76
|
+
},
|
|
98
77
|
};
|
|
99
78
|
|
|
100
79
|
// Create auth provider
|
|
@@ -105,15 +84,10 @@ async function createCheckoutSessionLogic(
|
|
|
105
84
|
},
|
|
106
85
|
};
|
|
107
86
|
|
|
108
|
-
//
|
|
109
|
-
const requestWithUserId = {
|
|
110
|
-
...data,
|
|
111
|
-
userId: context.uid,
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// Delegate to shared algorithm (SSOT)
|
|
87
|
+
// userId comes from the authenticated context, never from the client
|
|
115
88
|
return createCheckoutAlgorithm(
|
|
116
|
-
|
|
89
|
+
data,
|
|
90
|
+
context.uid,
|
|
117
91
|
stripeProvider,
|
|
118
92
|
authProvider,
|
|
119
93
|
billingConfig
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type {
|
|
13
|
+
CallableFunction,
|
|
14
|
+
CallableRequest,
|
|
15
|
+
} from 'firebase-functions/v2/https';
|
|
12
16
|
import * as v from 'valibot';
|
|
13
17
|
|
|
14
18
|
import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
|
|
@@ -23,11 +27,6 @@ import { createBaseFunction } from '../baseFunction.js';
|
|
|
23
27
|
import { STRIPE_CONFIG } from '../config/constants.js';
|
|
24
28
|
import { stripeSecretKey } from '../config/secrets.js'; // ✅ IMPORT SECRET
|
|
25
29
|
|
|
26
|
-
import type {
|
|
27
|
-
CallableFunction,
|
|
28
|
-
CallableRequest,
|
|
29
|
-
} from 'firebase-functions/v2/https';
|
|
30
|
-
|
|
31
30
|
const customerPortalSchema = v.object({
|
|
32
31
|
userId: v.string(),
|
|
33
32
|
returnUrl: v.optional(v.pipe(v.string(), v.url())),
|
|
File without changes
|
|
@@ -21,10 +21,17 @@ export { createStripeWebhook } from './webhookHandler.js';
|
|
|
21
21
|
// Helpers (via shared)
|
|
22
22
|
export * from '../../shared/billing/helpers/index.js';
|
|
23
23
|
|
|
24
|
-
//
|
|
24
|
+
// Webhook idempotency stores
|
|
25
25
|
export {
|
|
26
|
+
createFirestoreIdempotencyStore,
|
|
26
27
|
createIdempotencyStore,
|
|
27
28
|
resetIdempotencyStore,
|
|
29
|
+
ReservationLostError,
|
|
30
|
+
} from '../../shared/billing/idempotency.js';
|
|
31
|
+
export type {
|
|
32
|
+
IdempotencyStore,
|
|
33
|
+
LegacyIdempotencyStore,
|
|
34
|
+
ReservationResult,
|
|
28
35
|
} from '../../shared/billing/idempotency.js';
|
|
29
36
|
|
|
30
37
|
// Detection utilities
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
13
|
+
import type Stripe from 'stripe';
|
|
12
14
|
import * as v from 'valibot';
|
|
13
15
|
|
|
14
16
|
import type { RefreshSubscriptionRequest } from '@donotdev/core/server';
|
|
@@ -18,9 +20,6 @@ import { stripe, validateStripeEnvironment } from '../../shared/utils.js';
|
|
|
18
20
|
import { createBaseFunction } from '../baseFunction.js';
|
|
19
21
|
import { STRIPE_CONFIG } from '../config/constants.js';
|
|
20
22
|
|
|
21
|
-
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
22
|
-
import type Stripe from 'stripe';
|
|
23
|
-
|
|
24
23
|
/**
|
|
25
24
|
* Schema for refreshing subscription status
|
|
26
25
|
*/
|
|
@@ -11,11 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
import { logger } from 'firebase-functions/v2';
|
|
13
13
|
import { onRequest } from 'firebase-functions/v2/https';
|
|
14
|
+
import type { HttpsFunction } from 'firebase-functions/v2/https';
|
|
14
15
|
|
|
15
16
|
import type { StripeBackConfig } from '@donotdev/core/server';
|
|
16
17
|
import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
|
|
17
18
|
|
|
18
19
|
import { updateUserSubscription } from '../../shared/billing/helpers/updateUserSubscription.js';
|
|
20
|
+
import { createFirestoreIdempotencyStore } from '../../shared/billing/idempotency.js';
|
|
19
21
|
import { processWebhook } from '../../shared/billing/webhookHandler.js';
|
|
20
22
|
import { handleError } from '../../shared/errorHandling.js';
|
|
21
23
|
import {
|
|
@@ -26,8 +28,6 @@ import {
|
|
|
26
28
|
import { STRIPE_CONFIG } from '../config/constants.js';
|
|
27
29
|
import { stripeSecretKey, stripeWebhookSecret } from '../config/secrets.js'; // ✅ IMPORT SECRETS
|
|
28
30
|
|
|
29
|
-
import type { HttpsFunction } from 'firebase-functions/v2/https';
|
|
30
|
-
|
|
31
31
|
/**
|
|
32
32
|
* Read raw body from request stream
|
|
33
33
|
*/
|
|
@@ -48,7 +48,22 @@ async function getRawBody(req: any): Promise<Buffer> {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
* Create Firebase webhook
|
|
51
|
+
* Create the Firebase Stripe webhook (HTTPS function) from the app's back config.
|
|
52
|
+
* Events are stored in Firestore `webhook_idempotency`; any failure answers
|
|
53
|
+
* non-2xx so Stripe retries the event.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // functions/src/index.ts
|
|
58
|
+
* import { createStripeWebhook } from '@donotdev/functions/firebase';
|
|
59
|
+
* import { stripeBackConfig } from './config/stripeBackConfig.js';
|
|
60
|
+
*
|
|
61
|
+
* export const stripeWebhook = createStripeWebhook(stripeBackConfig);
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @version 0.2.0
|
|
65
|
+
* @since 0.0.1
|
|
66
|
+
* @author AMBROISE PARK Consulting
|
|
52
67
|
*/
|
|
53
68
|
export function createStripeWebhook(
|
|
54
69
|
billingConfig: StripeBackConfig
|
|
@@ -117,7 +132,8 @@ export function createStripeWebhook(
|
|
|
117
132
|
stripe,
|
|
118
133
|
billingConfig,
|
|
119
134
|
updateUserSubscription,
|
|
120
|
-
authProvider
|
|
135
|
+
authProvider,
|
|
136
|
+
createFirestoreIdempotencyStore()
|
|
121
137
|
);
|
|
122
138
|
|
|
123
139
|
logger.info('[Firebase Webhook] Success', result);
|
|
@@ -74,8 +74,10 @@ vi.mock('@donotdev/firebase/server', () => ({
|
|
|
74
74
|
}));
|
|
75
75
|
|
|
76
76
|
// Import AFTER mocks are in place.
|
|
77
|
-
import { bulkEntityLogicFactory } from '../bulk';
|
|
78
77
|
import { BulkCollisionError } from '@donotdev/core/server';
|
|
78
|
+
|
|
79
|
+
import { bulkEntityLogicFactory } from '../bulk';
|
|
80
|
+
|
|
79
81
|
import * as v from 'valibot';
|
|
80
82
|
|
|
81
83
|
// ---------------------------------------------------------------------------
|
|
@@ -126,6 +128,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
126
128
|
const logic = bulkEntityLogicFactory(
|
|
127
129
|
COLLECTION,
|
|
128
130
|
createSchema,
|
|
131
|
+
createSchema,
|
|
129
132
|
updateSchema,
|
|
130
133
|
access
|
|
131
134
|
);
|
|
@@ -175,6 +178,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
175
178
|
const logic = bulkEntityLogicFactory(
|
|
176
179
|
COLLECTION,
|
|
177
180
|
createSchema,
|
|
181
|
+
createSchema,
|
|
178
182
|
updateSchema,
|
|
179
183
|
access
|
|
180
184
|
);
|
|
@@ -194,6 +198,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
194
198
|
const logic = bulkEntityLogicFactory(
|
|
195
199
|
COLLECTION,
|
|
196
200
|
createSchema,
|
|
201
|
+
createSchema,
|
|
197
202
|
updateSchema,
|
|
198
203
|
access
|
|
199
204
|
);
|
|
@@ -209,6 +214,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
209
214
|
const logic = bulkEntityLogicFactory(
|
|
210
215
|
COLLECTION,
|
|
211
216
|
createSchema,
|
|
217
|
+
createSchema,
|
|
212
218
|
updateSchema,
|
|
213
219
|
access
|
|
214
220
|
);
|
|
@@ -232,6 +238,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
232
238
|
const logic = bulkEntityLogicFactory(
|
|
233
239
|
COLLECTION,
|
|
234
240
|
createSchema,
|
|
241
|
+
createSchema,
|
|
235
242
|
updateSchema,
|
|
236
243
|
access
|
|
237
244
|
);
|
|
@@ -259,6 +266,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
259
266
|
const logic = bulkEntityLogicFactory(
|
|
260
267
|
COLLECTION,
|
|
261
268
|
createSchema,
|
|
269
|
+
createSchema,
|
|
262
270
|
updateSchema,
|
|
263
271
|
strictAccess
|
|
264
272
|
);
|
|
@@ -286,6 +294,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
286
294
|
const logic = bulkEntityLogicFactory(
|
|
287
295
|
COLLECTION,
|
|
288
296
|
createSchema,
|
|
297
|
+
createSchema,
|
|
289
298
|
updateSchema,
|
|
290
299
|
strictAccess
|
|
291
300
|
);
|
|
@@ -301,6 +310,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
301
310
|
const logic = bulkEntityLogicFactory(
|
|
302
311
|
COLLECTION,
|
|
303
312
|
createSchema,
|
|
313
|
+
createSchema,
|
|
304
314
|
updateSchema,
|
|
305
315
|
access
|
|
306
316
|
);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @author AMBROISE PARK Consulting
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
13
14
|
import * as v from 'valibot';
|
|
14
15
|
|
|
15
16
|
import { hasRoleAccess } from '@donotdev/core/server';
|
|
@@ -21,8 +22,6 @@ import { DoNotDevError } from '../../shared/utils.js';
|
|
|
21
22
|
import { createBaseFunction } from '../baseFunction.js';
|
|
22
23
|
import { CRUD_CONFIG } from '../config/constants.js';
|
|
23
24
|
|
|
24
|
-
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
25
|
-
|
|
26
25
|
/** Supported aggregation operations */
|
|
27
26
|
export type AggregateOperation = 'count' | 'sum' | 'avg' | 'min' | 'max';
|
|
28
27
|
|