@donotdev/functions 0.0.19 → 0.0.20

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 (149) hide show
  1. package/lib/firebase/auth/getCustomClaims.d.ts +25 -0
  2. package/lib/firebase/auth/getUserAuthStatus.d.ts +29 -0
  3. package/lib/firebase/auth/index.d.ts +12 -0
  4. package/lib/firebase/auth/removeCustomClaims.d.ts +28 -0
  5. package/lib/firebase/auth/setCustomClaims.d.ts +34 -0
  6. package/lib/firebase/baseFunction.d.ts +26 -0
  7. package/lib/firebase/billing/cancelSubscription.d.ts +10 -0
  8. package/lib/firebase/billing/changePlan.d.ts +13 -0
  9. package/lib/firebase/billing/createCheckoutSession.d.ts +21 -0
  10. package/lib/firebase/billing/createCustomerPortal.d.ts +19 -0
  11. package/lib/firebase/billing/healthCheck.d.ts +5 -0
  12. package/lib/firebase/billing/index.d.ts +18 -0
  13. package/lib/firebase/billing/refreshSubscriptionStatus.d.ts +19 -0
  14. package/lib/firebase/billing/webhookHandler.d.ts +6 -0
  15. package/lib/firebase/config/constants.d.ts +89 -0
  16. package/lib/firebase/config/index.d.ts +9 -0
  17. package/lib/firebase/config/secrets.d.ts +15 -0
  18. package/lib/firebase/crud/aggregate.d.ts +98 -0
  19. package/lib/firebase/crud/create.d.ts +16 -0
  20. package/lib/firebase/crud/delete.d.ts +20 -0
  21. package/lib/firebase/crud/get.d.ts +24 -0
  22. package/lib/firebase/crud/index.d.ts +14 -0
  23. package/lib/firebase/crud/list.d.ts +25 -0
  24. package/lib/firebase/crud/update.d.ts +25 -0
  25. package/lib/firebase/helpers/githubAccessHelper.d.ts +30 -0
  26. package/lib/firebase/helpers/githubTeamAccessHelper.d.ts +36 -0
  27. package/lib/firebase/helpers/index.d.ts +10 -0
  28. package/lib/firebase/index.d.ts +17 -0
  29. package/lib/firebase/index.js +25 -9110
  30. package/lib/firebase/index.js.map +4 -4
  31. package/lib/firebase/oauth/disconnect.d.ts +12 -0
  32. package/lib/firebase/oauth/exchangeToken.d.ts +9 -0
  33. package/lib/firebase/oauth/getConnections.d.ts +11 -0
  34. package/lib/firebase/oauth/githubAccess.d.ts +83 -0
  35. package/lib/firebase/oauth/index.d.ts +13 -0
  36. package/lib/firebase/oauth/refreshToken.d.ts +9 -0
  37. package/lib/firebase/registerCrudFunctions.d.ts +32 -0
  38. package/lib/firebase/scheduled/checkExpiredSubscriptions.d.ts +14 -0
  39. package/lib/firebase/scheduled/index.d.ts +9 -0
  40. package/lib/shared/billing/createCheckout.d.ts +50 -0
  41. package/lib/shared/billing/helpers/index.d.ts +10 -0
  42. package/lib/shared/billing/helpers/subscriptionManagement.d.ts +34 -0
  43. package/lib/shared/billing/helpers/updateUserSubscription.d.ts +45 -0
  44. package/lib/shared/billing/idempotency.d.ts +22 -0
  45. package/lib/shared/billing/index.d.ts +11 -0
  46. package/lib/shared/billing/webhookHandler.d.ts +37 -0
  47. package/lib/shared/errorHandling.d.ts +14 -0
  48. package/lib/shared/firebase.d.ts +73 -0
  49. package/lib/shared/github.d.ts +128 -0
  50. package/lib/shared/index.d.ts +16 -0
  51. package/lib/shared/index.js +25 -6927
  52. package/lib/shared/index.js.map +4 -4
  53. package/lib/shared/logger.d.ts +133 -0
  54. package/lib/shared/metadata.d.ts +36 -0
  55. package/lib/shared/oauth/exchangeToken.d.ts +24 -0
  56. package/lib/shared/oauth/grantAccess.d.ts +30 -0
  57. package/lib/shared/oauth/index.d.ts +10 -0
  58. package/lib/shared/schema.d.ts +56 -0
  59. package/lib/shared/utils/detectFirestore.d.ts +31 -0
  60. package/lib/shared/utils/external/date.d.ts +36 -0
  61. package/lib/shared/utils/external/index.d.ts +11 -0
  62. package/lib/shared/utils/external/references.d.ts +12 -0
  63. package/lib/shared/utils/external/subscription.d.ts +41 -0
  64. package/lib/shared/utils/firebaseHelpers.d.ts +23 -0
  65. package/lib/shared/utils/functionWrapper.d.ts +36 -0
  66. package/lib/shared/utils/index.d.ts +14 -0
  67. package/lib/shared/utils/internal/auth.d.ts +57 -0
  68. package/lib/shared/utils/internal/firebase.d.ts +5 -0
  69. package/lib/shared/utils/internal/idempotency.d.ts +21 -0
  70. package/lib/shared/utils/internal/index.d.ts +14 -0
  71. package/lib/shared/utils/internal/monitoring.d.ts +80 -0
  72. package/lib/shared/utils/internal/rateLimiter.d.ts +82 -0
  73. package/lib/shared/utils/internal/validation.d.ts +43 -0
  74. package/lib/shared/utils/schemaValidation.d.ts +60 -0
  75. package/lib/shared/utils/validation.d.ts +98 -0
  76. package/lib/shared/utils/vercelHelpers.d.ts +18 -0
  77. package/lib/shared/utils.d.ts +234 -0
  78. package/lib/shared/validation.d.ts +16 -0
  79. package/lib/supabase/auth/deleteAccount.d.ts +16 -0
  80. package/lib/supabase/auth/getCustomClaims.d.ts +16 -0
  81. package/lib/supabase/auth/getUserAuthStatus.d.ts +18 -0
  82. package/lib/supabase/auth/removeCustomClaims.d.ts +16 -0
  83. package/lib/supabase/auth/setCustomClaims.d.ts +18 -0
  84. package/lib/supabase/baseFunction.d.ts +43 -0
  85. package/lib/supabase/billing/cancelSubscription.d.ts +9 -0
  86. package/lib/supabase/billing/changePlan.d.ts +11 -0
  87. package/lib/supabase/billing/createCheckoutSession.d.ts +11 -0
  88. package/lib/supabase/billing/createCustomerPortal.d.ts +9 -0
  89. package/lib/supabase/billing/refreshSubscriptionStatus.d.ts +9 -0
  90. package/lib/supabase/crud/aggregate.d.ts +27 -0
  91. package/lib/supabase/crud/create.d.ts +23 -0
  92. package/lib/supabase/crud/delete.d.ts +30 -0
  93. package/lib/supabase/crud/get.d.ts +23 -0
  94. package/lib/supabase/crud/index.d.ts +20 -0
  95. package/lib/supabase/crud/list.d.ts +33 -0
  96. package/lib/supabase/crud/update.d.ts +24 -0
  97. package/lib/supabase/helpers/authProvider.d.ts +22 -0
  98. package/lib/supabase/index.d.ts +29 -0
  99. package/lib/supabase/index.js +23 -0
  100. package/lib/supabase/index.js.map +7 -0
  101. package/lib/supabase/registerCrudFunctions.d.ts +24 -0
  102. package/lib/supabase/utils/idempotency.d.ts +36 -0
  103. package/lib/supabase/utils/monitoring.d.ts +59 -0
  104. package/lib/supabase/utils/rateLimiter.d.ts +56 -0
  105. package/lib/vercel/api/auth/get-custom-claims.d.ts +2 -0
  106. package/lib/vercel/api/auth/get-user-auth-status.d.ts +2 -0
  107. package/lib/vercel/api/auth/index.d.ts +12 -0
  108. package/lib/vercel/api/auth/remove-custom-claims.d.ts +2 -0
  109. package/lib/vercel/api/auth/set-custom-claims.d.ts +10 -0
  110. package/lib/vercel/api/billing/cancel.d.ts +10 -0
  111. package/lib/vercel/api/billing/change-plan.d.ts +11 -0
  112. package/lib/vercel/api/billing/create-checkout-session.d.ts +13 -0
  113. package/lib/vercel/api/billing/customer-portal.d.ts +3 -0
  114. package/lib/vercel/api/billing/index.d.ts +14 -0
  115. package/lib/vercel/api/billing/refresh-subscription-status.d.ts +31 -0
  116. package/lib/vercel/api/billing/webhook-handler.d.ts +22 -0
  117. package/lib/vercel/api/config/constants.d.ts +103 -0
  118. package/lib/vercel/api/config/firebase-admin.d.ts +19 -0
  119. package/lib/vercel/api/config/index.d.ts +10 -0
  120. package/lib/vercel/api/crud/create.d.ts +2 -0
  121. package/lib/vercel/api/crud/delete.d.ts +2 -0
  122. package/lib/vercel/api/crud/get.d.ts +2 -0
  123. package/lib/vercel/api/crud/index.d.ts +13 -0
  124. package/lib/vercel/api/crud/list.d.ts +2 -0
  125. package/lib/vercel/api/crud/update.d.ts +2 -0
  126. package/lib/vercel/api/index.d.ts +13 -0
  127. package/lib/vercel/api/index.js +22 -4790
  128. package/lib/vercel/api/index.js.map +4 -4
  129. package/lib/vercel/api/oauth/check-github-access.d.ts +12 -0
  130. package/lib/vercel/api/oauth/exchange-token.d.ts +8 -0
  131. package/lib/vercel/api/oauth/grant-github-access.d.ts +12 -0
  132. package/lib/vercel/api/oauth/index.d.ts +12 -0
  133. package/lib/vercel/api/oauth/revoke-github-access.d.ts +11 -0
  134. package/lib/vercel/api/utils/cors.d.ts +49 -0
  135. package/lib/vercel/baseFunction.d.ts +25 -0
  136. package/package.json +4 -4
  137. package/src/firebase/auth/setCustomClaims.ts +61 -16
  138. package/src/firebase/billing/healthCheck.ts +7 -23
  139. package/src/firebase/billing/webhookHandler.ts +0 -1
  140. package/src/firebase/crud/create.ts +17 -2
  141. package/src/firebase/oauth/exchangeToken.ts +5 -5
  142. package/src/shared/billing/createCheckout.ts +6 -1
  143. package/src/shared/utils/internal/validation.ts +1 -1
  144. package/src/supabase/crud/aggregate.ts +10 -7
  145. package/src/supabase/crud/create.ts +1 -1
  146. package/src/supabase/crud/get.ts +1 -1
  147. package/src/supabase/crud/list.ts +1 -1
  148. package/src/supabase/crud/update.ts +1 -1
  149. package/src/vercel/api/auth/set-custom-claims.ts +70 -23
@@ -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.0.1
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.0.1
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.0.1
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.0.1
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.0.1
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.0.1
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.0.1
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.0.1
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.0.1
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.0.3
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,10 @@
1
+ /**
2
+ * Cancel subscription function
3
+ *
4
+ * @version 0.0.1
5
+ * @since 0.0.1
6
+ * @author AMBROISE PARK Consulting
7
+ */
8
+ export declare function cancelSubscription(): import("firebase-functions/https").CallableFunction<{
9
+ userId: string;
10
+ }, any, unknown>;
@@ -0,0 +1,13 @@
1
+ import type { StripeBackConfig } from '@donotdev/core/server';
2
+ /**
3
+ * Change subscription plan function
4
+ *
5
+ * @version 0.0.1
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.0.1
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,5 @@
1
+ /**
2
+ * Comprehensive health check for billing system
3
+ * GET /billingHealth
4
+ */
5
+ export declare const billingHealth: import("firebase-functions/https").HttpsFunction;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @fileoverview Firebase billing functions barrel exports
3
+ * @description Centralized exports for Firebase billing functions
4
+ *
5
+ * @version 0.0.1
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.0.1
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.0.1
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.0.1
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.0.1
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.0.1
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.0.1
86
+ * @since 0.0.1
87
+ * @author AMBROISE PARK Consulting
88
+ */
89
+ export type FirebaseRegion = keyof typeof AVAILABLE_REGIONS;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @fileoverview Firebase config barrel exports
3
+ * @description Centralized exports for Firebase configuration
4
+ *
5
+ * @version 0.0.1
6
+ * @since 0.0.1
7
+ * @author AMBROISE PARK Consulting
8
+ */
9
+ export * from './constants.js';
@@ -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.0.1
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.0.1
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.0.1
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.0.1
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.0.1
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.0.1
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>>;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Grant GitHub repository access to a user (helper function)
3
+ * Can be called directly from other functions
4
+ *
5
+ * @version 0.0.1
6
+ * @since 0.0.1
7
+ * @author AMBROISE PARK Consulting
8
+ */
9
+ export declare function grantGitHubAccessHelper(userId: string, githubUsername: string, repoConfig: {
10
+ owner: string;
11
+ repo: string;
12
+ }, permission?: 'pull' | 'triage' | 'push' | 'maintain' | 'admin', customClaims?: Record<string, any>): Promise<void>;
13
+ /**
14
+ * Get custom claims for a user (helper function)
15
+ * Can be called directly from other functions
16
+ *
17
+ * @version 0.0.1
18
+ * @since 0.0.1
19
+ * @author AMBROISE PARK Consulting
20
+ */
21
+ export declare function getCustomClaimsHelper(userId: string, claimKeys?: string[]): Promise<Record<string, any>>;
22
+ /**
23
+ * Set custom claims for a user (helper function)
24
+ * Can be called directly from other functions
25
+ *
26
+ * @version 0.0.1
27
+ * @since 0.0.1
28
+ * @author AMBROISE PARK Consulting
29
+ */
30
+ export declare function setCustomClaimsHelper(userId: string, claims: Record<string, any>, merge?: boolean): Promise<void>;