@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.
- package/lib/firebase/auth/getCustomClaims.d.ts +25 -0
- package/lib/firebase/auth/getUserAuthStatus.d.ts +29 -0
- package/lib/firebase/auth/index.d.ts +12 -0
- package/lib/firebase/auth/removeCustomClaims.d.ts +28 -0
- package/lib/firebase/auth/setCustomClaims.d.ts +34 -0
- package/lib/firebase/baseFunction.d.ts +26 -0
- package/lib/firebase/billing/cancelSubscription.d.ts +10 -0
- package/lib/firebase/billing/changePlan.d.ts +13 -0
- package/lib/firebase/billing/createCheckoutSession.d.ts +21 -0
- package/lib/firebase/billing/createCustomerPortal.d.ts +19 -0
- package/lib/firebase/billing/healthCheck.d.ts +5 -0
- package/lib/firebase/billing/index.d.ts +18 -0
- package/lib/firebase/billing/refreshSubscriptionStatus.d.ts +19 -0
- package/lib/firebase/billing/webhookHandler.d.ts +6 -0
- package/lib/firebase/config/constants.d.ts +89 -0
- package/lib/firebase/config/index.d.ts +9 -0
- package/lib/firebase/config/secrets.d.ts +15 -0
- package/lib/firebase/crud/aggregate.d.ts +98 -0
- package/lib/firebase/crud/create.d.ts +16 -0
- package/lib/firebase/crud/delete.d.ts +20 -0
- package/lib/firebase/crud/get.d.ts +24 -0
- package/lib/firebase/crud/index.d.ts +14 -0
- package/lib/firebase/crud/list.d.ts +25 -0
- package/lib/firebase/crud/update.d.ts +25 -0
- package/lib/firebase/helpers/githubAccessHelper.d.ts +30 -0
- package/lib/firebase/helpers/githubTeamAccessHelper.d.ts +36 -0
- package/lib/firebase/helpers/index.d.ts +10 -0
- package/lib/firebase/index.d.ts +17 -0
- package/lib/firebase/index.js +25 -9110
- package/lib/firebase/index.js.map +4 -4
- package/lib/firebase/oauth/disconnect.d.ts +12 -0
- package/lib/firebase/oauth/exchangeToken.d.ts +9 -0
- package/lib/firebase/oauth/getConnections.d.ts +11 -0
- package/lib/firebase/oauth/githubAccess.d.ts +83 -0
- package/lib/firebase/oauth/index.d.ts +13 -0
- package/lib/firebase/oauth/refreshToken.d.ts +9 -0
- package/lib/firebase/registerCrudFunctions.d.ts +32 -0
- package/lib/firebase/scheduled/checkExpiredSubscriptions.d.ts +14 -0
- package/lib/firebase/scheduled/index.d.ts +9 -0
- package/lib/shared/billing/createCheckout.d.ts +50 -0
- package/lib/shared/billing/helpers/index.d.ts +10 -0
- package/lib/shared/billing/helpers/subscriptionManagement.d.ts +34 -0
- package/lib/shared/billing/helpers/updateUserSubscription.d.ts +45 -0
- package/lib/shared/billing/idempotency.d.ts +22 -0
- package/lib/shared/billing/index.d.ts +11 -0
- package/lib/shared/billing/webhookHandler.d.ts +37 -0
- package/lib/shared/errorHandling.d.ts +14 -0
- package/lib/shared/firebase.d.ts +73 -0
- package/lib/shared/github.d.ts +128 -0
- package/lib/shared/index.d.ts +16 -0
- package/lib/shared/index.js +25 -6927
- package/lib/shared/index.js.map +4 -4
- package/lib/shared/logger.d.ts +133 -0
- package/lib/shared/metadata.d.ts +36 -0
- package/lib/shared/oauth/exchangeToken.d.ts +24 -0
- package/lib/shared/oauth/grantAccess.d.ts +30 -0
- package/lib/shared/oauth/index.d.ts +10 -0
- package/lib/shared/schema.d.ts +56 -0
- package/lib/shared/utils/detectFirestore.d.ts +31 -0
- package/lib/shared/utils/external/date.d.ts +36 -0
- package/lib/shared/utils/external/index.d.ts +11 -0
- package/lib/shared/utils/external/references.d.ts +12 -0
- package/lib/shared/utils/external/subscription.d.ts +41 -0
- package/lib/shared/utils/firebaseHelpers.d.ts +23 -0
- package/lib/shared/utils/functionWrapper.d.ts +36 -0
- package/lib/shared/utils/index.d.ts +14 -0
- package/lib/shared/utils/internal/auth.d.ts +57 -0
- package/lib/shared/utils/internal/firebase.d.ts +5 -0
- package/lib/shared/utils/internal/idempotency.d.ts +21 -0
- package/lib/shared/utils/internal/index.d.ts +14 -0
- package/lib/shared/utils/internal/monitoring.d.ts +80 -0
- package/lib/shared/utils/internal/rateLimiter.d.ts +82 -0
- package/lib/shared/utils/internal/validation.d.ts +43 -0
- package/lib/shared/utils/schemaValidation.d.ts +60 -0
- package/lib/shared/utils/validation.d.ts +98 -0
- package/lib/shared/utils/vercelHelpers.d.ts +18 -0
- package/lib/shared/utils.d.ts +234 -0
- package/lib/shared/validation.d.ts +16 -0
- package/lib/supabase/auth/deleteAccount.d.ts +16 -0
- package/lib/supabase/auth/getCustomClaims.d.ts +16 -0
- package/lib/supabase/auth/getUserAuthStatus.d.ts +18 -0
- package/lib/supabase/auth/removeCustomClaims.d.ts +16 -0
- package/lib/supabase/auth/setCustomClaims.d.ts +18 -0
- package/lib/supabase/baseFunction.d.ts +43 -0
- package/lib/supabase/billing/cancelSubscription.d.ts +9 -0
- package/lib/supabase/billing/changePlan.d.ts +11 -0
- package/lib/supabase/billing/createCheckoutSession.d.ts +11 -0
- package/lib/supabase/billing/createCustomerPortal.d.ts +9 -0
- package/lib/supabase/billing/refreshSubscriptionStatus.d.ts +9 -0
- package/lib/supabase/crud/aggregate.d.ts +27 -0
- package/lib/supabase/crud/create.d.ts +23 -0
- package/lib/supabase/crud/delete.d.ts +30 -0
- package/lib/supabase/crud/get.d.ts +23 -0
- package/lib/supabase/crud/index.d.ts +20 -0
- package/lib/supabase/crud/list.d.ts +33 -0
- package/lib/supabase/crud/update.d.ts +24 -0
- package/lib/supabase/helpers/authProvider.d.ts +22 -0
- package/lib/supabase/index.d.ts +29 -0
- package/lib/supabase/index.js +23 -0
- package/lib/supabase/index.js.map +7 -0
- package/lib/supabase/registerCrudFunctions.d.ts +24 -0
- package/lib/supabase/utils/idempotency.d.ts +36 -0
- package/lib/supabase/utils/monitoring.d.ts +59 -0
- package/lib/supabase/utils/rateLimiter.d.ts +56 -0
- package/lib/vercel/api/auth/get-custom-claims.d.ts +2 -0
- package/lib/vercel/api/auth/get-user-auth-status.d.ts +2 -0
- package/lib/vercel/api/auth/index.d.ts +12 -0
- package/lib/vercel/api/auth/remove-custom-claims.d.ts +2 -0
- package/lib/vercel/api/auth/set-custom-claims.d.ts +10 -0
- package/lib/vercel/api/billing/cancel.d.ts +10 -0
- package/lib/vercel/api/billing/change-plan.d.ts +11 -0
- package/lib/vercel/api/billing/create-checkout-session.d.ts +13 -0
- package/lib/vercel/api/billing/customer-portal.d.ts +3 -0
- package/lib/vercel/api/billing/index.d.ts +14 -0
- package/lib/vercel/api/billing/refresh-subscription-status.d.ts +31 -0
- package/lib/vercel/api/billing/webhook-handler.d.ts +22 -0
- package/lib/vercel/api/config/constants.d.ts +103 -0
- package/lib/vercel/api/config/firebase-admin.d.ts +19 -0
- package/lib/vercel/api/config/index.d.ts +10 -0
- package/lib/vercel/api/crud/create.d.ts +2 -0
- package/lib/vercel/api/crud/delete.d.ts +2 -0
- package/lib/vercel/api/crud/get.d.ts +2 -0
- package/lib/vercel/api/crud/index.d.ts +13 -0
- package/lib/vercel/api/crud/list.d.ts +2 -0
- package/lib/vercel/api/crud/update.d.ts +2 -0
- package/lib/vercel/api/index.d.ts +13 -0
- package/lib/vercel/api/index.js +22 -4790
- package/lib/vercel/api/index.js.map +4 -4
- package/lib/vercel/api/oauth/check-github-access.d.ts +12 -0
- package/lib/vercel/api/oauth/exchange-token.d.ts +8 -0
- package/lib/vercel/api/oauth/grant-github-access.d.ts +12 -0
- package/lib/vercel/api/oauth/index.d.ts +12 -0
- package/lib/vercel/api/oauth/revoke-github-access.d.ts +11 -0
- package/lib/vercel/api/utils/cors.d.ts +49 -0
- package/lib/vercel/baseFunction.d.ts +25 -0
- package/package.json +4 -4
- package/src/firebase/auth/setCustomClaims.ts +61 -16
- package/src/firebase/billing/healthCheck.ts +7 -23
- package/src/firebase/billing/webhookHandler.ts +0 -1
- package/src/firebase/crud/create.ts +17 -2
- package/src/firebase/oauth/exchangeToken.ts +5 -5
- package/src/shared/billing/createCheckout.ts +6 -1
- package/src/shared/utils/internal/validation.ts +1 -1
- package/src/supabase/crud/aggregate.ts +10 -7
- package/src/supabase/crud/create.ts +1 -1
- package/src/supabase/crud/get.ts +1 -1
- package/src/supabase/crud/list.ts +1 -1
- package/src/supabase/crud/update.ts +1 -1
- package/src/vercel/api/auth/set-custom-claims.ts +70 -23
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a Supabase Edge Function handler for removing custom claims from app_metadata.
|
|
3
|
+
*
|
|
4
|
+
* @returns `(req: Request) => Promise<Response>` handler
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // supabase/functions/remove-custom-claims/index.ts
|
|
9
|
+
* import { createRemoveCustomClaims } from '@donotdev/functions/supabase';
|
|
10
|
+
* Deno.serve(createRemoveCustomClaims());
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @version 0.0.1
|
|
14
|
+
* @since 0.6.0
|
|
15
|
+
*/
|
|
16
|
+
export declare function createRemoveCustomClaims(): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a Supabase Edge Function handler for setting custom claims (app_metadata).
|
|
3
|
+
*
|
|
4
|
+
* Merges provided claims into the user's existing app_metadata.
|
|
5
|
+
*
|
|
6
|
+
* @returns `(req: Request) => Promise<Response>` handler
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // supabase/functions/set-custom-claims/index.ts
|
|
11
|
+
* import { createSetCustomClaims } from '@donotdev/functions/supabase';
|
|
12
|
+
* Deno.serve(createSetCustomClaims());
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @version 0.0.1
|
|
16
|
+
* @since 0.6.0
|
|
17
|
+
*/
|
|
18
|
+
export declare function createSetCustomClaims(): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import type { UserRole, SecurityContext } from '@donotdev/core/server';
|
|
3
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
4
|
+
/**
|
|
5
|
+
* Context passed to Supabase Edge Function business logic
|
|
6
|
+
*
|
|
7
|
+
* @version 0.0.1
|
|
8
|
+
* @since 0.5.0
|
|
9
|
+
*/
|
|
10
|
+
export interface SupabaseHandlerContext {
|
|
11
|
+
/** Authenticated user ID (from JWT verification) */
|
|
12
|
+
uid: string;
|
|
13
|
+
/** User role extracted from app_metadata.role */
|
|
14
|
+
userRole: UserRole;
|
|
15
|
+
/** Supabase admin client (service role — full access) */
|
|
16
|
+
supabaseAdmin: SupabaseClient;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a Supabase Edge Function handler with built-in auth, validation, role checking, and error handling.
|
|
20
|
+
*
|
|
21
|
+
* @param operationName - Operation name for logging
|
|
22
|
+
* @param schema - Valibot schema for request body validation
|
|
23
|
+
* @param handler - Business logic function
|
|
24
|
+
* @param requiredRole - Minimum role required (default: 'user')
|
|
25
|
+
* @returns A `(req: Request) => Promise<Response>` handler for Deno.serve
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import * as v from 'valibot';
|
|
30
|
+
* import { createSupabaseHandler } from '@donotdev/functions/supabase';
|
|
31
|
+
*
|
|
32
|
+
* const schema = v.object({ userId: v.string() });
|
|
33
|
+
*
|
|
34
|
+
* export default createSupabaseHandler('delete-account', schema, async (data, ctx) => {
|
|
35
|
+
* await ctx.supabaseAdmin.auth.admin.deleteUser(data.userId);
|
|
36
|
+
* return { success: true };
|
|
37
|
+
* }, 'admin');
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @version 0.0.1
|
|
41
|
+
* @since 0.5.0
|
|
42
|
+
*/
|
|
43
|
+
export declare function createSupabaseHandler<TReq, TRes>(operationName: string, schema: v.BaseSchema<unknown, TReq, v.BaseIssue<unknown>>, handler: (data: TReq, context: SupabaseHandlerContext) => Promise<TRes>, requiredRole?: UserRole, security?: SecurityContext): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a Supabase Edge Function handler for subscription cancellation.
|
|
3
|
+
*
|
|
4
|
+
* @returns `(req: Request) => Promise<Response>` handler
|
|
5
|
+
*
|
|
6
|
+
* @version 0.0.1
|
|
7
|
+
* @since 0.5.0
|
|
8
|
+
*/
|
|
9
|
+
export declare function createCancelSubscription(): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StripeBackConfig } from '@donotdev/core/server';
|
|
2
|
+
/**
|
|
3
|
+
* Create a Supabase Edge Function handler for plan changes.
|
|
4
|
+
*
|
|
5
|
+
* @param billingConfig - Billing configuration with product definitions
|
|
6
|
+
* @returns `(req: Request) => Promise<Response>` handler
|
|
7
|
+
*
|
|
8
|
+
* @version 0.0.1
|
|
9
|
+
* @since 0.5.0
|
|
10
|
+
*/
|
|
11
|
+
export declare function createChangePlan(billingConfig: StripeBackConfig): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StripeBackConfig } from '@donotdev/core/server';
|
|
2
|
+
/**
|
|
3
|
+
* Create a Supabase Edge Function handler for Stripe checkout session creation.
|
|
4
|
+
*
|
|
5
|
+
* @param billingConfig - Billing configuration with product definitions
|
|
6
|
+
* @returns `(req: Request) => Promise<Response>` handler
|
|
7
|
+
*
|
|
8
|
+
* @version 0.0.1
|
|
9
|
+
* @since 0.5.0
|
|
10
|
+
*/
|
|
11
|
+
export declare function createCheckoutSession(billingConfig: StripeBackConfig): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a Supabase Edge Function handler for Stripe Customer Portal.
|
|
3
|
+
*
|
|
4
|
+
* @returns `(req: Request) => Promise<Response>` handler
|
|
5
|
+
*
|
|
6
|
+
* @version 0.0.1
|
|
7
|
+
* @since 0.5.0
|
|
8
|
+
*/
|
|
9
|
+
export declare function createCustomerPortal(): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a Supabase Edge Function handler for refreshing subscription status.
|
|
3
|
+
*
|
|
4
|
+
* @returns `(req: Request) => Promise<Response>` handler
|
|
5
|
+
*
|
|
6
|
+
* @version 0.0.1
|
|
7
|
+
* @since 0.5.0
|
|
8
|
+
*/
|
|
9
|
+
export declare function createRefreshSubscriptionStatus(): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic handler to aggregate entities in Supabase.
|
|
3
|
+
* @description Provides aggregate operations (COUNT, SUM, AVG, MIN, MAX, GROUP BY) for PostgreSQL.
|
|
4
|
+
*
|
|
5
|
+
* @version 0.0.1
|
|
6
|
+
* @since 0.5.0
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { UserRole } from '@donotdev/core/server';
|
|
11
|
+
export type AggregateEntityRequest = {
|
|
12
|
+
where?: Array<[string, any, any]>;
|
|
13
|
+
aggregate: {
|
|
14
|
+
field: string;
|
|
15
|
+
operation: 'count' | 'sum' | 'avg' | 'min' | 'max';
|
|
16
|
+
};
|
|
17
|
+
groupBy?: string[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Create a Supabase Edge Function handler for aggregating entities.
|
|
21
|
+
*
|
|
22
|
+
* @param collection - The Supabase table name
|
|
23
|
+
* @param documentSchema - The Valibot schema for document validation
|
|
24
|
+
* @param requiredRole - Minimum role required for this operation
|
|
25
|
+
* @returns A `(req: Request) => Promise<Response>` handler for Deno.serve
|
|
26
|
+
*/
|
|
27
|
+
export declare function createSupabaseAggregateEntities(collection: string, documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, requiredRole: UserRole): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic handler to create an entity in Supabase.
|
|
3
|
+
* @description Provides a reusable implementation for creating documents in PostgreSQL with validation.
|
|
4
|
+
*
|
|
5
|
+
* @version 0.0.1
|
|
6
|
+
* @since 0.5.0
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { UserRole } from '@donotdev/core/server';
|
|
11
|
+
export type CreateEntityRequest = {
|
|
12
|
+
payload: Record<string, any>;
|
|
13
|
+
idempotencyKey?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Create a Supabase Edge Function handler for creating an entity.
|
|
17
|
+
*
|
|
18
|
+
* @param collection - The Supabase table name
|
|
19
|
+
* @param documentSchema - The Valibot schema for document validation
|
|
20
|
+
* @param requiredRole - Minimum role required for this operation
|
|
21
|
+
* @returns A `(req: Request) => Promise<Response>` handler for Deno.serve
|
|
22
|
+
*/
|
|
23
|
+
export declare function createSupabaseCreateEntity(collection: string, documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, requiredRole: UserRole): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { UserRole } from '@donotdev/core/server';
|
|
2
|
+
export type DeleteEntityRequest = {
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Reference metadata for entity deletion checking
|
|
7
|
+
*/
|
|
8
|
+
export interface ReferenceMetadata {
|
|
9
|
+
/** Fields in THIS entity that reference OTHER entities */
|
|
10
|
+
outgoing?: Array<{
|
|
11
|
+
field: string;
|
|
12
|
+
targetCollection: string;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
/** Fields in OTHER entities that reference THIS entity */
|
|
16
|
+
incoming?: Array<{
|
|
17
|
+
sourceCollection: string;
|
|
18
|
+
sourceField: string;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a Supabase Edge Function handler for deleting an entity.
|
|
24
|
+
*
|
|
25
|
+
* @param collection - The Supabase table name
|
|
26
|
+
* @param requiredRole - Minimum role required for this operation
|
|
27
|
+
* @param referenceMetadata - Optional reference metadata for deletion checking
|
|
28
|
+
* @returns A `(req: Request) => Promise<Response>` handler for Deno.serve
|
|
29
|
+
*/
|
|
30
|
+
export declare function createSupabaseDeleteEntity(collection: string, requiredRole: UserRole, referenceMetadata?: ReferenceMetadata): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic handler to retrieve a single entity from Supabase.
|
|
3
|
+
* @description Provides a reusable implementation for retrieving documents from PostgreSQL with visibility filtering.
|
|
4
|
+
*
|
|
5
|
+
* @version 0.0.1
|
|
6
|
+
* @since 0.5.0
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { EntityOwnershipConfig, UserRole } from '@donotdev/core/server';
|
|
11
|
+
export type GetEntityRequest = {
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Create a Supabase Edge Function handler for getting a single entity.
|
|
16
|
+
*
|
|
17
|
+
* @param collection - The Supabase table name
|
|
18
|
+
* @param documentSchema - The Valibot schema for document validation
|
|
19
|
+
* @param requiredRole - Minimum role required for this operation
|
|
20
|
+
* @param ownership - Optional ownership config for visibility: 'owner' field masking
|
|
21
|
+
* @returns A `(req: Request) => Promise<Response>` handler for Deno.serve
|
|
22
|
+
*/
|
|
23
|
+
export declare function createSupabaseGetEntity(collection: string, documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, requiredRole: UserRole, ownership?: EntityOwnershipConfig): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Supabase CRUD handlers barrel export
|
|
3
|
+
* @description Exports all Supabase CRUD handler factories
|
|
4
|
+
*
|
|
5
|
+
* @version 0.0.1
|
|
6
|
+
* @since 0.5.0
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
export { createSupabaseGetEntity } from './get.js';
|
|
10
|
+
export { createSupabaseCreateEntity } from './create.js';
|
|
11
|
+
export { createSupabaseUpdateEntity } from './update.js';
|
|
12
|
+
export { createSupabaseDeleteEntity } from './delete.js';
|
|
13
|
+
export { createSupabaseListEntities } from './list.js';
|
|
14
|
+
export { createSupabaseAggregateEntities } from './aggregate.js';
|
|
15
|
+
export type { GetEntityRequest } from './get.js';
|
|
16
|
+
export type { CreateEntityRequest } from './create.js';
|
|
17
|
+
export type { UpdateEntityRequest } from './update.js';
|
|
18
|
+
export type { DeleteEntityRequest, ReferenceMetadata } from './delete.js';
|
|
19
|
+
export type { ListEntityRequest } from './list.js';
|
|
20
|
+
export type { AggregateEntityRequest } from './aggregate.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic handler to list entities from Supabase with pagination, filtering, and sorting.
|
|
3
|
+
* @description Provides a reusable implementation for listing documents from PostgreSQL with advanced query capabilities.
|
|
4
|
+
*
|
|
5
|
+
* @version 0.0.1
|
|
6
|
+
* @since 0.5.0
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { EntityOwnershipConfig, UserRole } from '@donotdev/core/server';
|
|
11
|
+
export interface ListEntityRequest {
|
|
12
|
+
where?: Array<[string, any, any]>;
|
|
13
|
+
orderBy?: Array<[string, 'asc' | 'desc']>;
|
|
14
|
+
limit?: number;
|
|
15
|
+
startAfterId?: string;
|
|
16
|
+
startAfterCursor?: string;
|
|
17
|
+
search?: {
|
|
18
|
+
field: string;
|
|
19
|
+
query: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a Supabase Edge Function handler for listing entities.
|
|
24
|
+
*
|
|
25
|
+
* @param collection - The Supabase table name
|
|
26
|
+
* @param documentSchema - The Valibot schema for document validation
|
|
27
|
+
* @param requiredRole - Minimum role required for this operation
|
|
28
|
+
* @param listFields - Optional array of field names to include (plus id)
|
|
29
|
+
* @param ownership - Optional ownership config for list constraints and visibility: 'owner' masking
|
|
30
|
+
* @param isListCard - When true and ownership is set, applies public condition; when false, applies "mine" filter
|
|
31
|
+
* @returns A `(req: Request) => Promise<Response>` handler for Deno.serve
|
|
32
|
+
*/
|
|
33
|
+
export declare function createSupabaseListEntities(collection: string, documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, requiredRole: UserRole, listFields?: string[], ownership?: EntityOwnershipConfig, isListCard?: boolean): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic handler to update an entity in Supabase.
|
|
3
|
+
* @description Provides a reusable implementation for updating documents in PostgreSQL with validation.
|
|
4
|
+
*
|
|
5
|
+
* @version 0.0.1
|
|
6
|
+
* @since 0.5.0
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import type { UserRole } from '@donotdev/core/server';
|
|
11
|
+
export type UpdateEntityRequest = {
|
|
12
|
+
id: string;
|
|
13
|
+
payload: Record<string, any>;
|
|
14
|
+
idempotencyKey?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Create a Supabase Edge Function handler for updating an entity.
|
|
18
|
+
*
|
|
19
|
+
* @param collection - The Supabase table name
|
|
20
|
+
* @param documentSchema - The Valibot schema for document validation
|
|
21
|
+
* @param requiredRole - Minimum role required for this operation
|
|
22
|
+
* @returns A `(req: Request) => Promise<Response>` handler for Deno.serve
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSupabaseUpdateEntity(collection: string, documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, requiredRole: UserRole): (req: Request) => Promise<Response>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Supabase Auth Provider for shared billing logic
|
|
3
|
+
* @description Maps Supabase Admin auth to the shared `AuthProvider` interface,
|
|
4
|
+
* bridging `app_metadata` ↔ `customClaims`.
|
|
5
|
+
*
|
|
6
|
+
* @version 0.0.1
|
|
7
|
+
* @since 0.5.0
|
|
8
|
+
* @author AMBROISE PARK Consulting
|
|
9
|
+
*/
|
|
10
|
+
import type { AuthProvider } from '../../shared/billing/helpers/updateUserSubscription.js';
|
|
11
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
12
|
+
/**
|
|
13
|
+
* Create an AuthProvider backed by Supabase Admin.
|
|
14
|
+
* `app_metadata` is used as the equivalent of Firebase custom claims.
|
|
15
|
+
*
|
|
16
|
+
* @param supabaseAdmin - Supabase client created with the service role key
|
|
17
|
+
* @returns AuthProvider compatible with shared billing helpers
|
|
18
|
+
*
|
|
19
|
+
* @version 0.0.1
|
|
20
|
+
* @since 0.5.0
|
|
21
|
+
*/
|
|
22
|
+
export declare function createSupabaseAuthProvider(supabaseAdmin: SupabaseClient): AuthProvider;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Supabase Edge Functions barrel exports
|
|
3
|
+
* @description All Supabase Edge Function handlers for auth and billing.
|
|
4
|
+
*
|
|
5
|
+
* @version 0.0.1
|
|
6
|
+
* @since 0.5.0
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
export { createSupabaseHandler } from './baseFunction.js';
|
|
10
|
+
export type { SupabaseHandlerContext } from './baseFunction.js';
|
|
11
|
+
export { createSupabaseAuthProvider } from './helpers/authProvider.js';
|
|
12
|
+
export { createDeleteAccount } from './auth/deleteAccount.js';
|
|
13
|
+
export { createSetCustomClaims } from './auth/setCustomClaims.js';
|
|
14
|
+
export { createGetCustomClaims } from './auth/getCustomClaims.js';
|
|
15
|
+
export { createRemoveCustomClaims } from './auth/removeCustomClaims.js';
|
|
16
|
+
export { createGetUserAuthStatus } from './auth/getUserAuthStatus.js';
|
|
17
|
+
export { createCheckoutSession } from './billing/createCheckoutSession.js';
|
|
18
|
+
export { createCancelSubscription } from './billing/cancelSubscription.js';
|
|
19
|
+
export { createChangePlan } from './billing/changePlan.js';
|
|
20
|
+
export { createCustomerPortal } from './billing/createCustomerPortal.js';
|
|
21
|
+
export { createRefreshSubscriptionStatus } from './billing/refreshSubscriptionStatus.js';
|
|
22
|
+
export { createSupabaseGetEntity, createSupabaseCreateEntity, createSupabaseUpdateEntity, createSupabaseDeleteEntity, createSupabaseListEntities, createSupabaseAggregateEntities, } from './crud/index.js';
|
|
23
|
+
export { createSupabaseCrudFunctions } from './registerCrudFunctions.js';
|
|
24
|
+
export type { GetEntityRequest, CreateEntityRequest, UpdateEntityRequest, DeleteEntityRequest, ListEntityRequest, AggregateEntityRequest, ReferenceMetadata, } from './crud/index.js';
|
|
25
|
+
export { checkIdempotency, storeIdempotency, cleanupExpiredIdempotency, } from './utils/idempotency.js';
|
|
26
|
+
export { checkRateLimitWithPostgres, DEFAULT_RATE_LIMITS, } from './utils/rateLimiter.js';
|
|
27
|
+
export type { RateLimitConfig, RateLimitResult } from './utils/rateLimiter.js';
|
|
28
|
+
export { recordOperationMetrics, getFailureRate, getOperationCounts, getSlowOperations, } from './utils/monitoring.js';
|
|
29
|
+
export type { OperationMetrics } from './utils/monitoring.js';
|