@donotdev/functions 0.0.19 → 0.1.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/LICENSE.md +3 -3
- package/lib/firebase/auth/getCustomClaims.d.ts +25 -0
- package/lib/firebase/auth/getUserAuthStatus.d.ts +29 -0
- package/lib/firebase/auth/index.d.ts +12 -0
- package/lib/firebase/auth/removeCustomClaims.d.ts +28 -0
- package/lib/firebase/auth/setCustomClaims.d.ts +34 -0
- package/lib/firebase/baseFunction.d.ts +26 -0
- package/lib/firebase/billing/cancelSubscription.d.ts +10 -0
- package/lib/firebase/billing/changePlan.d.ts +13 -0
- package/lib/firebase/billing/createCheckoutSession.d.ts +21 -0
- package/lib/firebase/billing/createCustomerPortal.d.ts +19 -0
- package/lib/firebase/billing/healthCheck.d.ts +5 -0
- package/lib/firebase/billing/index.d.ts +18 -0
- package/lib/firebase/billing/refreshSubscriptionStatus.d.ts +19 -0
- package/lib/firebase/billing/webhookHandler.d.ts +6 -0
- package/lib/firebase/config/constants.d.ts +89 -0
- package/lib/firebase/config/index.d.ts +9 -0
- package/lib/firebase/config/secrets.d.ts +15 -0
- package/lib/firebase/crud/aggregate.d.ts +98 -0
- package/lib/firebase/crud/create.d.ts +16 -0
- package/lib/firebase/crud/delete.d.ts +20 -0
- package/lib/firebase/crud/get.d.ts +24 -0
- package/lib/firebase/crud/index.d.ts +14 -0
- package/lib/firebase/crud/list.d.ts +25 -0
- package/lib/firebase/crud/update.d.ts +25 -0
- package/lib/firebase/helpers/githubAccessHelper.d.ts +30 -0
- package/lib/firebase/helpers/githubTeamAccessHelper.d.ts +36 -0
- package/lib/firebase/helpers/index.d.ts +10 -0
- package/lib/firebase/index.d.ts +17 -0
- package/lib/firebase/index.js +25 -9110
- package/lib/firebase/index.js.map +4 -4
- package/lib/firebase/oauth/disconnect.d.ts +12 -0
- package/lib/firebase/oauth/exchangeToken.d.ts +9 -0
- package/lib/firebase/oauth/getConnections.d.ts +11 -0
- package/lib/firebase/oauth/githubAccess.d.ts +83 -0
- package/lib/firebase/oauth/index.d.ts +13 -0
- package/lib/firebase/oauth/refreshToken.d.ts +9 -0
- package/lib/firebase/registerCrudFunctions.d.ts +32 -0
- package/lib/firebase/scheduled/checkExpiredSubscriptions.d.ts +14 -0
- package/lib/firebase/scheduled/index.d.ts +9 -0
- package/lib/shared/billing/createCheckout.d.ts +50 -0
- package/lib/shared/billing/helpers/index.d.ts +10 -0
- package/lib/shared/billing/helpers/subscriptionManagement.d.ts +34 -0
- package/lib/shared/billing/helpers/updateUserSubscription.d.ts +45 -0
- package/lib/shared/billing/idempotency.d.ts +22 -0
- package/lib/shared/billing/index.d.ts +11 -0
- package/lib/shared/billing/webhookHandler.d.ts +37 -0
- package/lib/shared/errorHandling.d.ts +14 -0
- package/lib/shared/firebase.d.ts +73 -0
- package/lib/shared/github.d.ts +128 -0
- package/lib/shared/index.d.ts +16 -0
- package/lib/shared/index.js +25 -6927
- package/lib/shared/index.js.map +4 -4
- package/lib/shared/logger.d.ts +133 -0
- package/lib/shared/metadata.d.ts +36 -0
- package/lib/shared/oauth/exchangeToken.d.ts +24 -0
- package/lib/shared/oauth/grantAccess.d.ts +30 -0
- package/lib/shared/oauth/index.d.ts +10 -0
- package/lib/shared/schema.d.ts +56 -0
- package/lib/shared/utils/detectFirestore.d.ts +31 -0
- package/lib/shared/utils/external/date.d.ts +36 -0
- package/lib/shared/utils/external/index.d.ts +11 -0
- package/lib/shared/utils/external/references.d.ts +12 -0
- package/lib/shared/utils/external/subscription.d.ts +41 -0
- package/lib/shared/utils/firebaseHelpers.d.ts +23 -0
- package/lib/shared/utils/functionWrapper.d.ts +36 -0
- package/lib/shared/utils/index.d.ts +14 -0
- package/lib/shared/utils/internal/auth.d.ts +57 -0
- package/lib/shared/utils/internal/firebase.d.ts +5 -0
- package/lib/shared/utils/internal/idempotency.d.ts +21 -0
- package/lib/shared/utils/internal/index.d.ts +14 -0
- package/lib/shared/utils/internal/monitoring.d.ts +80 -0
- package/lib/shared/utils/internal/rateLimiter.d.ts +82 -0
- package/lib/shared/utils/internal/validation.d.ts +43 -0
- package/lib/shared/utils/schemaValidation.d.ts +60 -0
- package/lib/shared/utils/validation.d.ts +98 -0
- package/lib/shared/utils/vercelHelpers.d.ts +18 -0
- package/lib/shared/utils.d.ts +234 -0
- package/lib/shared/validation.d.ts +16 -0
- package/lib/supabase/auth/deleteAccount.d.ts +16 -0
- package/lib/supabase/auth/getCustomClaims.d.ts +16 -0
- package/lib/supabase/auth/getUserAuthStatus.d.ts +18 -0
- package/lib/supabase/auth/removeCustomClaims.d.ts +16 -0
- package/lib/supabase/auth/setCustomClaims.d.ts +18 -0
- package/lib/supabase/baseFunction.d.ts +43 -0
- package/lib/supabase/billing/cancelSubscription.d.ts +9 -0
- package/lib/supabase/billing/changePlan.d.ts +11 -0
- package/lib/supabase/billing/createCheckoutSession.d.ts +11 -0
- package/lib/supabase/billing/createCustomerPortal.d.ts +9 -0
- package/lib/supabase/billing/refreshSubscriptionStatus.d.ts +9 -0
- package/lib/supabase/crud/aggregate.d.ts +27 -0
- package/lib/supabase/crud/create.d.ts +23 -0
- package/lib/supabase/crud/delete.d.ts +30 -0
- package/lib/supabase/crud/get.d.ts +23 -0
- package/lib/supabase/crud/index.d.ts +20 -0
- package/lib/supabase/crud/list.d.ts +33 -0
- package/lib/supabase/crud/update.d.ts +24 -0
- package/lib/supabase/helpers/authProvider.d.ts +22 -0
- package/lib/supabase/index.d.ts +30 -0
- package/lib/supabase/index.js +23 -0
- package/lib/supabase/index.js.map +7 -0
- package/lib/supabase/oauth/disconnect.d.ts +13 -0
- package/lib/supabase/oauth/exchangeToken.d.ts +13 -0
- package/lib/supabase/oauth/getConnections.d.ts +13 -0
- package/lib/supabase/oauth/index.d.ts +12 -0
- package/lib/supabase/oauth/refreshToken.d.ts +13 -0
- package/lib/supabase/registerCrudFunctions.d.ts +24 -0
- package/lib/supabase/utils/idempotency.d.ts +36 -0
- package/lib/supabase/utils/monitoring.d.ts +59 -0
- package/lib/supabase/utils/rateLimiter.d.ts +56 -0
- package/lib/vercel/api/auth/get-custom-claims.d.ts +2 -0
- package/lib/vercel/api/auth/get-user-auth-status.d.ts +2 -0
- package/lib/vercel/api/auth/index.d.ts +12 -0
- package/lib/vercel/api/auth/remove-custom-claims.d.ts +2 -0
- package/lib/vercel/api/auth/set-custom-claims.d.ts +10 -0
- package/lib/vercel/api/billing/cancel.d.ts +10 -0
- package/lib/vercel/api/billing/change-plan.d.ts +11 -0
- package/lib/vercel/api/billing/create-checkout-session.d.ts +13 -0
- package/lib/vercel/api/billing/customer-portal.d.ts +3 -0
- package/lib/vercel/api/billing/index.d.ts +14 -0
- package/lib/vercel/api/billing/refresh-subscription-status.d.ts +31 -0
- package/lib/vercel/api/billing/webhook-handler.d.ts +22 -0
- package/lib/vercel/api/config/constants.d.ts +103 -0
- package/lib/vercel/api/config/firebase-admin.d.ts +19 -0
- package/lib/vercel/api/config/index.d.ts +10 -0
- package/lib/vercel/api/crud/create.d.ts +2 -0
- package/lib/vercel/api/crud/delete.d.ts +2 -0
- package/lib/vercel/api/crud/get.d.ts +2 -0
- package/lib/vercel/api/crud/index.d.ts +13 -0
- package/lib/vercel/api/crud/list.d.ts +2 -0
- package/lib/vercel/api/crud/update.d.ts +2 -0
- package/lib/vercel/api/index.d.ts +13 -0
- package/lib/vercel/api/index.js +22 -4790
- package/lib/vercel/api/index.js.map +4 -4
- package/lib/vercel/api/oauth/check-github-access.d.ts +12 -0
- package/lib/vercel/api/oauth/exchange-token.d.ts +8 -0
- package/lib/vercel/api/oauth/grant-github-access.d.ts +12 -0
- package/lib/vercel/api/oauth/index.d.ts +12 -0
- package/lib/vercel/api/oauth/revoke-github-access.d.ts +11 -0
- package/lib/vercel/api/utils/cors.d.ts +49 -0
- package/lib/vercel/baseFunction.d.ts +25 -0
- package/package.json +4 -4
- package/src/firebase/auth/getCustomClaims.ts +3 -3
- package/src/firebase/auth/getUserAuthStatus.ts +3 -3
- package/src/firebase/auth/index.ts +1 -1
- package/src/firebase/auth/removeCustomClaims.ts +3 -3
- package/src/firebase/auth/setCustomClaims.ts +130 -84
- package/src/firebase/baseFunction.ts +2 -2
- package/src/firebase/billing/cancelSubscription.ts +3 -3
- package/src/firebase/billing/changePlan.ts +3 -3
- package/src/firebase/billing/createCheckoutSession.ts +1 -1
- package/src/firebase/billing/createCustomerPortal.ts +1 -1
- package/src/firebase/billing/healthCheck.ts +8 -24
- package/src/firebase/billing/index.d.ts +11 -11
- package/src/firebase/billing/index.ts +1 -1
- package/src/firebase/billing/refreshSubscriptionStatus.ts +3 -3
- package/src/firebase/billing/webhookHandler.ts +1 -2
- package/src/firebase/config/constants.ts +4 -4
- package/src/firebase/config/index.ts +1 -1
- package/src/firebase/config/secrets.ts +1 -1
- package/src/firebase/crud/aggregate.ts +2 -2
- package/src/firebase/crud/create.ts +19 -4
- package/src/firebase/crud/delete.ts +3 -3
- package/src/firebase/crud/get.ts +1 -1
- package/src/firebase/crud/index.ts +1 -1
- package/src/firebase/crud/list.ts +1 -1
- package/src/firebase/crud/update.ts +2 -2
- package/src/firebase/helpers/githubAccessHelper.ts +4 -4
- package/src/firebase/helpers/githubTeamAccessHelper.ts +3 -3
- package/src/firebase/helpers/index.ts +1 -1
- package/src/firebase/index.d.ts +9 -9
- package/src/firebase/index.ts +1 -1
- package/src/firebase/oauth/disconnect.ts +2 -2
- package/src/firebase/oauth/exchangeToken.ts +7 -7
- package/src/firebase/oauth/getConnections.ts +2 -2
- package/src/firebase/oauth/githubAccess.ts +10 -10
- package/src/firebase/oauth/index.ts +1 -1
- package/src/firebase/oauth/refreshToken.ts +2 -2
- package/src/firebase/registerCrudFunctions.ts +1 -1
- package/src/firebase/scheduled/checkExpiredSubscriptions.ts +1 -1
- package/src/firebase/scheduled/index.ts +1 -1
- package/src/shared/__tests__/auth.test.ts +46 -0
- package/src/shared/__tests__/errorHandling.test.ts +66 -1
- package/src/shared/__tests__/firebase.test.ts +293 -0
- package/src/shared/__tests__/internalValidation.test.ts +190 -0
- package/src/shared/__tests__/metadata.test.ts +66 -0
- package/src/shared/__tests__/schema.test.ts +219 -0
- package/src/shared/__tests__/schemaValidation.test.ts +72 -0
- package/src/shared/__tests__/subscription.test.ts +45 -0
- package/src/shared/__tests__/utils.test.ts +281 -0
- package/src/shared/__tests__/validation-env.test.ts +73 -0
- package/src/shared/billing/__tests__/createCheckout.test.ts +1 -1
- package/src/shared/billing/__tests__/webhookHandler.test.ts +1 -1
- package/src/shared/billing/createCheckout.ts +10 -5
- package/src/shared/billing/helpers/index.ts +1 -1
- package/src/shared/billing/helpers/subscriptionManagement.ts +4 -4
- package/src/shared/billing/helpers/updateUserSubscription.ts +4 -4
- package/src/shared/billing/idempotency.ts +4 -4
- package/src/shared/billing/index.ts +1 -1
- package/src/shared/billing/webhookHandler.ts +7 -7
- package/src/shared/errorHandling.ts +2 -2
- package/src/shared/firebase.ts +7 -7
- package/src/shared/github.ts +11 -11
- package/src/shared/index.d.ts +9 -9
- package/src/shared/index.ts +1 -1
- package/src/shared/logger.ts +8 -8
- package/src/shared/metadata.ts +3 -3
- package/src/shared/oauth/__tests__/exchangeToken.test.ts +1 -1
- package/src/shared/oauth/exchangeToken.ts +2 -2
- package/src/shared/oauth/grantAccess.ts +2 -2
- package/src/shared/oauth/index.ts +1 -1
- package/src/shared/schema.ts +4 -4
- package/src/shared/utils/__tests__/functionWrapper.test.ts +1 -1
- package/src/shared/utils/detectFirestore.ts +3 -3
- package/src/shared/utils/external/date.ts +5 -5
- package/src/shared/utils/external/index.ts +1 -1
- package/src/shared/utils/external/references.ts +2 -2
- package/src/shared/utils/external/subscription.ts +5 -5
- package/src/shared/utils/firebaseHelpers.ts +3 -3
- package/src/shared/utils/functionWrapper.ts +4 -4
- package/src/shared/utils/index.ts +1 -1
- package/src/shared/utils/internal/auth.ts +7 -7
- package/src/shared/utils/internal/firebase.ts +1 -1
- package/src/shared/utils/internal/idempotency.ts +3 -3
- package/src/shared/utils/internal/index.ts +1 -1
- package/src/shared/utils/internal/monitoring.ts +8 -8
- package/src/shared/utils/internal/rateLimiter.ts +6 -6
- package/src/shared/utils/internal/validation.ts +6 -6
- package/src/shared/utils/schemaValidation.ts +6 -6
- package/src/shared/utils/validation.ts +10 -10
- package/src/shared/utils/vercelHelpers.ts +3 -3
- package/src/shared/utils.ts +19 -19
- package/src/shared/validation.ts +2 -2
- package/src/supabase/auth/deleteAccount.ts +2 -2
- package/src/supabase/auth/getCustomClaims.ts +2 -2
- package/src/supabase/auth/getUserAuthStatus.ts +2 -2
- package/src/supabase/auth/removeCustomClaims.ts +2 -2
- package/src/supabase/auth/setCustomClaims.ts +2 -2
- package/src/supabase/baseFunction.ts +3 -3
- package/src/supabase/billing/cancelSubscription.ts +2 -2
- package/src/supabase/billing/changePlan.ts +2 -2
- package/src/supabase/billing/createCheckoutSession.ts +2 -2
- package/src/supabase/billing/createCustomerPortal.ts +2 -2
- package/src/supabase/billing/refreshSubscriptionStatus.ts +2 -2
- package/src/supabase/crud/aggregate.ts +11 -8
- package/src/supabase/crud/create.ts +2 -2
- package/src/supabase/crud/delete.ts +1 -1
- package/src/supabase/crud/get.ts +2 -2
- package/src/supabase/crud/index.ts +1 -1
- package/src/supabase/crud/list.ts +2 -2
- package/src/supabase/crud/update.ts +2 -2
- package/src/supabase/helpers/authProvider.ts +2 -2
- package/src/supabase/index.ts +10 -2
- package/src/supabase/oauth/disconnect.ts +104 -0
- package/src/supabase/oauth/exchangeToken.ts +152 -0
- package/src/supabase/oauth/getConnections.ts +85 -0
- package/src/supabase/oauth/index.ts +15 -0
- package/src/supabase/oauth/refreshToken.ts +131 -0
- package/src/supabase/registerCrudFunctions.ts +1 -1
- package/src/supabase/utils/idempotency.ts +1 -1
- package/src/supabase/utils/monitoring.ts +1 -1
- package/src/supabase/utils/rateLimiter.ts +1 -1
- package/src/vercel/api/auth/get-custom-claims.ts +1 -1
- package/src/vercel/api/auth/get-user-auth-status.ts +1 -1
- package/src/vercel/api/auth/index.ts +1 -1
- package/src/vercel/api/auth/remove-custom-claims.ts +1 -1
- package/src/vercel/api/auth/set-custom-claims.ts +69 -24
- package/src/vercel/api/billing/cancel.ts +3 -3
- package/src/vercel/api/billing/change-plan.ts +3 -3
- package/src/vercel/api/billing/create-checkout-session.ts +3 -3
- package/src/vercel/api/billing/customer-portal.ts +1 -1
- package/src/vercel/api/billing/index.ts +1 -1
- package/src/vercel/api/billing/refresh-subscription-status.ts +1 -1
- package/src/vercel/api/billing/webhook-handler.ts +3 -3
- package/src/vercel/api/config/constants.ts +9 -9
- package/src/vercel/api/config/firebase-admin.ts +3 -3
- package/src/vercel/api/config/index.ts +1 -1
- package/src/vercel/api/crud/create.ts +1 -1
- package/src/vercel/api/crud/delete.ts +1 -1
- package/src/vercel/api/crud/get.ts +1 -1
- package/src/vercel/api/crud/index.ts +1 -1
- package/src/vercel/api/crud/list.ts +1 -1
- package/src/vercel/api/crud/update.ts +1 -1
- package/src/vercel/api/index.d.ts +1 -1
- package/src/vercel/api/index.ts +1 -1
- package/src/vercel/api/oauth/check-github-access.ts +3 -3
- package/src/vercel/api/oauth/exchange-token.ts +1 -1
- package/src/vercel/api/oauth/grant-github-access.ts +3 -3
- package/src/vercel/api/oauth/index.ts +1 -1
- package/src/vercel/api/oauth/revoke-github-access.ts +1 -1
- package/src/vercel/api/utils/cors.ts +4 -4
- package/src/vercel/baseFunction.ts +2 -2
package/LICENSE.md
CHANGED
|
@@ -8,7 +8,7 @@ Copyright © 2025 Ambroise Park Consulting. All rights reserved.
|
|
|
8
8
|
|
|
9
9
|
## 1. DEFINITIONS
|
|
10
10
|
|
|
11
|
-
**1.1 "Framework"** means the DoNotDev commercial software packages (excluding @donotdev/cli and @donotdev/
|
|
11
|
+
**1.1 "Framework"** means the DoNotDev commercial software packages (excluding @donotdev/cli, @donotdev/components, @donotdev/expo, and @donotdev/templates, which are licensed under MIT), including all compiled JavaScript files, TypeScript definition files, and associated documentation.
|
|
12
12
|
|
|
13
13
|
**1.2 "License Key"** means the unique alphanumeric key provided to you upon purchase, required to suppress watermarks and unlock full Framework functionality.
|
|
14
14
|
|
|
@@ -231,12 +231,12 @@ Ambroise Park Consulting has no obligation to provide support, updates, or maint
|
|
|
231
231
|
|
|
232
232
|
Questions about licensing or compliance:
|
|
233
233
|
|
|
234
|
-
**Email:**
|
|
234
|
+
**Email:** contact@donotdev.com
|
|
235
235
|
**Website:** donotdev.com
|
|
236
236
|
|
|
237
237
|
---
|
|
238
238
|
|
|
239
239
|
**END OF LICENSE AGREEMENT**
|
|
240
240
|
|
|
241
|
-
**DoNotDev Framework License
|
|
241
|
+
**DoNotDev Framework License v1.0**
|
|
242
242
|
Ambroise Park Consulting – 2025
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Get custom claims Firebase function
|
|
3
|
+
* @description Firebase callable function for retrieving custom user claims
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
11
|
+
declare const getCustomClaimsSchema: v.ObjectSchema<{}, undefined>;
|
|
12
|
+
type GetCustomClaimsRequest = v.InferOutput<typeof getCustomClaimsSchema>;
|
|
13
|
+
type GetCustomClaimsResponse = {
|
|
14
|
+
customClaims: Record<string, any>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Gets user's custom claims
|
|
18
|
+
* Base function handles all common concerns automatically
|
|
19
|
+
*
|
|
20
|
+
* @version 0.1.0
|
|
21
|
+
* @since 0.0.1
|
|
22
|
+
* @author AMBROISE PARK Consulting
|
|
23
|
+
*/
|
|
24
|
+
export declare const getCustomClaims: (customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>) => CallableFunction<GetCustomClaimsRequest, Promise<GetCustomClaimsResponse>>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Get user auth status Firebase function
|
|
3
|
+
* @description Firebase callable function for retrieving user authentication status
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
11
|
+
declare const getUserAuthStatusSchema: v.ObjectSchema<{}, undefined>;
|
|
12
|
+
export type GetUserAuthStatusRequest = v.InferOutput<typeof getUserAuthStatusSchema>;
|
|
13
|
+
export type GetUserAuthStatusResponse = {
|
|
14
|
+
uid: string;
|
|
15
|
+
email?: string;
|
|
16
|
+
emailVerified: boolean;
|
|
17
|
+
customClaims: Record<string, any>;
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Gets user authentication status
|
|
22
|
+
* Base function handles all common concerns automatically
|
|
23
|
+
*
|
|
24
|
+
* @version 0.1.0
|
|
25
|
+
* @since 0.0.1
|
|
26
|
+
* @author AMBROISE PARK Consulting
|
|
27
|
+
*/
|
|
28
|
+
export declare const getUserAuthStatus: (customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>) => CallableFunction<GetUserAuthStatusRequest, Promise<GetUserAuthStatusResponse>>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Firebase auth functions barrel exports
|
|
3
|
+
* @description Centralized exports for Firebase authentication functions
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
export * from './getCustomClaims.js';
|
|
10
|
+
export * from './getUserAuthStatus.js';
|
|
11
|
+
export * from './removeCustomClaims.js';
|
|
12
|
+
export * from './setCustomClaims.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Remove custom claims Firebase function
|
|
3
|
+
* @description Firebase callable function for removing custom user claims
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
11
|
+
declare const removeCustomClaimsSchema: v.ObjectSchema<{
|
|
12
|
+
readonly claimsToRemove: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, "At least one claim must be specified">]>;
|
|
13
|
+
}, undefined>;
|
|
14
|
+
export type RemoveCustomClaimsRequest = v.InferOutput<typeof removeCustomClaimsSchema>;
|
|
15
|
+
export type RemoveCustomClaimsResponse = {
|
|
16
|
+
success: boolean;
|
|
17
|
+
customClaims: Record<string, any>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Removes user's custom claims
|
|
21
|
+
* Base function handles all common concerns automatically
|
|
22
|
+
*
|
|
23
|
+
* @version 0.1.0
|
|
24
|
+
* @since 0.0.1
|
|
25
|
+
* @author AMBROISE PARK Consulting
|
|
26
|
+
*/
|
|
27
|
+
export declare const removeCustomClaims: (customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>) => CallableFunction<RemoveCustomClaimsRequest, Promise<RemoveCustomClaimsResponse>>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Set custom claims Firebase function
|
|
3
|
+
* @description Firebase callable function for setting custom user claims
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
11
|
+
declare const setCustomClaimsSchema: v.ObjectSchema<{
|
|
12
|
+
readonly customClaims: v.RecordSchema<v.StringSchema<undefined>, v.AnySchema, undefined>;
|
|
13
|
+
readonly idempotencyKey: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
14
|
+
}, undefined>;
|
|
15
|
+
export type SetCustomClaimsRequest = v.InferOutput<typeof setCustomClaimsSchema>;
|
|
16
|
+
export type SetCustomClaimsResponse = {
|
|
17
|
+
success: boolean;
|
|
18
|
+
customClaims: Record<string, any>;
|
|
19
|
+
};
|
|
20
|
+
export interface SetCustomClaimsOptions {
|
|
21
|
+
/** Explicit allowlist of claim keys users may set on themselves. Required. */
|
|
22
|
+
allowedClaimKeys: string[];
|
|
23
|
+
customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Sets custom claims for a user, restricted to allowed keys.
|
|
27
|
+
* Consumers MUST specify which claim keys are self-assignable.
|
|
28
|
+
*
|
|
29
|
+
* @version 0.1.0
|
|
30
|
+
* @since 0.0.1
|
|
31
|
+
* @author AMBROISE PARK Consulting
|
|
32
|
+
*/
|
|
33
|
+
export declare const setCustomClaims: (options: SetCustomClaimsOptions) => CallableFunction<SetCustomClaimsRequest, Promise<SetCustomClaimsResponse>>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import type { SecurityContext } from '@donotdev/core';
|
|
3
|
+
import type { UserRole } from '@donotdev/core/server';
|
|
4
|
+
import type { CallableRequest, CallableOptions } from 'firebase-functions/v2/https';
|
|
5
|
+
/**
|
|
6
|
+
* Base Firebase function that handles all common concerns
|
|
7
|
+
* Users just provide their business logic
|
|
8
|
+
*
|
|
9
|
+
* Rate limiting and metrics are enabled by default.
|
|
10
|
+
* Set `DISABLE_RATE_LIMITING=true` or `DISABLE_METRICS=true` to opt out.
|
|
11
|
+
*
|
|
12
|
+
* @param config - Firebase function config (region, memory, etc.)
|
|
13
|
+
* @param schema - Valibot schema for request validation
|
|
14
|
+
* @param operation - Operation name for logging/metrics
|
|
15
|
+
* @param businessLogic - The actual business logic to execute
|
|
16
|
+
* @param requiredRole - Minimum role required (default: 'user' for backwards compatibility)
|
|
17
|
+
*
|
|
18
|
+
* @version 0.1.0
|
|
19
|
+
* @since 0.0.1
|
|
20
|
+
* @author AMBROISE PARK Consulting
|
|
21
|
+
*/
|
|
22
|
+
export declare function createBaseFunction<TRequest, TResponse>(config: CallableOptions, schema: v.BaseSchema<unknown, TRequest, v.BaseIssue<unknown>>, operation: string, businessLogic: (data: TRequest, context: {
|
|
23
|
+
uid: string;
|
|
24
|
+
userRole: UserRole;
|
|
25
|
+
request: CallableRequest<TRequest>;
|
|
26
|
+
}) => Promise<TResponse>, requiredRole?: UserRole, security?: SecurityContext): import("firebase-functions/https").CallableFunction<TRequest, any, unknown>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StripeBackConfig } from '@donotdev/core/server';
|
|
2
|
+
/**
|
|
3
|
+
* Change subscription plan function
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
export declare function changePlan(billingConfig: StripeBackConfig): import("firebase-functions/https").CallableFunction<{
|
|
10
|
+
userId: string;
|
|
11
|
+
newPriceId: string;
|
|
12
|
+
billingConfigKey: string;
|
|
13
|
+
}, any, unknown>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CreateCheckoutSessionRequest, StripeBackConfig } from '@donotdev/core/server';
|
|
2
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
3
|
+
/**
|
|
4
|
+
* Create Firebase function for checkout session creation
|
|
5
|
+
*
|
|
6
|
+
* @param billingConfig - Billing configuration with product definitions
|
|
7
|
+
* @returns Firebase function for checkout session creation
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const createCheckout = createCheckoutSession(billingConfig);
|
|
11
|
+
* const result = await createCheckout({
|
|
12
|
+
* priceId: 'price_xxx',
|
|
13
|
+
* userId: 'user123',
|
|
14
|
+
* metadata: { billingConfigKey: 'early_bird' }
|
|
15
|
+
* });
|
|
16
|
+
* window.location.href = result.data.sessionUrl;
|
|
17
|
+
*/
|
|
18
|
+
export declare function createCheckoutSession(billingConfig: StripeBackConfig): CallableFunction<CreateCheckoutSessionRequest, Promise<{
|
|
19
|
+
sessionId: string;
|
|
20
|
+
sessionUrl: string;
|
|
21
|
+
}>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Create Customer Portal Function
|
|
3
|
+
* @description Generates Stripe Customer Portal URL for payment method management
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
11
|
+
declare const customerPortalSchema: v.ObjectSchema<{
|
|
12
|
+
readonly userId: v.StringSchema<undefined>;
|
|
13
|
+
readonly returnUrl: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>]>, undefined>;
|
|
14
|
+
}, undefined>;
|
|
15
|
+
type CustomerPortalRequest = v.InferOutput<typeof customerPortalSchema>;
|
|
16
|
+
export declare function createCustomerPortal(): CallableFunction<CustomerPortalRequest, Promise<{
|
|
17
|
+
url: string;
|
|
18
|
+
}>>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Firebase billing functions barrel exports
|
|
3
|
+
* @description Centralized exports for Firebase billing functions
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
export { createCheckoutSession } from './createCheckoutSession.js';
|
|
10
|
+
export { createStripeWebhook } from './webhookHandler.js';
|
|
11
|
+
export * from '../../shared/billing/helpers/index.js';
|
|
12
|
+
export { createIdempotencyStore, resetIdempotencyStore, } from '../../shared/billing/idempotency.js';
|
|
13
|
+
export { isFirestoreConfigured, isFirestoreAvailable, } from '../../shared/utils/detectFirestore.js';
|
|
14
|
+
export { billingHealth } from './healthCheck.js';
|
|
15
|
+
export * from './refreshSubscriptionStatus.js';
|
|
16
|
+
export { cancelSubscription } from './cancelSubscription.js';
|
|
17
|
+
export { changePlan } from './changePlan.js';
|
|
18
|
+
export { createCustomerPortal } from './createCustomerPortal.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Refresh subscription status Firebase function
|
|
3
|
+
* @description Firebase callable function for refreshing user subscription status
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { RefreshSubscriptionRequest } from '@donotdev/core/server';
|
|
11
|
+
/**
|
|
12
|
+
* Refreshes user's subscription status from Stripe
|
|
13
|
+
* Base function handles all common concerns automatically
|
|
14
|
+
*
|
|
15
|
+
* @version 0.1.0
|
|
16
|
+
* @since 0.0.1
|
|
17
|
+
* @author AMBROISE PARK Consulting
|
|
18
|
+
*/
|
|
19
|
+
export declare const refreshSubscriptionStatus: (customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>) => import("firebase-functions/https").CallableFunction<RefreshSubscriptionRequest, any, unknown>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { StripeBackConfig } from '@donotdev/core/server';
|
|
2
|
+
import type { HttpsFunction } from 'firebase-functions/v2/https';
|
|
3
|
+
/**
|
|
4
|
+
* Create Firebase webhook handler from billing config
|
|
5
|
+
*/
|
|
6
|
+
export declare function createStripeWebhook(billingConfig: StripeBackConfig): HttpsFunction;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Firebase Functions configuration constants
|
|
3
|
+
* @description DRY configuration for regions, timeouts, and other function settings
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
/** Default region - override with FIREBASE_REGION env var */
|
|
10
|
+
export declare const FIREBASE_REGION: string;
|
|
11
|
+
/** Default function config */
|
|
12
|
+
export declare const FUNCTION_CONFIG: {
|
|
13
|
+
readonly invoker: "public";
|
|
14
|
+
readonly memory: "1GiB";
|
|
15
|
+
readonly timeoutSeconds: 60;
|
|
16
|
+
readonly cors: true;
|
|
17
|
+
readonly enforceAppCheck?: boolean | undefined;
|
|
18
|
+
readonly region: string;
|
|
19
|
+
};
|
|
20
|
+
/** Stripe/billing functions */
|
|
21
|
+
export declare const STRIPE_CONFIG: {
|
|
22
|
+
memory: "512MiB";
|
|
23
|
+
timeoutSeconds: number;
|
|
24
|
+
cors: boolean;
|
|
25
|
+
enforceAppCheck?: boolean | undefined;
|
|
26
|
+
region: string;
|
|
27
|
+
};
|
|
28
|
+
/** Auth functions */
|
|
29
|
+
export declare const AUTH_CONFIG: {
|
|
30
|
+
readonly memory: "256MiB";
|
|
31
|
+
readonly timeoutSeconds: 20;
|
|
32
|
+
readonly enforceAppCheck?: boolean | undefined;
|
|
33
|
+
readonly region: string;
|
|
34
|
+
};
|
|
35
|
+
/** CRUD functions - all use public invoker (security enforced via role-based access in code) */
|
|
36
|
+
export declare const CRUD_CONFIG: {
|
|
37
|
+
readonly invoker: "public";
|
|
38
|
+
readonly memory: "256MiB";
|
|
39
|
+
readonly timeoutSeconds: 15;
|
|
40
|
+
readonly cors: true;
|
|
41
|
+
readonly enforceAppCheck?: boolean | undefined;
|
|
42
|
+
readonly region: string;
|
|
43
|
+
};
|
|
44
|
+
/** CRUD read functions (get, list) - can be public for guest access */
|
|
45
|
+
export declare const CRUD_READ_CONFIG: {
|
|
46
|
+
readonly invoker: "public";
|
|
47
|
+
readonly memory: "256MiB";
|
|
48
|
+
readonly timeoutSeconds: 15;
|
|
49
|
+
readonly cors: true;
|
|
50
|
+
readonly enforceAppCheck?: boolean | undefined;
|
|
51
|
+
readonly region: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Available Firebase regions for reference
|
|
55
|
+
*
|
|
56
|
+
* @version 0.1.0
|
|
57
|
+
* @since 0.0.1
|
|
58
|
+
* @author AMBROISE PARK Consulting
|
|
59
|
+
*/
|
|
60
|
+
export declare const AVAILABLE_REGIONS: {
|
|
61
|
+
readonly 'europe-west1': "Belgium";
|
|
62
|
+
readonly 'europe-west2': "London";
|
|
63
|
+
readonly 'europe-west3': "Frankfurt";
|
|
64
|
+
readonly 'europe-west6': "Zurich";
|
|
65
|
+
readonly 'europe-central2': "Warsaw";
|
|
66
|
+
readonly 'us-central1': "Iowa";
|
|
67
|
+
readonly 'us-east1': "South Carolina";
|
|
68
|
+
readonly 'us-east4': "Northern Virginia";
|
|
69
|
+
readonly 'us-west1': "Oregon";
|
|
70
|
+
readonly 'asia-east1': "Taiwan";
|
|
71
|
+
readonly 'asia-northeast1': "Tokyo";
|
|
72
|
+
readonly 'asia-southeast1': "Singapore";
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Environment validation
|
|
76
|
+
*
|
|
77
|
+
* @version 0.1.0
|
|
78
|
+
* @since 0.0.1
|
|
79
|
+
* @author AMBROISE PARK Consulting
|
|
80
|
+
*/
|
|
81
|
+
export declare const validateEnvironment: () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Type for Firebase region keys
|
|
84
|
+
*
|
|
85
|
+
* @version 0.1.0
|
|
86
|
+
* @since 0.0.1
|
|
87
|
+
* @author AMBROISE PARK Consulting
|
|
88
|
+
*/
|
|
89
|
+
export type FirebaseRegion = keyof typeof AVAILABLE_REGIONS;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stripe Secret Key
|
|
3
|
+
* Used for server-side Stripe API operations
|
|
4
|
+
*/
|
|
5
|
+
export declare const stripeSecretKey: import("firebase-functions/params").SecretParam;
|
|
6
|
+
/**
|
|
7
|
+
* Stripe Webhook Secret
|
|
8
|
+
* Used to verify signatures of incoming Stripe webhooks
|
|
9
|
+
*/
|
|
10
|
+
export declare const stripeWebhookSecret: import("firebase-functions/params").SecretParam;
|
|
11
|
+
/**
|
|
12
|
+
* GitHub Personal Access Token
|
|
13
|
+
* Used for GitHub API operations (repo access, etc.)
|
|
14
|
+
*/
|
|
15
|
+
export declare const githubPersonalAccessToken: import("firebase-functions/params").SecretParam;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic function to aggregate entities with metrics and grouping.
|
|
3
|
+
* @description Provides a reusable implementation for computing aggregations on Firestore collections.
|
|
4
|
+
* Returns only computed metrics, never raw data - optimized for analytics dashboards.
|
|
5
|
+
*
|
|
6
|
+
* @version 0.1.0
|
|
7
|
+
* @since 0.0.1
|
|
8
|
+
* @author AMBROISE PARK Consulting
|
|
9
|
+
*/
|
|
10
|
+
import * as v from 'valibot';
|
|
11
|
+
/** Supported aggregation operations */
|
|
12
|
+
export type AggregateOperation = 'count' | 'sum' | 'avg' | 'min' | 'max';
|
|
13
|
+
/** Single metric definition */
|
|
14
|
+
export interface MetricDefinition {
|
|
15
|
+
/** Field to aggregate ('*' for count all) */
|
|
16
|
+
field: string;
|
|
17
|
+
/** Aggregation operation */
|
|
18
|
+
operation: AggregateOperation;
|
|
19
|
+
/** Output name for this metric */
|
|
20
|
+
as: string;
|
|
21
|
+
/** Optional filter for this metric */
|
|
22
|
+
filter?: {
|
|
23
|
+
field: string;
|
|
24
|
+
operator: '==' | '!=' | '>' | '<' | '>=' | '<=';
|
|
25
|
+
value: any;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Group by definition */
|
|
29
|
+
export interface GroupByDefinition {
|
|
30
|
+
/** Field to group by */
|
|
31
|
+
field: string;
|
|
32
|
+
/** Metrics to compute per group */
|
|
33
|
+
metrics: MetricDefinition[];
|
|
34
|
+
}
|
|
35
|
+
/** Aggregation configuration */
|
|
36
|
+
export interface AggregateConfig {
|
|
37
|
+
/** Top-level metrics (computed on entire collection) */
|
|
38
|
+
metrics?: MetricDefinition[];
|
|
39
|
+
/** Group by configurations */
|
|
40
|
+
groupBy?: GroupByDefinition[];
|
|
41
|
+
/** Optional global filters */
|
|
42
|
+
where?: Array<[string, any, any]>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Generic function to aggregate entities from any Firestore collection.
|
|
46
|
+
* Returns only computed metrics, never raw data.
|
|
47
|
+
*
|
|
48
|
+
* @param collection - The Firestore collection name
|
|
49
|
+
* @param documentSchema - The Valibot schema (used for visibility checks)
|
|
50
|
+
* @param config - Aggregation configuration (metrics, groupBy, filters)
|
|
51
|
+
* @returns Firebase callable function
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // Define analytics for cars collection
|
|
56
|
+
* export const getCarsAnalytics = aggregateEntities('cars', carSchema, {
|
|
57
|
+
* metrics: [
|
|
58
|
+
* { field: '*', operation: 'count', as: 'total' },
|
|
59
|
+
* { field: 'price', operation: 'sum', as: 'totalValue' },
|
|
60
|
+
* { field: 'price', operation: 'avg', as: 'avgPrice' },
|
|
61
|
+
* ],
|
|
62
|
+
* groupBy: [
|
|
63
|
+
* {
|
|
64
|
+
* field: 'status',
|
|
65
|
+
* metrics: [
|
|
66
|
+
* { field: '*', operation: 'count', as: 'count' },
|
|
67
|
+
* { field: 'price', operation: 'sum', as: 'value' },
|
|
68
|
+
* ],
|
|
69
|
+
* },
|
|
70
|
+
* ],
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* // Returns:
|
|
74
|
+
* // {
|
|
75
|
+
* // metrics: { total: 150, totalValue: 4500000, avgPrice: 30000 },
|
|
76
|
+
* // groups: {
|
|
77
|
+
* // status: {
|
|
78
|
+
* // Available: { count: 80, value: 2400000 },
|
|
79
|
+
* // Reserved: { count: 20, value: 600000 },
|
|
80
|
+
* // Sold: { count: 50, value: 1500000 },
|
|
81
|
+
* // }
|
|
82
|
+
* // },
|
|
83
|
+
* // meta: { collection: 'cars', totalDocs: 150, computedAt: '...' }
|
|
84
|
+
* // }
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @version 0.1.0
|
|
88
|
+
* @since 0.0.1
|
|
89
|
+
* @author AMBROISE PARK Consulting
|
|
90
|
+
*/
|
|
91
|
+
export declare const aggregateEntities: (collection: string, documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, config: AggregateConfig) => import("firebase-functions/https").CallableFunction<{
|
|
92
|
+
where?: [string, any, any][] | undefined;
|
|
93
|
+
dateRange?: {
|
|
94
|
+
field: string;
|
|
95
|
+
start?: string | undefined;
|
|
96
|
+
end?: string | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
}, any, unknown>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import type { UserRole } from '@donotdev/core/server';
|
|
3
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
4
|
+
export type CreateEntityRequest = {
|
|
5
|
+
payload: Record<string, any>;
|
|
6
|
+
idempotencyKey?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Generic function to create entities in any Firestore collection
|
|
10
|
+
* @param collection - The Firestore collection name
|
|
11
|
+
* @param documentSchema - The Valibot schema for document validation
|
|
12
|
+
* @param requiredRole - Minimum role required for this operation
|
|
13
|
+
* @param customSchema - Optional custom request schema
|
|
14
|
+
* @returns Firebase callable function
|
|
15
|
+
*/
|
|
16
|
+
export declare const createEntity: (collection: string, documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, requiredRole: UserRole, customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>) => CallableFunction<CreateEntityRequest, Promise<any>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import type { UserRole } from '@donotdev/core/server';
|
|
3
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
4
|
+
export type DeleteEntityRequest = {
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Generic function to delete entities from any Firestore collection
|
|
9
|
+
* @param collection - The Firestore collection name
|
|
10
|
+
* @param requiredRole - Minimum role required for this operation
|
|
11
|
+
* @param customSchema - Optional custom request schema
|
|
12
|
+
* @returns Firebase callable function
|
|
13
|
+
*
|
|
14
|
+
* @version 0.1.0
|
|
15
|
+
* @since 0.0.1
|
|
16
|
+
* @author AMBROISE PARK Consulting
|
|
17
|
+
*/
|
|
18
|
+
export declare const deleteEntity: (collection: string, requiredRole: UserRole, customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>) => CallableFunction<DeleteEntityRequest, Promise<{
|
|
19
|
+
success: boolean;
|
|
20
|
+
}>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic function to retrieve a single entity.
|
|
3
|
+
* @description Provides a reusable implementation for retrieving documents from Firestore with visibility filtering.
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { EntityOwnershipConfig, UserRole } from '@donotdev/core/server';
|
|
11
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
12
|
+
export type GetEntityRequest = {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Generic function to get entities from any Firestore collection
|
|
17
|
+
* @param collection - The Firestore collection name
|
|
18
|
+
* @param documentSchema - The Valibot schema for document validation
|
|
19
|
+
* @param requiredRole - Minimum role required for this operation
|
|
20
|
+
* @param customSchema - Optional custom request schema
|
|
21
|
+
* @param ownership - Optional ownership config for visibility: 'owner' field masking
|
|
22
|
+
* @returns Firebase callable function
|
|
23
|
+
*/
|
|
24
|
+
export declare const getEntity: (collection: string, documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, requiredRole: UserRole, customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, ownership?: EntityOwnershipConfig) => CallableFunction<GetEntityRequest, Promise<any>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Firebase CRUD functions barrel exports
|
|
3
|
+
* @description Centralized exports for Firebase CRUD functions
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
export * from './aggregate.js';
|
|
10
|
+
export * from './create.js';
|
|
11
|
+
export * from './delete.js';
|
|
12
|
+
export * from './get.js';
|
|
13
|
+
export * from './list.js';
|
|
14
|
+
export * from './update.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import type { EntityOwnershipConfig, UserRole } from '@donotdev/core/server';
|
|
3
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
4
|
+
export interface ListEntityRequest {
|
|
5
|
+
where?: Array<[string, any, any]>;
|
|
6
|
+
orderBy?: Array<[string, 'asc' | 'desc']>;
|
|
7
|
+
limit?: number;
|
|
8
|
+
startAfterId?: string;
|
|
9
|
+
search?: {
|
|
10
|
+
field: string;
|
|
11
|
+
query: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generic function to list entities from any Firestore collection
|
|
16
|
+
* @param collection - The Firestore collection name
|
|
17
|
+
* @param documentSchema - The Valibot schema for document validation
|
|
18
|
+
* @param requiredRole - Minimum role required for this operation
|
|
19
|
+
* @param customSchema - Optional custom request schema
|
|
20
|
+
* @param listFields - Optional array of field names to include (plus id). If not provided, all visible fields are returned.
|
|
21
|
+
* @param ownership - Optional ownership config for list constraints and visibility: 'owner' masking
|
|
22
|
+
* @param isListCard - When true and ownership is set, applies public condition; when false, applies "mine" filter
|
|
23
|
+
* @returns Firebase callable function
|
|
24
|
+
*/
|
|
25
|
+
export declare const listEntities: (collection: string, documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, requiredRole: UserRole, customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, listFields?: string[], ownership?: EntityOwnershipConfig, isListCard?: boolean) => CallableFunction<ListEntityRequest, Promise<any>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic function to update an entity.
|
|
3
|
+
* @description Provides a reusable implementation for updating documents in Firestore with validation.
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { UserRole } from '@donotdev/core/server';
|
|
11
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
12
|
+
export type UpdateEntityRequest = {
|
|
13
|
+
id: string;
|
|
14
|
+
payload: Record<string, any>;
|
|
15
|
+
idempotencyKey?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Generic function to update entities in any Firestore collection
|
|
19
|
+
* @param collection - The Firestore collection name
|
|
20
|
+
* @param documentSchema - The Valibot schema for document validation
|
|
21
|
+
* @param requiredRole - Minimum role required for this operation
|
|
22
|
+
* @param customSchema - Optional custom request schema
|
|
23
|
+
* @returns Firebase callable function
|
|
24
|
+
*/
|
|
25
|
+
export declare const updateEntity: (collection: string, documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, requiredRole: UserRole, customSchema?: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>) => CallableFunction<UpdateEntityRequest, Promise<any>>;
|