Skip to content

Commit a99d0a0

Browse files
Merge pull request #867 from sparrowapp-dev/development
merge development into release v2
2 parents 54a2d92 + 71f7e99 commit a99d0a0

23 files changed

+2542
-50
lines changed

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ EMAIL_VALIDATION_CODE_EXPIRY_TIME= # Expiration time for email validation links
6464
# Automatic update checking configuration
6565
APP_UPDATE_AVAILABLE=false # Enable/disable update checks
6666
APP_VERSION= # Current application version (semantic versioning)
67+
APP_MAC_VERSION= # Mac app version
68+
APP_LINUX_VERSION= # Linux app version
6769
WINDOWS_APP_SIGNATURE= # Windows app signature for update verification
6870
WINDOWS_APP_URL= # Windows app download URL
6971
MAC_APPLE_SILICON_APP_SIGNATURE= # Mac (Apple Silicon) app signature
@@ -131,3 +133,6 @@ SELF_HOST_ADMIN_PASSWORD=
131133

132134
# [Hub Domain]
133135
HUB_BASE_DOMAIN=yourdomain.com # Base domain for the hub (e.g., yourdomain.com)
136+
137+
SPARROW_PROXY_BASE_URL=http://localhost:3000
138+
SPARROW_APP_BASE_URL=http://localhost:1422

deploymentManifests/deployment.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,26 @@ spec:
406406
secretKeyRef:
407407
name: sparrow-api-secret
408408
key: HUB_BASE_DOMAIN
409-
409+
- name: SPARROW_PROXY_BASE_URL
410+
valueFrom:
411+
secretKeyRef:
412+
name: sparrow-api-secret
413+
key: SPARROW_PROXY_BASE_URL
414+
- name: SPARROW_APP_BASE_URL
415+
valueFrom:
416+
secretKeyRef:
417+
name: sparrow-api-secret
418+
key: SPARROW_APP_BASE_URL
419+
- name: APP_MAC_VERSION
420+
valueFrom:
421+
secretKeyRef:
422+
name: sparrow-api-secret
423+
key: APP_MAC_VERSION
424+
- name: APP_LINUX_VERSION
425+
valueFrom:
426+
secretKeyRef:
427+
name: sparrow-api-secret
428+
key: APP_LINUX_VERSION
410429
---
411430
apiVersion: v1
412431
kind: Service

deploymentManifests/release-v2.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,27 @@ spec:
375375
secretKeyRef:
376376
name: release-api-v2-secret
377377
key: HUB_BASE_DOMAIN
378+
- name: SPARROW_PROXY_BASE_URL
379+
valueFrom:
380+
secretKeyRef:
381+
name: release-api-v2-secret
382+
key: SPARROW_PROXY_BASE_URL
383+
- name: SPARROW_APP_BASE_URL
384+
valueFrom:
385+
secretKeyRef:
386+
name: release-api-v2-secret
387+
key: SPARROW_APP_BASE_URL
388+
- name: APP_MAC_VERSION
389+
valueFrom:
390+
secretKeyRef:
391+
name: release-api-v2-secret
392+
key: APP_MAC_VERSION
393+
- name: APP_LINUX_VERSION
394+
valueFrom:
395+
secretKeyRef:
396+
name: release-api-v2-secret
397+
key: APP_LINUX_VERSION
398+
378399

379400
---
380401
apiVersion: v1

migrations/create-plan.migration.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export class CreatePlanMigration implements OnModuleInit {
6868
area: LimitArea.AI,
6969
value: 50,
7070
},
71+
testflowScheduleRun: {
72+
area: LimitArea.TESTFLOW_SCHEDULE_RUN,
73+
value: 3,
74+
},
7175
},
7276
createdAt: new Date(),
7377
updatedAt: new Date(),
@@ -126,6 +130,10 @@ export class CreatePlanMigration implements OnModuleInit {
126130
area: LimitArea.AI,
127131
value: 200,
128132
},
133+
testflowScheduleRun: {
134+
area: LimitArea.TESTFLOW_SCHEDULE_RUN,
135+
value: 10,
136+
},
129137
},
130138
createdAt: new Date(),
131139
updatedAt: new Date(),
@@ -184,6 +192,10 @@ export class CreatePlanMigration implements OnModuleInit {
184192
area: LimitArea.AI,
185193
value: Infinity,
186194
},
195+
testflowScheduleRun: {
196+
area: LimitArea.TESTFLOW_SCHEDULE_RUN,
197+
value: 25,
198+
},
187199
},
188200
createdAt: new Date(),
189201
updatedAt: new Date(),
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import { Injectable, OnModuleInit, Inject } from "@nestjs/common";
2+
import { Collections } from "@src/modules/common/enum/database.collection.enum";
3+
import { LimitArea, Plan } from "@src/modules/common/models/plan.model";
4+
import { Team } from "@src/modules/common/models/team.model";
5+
import { Db } from "mongodb";
6+
7+
@Injectable()
8+
export class UpdatePlanTestflowScheduleMigration implements OnModuleInit {
9+
private hasRun = false;
10+
constructor(@Inject("DATABASE_CONNECTION") private readonly db: Db) {}
11+
async onModuleInit(): Promise<void> {
12+
if (this.hasRun) return;
13+
try {
14+
console.log(
15+
"\x1b[36m[Nest]\x1b[0m \x1b[36mStarting UpdatePlanTestflowScheduleMigration...\x1b[0m",
16+
);
17+
18+
const planCollection = this.db.collection<Plan>(Collections.PLAN);
19+
const teamCollection = this.db.collection<Team>(Collections.TEAM);
20+
21+
const plans = await planCollection.find().toArray();
22+
const teams = await teamCollection.find().toArray();
23+
24+
let updatedPlanCount = 0;
25+
let updatedTeamCount = 0;
26+
27+
// --- Update PLANS ---
28+
for (const plan of plans) {
29+
const limits = plan.limits;
30+
let desiredValue = 3;
31+
32+
switch (plan.name) {
33+
case "Standard":
34+
desiredValue = 10;
35+
break;
36+
case "Professional":
37+
desiredValue = 25;
38+
break;
39+
case "Community":
40+
default:
41+
desiredValue = 3;
42+
break;
43+
}
44+
45+
const existingValue = limits.testflowScheduleRun?.value;
46+
const fieldExists = limits.testflowScheduleRun !== undefined;
47+
48+
if (!fieldExists || existingValue !== desiredValue) {
49+
await planCollection.updateOne(
50+
{ _id: plan._id },
51+
{
52+
$set: {
53+
"limits.testflowScheduleRun": {
54+
area: LimitArea.TESTFLOW_SCHEDULE_RUN,
55+
value: desiredValue,
56+
},
57+
updatedAt: new Date(),
58+
updatedBy: "system",
59+
},
60+
},
61+
);
62+
updatedPlanCount++;
63+
}
64+
}
65+
66+
// --- Update TEAM PLANS ---
67+
for (const team of teams) {
68+
const teamPlan = team.plan;
69+
if (!teamPlan) continue;
70+
71+
let desiredValue = 3;
72+
switch (teamPlan.name) {
73+
case "Standard":
74+
desiredValue = 10;
75+
break;
76+
case "Professional":
77+
desiredValue = 25;
78+
break;
79+
case "Community":
80+
default:
81+
desiredValue = 3;
82+
break;
83+
}
84+
85+
const existingValue = teamPlan.limits?.testflowScheduleRun?.value;
86+
const fieldExists = teamPlan.limits?.testflowScheduleRun !== undefined;
87+
88+
if (!fieldExists || existingValue !== desiredValue) {
89+
await teamCollection.updateOne(
90+
{ _id: team._id },
91+
{
92+
$set: {
93+
"plan.limits.testflowScheduleRun": {
94+
area: LimitArea.TESTFLOW_SCHEDULE_RUN,
95+
value: desiredValue,
96+
},
97+
updatedAt: new Date(),
98+
updatedBy: "system",
99+
},
100+
},
101+
);
102+
updatedTeamCount++;
103+
}
104+
}
105+
106+
console.log(
107+
`\x1b[32m[Nest]\x1b[0m \x1b[33m${updatedPlanCount}\x1b[0m plans updated and \x1b[33m${updatedTeamCount}\x1b[0m teams updated with correct 'testflowScheduleRun' values.\x1b[0m`,
108+
);
109+
110+
this.hasRun = true;
111+
} catch (error) {
112+
console.error(
113+
"\x1b[31m[Nest] Error during UpdatePlanTestflowScheduleMigration:\x1b[0m",
114+
error,
115+
);
116+
}
117+
}
118+
}

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "project-sparrow-api",
3-
"version": "2.32.1",
3+
"version": "2.33.0",
44
"description": "Backend APIs for Project Sparrow.",
55
"author": "techdome",
66
"license": "",
@@ -35,7 +35,8 @@
3535
"start:migration-hub-billing": "ts-node -r tsconfig-paths/register src/migrationHubBilling.ts",
3636
"start:migration-superadmin": "ts-node -r tsconfig-paths/register src/migration-superadmin.ts",
3737
"start:migration-email": "ts-node -r tsconfig-paths/register src/migration-emailId.ts",
38-
"start:add-test-request": "ts-node -r tsconfig-paths/register src/add-tests-to-request.ts"
38+
"start:add-test-request": "ts-node -r tsconfig-paths/register src/add-tests-to-request.ts",
39+
"start:add-testflow-schedule": "ts-node -r tsconfig-paths/register src/update-plan-testflow-schedule.ts"
3940
},
4041
"dependencies": {
4142
"@anthropic-ai/sdk": "^0.54.0",
@@ -77,6 +78,7 @@
7778
"class-transformer": "0.5.1",
7879
"class-transformer-validator": "^0.9.1",
7980
"class-validator": "^0.14.0",
81+
"cron": "^4.3.3",
8082
"crypto-js": "^4.2.0",
8183
"curlconverter": "^4.9.0",
8284
"dotenv": "16.0.1",
@@ -117,6 +119,7 @@
117119
"@jest/types": "^29.6.3",
118120
"@nestjs/testing": "^10.1.3",
119121
"@types/chai": "^4.3.5",
122+
"@types/cron": "^2.4.3",
120123
"@types/crypto-js": "^4.2.2",
121124
"@types/gravatar": "1.8.3",
122125
"@types/jest": "^29.5.3",
@@ -152,5 +155,10 @@
152155
"packageManager": "[email protected]",
153156
"optionalDependencies": {
154157
"@sparrowapp-dev/stripe-billing": "^1.3.1"
158+
},
159+
"pnpm": {
160+
"overrides": {
161+
"cron": "4.3.3"
162+
}
155163
}
156164
}

0 commit comments

Comments
 (0)