@donotdev/functions 0.0.20 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +3 -3
- package/guidelines/FUNCTIONS.md +9 -0
- package/guidelines/VERCEL.md +260 -0
- package/lib/firebase/auth/getCustomClaims.d.ts +2 -2
- package/lib/firebase/auth/getUserAuthStatus.d.ts +2 -2
- package/lib/firebase/auth/index.d.ts +1 -1
- package/lib/firebase/auth/removeCustomClaims.d.ts +2 -2
- package/lib/firebase/auth/setCustomClaims.d.ts +2 -2
- package/lib/firebase/baseFunction.d.ts +1 -1
- package/lib/firebase/billing/cancelSubscription.d.ts +1 -1
- package/lib/firebase/billing/changePlan.d.ts +1 -1
- package/lib/firebase/billing/createCheckoutSession.d.ts +10 -13
- package/lib/firebase/billing/createCustomerPortal.d.ts +1 -1
- package/lib/firebase/billing/index.d.ts +1 -1
- package/lib/firebase/billing/refreshSubscriptionStatus.d.ts +2 -2
- package/lib/firebase/config/constants.d.ts +4 -4
- package/lib/firebase/config/index.d.ts +1 -1
- package/lib/firebase/crud/aggregate.d.ts +2 -2
- package/lib/firebase/crud/delete.d.ts +1 -1
- package/lib/firebase/crud/get.d.ts +1 -1
- package/lib/firebase/crud/index.d.ts +1 -1
- package/lib/firebase/crud/update.d.ts +1 -1
- package/lib/firebase/helpers/githubAccessHelper.d.ts +3 -3
- package/lib/firebase/helpers/githubTeamAccessHelper.d.ts +2 -2
- package/lib/firebase/helpers/index.d.ts +1 -1
- package/lib/firebase/index.d.ts +1 -1
- package/lib/firebase/index.js +3 -3
- package/lib/firebase/index.js.map +4 -4
- package/lib/firebase/oauth/disconnect.d.ts +1 -1
- package/lib/firebase/oauth/exchangeToken.d.ts +1 -1
- package/lib/firebase/oauth/getConnections.d.ts +1 -1
- package/lib/firebase/oauth/githubAccess.d.ts +6 -6
- package/lib/firebase/oauth/index.d.ts +1 -1
- package/lib/firebase/oauth/refreshToken.d.ts +1 -1
- package/lib/firebase/scheduled/index.d.ts +1 -1
- package/lib/shared/ai/classifyAIError.d.ts +35 -0
- package/lib/shared/ai/costTracker.d.ts +20 -0
- package/lib/shared/ai/createAIRoute.d.ts +20 -0
- package/lib/shared/ai/index.d.ts +6 -0
- package/lib/shared/ai/resolveModelTier.d.ts +14 -0
- package/lib/shared/billing/createCheckout.d.ts +11 -5
- package/lib/shared/billing/helpers/index.d.ts +1 -1
- package/lib/shared/billing/helpers/subscriptionManagement.d.ts +3 -3
- package/lib/shared/billing/helpers/updateUserSubscription.d.ts +4 -4
- package/lib/shared/billing/idempotency.d.ts +2 -2
- package/lib/shared/billing/index.d.ts +1 -1
- package/lib/shared/billing/webhookHandler.d.ts +1 -1
- package/lib/shared/email/createEmailRoute.d.ts +30 -0
- package/lib/shared/email/index.d.ts +3 -0
- package/lib/shared/email/provider.d.ts +30 -0
- package/lib/shared/email/resendProvider.d.ts +22 -0
- package/lib/shared/errorHandling.d.ts +1 -1
- package/lib/shared/firebase.d.ts +7 -7
- package/lib/shared/github.d.ts +16 -11
- package/lib/shared/index.d.ts +3 -1
- package/lib/shared/index.js +4 -3
- package/lib/shared/index.js.map +4 -4
- package/lib/shared/logger.d.ts +8 -6
- package/lib/shared/metadata.d.ts +3 -3
- package/lib/shared/oauth/exchangeToken.d.ts +3 -2
- package/lib/shared/oauth/grantAccess.d.ts +3 -2
- package/lib/shared/oauth/index.d.ts +1 -1
- package/lib/shared/schema.d.ts +2 -2
- package/lib/shared/utils/detectFirestore.d.ts +3 -3
- package/lib/shared/utils/external/date.d.ts +2 -2
- package/lib/shared/utils/external/index.d.ts +1 -1
- package/lib/shared/utils/external/references.d.ts +1 -1
- package/lib/shared/utils/external/subscription.d.ts +5 -5
- package/lib/shared/utils/firebaseHelpers.d.ts +2 -2
- package/lib/shared/utils/functionWrapper.d.ts +4 -4
- package/lib/shared/utils/index.d.ts +1 -1
- package/lib/shared/utils/internal/auth.d.ts +4 -4
- package/lib/shared/utils/internal/idempotency.d.ts +3 -2
- package/lib/shared/utils/internal/index.d.ts +1 -1
- package/lib/shared/utils/internal/monitoring.d.ts +7 -7
- package/lib/shared/utils/internal/rateLimiter.d.ts +5 -5
- package/lib/shared/utils/internal/validation.d.ts +4 -4
- package/lib/shared/utils/schemaValidation.d.ts +6 -6
- package/lib/shared/utils/validation.d.ts +9 -9
- package/lib/shared/utils/vercelHelpers.d.ts +2 -2
- package/lib/shared/utils.d.ts +19 -19
- package/lib/shared/validation.d.ts +2 -2
- package/lib/supabase/ai/createAIFunction.d.ts +30 -0
- package/lib/supabase/auth/deleteAccount.d.ts +1 -1
- package/lib/supabase/auth/getCustomClaims.d.ts +1 -1
- package/lib/supabase/auth/getUserAuthStatus.d.ts +1 -1
- package/lib/supabase/auth/removeCustomClaims.d.ts +1 -1
- package/lib/supabase/auth/setCustomClaims.d.ts +12 -4
- package/lib/supabase/baseFunction.d.ts +2 -2
- package/lib/supabase/billing/cancelSubscription.d.ts +1 -1
- package/lib/supabase/billing/changePlan.d.ts +2 -2
- package/lib/supabase/billing/createCheckoutSession.d.ts +1 -1
- package/lib/supabase/billing/createCustomerPortal.d.ts +1 -1
- package/lib/supabase/billing/refreshSubscriptionStatus.d.ts +1 -1
- package/lib/supabase/crud/aggregate.d.ts +2 -1
- package/lib/supabase/crud/create.d.ts +2 -1
- package/lib/supabase/crud/delete.d.ts +1 -0
- package/lib/supabase/crud/get.d.ts +2 -1
- package/lib/supabase/crud/index.d.ts +1 -1
- package/lib/supabase/crud/list.d.ts +2 -1
- package/lib/supabase/crud/update.d.ts +2 -1
- package/lib/supabase/edgeFunction.d.ts +56 -0
- package/lib/supabase/email/createEmailFunction.d.ts +31 -0
- package/lib/supabase/helpers/authProvider.d.ts +2 -2
- package/lib/supabase/index.d.ts +11 -2
- package/lib/supabase/index.js +3 -2
- package/lib/supabase/index.js.map +4 -4
- 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/utils/idempotency.d.ts +1 -1
- package/lib/supabase/utils/monitoring.d.ts +1 -1
- package/lib/supabase/utils/rateLimiter.d.ts +1 -1
- package/lib/vercel/api/ai/chat.d.ts +29 -0
- package/lib/vercel/api/ai/index.d.ts +1 -0
- package/lib/vercel/api/auth/index.d.ts +1 -1
- package/lib/vercel/api/billing/cancel.d.ts +1 -1
- package/lib/vercel/api/billing/change-plan.d.ts +1 -1
- package/lib/vercel/api/billing/create-checkout-session.d.ts +1 -1
- package/lib/vercel/api/billing/index.d.ts +1 -1
- package/lib/vercel/api/billing/refresh-subscription-status.d.ts +1 -1
- package/lib/vercel/api/billing/webhook-handler.d.ts +2 -2
- package/lib/vercel/api/config/constants.d.ts +9 -9
- package/lib/vercel/api/config/firebase-admin.d.ts +2 -2
- package/lib/vercel/api/config/index.d.ts +1 -1
- package/lib/vercel/api/crud/index.d.ts +1 -1
- package/lib/vercel/api/index.d.ts +2 -1
- package/lib/vercel/api/index.js +3 -2
- package/lib/vercel/api/index.js.map +4 -4
- package/lib/vercel/api/oauth/check-github-access.d.ts +1 -1
- package/lib/vercel/api/oauth/grant-github-access.d.ts +1 -1
- package/lib/vercel/api/oauth/index.d.ts +1 -1
- package/lib/vercel/api/oauth/revoke-github-access.d.ts +1 -1
- package/lib/vercel/api/utils/cors.d.ts +4 -4
- package/lib/vercel/baseFunction.d.ts +2 -2
- package/package.json +38 -5
- 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 +70 -69
- 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 +79 -187
- package/src/firebase/billing/createCustomerPortal.ts +1 -1
- package/src/firebase/billing/healthCheck.ts +1 -1
- 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 -1
- 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 +2 -2
- 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 +6 -6
- 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 +6 -6
- 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/ai/__tests__/costTracker.test.ts +121 -0
- package/src/shared/ai/classifyAIError.ts +163 -0
- package/src/shared/ai/costTracker.ts +51 -0
- package/src/shared/ai/createAIRoute.ts +397 -0
- package/src/shared/ai/index.ts +8 -0
- package/src/shared/ai/resolveModelTier.ts +58 -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 +156 -11
- package/src/shared/billing/helpers/index.ts +1 -1
- package/src/shared/billing/helpers/subscriptionManagement.ts +13 -4
- package/src/shared/billing/helpers/updateUserSubscription.ts +4 -4
- package/src/shared/billing/idempotency.ts +9 -4
- package/src/shared/billing/index.ts +1 -1
- package/src/shared/billing/webhookHandler.ts +7 -7
- package/src/shared/email/createEmailRoute.ts +81 -0
- package/src/shared/email/index.ts +5 -0
- package/src/shared/email/provider.ts +31 -0
- package/src/shared/email/resendProvider.ts +56 -0
- package/src/shared/errorHandling.ts +12 -6
- package/src/shared/firebase.ts +7 -7
- package/src/shared/github.ts +49 -11
- package/src/shared/index.d.ts +9 -9
- package/src/shared/index.ts +3 -1
- package/src/shared/logger.ts +10 -8
- package/src/shared/metadata.ts +3 -3
- package/src/shared/oauth/__tests__/exchangeToken.test.ts +1 -1
- package/src/shared/oauth/exchangeToken.ts +3 -2
- package/src/shared/oauth/grantAccess.ts +3 -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 +4 -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 +12 -9
- package/src/shared/utils/internal/validation.ts +5 -5
- 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 +3 -3
- package/src/supabase/ai/createAIFunction.ts +75 -0
- 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 +38 -2
- package/src/supabase/auth/setCustomClaims.ts +66 -5
- package/src/supabase/baseFunction.ts +29 -5
- package/src/supabase/billing/cancelSubscription.ts +2 -2
- package/src/supabase/billing/changePlan.ts +8 -3
- package/src/supabase/billing/createCheckoutSession.ts +18 -4
- package/src/supabase/billing/createCustomerPortal.ts +2 -2
- package/src/supabase/billing/refreshSubscriptionStatus.ts +2 -2
- package/src/supabase/crud/aggregate.ts +2 -1
- package/src/supabase/crud/create.ts +2 -1
- package/src/supabase/crud/delete.ts +2 -1
- package/src/supabase/crud/get.ts +2 -1
- package/src/supabase/crud/index.ts +1 -1
- package/src/supabase/crud/list.ts +2 -1
- package/src/supabase/crud/update.ts +2 -1
- package/src/supabase/edgeFunction.ts +195 -0
- package/src/supabase/email/createEmailFunction.ts +75 -0
- package/src/supabase/helpers/authProvider.ts +2 -2
- package/src/supabase/index.ts +22 -2
- package/src/supabase/oauth/disconnect.ts +104 -0
- package/src/supabase/oauth/exchangeToken.ts +183 -0
- package/src/supabase/oauth/getConnections.ts +85 -0
- package/src/supabase/oauth/index.ts +15 -0
- package/src/supabase/oauth/refreshToken.ts +130 -0
- package/src/supabase/registerCrudFunctions.ts +30 -42
- package/src/supabase/utils/idempotency.ts +7 -3
- package/src/supabase/utils/monitoring.ts +1 -1
- package/src/supabase/utils/rateLimiter.ts +1 -1
- package/src/vercel/api/ai/chat.ts +77 -0
- package/src/vercel/api/ai/index.ts +1 -0
- 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 +2 -4
- 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 +30 -7
- 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 +11 -4
- 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 +2 -1
- package/src/vercel/api/oauth/check-github-access.ts +3 -3
- package/src/vercel/api/oauth/exchange-token.ts +25 -2
- 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 +10 -4
- package/src/vercel/baseFunction.ts +2 -2
package/src/shared/firebase.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @fileoverview Firebase data transformation utilities for functions
|
|
5
5
|
* @description Server-safe functions for converting data between Firebase and application formats
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
@@ -16,7 +16,7 @@ import type { DateValue, FirestoreTimestamp } from '@donotdev/core/server';
|
|
|
16
16
|
* @param date - The Date object to convert
|
|
17
17
|
* @returns A representation of the timestamp
|
|
18
18
|
*
|
|
19
|
-
* @version 0.0
|
|
19
|
+
* @version 0.1.0
|
|
20
20
|
* @since 0.0.1
|
|
21
21
|
* @author AMBROISE PARK Consulting
|
|
22
22
|
*/
|
|
@@ -40,7 +40,7 @@ export function createTimestamp(date: Date): FirestoreTimestamp {
|
|
|
40
40
|
* @returns The Firestore Timestamp
|
|
41
41
|
* @throws Error if the date is invalid
|
|
42
42
|
*
|
|
43
|
-
* @version 0.0
|
|
43
|
+
* @version 0.1.0
|
|
44
44
|
* @since 0.0.1
|
|
45
45
|
* @author AMBROISE PARK Consulting
|
|
46
46
|
*/
|
|
@@ -72,7 +72,7 @@ export function toTimestamp(date: string | Date): FirestoreTimestamp {
|
|
|
72
72
|
* @param timestamp - The Firestore Timestamp
|
|
73
73
|
* @returns The ISO string representation
|
|
74
74
|
*
|
|
75
|
-
* @version 0.0
|
|
75
|
+
* @version 0.1.0
|
|
76
76
|
* @since 0.0.1
|
|
77
77
|
* @author AMBROISE PARK Consulting
|
|
78
78
|
*/
|
|
@@ -85,7 +85,7 @@ export function toISOString(timestamp: FirestoreTimestamp): string {
|
|
|
85
85
|
* @param value - The value to check
|
|
86
86
|
* @returns True if the value is a Timestamp
|
|
87
87
|
*
|
|
88
|
-
* @version 0.0
|
|
88
|
+
* @version 0.1.0
|
|
89
89
|
* @since 0.0.1
|
|
90
90
|
* @author AMBROISE PARK Consulting
|
|
91
91
|
*/
|
|
@@ -106,7 +106,7 @@ export function isTimestamp(value: any): value is FirestoreTimestamp {
|
|
|
106
106
|
* @param includeDocumentIds - Whether to include document IDs
|
|
107
107
|
* @returns The transformed data
|
|
108
108
|
*
|
|
109
|
-
* @version 0.0
|
|
109
|
+
* @version 0.1.0
|
|
110
110
|
* @since 0.0.1
|
|
111
111
|
* @author AMBROISE PARK Consulting
|
|
112
112
|
*/
|
|
@@ -164,7 +164,7 @@ export function transformFirestoreData<T = any>(
|
|
|
164
164
|
* @param removeFields - Optional array of field names to remove
|
|
165
165
|
* @returns The prepared data
|
|
166
166
|
*
|
|
167
|
-
* @version 0.0
|
|
167
|
+
* @version 0.1.0
|
|
168
168
|
* @since 0.0.1
|
|
169
169
|
* @author AMBROISE PARK Consulting
|
|
170
170
|
*/
|
package/src/shared/github.ts
CHANGED
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
* @fileoverview GitHub API Service for functions
|
|
5
5
|
* @description Server-safe GitHub API utilities for repository management
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/** Configuration for authenticating with the GitHub API. */
|
|
12
13
|
export interface GitHubApiConfig {
|
|
13
14
|
accessToken: string;
|
|
14
15
|
baseUrl?: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
/** GitHub user profile returned by the API. */
|
|
17
19
|
export interface GitHubUser {
|
|
18
20
|
id: number;
|
|
19
21
|
login: string;
|
|
@@ -22,6 +24,7 @@ export interface GitHubUser {
|
|
|
22
24
|
avatar_url: string;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
/** GitHub repository metadata returned by the API. */
|
|
25
28
|
export interface GitHubRepository {
|
|
26
29
|
id: number;
|
|
27
30
|
name: string;
|
|
@@ -33,6 +36,7 @@ export interface GitHubRepository {
|
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
/** Request payload for adding a collaborator to a GitHub repository. */
|
|
36
40
|
export interface AddCollaboratorRequest {
|
|
37
41
|
owner: string;
|
|
38
42
|
repo: string;
|
|
@@ -40,16 +44,29 @@ export interface AddCollaboratorRequest {
|
|
|
40
44
|
permission?: 'pull' | 'triage' | 'push' | 'maintain' | 'admin';
|
|
41
45
|
}
|
|
42
46
|
|
|
47
|
+
/** Error response structure from the GitHub API. */
|
|
43
48
|
export interface GitHubApiError {
|
|
44
49
|
message: string;
|
|
45
50
|
documentation_url?: string;
|
|
46
51
|
status?: number;
|
|
47
52
|
}
|
|
48
53
|
|
|
54
|
+
/** Pattern for valid GitHub usernames, org names, repo names, and team slugs */
|
|
55
|
+
const SAFE_GITHUB_NAME = /^[a-zA-Z0-9_.-]+$/;
|
|
56
|
+
|
|
57
|
+
/** Validate a GitHub name (username, owner, repo, team slug) against path injection */
|
|
58
|
+
function validateGitHubName(name: string, label: string): void {
|
|
59
|
+
if (!SAFE_GITHUB_NAME.test(name)) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Invalid ${label}: must contain only alphanumeric, hyphens, underscores, and dots`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
49
66
|
/**
|
|
50
67
|
* GitHub API Service for server-side operations
|
|
51
68
|
*
|
|
52
|
-
* @version 0.0
|
|
69
|
+
* @version 0.1.0
|
|
53
70
|
* @since 0.0.1
|
|
54
71
|
* @author AMBROISE PARK Consulting
|
|
55
72
|
*/
|
|
@@ -66,7 +83,7 @@ export class GitHubApiService {
|
|
|
66
83
|
/**
|
|
67
84
|
* Get the current authenticated user
|
|
68
85
|
*
|
|
69
|
-
* @version 0.0
|
|
86
|
+
* @version 0.1.0
|
|
70
87
|
* @since 0.0.1
|
|
71
88
|
* @author AMBROISE PARK Consulting
|
|
72
89
|
*/
|
|
@@ -78,11 +95,14 @@ export class GitHubApiService {
|
|
|
78
95
|
/**
|
|
79
96
|
* Get user repositories
|
|
80
97
|
*
|
|
81
|
-
* @version 0.0
|
|
98
|
+
* @version 0.1.0
|
|
82
99
|
* @since 0.0.1
|
|
83
100
|
* @author AMBROISE PARK Consulting
|
|
84
101
|
*/
|
|
85
102
|
async getUserRepositories(username?: string): Promise<GitHubRepository[]> {
|
|
103
|
+
if (username) {
|
|
104
|
+
validateGitHubName(username, 'username');
|
|
105
|
+
}
|
|
86
106
|
const endpoint = username ? `/users/${username}/repos` : '/user/repos';
|
|
87
107
|
const response = await this.request<GitHubRepository[]>(endpoint);
|
|
88
108
|
return response;
|
|
@@ -91,11 +111,14 @@ export class GitHubApiService {
|
|
|
91
111
|
/**
|
|
92
112
|
* Add a collaborator to a repository
|
|
93
113
|
*
|
|
94
|
-
* @version 0.0
|
|
114
|
+
* @version 0.1.0
|
|
95
115
|
* @since 0.0.1
|
|
96
116
|
* @author AMBROISE PARK Consulting
|
|
97
117
|
*/
|
|
98
118
|
async addCollaborator(request: AddCollaboratorRequest): Promise<boolean> {
|
|
119
|
+
validateGitHubName(request.owner, 'owner');
|
|
120
|
+
validateGitHubName(request.repo, 'repo');
|
|
121
|
+
validateGitHubName(request.username, 'username');
|
|
99
122
|
try {
|
|
100
123
|
await this.request(
|
|
101
124
|
`/repos/${request.owner}/${request.repo}/collaborators/${request.username}`,
|
|
@@ -117,7 +140,7 @@ export class GitHubApiService {
|
|
|
117
140
|
* Check if a user is a collaborator on a repository
|
|
118
141
|
* Uses GitHub's direct API endpoint for efficiency
|
|
119
142
|
*
|
|
120
|
-
* @version 0.0
|
|
143
|
+
* @version 0.1.0
|
|
121
144
|
* @since 0.0.1
|
|
122
145
|
* @author AMBROISE PARK Consulting
|
|
123
146
|
*/
|
|
@@ -126,6 +149,9 @@ export class GitHubApiService {
|
|
|
126
149
|
repo: string,
|
|
127
150
|
username: string
|
|
128
151
|
): Promise<boolean> {
|
|
152
|
+
validateGitHubName(owner, 'owner');
|
|
153
|
+
validateGitHubName(repo, 'repo');
|
|
154
|
+
validateGitHubName(username, 'username');
|
|
129
155
|
try {
|
|
130
156
|
// GitHub returns 204 if user is collaborator, 404 if not
|
|
131
157
|
await this.request(`/repos/${owner}/${repo}/collaborators/${username}`, {
|
|
@@ -144,7 +170,7 @@ export class GitHubApiService {
|
|
|
144
170
|
/**
|
|
145
171
|
* Remove a collaborator from a repository
|
|
146
172
|
*
|
|
147
|
-
* @version 0.0
|
|
173
|
+
* @version 0.1.0
|
|
148
174
|
* @since 0.0.1
|
|
149
175
|
* @author AMBROISE PARK Consulting
|
|
150
176
|
*/
|
|
@@ -153,6 +179,9 @@ export class GitHubApiService {
|
|
|
153
179
|
repo: string,
|
|
154
180
|
username: string
|
|
155
181
|
): Promise<boolean> {
|
|
182
|
+
validateGitHubName(owner, 'owner');
|
|
183
|
+
validateGitHubName(repo, 'repo');
|
|
184
|
+
validateGitHubName(username, 'username');
|
|
156
185
|
try {
|
|
157
186
|
await this.request(`/repos/${owner}/${repo}/collaborators/${username}`, {
|
|
158
187
|
method: 'DELETE',
|
|
@@ -167,7 +196,7 @@ export class GitHubApiService {
|
|
|
167
196
|
/**
|
|
168
197
|
* Add a user to an organization team
|
|
169
198
|
*
|
|
170
|
-
* @version 0.0
|
|
199
|
+
* @version 0.1.0
|
|
171
200
|
* @since 0.0.1
|
|
172
201
|
* @author AMBROISE PARK Consulting
|
|
173
202
|
*/
|
|
@@ -177,6 +206,9 @@ export class GitHubApiService {
|
|
|
177
206
|
username: string,
|
|
178
207
|
role: 'member' | 'maintainer' = 'member'
|
|
179
208
|
): Promise<boolean> {
|
|
209
|
+
validateGitHubName(org, 'org');
|
|
210
|
+
validateGitHubName(teamSlug, 'teamSlug');
|
|
211
|
+
validateGitHubName(username, 'username');
|
|
180
212
|
try {
|
|
181
213
|
await this.request(
|
|
182
214
|
`/orgs/${org}/teams/${teamSlug}/memberships/${username}`,
|
|
@@ -195,7 +227,7 @@ export class GitHubApiService {
|
|
|
195
227
|
/**
|
|
196
228
|
* Remove a user from an organization team
|
|
197
229
|
*
|
|
198
|
-
* @version 0.0
|
|
230
|
+
* @version 0.1.0
|
|
199
231
|
* @since 0.0.1
|
|
200
232
|
* @author AMBROISE PARK Consulting
|
|
201
233
|
*/
|
|
@@ -204,6 +236,9 @@ export class GitHubApiService {
|
|
|
204
236
|
teamSlug: string,
|
|
205
237
|
username: string
|
|
206
238
|
): Promise<boolean> {
|
|
239
|
+
validateGitHubName(org, 'org');
|
|
240
|
+
validateGitHubName(teamSlug, 'teamSlug');
|
|
241
|
+
validateGitHubName(username, 'username');
|
|
207
242
|
try {
|
|
208
243
|
await this.request(
|
|
209
244
|
`/orgs/${org}/teams/${teamSlug}/memberships/${username}`,
|
|
@@ -221,7 +256,7 @@ export class GitHubApiService {
|
|
|
221
256
|
/**
|
|
222
257
|
* Check if a user is a member of an organization team
|
|
223
258
|
*
|
|
224
|
-
* @version 0.0
|
|
259
|
+
* @version 0.1.0
|
|
225
260
|
* @since 0.0.1
|
|
226
261
|
* @author AMBROISE PARK Consulting
|
|
227
262
|
*/
|
|
@@ -230,6 +265,9 @@ export class GitHubApiService {
|
|
|
230
265
|
teamSlug: string,
|
|
231
266
|
username: string
|
|
232
267
|
): Promise<boolean> {
|
|
268
|
+
validateGitHubName(org, 'org');
|
|
269
|
+
validateGitHubName(teamSlug, 'teamSlug');
|
|
270
|
+
validateGitHubName(username, 'username');
|
|
233
271
|
try {
|
|
234
272
|
await this.request(
|
|
235
273
|
`/orgs/${org}/teams/${teamSlug}/memberships/${username}`,
|
|
@@ -250,7 +288,7 @@ export class GitHubApiService {
|
|
|
250
288
|
/**
|
|
251
289
|
* Make an authenticated request to the GitHub API
|
|
252
290
|
*
|
|
253
|
-
* @version 0.0
|
|
291
|
+
* @version 0.1.0
|
|
254
292
|
* @since 0.0.1
|
|
255
293
|
* @author AMBROISE PARK Consulting
|
|
256
294
|
*/
|
package/src/shared/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @fileoverview Shared Functions Utilities
|
|
5
5
|
* @description Barrel exports for shared utilities used across Firebase and Vercel functions. Provides centralized access to common function utilities.
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
/**
|
|
13
13
|
* Error handling utilities
|
|
14
14
|
*
|
|
15
|
-
* @version 0.0
|
|
15
|
+
* @version 0.1.0
|
|
16
16
|
* @since 0.0.1
|
|
17
17
|
* @author AMBROISE PARK Consulting
|
|
18
18
|
*/
|
|
@@ -21,7 +21,7 @@ export * from './errorHandling.js';
|
|
|
21
21
|
/**
|
|
22
22
|
* GitHub integration utilities
|
|
23
23
|
*
|
|
24
|
-
* @version 0.0
|
|
24
|
+
* @version 0.1.0
|
|
25
25
|
* @since 0.0.1
|
|
26
26
|
* @author AMBROISE PARK Consulting
|
|
27
27
|
*/
|
|
@@ -30,7 +30,7 @@ export * from './github.js';
|
|
|
30
30
|
/**
|
|
31
31
|
* Metadata utilities
|
|
32
32
|
*
|
|
33
|
-
* @version 0.0
|
|
33
|
+
* @version 0.1.0
|
|
34
34
|
* @since 0.0.1
|
|
35
35
|
* @author AMBROISE PARK Consulting
|
|
36
36
|
*/
|
|
@@ -39,7 +39,7 @@ export * from './metadata.js';
|
|
|
39
39
|
/**
|
|
40
40
|
* Schema validation utilities
|
|
41
41
|
*
|
|
42
|
-
* @version 0.0
|
|
42
|
+
* @version 0.1.0
|
|
43
43
|
* @since 0.0.1
|
|
44
44
|
* @author AMBROISE PARK Consulting
|
|
45
45
|
*/
|
|
@@ -48,7 +48,7 @@ export * from './schema.js';
|
|
|
48
48
|
/**
|
|
49
49
|
* General utility functions
|
|
50
50
|
*
|
|
51
|
-
* @version 0.0
|
|
51
|
+
* @version 0.1.0
|
|
52
52
|
* @since 0.0.1
|
|
53
53
|
* @author AMBROISE PARK Consulting
|
|
54
54
|
*/
|
|
@@ -57,7 +57,7 @@ export * from './utils/index.js';
|
|
|
57
57
|
/**
|
|
58
58
|
* Billing utilities
|
|
59
59
|
*
|
|
60
|
-
* @version 0.0
|
|
60
|
+
* @version 0.1.0
|
|
61
61
|
* @since 0.0.1
|
|
62
62
|
* @author AMBROISE PARK Consulting
|
|
63
63
|
*/
|
|
@@ -66,7 +66,7 @@ export * from './billing/index.js';
|
|
|
66
66
|
/**
|
|
67
67
|
* OAuth utilities
|
|
68
68
|
*
|
|
69
|
-
* @version 0.0
|
|
69
|
+
* @version 0.1.0
|
|
70
70
|
* @since 0.0.1
|
|
71
71
|
* @author AMBROISE PARK Consulting
|
|
72
72
|
*/
|
|
@@ -75,7 +75,7 @@ export * from './oauth/index.js';
|
|
|
75
75
|
/**
|
|
76
76
|
* Firebase timestamp and data transformation utilities
|
|
77
77
|
*
|
|
78
|
-
* @version 0.0
|
|
78
|
+
* @version 0.1.0
|
|
79
79
|
* @since 0.0.1
|
|
80
80
|
* @author AMBROISE PARK Consulting
|
|
81
81
|
*/
|
package/src/shared/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @fileoverview Shared utilities barrel exports
|
|
5
5
|
* @description Centralized exports for shared function utilities
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
@@ -14,7 +14,9 @@ export * from './github.js';
|
|
|
14
14
|
export * from './metadata.js';
|
|
15
15
|
export * from './schema.js';
|
|
16
16
|
export * from './utils/index.js';
|
|
17
|
+
export * from './ai/index.js';
|
|
17
18
|
export * from './billing/index.js';
|
|
19
|
+
export * from './email/index.js';
|
|
18
20
|
export * from './oauth/index.js';
|
|
19
21
|
export {
|
|
20
22
|
createTimestamp,
|
package/src/shared/logger.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* logger.error('Database connection failed', { error: err });
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
-
* @version 0.0
|
|
21
|
+
* @version 0.1.0
|
|
22
22
|
* @since 0.0.1
|
|
23
23
|
* @author AMBROISE PARK Consulting
|
|
24
24
|
*/
|
|
@@ -41,7 +41,7 @@ let sentryInitialized = false;
|
|
|
41
41
|
* Initialize Sentry if not already done
|
|
42
42
|
* Called lazily to avoid Firebase Functions issues
|
|
43
43
|
*
|
|
44
|
-
* @version 0.0
|
|
44
|
+
* @version 0.1.0
|
|
45
45
|
* @since 0.0.1
|
|
46
46
|
* @author AMBROISE PARK Consulting
|
|
47
47
|
*/
|
|
@@ -128,7 +128,7 @@ export const logger = {
|
|
|
128
128
|
* @param message - Log message
|
|
129
129
|
* @param context - Additional context data
|
|
130
130
|
*
|
|
131
|
-
* @version 0.0
|
|
131
|
+
* @version 0.1.0
|
|
132
132
|
* @since 0.0.1
|
|
133
133
|
* @author AMBROISE PARK Consulting
|
|
134
134
|
*/
|
|
@@ -141,7 +141,7 @@ export const logger = {
|
|
|
141
141
|
* @param message - Log message
|
|
142
142
|
* @param context - Additional context data
|
|
143
143
|
*
|
|
144
|
-
* @version 0.0
|
|
144
|
+
* @version 0.1.0
|
|
145
145
|
* @since 0.0.1
|
|
146
146
|
* @author AMBROISE PARK Consulting
|
|
147
147
|
*/
|
|
@@ -154,7 +154,7 @@ export const logger = {
|
|
|
154
154
|
* @param message - Log message
|
|
155
155
|
* @param context - Additional context data
|
|
156
156
|
*
|
|
157
|
-
* @version 0.0
|
|
157
|
+
* @version 0.1.0
|
|
158
158
|
* @since 0.0.1
|
|
159
159
|
* @author AMBROISE PARK Consulting
|
|
160
160
|
*/
|
|
@@ -167,7 +167,7 @@ export const logger = {
|
|
|
167
167
|
* @param message - Log message
|
|
168
168
|
* @param context - Additional context data
|
|
169
169
|
*
|
|
170
|
-
* @version 0.0
|
|
170
|
+
* @version 0.1.0
|
|
171
171
|
* @since 0.0.1
|
|
172
172
|
* @author AMBROISE PARK Consulting
|
|
173
173
|
*/
|
|
@@ -199,7 +199,7 @@ export const logger = {
|
|
|
199
199
|
* @param message - Log message
|
|
200
200
|
* @param context - Additional context data
|
|
201
201
|
*
|
|
202
|
-
* @version 0.0
|
|
202
|
+
* @version 0.1.0
|
|
203
203
|
* @since 0.0.1
|
|
204
204
|
* @author AMBROISE PARK Consulting
|
|
205
205
|
*/
|
|
@@ -232,7 +232,9 @@ export const logger = {
|
|
|
232
232
|
* @param message - Log message
|
|
233
233
|
* @param context - Additional context data
|
|
234
234
|
*
|
|
235
|
-
* @
|
|
235
|
+
* @security Callers MUST NOT pass secrets (tokens, passwords, API keys) in context. Context is logged in plaintext.
|
|
236
|
+
*
|
|
237
|
+
* @version 0.1.0
|
|
236
238
|
* @since 0.0.1
|
|
237
239
|
* @author AMBROISE PARK Consulting
|
|
238
240
|
*/
|
package/src/shared/metadata.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @fileoverview Document metadata utilities for functions
|
|
5
5
|
* @description Server-safe metadata creation and update utilities
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @param userId - The ID of the user creating the document
|
|
15
15
|
* @returns An object with creation and update timestamps and user IDs
|
|
16
16
|
*
|
|
17
|
-
* @version 0.0
|
|
17
|
+
* @version 0.1.0
|
|
18
18
|
* @since 0.0.1
|
|
19
19
|
* @author AMBROISE PARK Consulting
|
|
20
20
|
*/
|
|
@@ -33,7 +33,7 @@ export function createMetadata(userId: string) {
|
|
|
33
33
|
* @param userId - The ID of the user updating the document
|
|
34
34
|
* @returns An object with update timestamp and user ID
|
|
35
35
|
*
|
|
36
|
-
* @version 0.0
|
|
36
|
+
* @version 0.1.0
|
|
37
37
|
* @since 0.0.1
|
|
38
38
|
* @author AMBROISE PARK Consulting
|
|
39
39
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @fileoverview OAuth Token Exchange Algorithm
|
|
5
5
|
* @description Platform-agnostic algorithm for exchanging OAuth codes for tokens
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
TokenResponse,
|
|
15
15
|
} from '@donotdev/core/server';
|
|
16
16
|
|
|
17
|
+
/** Platform-agnostic provider for exchanging OAuth authorization codes for tokens. */
|
|
17
18
|
export interface OAuthProvider {
|
|
18
19
|
exchangeCodeForToken(params: {
|
|
19
20
|
code: string;
|
|
@@ -25,7 +26,7 @@ export interface OAuthProvider {
|
|
|
25
26
|
/**
|
|
26
27
|
* Exchange OAuth code for token
|
|
27
28
|
*
|
|
28
|
-
* @version 0.0
|
|
29
|
+
* @version 0.1.0
|
|
29
30
|
* @since 0.0.1
|
|
30
31
|
* @author AMBROISE PARK Consulting
|
|
31
32
|
*/
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* @fileoverview Grant OAuth Access Algorithm
|
|
5
5
|
* @description Platform-agnostic algorithm for granting OAuth access
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/** Platform-agnostic provider for granting OAuth access to a user. */
|
|
12
13
|
export interface OAuthGrantProvider {
|
|
13
14
|
grantAccess(params: {
|
|
14
15
|
userId: string;
|
|
@@ -21,7 +22,7 @@ export interface OAuthGrantProvider {
|
|
|
21
22
|
/**
|
|
22
23
|
* Grant OAuth access to user
|
|
23
24
|
*
|
|
24
|
-
* @version 0.0
|
|
25
|
+
* @version 0.1.0
|
|
25
26
|
* @since 0.0.1
|
|
26
27
|
* @author AMBROISE PARK Consulting
|
|
27
28
|
*/
|
package/src/shared/schema.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @fileoverview Schema utilities for functions
|
|
5
5
|
* @description Server-safe schema field visibility utilities
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
@@ -30,7 +30,7 @@ interface ValibotSchemaWithVisibility extends v.BaseSchema<
|
|
|
30
30
|
* @param field - A Valibot schema field (e.g., v.string()).
|
|
31
31
|
* @returns The visibility setting if found, otherwise undefined.
|
|
32
32
|
*
|
|
33
|
-
* @version 0.0
|
|
33
|
+
* @version 0.1.0
|
|
34
34
|
* @since 0.0.1
|
|
35
35
|
* @author AMBROISE PARK Consulting
|
|
36
36
|
*/
|
|
@@ -61,7 +61,7 @@ function getFieldVisibility(field: any): Visibility | undefined {
|
|
|
61
61
|
* @param isAuthenticated - Whether the current user is authenticated (defaults to true for backward compat).
|
|
62
62
|
* @returns True if the field should be visible, false otherwise.
|
|
63
63
|
*
|
|
64
|
-
* @version 0.0
|
|
64
|
+
* @version 0.1.0
|
|
65
65
|
* @since 0.0.1
|
|
66
66
|
* @author AMBROISE PARK Consulting
|
|
67
67
|
*/
|
|
@@ -114,7 +114,7 @@ export function isFieldVisible(
|
|
|
114
114
|
* @returns An array of strings, where each string is the name of a visible field.
|
|
115
115
|
* Returns an empty array if the schema is not an object schema or has no entries.
|
|
116
116
|
*
|
|
117
|
-
* @version 0.0
|
|
117
|
+
* @version 0.1.0
|
|
118
118
|
* @since 0.0.1
|
|
119
119
|
* @author AMBROISE PARK Consulting
|
|
120
120
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @fileoverview Firestore Detection Utility
|
|
5
5
|
* @description Detects if Firestore credentials are available
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* OR checks if running in Firebase Functions environment
|
|
21
21
|
*
|
|
22
|
-
* @version 0.0
|
|
22
|
+
* @version 0.1.0
|
|
23
23
|
* @since 0.0.1
|
|
24
24
|
* @author AMBROISE PARK Consulting
|
|
25
25
|
*/
|
|
@@ -40,7 +40,7 @@ export function isFirestoreConfigured(): boolean {
|
|
|
40
40
|
/**
|
|
41
41
|
* Check if Firestore is actually available (can connect)
|
|
42
42
|
*
|
|
43
|
-
* @version 0.0
|
|
43
|
+
* @version 0.1.0
|
|
44
44
|
* @since 0.0.1
|
|
45
45
|
* @author AMBROISE PARK Consulting
|
|
46
46
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @fileoverview Date utility functions for functions package
|
|
5
5
|
* @description Self-contained date conversion utilities for server-side functions
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
@@ -33,7 +33,7 @@ export interface FirestoreTimestamp {
|
|
|
33
33
|
* Converts various date formats to ISO string
|
|
34
34
|
* Handles Date, FirestoreTimestamp, and string inputs
|
|
35
35
|
*
|
|
36
|
-
* @version 0.0
|
|
36
|
+
* @version 0.1.0
|
|
37
37
|
* @since 0.0.1
|
|
38
38
|
* @author AMBROISE PARK Consulting
|
|
39
39
|
*/
|
|
@@ -70,7 +70,7 @@ export function toISOString(date: DateValue): string {
|
|
|
70
70
|
* Add months to a date with proper edge case handling
|
|
71
71
|
* Fixes issues like Jan 31 + 1 month = March 3 (should be Feb 28/29)
|
|
72
72
|
*
|
|
73
|
-
* @version 0.0
|
|
73
|
+
* @version 0.1.0
|
|
74
74
|
* @since 0.0.1
|
|
75
75
|
* @author AMBROISE PARK Consulting
|
|
76
76
|
*/
|
|
@@ -91,7 +91,7 @@ function addMonths(date: Date, months: number): Date {
|
|
|
91
91
|
* Add years to a date with proper edge case handling
|
|
92
92
|
* Fixes issues like Feb 29 + 1 year in non-leap year
|
|
93
93
|
*
|
|
94
|
-
* @version 0.0
|
|
94
|
+
* @version 0.1.0
|
|
95
95
|
* @since 0.0.1
|
|
96
96
|
* @author AMBROISE PARK Consulting
|
|
97
97
|
*/
|
|
@@ -111,7 +111,7 @@ function addYears(date: Date, years: number): Date {
|
|
|
111
111
|
/**
|
|
112
112
|
* Calculate subscription end date with proper edge case handling
|
|
113
113
|
*
|
|
114
|
-
* @version 0.0
|
|
114
|
+
* @version 0.1.0
|
|
115
115
|
* @since 0.0.1
|
|
116
116
|
* @author AMBROISE PARK Consulting
|
|
117
117
|
* @param duration - Duration string (e.g., '1month', '3months', '1year', 'lifetime')
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @fileoverview Reference checking utilities
|
|
5
5
|
* @description Functions for checking document references before deletion
|
|
6
6
|
*
|
|
7
|
-
* @version 0.0
|
|
7
|
+
* @version 0.1.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
@@ -14,7 +14,7 @@ import { getFirebaseAdminFirestore } from '@donotdev/firebase/server';
|
|
|
14
14
|
/**
|
|
15
15
|
* Finds all documents that reference the given document ID
|
|
16
16
|
*
|
|
17
|
-
* @version 0.0
|
|
17
|
+
* @version 0.1.0
|
|
18
18
|
* @since 0.0.1
|
|
19
19
|
* @author AMBROISE PARK Consulting
|
|
20
20
|
*/
|