@donotdev/functions 0.1.44 → 0.2.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/README.md +25 -14
- package/lib/chunks/chunk-3F4BWKQD.js +22 -0
- package/lib/chunks/chunk-3F4BWKQD.js.map +7 -0
- package/lib/chunks/chunk-5IPULSUX.js +22 -0
- package/lib/chunks/chunk-5IPULSUX.js.map +7 -0
- package/lib/chunks/chunk-6USHTJED.js +22 -0
- package/lib/chunks/chunk-6USHTJED.js.map +7 -0
- package/lib/chunks/chunk-AYY7UXNI.js +22 -0
- package/lib/chunks/chunk-AYY7UXNI.js.map +7 -0
- package/lib/chunks/chunk-CXBSROEW.js +23 -0
- package/lib/chunks/chunk-CXBSROEW.js.map +7 -0
- package/lib/chunks/chunk-GYTCWMXV.js +22 -0
- package/lib/chunks/chunk-GYTCWMXV.js.map +7 -0
- package/lib/chunks/chunk-HLNYUAZH.js +22 -0
- package/lib/chunks/chunk-HLNYUAZH.js.map +7 -0
- package/lib/chunks/chunk-LCDLG4VG.js +151 -0
- package/lib/chunks/chunk-LCDLG4VG.js.map +7 -0
- package/lib/chunks/chunk-MQANUSY3.js +22 -0
- package/lib/chunks/chunk-MQANUSY3.js.map +7 -0
- package/lib/chunks/chunk-OFQVO3FD.js +22 -0
- package/lib/chunks/chunk-OFQVO3FD.js.map +7 -0
- package/lib/chunks/chunk-PWAGW4R6.js +22 -0
- package/lib/chunks/chunk-PWAGW4R6.js.map +7 -0
- package/lib/chunks/chunk-US2VOP4S.js +22 -0
- package/lib/chunks/chunk-US2VOP4S.js.map +7 -0
- package/lib/chunks/chunk-YTKDNZNW.js +22 -0
- package/lib/chunks/chunk-YTKDNZNW.js.map +7 -0
- package/lib/chunks/monitoring-E7JBYBHQ.js +22 -0
- package/lib/chunks/monitoring-E7JBYBHQ.js.map +7 -0
- package/lib/chunks/rateLimiter-SQISLOP5.js +22 -0
- package/lib/chunks/rateLimiter-SQISLOP5.js.map +7 -0
- package/lib/chunks/server-IQ5JNJOM.js +22 -0
- package/lib/chunks/server-IQ5JNJOM.js.map +7 -0
- package/lib/firebase/auth/getCustomClaims.d.ts +1 -1
- package/lib/firebase/auth/getUserAuthStatus.d.ts +1 -1
- package/lib/firebase/auth/index.d.ts +0 -0
- package/lib/firebase/auth/removeCustomClaims.d.ts +1 -1
- package/lib/firebase/auth/setCustomClaims.d.ts +1 -1
- package/lib/firebase/baseFunction.d.ts +1 -1
- package/lib/firebase/billing/cancelSubscription.d.ts +0 -0
- package/lib/firebase/billing/changePlan.d.ts +0 -0
- package/lib/firebase/billing/createCheckoutSession.d.ts +2 -2
- package/lib/firebase/billing/createCustomerPortal.d.ts +1 -1
- package/lib/firebase/billing/healthCheck.d.ts +0 -0
- package/lib/firebase/billing/index.d.ts +2 -1
- package/lib/firebase/billing/refreshSubscriptionStatus.d.ts +0 -8
- package/lib/firebase/billing/webhookHandler.d.ts +17 -2
- package/lib/firebase/config/constants.d.ts +0 -0
- package/lib/firebase/config/index.d.ts +0 -0
- package/lib/firebase/config/secrets.d.ts +0 -0
- package/lib/firebase/crud/aggregate.d.ts +0 -9
- package/lib/firebase/crud/bulk.d.ts +2 -2
- package/lib/firebase/crud/create.d.ts +1 -1
- package/lib/firebase/crud/delete.d.ts +1 -1
- package/lib/firebase/crud/get.d.ts +1 -1
- package/lib/firebase/crud/index.d.ts +0 -0
- package/lib/firebase/crud/list.d.ts +1 -1
- package/lib/firebase/crud/update.d.ts +1 -9
- package/lib/firebase/helpers/githubAccessHelper.d.ts +0 -0
- package/lib/firebase/helpers/githubTeamAccessHelper.d.ts +0 -0
- package/lib/firebase/helpers/index.d.ts +0 -0
- package/lib/firebase/index.d.ts +0 -0
- package/lib/firebase/index.js +1 -5
- package/lib/firebase/index.js.map +4 -4
- package/lib/firebase/oauth/disconnect.d.ts +0 -0
- package/lib/firebase/oauth/exchangeToken.d.ts +0 -0
- package/lib/firebase/oauth/getConnections.d.ts +0 -0
- package/lib/firebase/oauth/githubAccess.d.ts +2 -2
- package/lib/firebase/oauth/index.d.ts +0 -0
- package/lib/firebase/oauth/refreshToken.d.ts +0 -0
- package/lib/firebase/registerCrudFunctions.d.ts +9 -1
- package/lib/firebase/scheduled/checkExpiredSubscriptions.d.ts +0 -0
- package/lib/firebase/scheduled/index.d.ts +0 -0
- package/lib/shared/ai/classifyAIError.d.ts +0 -0
- package/lib/shared/ai/costTracker.d.ts +0 -0
- package/lib/shared/ai/createAIRoute.d.ts +0 -0
- package/lib/shared/ai/index.d.ts +0 -0
- package/lib/shared/ai/resolveModelTier.d.ts +0 -0
- package/lib/shared/billing/apiVersion.d.ts +22 -0
- package/lib/shared/billing/checkoutPrice.d.ts +27 -0
- package/lib/shared/billing/checkoutValidation.d.ts +89 -0
- package/lib/shared/billing/createCheckout.d.ts +73 -24
- package/lib/shared/billing/firestoreIdempotency.d.ts +13 -0
- package/lib/shared/billing/helpers/index.d.ts +0 -1
- package/lib/shared/billing/helpers/subscriptionManagement.d.ts +4 -4
- package/lib/shared/billing/helpers/updateUserSubscription.d.ts +2 -29
- package/lib/shared/billing/idempotency.d.ts +21 -10
- package/lib/shared/billing/idempotencyContract.d.ts +121 -0
- package/lib/shared/billing/index.d.ts +2 -0
- package/lib/shared/billing/orderWebhook.d.ts +75 -0
- package/lib/shared/billing/stripeClient.d.ts +45 -0
- package/lib/shared/billing/supabaseIdempotency.d.ts +32 -0
- package/lib/shared/billing/tierWebhookEvents.d.ts +54 -0
- package/lib/shared/billing/webhookHandler.d.ts +29 -20
- package/lib/shared/email/createEmailRoute.d.ts +0 -0
- package/lib/shared/email/index.d.ts +0 -0
- package/lib/shared/email/provider.d.ts +0 -0
- package/lib/shared/email/resendProvider.d.ts +0 -0
- package/lib/shared/errorHandling.d.ts +0 -0
- package/lib/shared/firebase.d.ts +0 -0
- package/lib/shared/github.d.ts +0 -0
- package/lib/shared/index.d.ts +0 -0
- package/lib/shared/index.js +1 -6
- package/lib/shared/index.js.map +4 -4
- package/lib/shared/logger.d.ts +0 -0
- package/lib/shared/metadata.d.ts +0 -0
- package/lib/shared/oauth/exchangeToken.d.ts +0 -0
- package/lib/shared/oauth/grantAccess.d.ts +0 -0
- package/lib/shared/oauth/index.d.ts +0 -0
- package/lib/shared/schema.d.ts +0 -0
- package/lib/shared/utils/detectFirestore.d.ts +0 -0
- package/lib/shared/utils/external/date.d.ts +0 -0
- package/lib/shared/utils/external/index.d.ts +0 -0
- package/lib/shared/utils/external/references.d.ts +0 -0
- package/lib/shared/utils/external/subscription.d.ts +0 -0
- package/lib/shared/utils/firebaseHelpers.d.ts +0 -0
- package/lib/shared/utils/functionWrapper.d.ts +1 -1
- package/lib/shared/utils/index.d.ts +0 -0
- package/lib/shared/utils/internal/auth.d.ts +38 -1
- package/lib/shared/utils/internal/firebase.d.ts +0 -0
- package/lib/shared/utils/internal/idempotency.d.ts +0 -0
- package/lib/shared/utils/internal/index.d.ts +0 -0
- package/lib/shared/utils/internal/monitoring.d.ts +0 -0
- package/lib/shared/utils/internal/rateLimiter.d.ts +8 -0
- package/lib/shared/utils/internal/validation.d.ts +0 -8
- package/lib/shared/utils/schemaValidation.d.ts +1 -1
- package/lib/shared/utils/validation.d.ts +0 -0
- package/lib/shared/utils/vercelHelpers.d.ts +8 -0
- package/lib/shared/utils.d.ts +0 -56
- package/lib/shared/validation.d.ts +0 -0
- package/lib/supabase/ai/createAIFunction.d.ts +0 -0
- package/lib/supabase/auth/deleteAccount.d.ts +0 -0
- package/lib/supabase/auth/getCustomClaims.d.ts +0 -0
- package/lib/supabase/auth/getUserAuthStatus.d.ts +0 -0
- package/lib/supabase/auth/removeCustomClaims.d.ts +0 -0
- package/lib/supabase/auth/setCustomClaims.d.ts +0 -0
- package/lib/supabase/baseFunction.d.ts +1 -1
- package/lib/supabase/billing/cancelSubscription.d.ts +0 -0
- package/lib/supabase/billing/changePlan.d.ts +0 -0
- package/lib/supabase/billing/createCheckoutSession.d.ts +0 -0
- package/lib/supabase/billing/createCustomerPortal.d.ts +0 -0
- package/lib/supabase/billing/refreshSubscriptionStatus.d.ts +0 -0
- package/lib/supabase/billing/stripeWebhook.d.ts +34 -0
- package/lib/supabase/crud/aggregate.d.ts +0 -0
- package/lib/supabase/crud/bulk.d.ts +1 -1
- package/lib/supabase/crud/create.d.ts +0 -0
- package/lib/supabase/crud/delete.d.ts +0 -0
- package/lib/supabase/crud/entityStore.d.ts +71 -0
- package/lib/supabase/crud/get.d.ts +0 -0
- package/lib/supabase/crud/index.d.ts +2 -0
- package/lib/supabase/crud/list.d.ts +0 -8
- package/lib/supabase/crud/update.d.ts +0 -0
- package/lib/supabase/edgeFunction.d.ts +0 -0
- package/lib/supabase/email/createEmailFunction.d.ts +0 -0
- package/lib/supabase/helpers/authProvider.d.ts +5 -5
- package/lib/supabase/index.d.ts +11 -2
- package/lib/supabase/index.js +1 -3
- package/lib/supabase/index.js.map +4 -4
- package/lib/supabase/oauth/disconnect.d.ts +0 -0
- package/lib/supabase/oauth/exchangeToken.d.ts +0 -0
- package/lib/supabase/oauth/getConnections.d.ts +0 -0
- package/lib/supabase/oauth/index.d.ts +0 -0
- package/lib/supabase/oauth/refreshToken.d.ts +0 -0
- package/lib/supabase/registerCrudFunctions.d.ts +0 -0
- package/lib/supabase/utils/idempotency.d.ts +0 -0
- package/lib/supabase/utils/monitoring.d.ts +0 -0
- package/lib/supabase/utils/rateLimiter.d.ts +1 -1
- package/lib/vercel/api/ai/chat.d.ts +0 -9
- package/lib/vercel/api/ai/index.d.ts +0 -0
- package/lib/vercel/api/auth/get-custom-claims.d.ts +8 -0
- package/lib/vercel/api/auth/get-user-auth-status.d.ts +8 -0
- package/lib/vercel/api/auth/index.d.ts +0 -0
- package/lib/vercel/api/auth/remove-custom-claims.d.ts +8 -0
- package/lib/vercel/api/auth/set-custom-claims.d.ts +8 -0
- package/lib/vercel/api/billing/backend.d.ts +39 -0
- package/lib/vercel/api/billing/cancel.d.ts +8 -0
- package/lib/vercel/api/billing/change-plan.d.ts +9 -1
- package/lib/vercel/api/billing/create-checkout-session.d.ts +25 -6
- package/lib/vercel/api/billing/customer-portal.d.ts +8 -0
- package/lib/vercel/api/billing/index.d.ts +4 -2
- package/lib/vercel/api/billing/refresh-subscription-status.d.ts +19 -3
- package/lib/vercel/api/billing/webhook-handler.d.ts +25 -4
- package/lib/vercel/api/config/constants.d.ts +0 -0
- package/lib/vercel/api/config/firebase-admin.d.ts +8 -0
- package/lib/vercel/api/config/index.d.ts +0 -0
- package/lib/vercel/api/crud/bulk.d.ts +17 -0
- package/lib/vercel/api/crud/create.d.ts +8 -0
- package/lib/vercel/api/crud/delete.d.ts +8 -0
- package/lib/vercel/api/crud/get.d.ts +8 -0
- package/lib/vercel/api/crud/index.d.ts +0 -0
- package/lib/vercel/api/crud/list.d.ts +8 -0
- package/lib/vercel/api/crud/update.d.ts +8 -0
- package/lib/vercel/api/index.d.ts +0 -0
- package/lib/vercel/api/index.js +1 -3
- package/lib/vercel/api/index.js.map +4 -4
- package/lib/vercel/api/oauth/check-github-access.d.ts +8 -0
- package/lib/vercel/api/oauth/exchange-token.d.ts +8 -0
- package/lib/vercel/api/oauth/grant-github-access.d.ts +8 -0
- package/lib/vercel/api/oauth/index.d.ts +0 -0
- package/lib/vercel/api/oauth/revoke-github-access.d.ts +1 -1
- package/lib/vercel/api/utils/cors.d.ts +0 -0
- package/lib/vercel/baseFunction.d.ts +4 -1
- package/lib/vercel/supabaseAdmin.d.ts +22 -0
- package/package.json +25 -26
- package/src/firebase/auth/getCustomClaims.ts +4 -5
- package/src/firebase/auth/getUserAuthStatus.ts +4 -5
- package/src/firebase/auth/removeCustomClaims.ts +4 -5
- package/src/firebase/auth/setCustomClaims.ts +4 -5
- package/src/firebase/baseFunction.ts +4 -5
- package/src/firebase/billing/cancelSubscription.ts +2 -3
- package/src/firebase/billing/changePlan.ts +3 -8
- package/src/firebase/billing/createCheckoutSession.ts +31 -61
- package/src/firebase/billing/createCustomerPortal.ts +5 -6
- package/src/firebase/billing/healthCheck.ts +1 -1
- package/src/firebase/billing/index.ts +8 -1
- package/src/firebase/billing/refreshSubscriptionStatus.ts +3 -4
- package/src/firebase/billing/webhookHandler.ts +21 -5
- package/src/firebase/crud/__tests__/bulk.test.ts +11 -1
- package/src/firebase/crud/aggregate.ts +1 -2
- package/src/firebase/crud/bulk.ts +5 -6
- package/src/firebase/crud/create.ts +5 -6
- package/src/firebase/crud/delete.ts +4 -5
- package/src/firebase/crud/get.ts +4 -5
- package/src/firebase/crud/list.ts +4 -5
- package/src/firebase/crud/update.ts +5 -6
- package/src/firebase/oauth/githubAccess.ts +2 -3
- package/src/firebase/registerCrudFunctions.ts +2 -2
- package/src/shared/__tests__/auth.test.ts +0 -3
- package/src/shared/__tests__/bulkCore.test.ts +3 -2
- package/src/shared/__tests__/errorHandling.test.ts +2 -2
- package/src/shared/__tests__/idempotency.test.ts +282 -55
- package/src/shared/__tests__/internalValidation.test.ts +3 -42
- package/src/shared/__tests__/logger.test.ts +31 -0
- package/src/shared/__tests__/rateLimiter.test.ts +2 -8
- package/src/shared/__tests__/schemaValidation.test.ts +1 -1
- package/src/shared/__tests__/utils.test.ts +3 -2
- package/src/shared/__tests__/validation-env.test.ts +0 -0
- package/src/shared/ai/createAIRoute.ts +53 -30
- package/src/shared/billing/__tests__/checkoutValidation.test.ts +219 -0
- package/src/shared/billing/__tests__/createCheckout.compat.test.ts +349 -0
- package/src/shared/billing/__tests__/createCheckout.test.ts +454 -411
- package/src/shared/billing/__tests__/firestoreIdempotency.emulator.test.ts +92 -0
- package/src/shared/billing/__tests__/webhookCorrectness.test.ts +387 -0
- package/src/shared/billing/__tests__/webhookHandler.test.ts +370 -23
- package/src/shared/billing/apiVersion.ts +25 -0
- package/src/shared/billing/checkoutPrice.ts +125 -0
- package/src/shared/billing/checkoutValidation.ts +284 -0
- package/src/shared/billing/createCheckout.ts +332 -196
- package/src/shared/billing/firestoreIdempotency.ts +189 -0
- package/src/shared/billing/helpers/index.ts +0 -1
- package/src/shared/billing/helpers/subscriptionManagement.ts +8 -10
- package/src/shared/billing/helpers/updateUserSubscription.ts +3 -36
- package/src/shared/billing/idempotency.ts +104 -168
- package/src/shared/billing/idempotencyContract.ts +135 -0
- package/src/shared/billing/index.ts +2 -0
- package/src/shared/billing/orderWebhook.ts +269 -0
- package/src/shared/billing/stripeClient.ts +91 -0
- package/src/shared/billing/supabaseIdempotency.ts +228 -0
- package/src/shared/billing/tierWebhookEvents.ts +432 -0
- package/src/shared/billing/webhookHandler.ts +189 -386
- package/src/shared/logger.ts +4 -6
- package/src/shared/utils/external/subscription.ts +0 -0
- package/src/shared/utils/firebaseHelpers.ts +2 -3
- package/src/shared/utils/functionWrapper.ts +1 -2
- package/src/shared/utils/internal/auth.ts +55 -7
- package/src/shared/utils/internal/monitoring.ts +17 -9
- package/src/shared/utils/internal/rateLimiter.ts +14 -5
- package/src/shared/utils/internal/validation.ts +0 -18
- package/src/shared/utils/schemaValidation.ts +1 -2
- package/src/shared/utils/vercelHelpers.ts +3 -3
- package/src/shared/utils.ts +5 -99
- package/src/shared/validation.ts +1 -1
- package/src/supabase/__tests__/bulk.test.ts +3 -1
- package/src/supabase/__tests__/entityStore.test.ts +90 -0
- package/src/supabase/baseFunction.ts +1 -2
- package/src/supabase/billing/cancelSubscription.ts +1 -1
- package/src/supabase/billing/changePlan.ts +1 -1
- package/src/supabase/billing/createCheckoutSession.ts +11 -41
- package/src/supabase/billing/createCustomerPortal.ts +1 -1
- package/src/supabase/billing/refreshSubscriptionStatus.ts +2 -7
- package/src/supabase/billing/stripeWebhook.ts +79 -0
- package/src/supabase/crud/aggregate.ts +1 -1
- package/src/supabase/crud/bulk.ts +3 -7
- package/src/supabase/crud/create.ts +1 -1
- package/src/supabase/crud/entityStore.ts +240 -0
- package/src/supabase/crud/index.ts +8 -0
- package/src/supabase/crud/list.ts +2 -0
- package/src/supabase/crud/update.ts +1 -1
- package/src/supabase/helpers/authProvider.ts +6 -5
- package/src/supabase/index.ts +26 -0
- package/src/supabase/utils/rateLimiter.ts +2 -2
- package/src/vercel/__tests__/bulk.test.ts +24 -21
- package/src/vercel/__tests__/firebaseOptional.test.ts +64 -0
- package/src/vercel/api/ai/chat.ts +2 -1
- package/src/vercel/api/auth/get-custom-claims.ts +2 -3
- package/src/vercel/api/auth/get-user-auth-status.ts +2 -3
- package/src/vercel/api/auth/remove-custom-claims.ts +2 -3
- package/src/vercel/api/auth/set-custom-claims.ts +3 -3
- package/src/vercel/api/billing/backend.ts +72 -0
- package/src/vercel/api/billing/cancel.ts +2 -4
- package/src/vercel/api/billing/change-plan.ts +4 -5
- package/src/vercel/api/billing/create-checkout-session.ts +43 -73
- package/src/vercel/api/billing/customer-portal.ts +3 -5
- package/src/vercel/api/billing/index.ts +4 -2
- package/src/vercel/api/billing/refresh-subscription-status.ts +22 -7
- package/src/vercel/api/billing/webhook-handler.ts +32 -26
- package/src/vercel/api/config/firebase-admin.ts +2 -2
- package/src/vercel/api/crud/bulk.ts +6 -9
- package/src/vercel/api/crud/create.ts +6 -5
- package/src/vercel/api/crud/delete.ts +4 -3
- package/src/vercel/api/crud/get.ts +6 -5
- package/src/vercel/api/crud/list.ts +6 -5
- package/src/vercel/api/crud/update.ts +6 -5
- package/src/vercel/api/oauth/check-github-access.ts +5 -5
- package/src/vercel/api/oauth/exchange-token.ts +3 -3
- package/src/vercel/api/oauth/grant-github-access.ts +5 -5
- package/src/vercel/api/oauth/revoke-github-access.ts +3 -4
- package/src/vercel/baseFunction.ts +23 -8
- package/src/vercel/supabaseAdmin.ts +45 -0
- package/lib/shared/ai/createAIHandler.d.ts +0 -39
- package/lib/shared/ai/providers/anthropic.d.ts +0 -12
- package/lib/shared/ai/providers/google.d.ts +0 -10
- package/lib/shared/ai/providers/index.d.ts +0 -23
- package/lib/shared/ai/providers/openai.d.ts +0 -10
- package/lib/shared/ai/utils/parseSSE.d.ts +0 -22
|
@@ -74,8 +74,10 @@ vi.mock('@donotdev/firebase/server', () => ({
|
|
|
74
74
|
}));
|
|
75
75
|
|
|
76
76
|
// Import AFTER mocks are in place.
|
|
77
|
-
import { bulkEntityLogicFactory } from '../bulk';
|
|
78
77
|
import { BulkCollisionError } from '@donotdev/core/server';
|
|
78
|
+
|
|
79
|
+
import { bulkEntityLogicFactory } from '../bulk';
|
|
80
|
+
|
|
79
81
|
import * as v from 'valibot';
|
|
80
82
|
|
|
81
83
|
// ---------------------------------------------------------------------------
|
|
@@ -126,6 +128,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
126
128
|
const logic = bulkEntityLogicFactory(
|
|
127
129
|
COLLECTION,
|
|
128
130
|
createSchema,
|
|
131
|
+
createSchema,
|
|
129
132
|
updateSchema,
|
|
130
133
|
access
|
|
131
134
|
);
|
|
@@ -175,6 +178,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
175
178
|
const logic = bulkEntityLogicFactory(
|
|
176
179
|
COLLECTION,
|
|
177
180
|
createSchema,
|
|
181
|
+
createSchema,
|
|
178
182
|
updateSchema,
|
|
179
183
|
access
|
|
180
184
|
);
|
|
@@ -194,6 +198,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
194
198
|
const logic = bulkEntityLogicFactory(
|
|
195
199
|
COLLECTION,
|
|
196
200
|
createSchema,
|
|
201
|
+
createSchema,
|
|
197
202
|
updateSchema,
|
|
198
203
|
access
|
|
199
204
|
);
|
|
@@ -209,6 +214,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
209
214
|
const logic = bulkEntityLogicFactory(
|
|
210
215
|
COLLECTION,
|
|
211
216
|
createSchema,
|
|
217
|
+
createSchema,
|
|
212
218
|
updateSchema,
|
|
213
219
|
access
|
|
214
220
|
);
|
|
@@ -232,6 +238,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
232
238
|
const logic = bulkEntityLogicFactory(
|
|
233
239
|
COLLECTION,
|
|
234
240
|
createSchema,
|
|
241
|
+
createSchema,
|
|
235
242
|
updateSchema,
|
|
236
243
|
access
|
|
237
244
|
);
|
|
@@ -259,6 +266,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
259
266
|
const logic = bulkEntityLogicFactory(
|
|
260
267
|
COLLECTION,
|
|
261
268
|
createSchema,
|
|
269
|
+
createSchema,
|
|
262
270
|
updateSchema,
|
|
263
271
|
strictAccess
|
|
264
272
|
);
|
|
@@ -286,6 +294,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
286
294
|
const logic = bulkEntityLogicFactory(
|
|
287
295
|
COLLECTION,
|
|
288
296
|
createSchema,
|
|
297
|
+
createSchema,
|
|
289
298
|
updateSchema,
|
|
290
299
|
strictAccess
|
|
291
300
|
);
|
|
@@ -301,6 +310,7 @@ describe('bulkEntityLogicFactory', () => {
|
|
|
301
310
|
const logic = bulkEntityLogicFactory(
|
|
302
311
|
COLLECTION,
|
|
303
312
|
createSchema,
|
|
313
|
+
createSchema,
|
|
304
314
|
updateSchema,
|
|
305
315
|
access
|
|
306
316
|
);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @author AMBROISE PARK Consulting
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
13
14
|
import * as v from 'valibot';
|
|
14
15
|
|
|
15
16
|
import { hasRoleAccess } from '@donotdev/core/server';
|
|
@@ -21,8 +22,6 @@ import { DoNotDevError } from '../../shared/utils.js';
|
|
|
21
22
|
import { createBaseFunction } from '../baseFunction.js';
|
|
22
23
|
import { CRUD_CONFIG } from '../config/constants.js';
|
|
23
24
|
|
|
24
|
-
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
25
|
-
|
|
26
25
|
/** Supported aggregation operations */
|
|
27
26
|
export type AggregateOperation = 'count' | 'sum' | 'avg' | 'min' | 'max';
|
|
28
27
|
|
|
@@ -15,7 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { logger } from 'firebase-functions/v2';
|
|
18
|
-
import
|
|
18
|
+
import type {
|
|
19
|
+
CallableFunction,
|
|
20
|
+
CallableRequest,
|
|
21
|
+
} from 'firebase-functions/v2/https';
|
|
22
|
+
import type * as v from 'valibot';
|
|
19
23
|
|
|
20
24
|
import { BulkRequestSchema, DEFAULT_STATUS_VALUE } from '@donotdev/core/server';
|
|
21
25
|
import type {
|
|
@@ -34,11 +38,6 @@ import {
|
|
|
34
38
|
import { createBaseFunction } from '../baseFunction.js';
|
|
35
39
|
import { CRUD_CONFIG } from '../config/constants.js';
|
|
36
40
|
|
|
37
|
-
import type {
|
|
38
|
-
CallableFunction,
|
|
39
|
-
CallableRequest,
|
|
40
|
-
} from 'firebase-functions/v2/https';
|
|
41
|
-
|
|
42
41
|
/**
|
|
43
42
|
* Request type for the bulk endpoint. Identical to the wire schema; kept as a
|
|
44
43
|
* named alias for parity with `CreateEntityRequest`, `UpdateEntityRequest`, etc.
|
|
@@ -9,7 +9,12 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type { Query, DocumentData } from 'firebase-admin/firestore';
|
|
12
13
|
import { logger } from 'firebase-functions/v2';
|
|
14
|
+
import type {
|
|
15
|
+
CallableFunction,
|
|
16
|
+
CallableRequest,
|
|
17
|
+
} from 'firebase-functions/v2/https';
|
|
13
18
|
import * as v from 'valibot';
|
|
14
19
|
|
|
15
20
|
import type { UserRole, UniqueKeyDefinition } from '@donotdev/core/server';
|
|
@@ -24,12 +29,6 @@ import { DoNotDevError, validateDocument } from '../../shared/utils.js';
|
|
|
24
29
|
import { createBaseFunction } from '../baseFunction.js';
|
|
25
30
|
import { CRUD_CONFIG } from '../config/constants.js';
|
|
26
31
|
|
|
27
|
-
import type { Query, DocumentData } from 'firebase-admin/firestore';
|
|
28
|
-
import type {
|
|
29
|
-
CallableFunction,
|
|
30
|
-
CallableRequest,
|
|
31
|
-
} from 'firebase-functions/v2/https';
|
|
32
|
-
|
|
33
32
|
export type CreateEntityRequest = {
|
|
34
33
|
payload: Record<string, any>;
|
|
35
34
|
idempotencyKey?: string;
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { logger } from 'firebase-functions/v2';
|
|
13
|
+
import type {
|
|
14
|
+
CallableFunction,
|
|
15
|
+
CallableRequest,
|
|
16
|
+
} from 'firebase-functions/v2/https';
|
|
13
17
|
import * as v from 'valibot';
|
|
14
18
|
|
|
15
19
|
import type { UserRole } from '@donotdev/core/server';
|
|
@@ -19,11 +23,6 @@ import { DoNotDevError, findReferences } from '../../shared/utils.js';
|
|
|
19
23
|
import { createBaseFunction } from '../baseFunction.js';
|
|
20
24
|
import { CRUD_CONFIG } from '../config/constants.js';
|
|
21
25
|
|
|
22
|
-
import type {
|
|
23
|
-
CallableFunction,
|
|
24
|
-
CallableRequest,
|
|
25
|
-
} from 'firebase-functions/v2/https';
|
|
26
|
-
|
|
27
26
|
export type DeleteEntityRequest = { id: string };
|
|
28
27
|
|
|
29
28
|
/**
|
package/src/firebase/crud/get.ts
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type {
|
|
13
|
+
CallableFunction,
|
|
14
|
+
CallableRequest,
|
|
15
|
+
} from 'firebase-functions/v2/https';
|
|
12
16
|
import * as v from 'valibot';
|
|
13
17
|
|
|
14
18
|
import {
|
|
@@ -24,11 +28,6 @@ import { DoNotDevError } from '../../shared/utils.js';
|
|
|
24
28
|
import { createBaseFunction } from '../baseFunction.js';
|
|
25
29
|
import { CRUD_READ_CONFIG } from '../config/constants.js';
|
|
26
30
|
|
|
27
|
-
import type {
|
|
28
|
-
CallableFunction,
|
|
29
|
-
CallableRequest,
|
|
30
|
-
} from 'firebase-functions/v2/https';
|
|
31
|
-
|
|
32
31
|
export type GetEntityRequest = { id: string };
|
|
33
32
|
|
|
34
33
|
/**
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { logger } from 'firebase-functions/v2';
|
|
13
|
+
import type {
|
|
14
|
+
CallableFunction,
|
|
15
|
+
CallableRequest,
|
|
16
|
+
} from 'firebase-functions/v2/https';
|
|
13
17
|
import * as v from 'valibot';
|
|
14
18
|
|
|
15
19
|
import {
|
|
@@ -30,11 +34,6 @@ import { DoNotDevError } from '../../shared/utils.js';
|
|
|
30
34
|
import { createBaseFunction } from '../baseFunction.js';
|
|
31
35
|
import { CRUD_READ_CONFIG } from '../config/constants.js';
|
|
32
36
|
|
|
33
|
-
import type {
|
|
34
|
-
CallableFunction,
|
|
35
|
-
CallableRequest,
|
|
36
|
-
} from 'firebase-functions/v2/https';
|
|
37
|
-
|
|
38
37
|
export interface ListEntityRequest {
|
|
39
38
|
where?: Array<[string, any, any]>;
|
|
40
39
|
orderBy?: Array<[string, 'asc' | 'desc']>;
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type { Query, DocumentData } from 'firebase-admin/firestore';
|
|
13
|
+
import type {
|
|
14
|
+
CallableFunction,
|
|
15
|
+
CallableRequest,
|
|
16
|
+
} from 'firebase-functions/v2/https';
|
|
12
17
|
import * as v from 'valibot';
|
|
13
18
|
|
|
14
19
|
import { DEFAULT_STATUS_VALUE } from '@donotdev/core/server';
|
|
@@ -24,12 +29,6 @@ import { DoNotDevError, validateDocument } from '../../shared/utils.js';
|
|
|
24
29
|
import { createBaseFunction } from '../baseFunction.js';
|
|
25
30
|
import { CRUD_CONFIG } from '../config/constants.js';
|
|
26
31
|
|
|
27
|
-
import type { Query, DocumentData } from 'firebase-admin/firestore';
|
|
28
|
-
import type {
|
|
29
|
-
CallableFunction,
|
|
30
|
-
CallableRequest,
|
|
31
|
-
} from 'firebase-functions/v2/https';
|
|
32
|
-
|
|
33
32
|
export type UpdateEntityRequest = {
|
|
34
33
|
id: string;
|
|
35
34
|
payload: Record<string, any>;
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
import { logger } from 'firebase-functions/v2';
|
|
13
13
|
import { onCall } from 'firebase-functions/v2/https';
|
|
14
|
+
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
15
|
+
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
14
16
|
import * as v from 'valibot';
|
|
15
17
|
|
|
16
18
|
import {
|
|
@@ -29,9 +31,6 @@ import { assertAuthenticated } from '../../shared/utils.js';
|
|
|
29
31
|
import { AUTH_CONFIG } from '../config/constants.js';
|
|
30
32
|
import { githubPersonalAccessToken } from '../config/secrets.js';
|
|
31
33
|
|
|
32
|
-
import type { CallableRequest } from 'firebase-functions/v2/https';
|
|
33
|
-
import type { CallableFunction } from 'firebase-functions/v2/https';
|
|
34
|
-
|
|
35
34
|
const OAUTH_CONFIG = {
|
|
36
35
|
...AUTH_CONFIG,
|
|
37
36
|
secrets: [githubPersonalAccessToken],
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import type { HttpsFunction } from 'firebase-functions/v2/https';
|
|
13
|
+
|
|
12
14
|
import { createSchemas, getListCardFieldNames } from '@donotdev/core/server';
|
|
13
15
|
import type { Entity } from '@donotdev/core/server';
|
|
14
16
|
|
|
@@ -21,8 +23,6 @@ import {
|
|
|
21
23
|
listEntities,
|
|
22
24
|
} from './crud/index.js';
|
|
23
25
|
|
|
24
|
-
import type { HttpsFunction } from 'firebase-functions/v2/https';
|
|
25
|
-
|
|
26
26
|
interface RegisterOptions {
|
|
27
27
|
prefix?: string;
|
|
28
28
|
}
|
|
@@ -5,9 +5,6 @@ vi.mock('@donotdev/core/server', () => ({
|
|
|
5
5
|
hasProvider: vi.fn(() => false),
|
|
6
6
|
getProvider: vi.fn(),
|
|
7
7
|
}));
|
|
8
|
-
vi.mock('@donotdev/firebase/server', () => ({
|
|
9
|
-
getFirebaseAdminAuth: vi.fn(),
|
|
10
|
-
}));
|
|
11
8
|
|
|
12
9
|
import { assertAuthenticated } from '../utils/internal/auth';
|
|
13
10
|
|
|
@@ -9,14 +9,15 @@
|
|
|
9
9
|
* firing once with counts.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
13
12
|
import * as v from 'valibot';
|
|
13
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
14
14
|
|
|
15
|
-
import { executeBulk } from '../crud/bulkCore.js';
|
|
16
15
|
import { BulkCollisionError } from '@donotdev/core/server';
|
|
17
16
|
import { DoNotDevError } from '@donotdev/core/server';
|
|
18
17
|
import { DEFAULT_STATUS_VALUE } from '@donotdev/core/server';
|
|
19
18
|
|
|
19
|
+
import { executeBulk } from '../crud/bulkCore.js';
|
|
20
|
+
|
|
20
21
|
// ---------------------------------------------------------------------------
|
|
21
22
|
// Fixtures
|
|
22
23
|
// ---------------------------------------------------------------------------
|
|
@@ -66,14 +66,14 @@ describe('handleError', () => {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
it('throws DoNotDevError with code "internal" for generic Error', () => {
|
|
69
|
+
it('throws DoNotDevError with code "internal" and a generic message for generic Error', () => {
|
|
70
70
|
try {
|
|
71
71
|
handleError(new Error('Something broke'));
|
|
72
72
|
expect.fail('should have thrown');
|
|
73
73
|
} catch (error) {
|
|
74
74
|
expect(error).toBeInstanceOf(DoNotDevError);
|
|
75
75
|
expect((error as DoNotDevError).code).toBe('internal');
|
|
76
|
-
expect((error as DoNotDevError).message).toBe('
|
|
76
|
+
expect((error as DoNotDevError).message).toBe('An unexpected error occurred');
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
|