@donotdev/functions 0.0.7 → 0.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/functions",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "private": false,
5
5
  "description": "Backend functions for DoNotDev Framework - Firebase, Vercel, and platform-agnostic implementations for auth, billing, CRUD, and OAuth",
6
6
  "main": "./lib/firebase/index.js",
@@ -42,8 +42,8 @@
42
42
  "serve": "firebase emulators:start --only functions"
43
43
  },
44
44
  "dependencies": {
45
- "@donotdev/core": "^0.0.14",
46
- "@donotdev/firebase": "^0.0.6"
45
+ "@donotdev/core": "^0.0.18",
46
+ "@donotdev/firebase": "^0.0.7"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@sentry/node": "^10.33.0",
@@ -57,7 +57,7 @@ function listEntitiesLogicFactory(
57
57
  request: CallableRequest<ListEntityRequest>;
58
58
  }
59
59
  ) {
60
- const { where = [], orderBy = [], limit = 50, startAfterId, search } = data;
60
+ const { where = [], orderBy = [], limit, startAfterId, search } = data;
61
61
  const { userRole } = context;
62
62
 
63
63
  const isAdmin = hasRoleAccess(userRole, 'admin'); // Uses role hierarchy
@@ -103,8 +103,10 @@ function listEntitiesLogicFactory(
103
103
  query = query.startAfter(startAfterDoc);
104
104
  }
105
105
 
106
- // Apply limit for page size
107
- query = query.limit(limit);
106
+ // Apply limit only if provided (no limit = fetch all)
107
+ if (limit !== undefined && limit > 0) {
108
+ query = query.limit(limit);
109
+ }
108
110
 
109
111
  // DEBUG: Log query details
110
112
  console.log(
@@ -190,7 +192,7 @@ export const listEntities = (
190
192
  orderBy: v.optional(
191
193
  v.array(v.tuple([v.string(), v.picklist(['asc', 'desc'])]))
192
194
  ),
193
- limit: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(100))),
195
+ limit: v.optional(v.pipe(v.number(), v.minValue(1))),
194
196
  startAfterId: v.optional(v.string()),
195
197
  search: v.optional(
196
198
  v.object({
@@ -13,6 +13,7 @@ import type {
13
13
  SubscriptionStatus,
14
14
  SubscriptionClaims,
15
15
  } from '@donotdev/core/server';
16
+ import { SUBSCRIPTION_STATUS } from '@donotdev/core/server';
16
17
  import {
17
18
  getFirebaseAdminAuth,
18
19
  getFirebaseAdminFirestore,
@@ -59,11 +60,24 @@ export async function updateUserSubscription(
59
60
  const priceId = subscription.items?.data?.[0]?.price?.id;
60
61
  const tier = getTierFromPriceId(priceId);
61
62
 
63
+ // Validate status: must be a framework value OR a valid custom consumer value (non-empty string)
64
+ // Default to 'incomplete' if invalid/empty
65
+ const frameworkStatuses = Object.values(SUBSCRIPTION_STATUS);
66
+ const rawStatus = subscription.status || '';
67
+ const isValidFrameworkStatus = frameworkStatuses.includes(rawStatus as any);
68
+ const isValidCustomStatus =
69
+ typeof rawStatus === 'string' && rawStatus.trim().length > 0;
70
+
71
+ const status: SubscriptionStatus =
72
+ isValidFrameworkStatus || isValidCustomStatus
73
+ ? (rawStatus as SubscriptionStatus)
74
+ : SUBSCRIPTION_STATUS.INCOMPLETE;
75
+
62
76
  const subscriptionClaims: SubscriptionClaims = {
63
77
  tier,
64
78
  subscriptionId: subscription.id,
65
79
  customerId: subscription.customer,
66
- status: subscription.status as SubscriptionStatus,
80
+ status,
67
81
  subscriptionEnd: subscription.current_period_end
68
82
  ? new Date(subscription.current_period_end * 1000).toISOString()
69
83
  : null,