Skip to content

Commit 552d2ab

Browse files
authored
Merge pull request #2 from topcoder-platform/develop
dev to master sync
2 parents 8303b66 + 32fdb5f commit 552d2ab

File tree

15,267 files changed

+3329
-1599299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

15,267 files changed

+3329
-1599299
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/topcoder-services?schema=billing-accounts"
22

3+
# Connection string for the Members DB used by import:access
4+
# Example: postgresql://postgres:postgres@localhost:5432/topcoder-services?schema=members
5+
MEMBER_DB_URL=""
6+
37
# Auth (tc-core-library-js)
48
AUTH_SECRET=""
59
AUTH0_URL="" # e.g. https://topcoder-dev.auth0.com/ (optional)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: AI PR Reviewer
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
permissions:
9+
pull-requests: write
10+
jobs:
11+
tc-ai-pr-review:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repo
15+
uses: actions/checkout@v3
16+
17+
- name: TC AI PR Reviewer
18+
uses: topcoder-platform/tc-ai-pr-reviewer@master
19+
with:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # The GITHUB_TOKEN is there by default so you just need to keep it like it is and not necessarily need to add it as secret as it will throw an error. [More Details](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret)
21+
LAB45_API_KEY: ${{ secrets.LAB45_API_KEY }}
22+
exclude: '**/*.json, **/*.md, **/*.jpg, **/*.png, **/*.jpeg, **/*.bmp, **/*.webp' # Optional: exclude patterns separated by commas

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/dist
33
/node_modules
44
/build
5+
dist
56

67
# Logs
78
logs
@@ -56,3 +57,4 @@ pids
5657
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
5758

5859
/generated/prisma
60+
node_modules

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ RUN pnpm build
2121

2222
# ---- Production Stage ----
2323
FROM base AS production
24-
ENV NODE_ENV production
24+
ENV NODE_ENV=production
25+
# Install OpenSSL runtime (provides libssl.so.3 for Prisma musl OpenSSL 3)
26+
RUN apk add --no-cache openssl
2527
# Copy built application from the build stage
2628
COPY --from=build /usr/src/app/dist ./dist
27-
# Copy production dependencies from the deps stage
28-
COPY --from=deps /usr/src/app/node_modules ./node_modules
29+
# Copy production dependencies (including generated Prisma client) from the build stage
30+
COPY --from=build /usr/src/app/node_modules ./node_modules
2931

3032
# Expose the application port
3133
EXPOSE 3000

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
**Project structure:**
44
- NestJS project
55
- Prisma schema for Clients, Billing Accounts, Locked & Consumed amounts
6+
- BillingAccount `id` is a Postgres `INT` auto-increment sequence (numeric, increasing)
67
- Endpoints:
78
- `GET /billing-accounts`
89
- `POST /billing-accounts`
910
- `GET /billing-accounts/:billingAccountId` (includes locked/consumed arrays + budget totals)
1011
- `PATCH /billing-accounts/:billingAccountId`
1112
- `PATCH /billing-accounts/:billingAccountId/lock-amount` (0 amount = unlock)
1213
- `PATCH /billing-accounts/:billingAccountId/consume-amount` (deletes locks for challenge, then upserts consumed)
14+
- `GET /billing-accounts/:billingAccountId/users` (list users with access)
15+
- `POST /billing-accounts/:billingAccountId/users` (grant access; accepts `{ param: { userId } }` or `{ userId }`)
16+
- `DELETE /billing-accounts/:billingAccountId/users/:userId` (revoke access)
17+
- `GET /billing-accounts/:billingAccountId/users/:userId/access` (boolean access check)
1318
- `GET /clients` (search by name/codeName/status/date range; sort & pagination)
1419
- `GET /clients/:clientId`
1520
- `PATCH /clients/:clientId`
21+
- `POST /clients`
1622

1723
**Authorization**
1824
- JWT middleware via `tc-core-library-js` attaches `req.authUser`
@@ -33,3 +39,65 @@ pnpm run dev
3339
# or
3440
pnpm run build && pnpm start
3541
```
42+
43+
## Import scripts
44+
45+
- Legacy import (clients, billing accounts, challenge budgets):
46+
- `pnpm run import:legacy -- <file1.json> [file2.json ...] [--defaultClientId=<id>]`
47+
48+
- BillingAccountAccess import (from time_oltp exports):
49+
- Requires `MEMBER_DB_URL` in `.env` pointing to the Members DB.
50+
- Usage:
51+
- `pnpm run import:access -- /mnt/export/billing_accounts/time_oltp:project_manager_1.json /mnt/export/billing_accounts/time_oltp:user_account_1.json`
52+
- The script will:
53+
- Read `time_oltp:project_manager` and `time_oltp:user_account` records
54+
- For each project manager row, map `project_id` to `BillingAccountAccess.billingAccountId`
55+
- Lookup the matching `user_account` by `user_account_id`, then query the Members DB by `user_name` (handle)
56+
- Upsert `BillingAccountAccess` for the resolved `userId`
57+
58+
## Downstream Usage
59+
60+
- This service is consumed (directly or indirectly) by multiple Topcoder apps. The pointers below help with debugging.
61+
62+
**platform-ui**
63+
64+
- Admin pages use v6 endpoints to manage Clients, Billing Accounts, and Billing Account resources (users):
65+
- Search billing accounts: `GET /v6/billing-accounts?{filters}&page&perPage&sortBy&sortOrder`.
66+
- Get billing account detail: `GET /v6/billing-accounts/{id}`.
67+
- Create billing account: `POST /v6/billing-accounts`.
68+
- Update billing account: `PATCH /v6/billing-accounts/{id}`.
69+
- List billing account users: `GET /v6/billing-accounts/{id}/users`.
70+
- Add billing account user: `POST /v6/billing-accounts/{id}/users` with `{ param: { userId } }`.
71+
- Remove billing account user: `DELETE /v6/billing-accounts/{id}/users/{userId}`.
72+
- Search clients: `GET /v6/clients?{filters}&page&perPage&sortBy&sortOrder`.
73+
- Get client detail: `GET /v6/clients/{id}`.
74+
- Create client: `POST /v6/clients`.
75+
- Update client: `PATCH /v6/clients/{id}`.
76+
- Key references in the UI codebase:
77+
- `platform-ui/src/apps/admin/src/lib/services/billing-accounts.service.ts`
78+
- `platform-ui/src/apps/admin/src/lib/services/client.service.ts`
79+
- `platform-ui/src/apps/admin/src/lib/hooks/useManageBillingAccounts.ts`
80+
- `platform-ui/src/apps/admin/src/lib/hooks/useManageBillingAccountDetail.ts`
81+
- `platform-ui/src/apps/admin/src/lib/hooks/useManageBillingAccountResources.ts`
82+
- `platform-ui/src/apps/admin/src/lib/hooks/useManageAddBillingAccount.ts`
83+
- `platform-ui/src/apps/admin/src/lib/hooks/useManageAddBillingAccountResource.ts`
84+
- Local dev proxy maps the Billing Accounts & Clients routes to this service:
85+
- See `platform-ui/src/config/environments/local.env.ts` for entries routing `/v6/billing-accounts` and `/v6/clients` (and `/v5/billing-accounts`) to `http://localhost:3010`.
86+
- Swagger is available at `http://localhost:<PORT>/v6/billing-accounts/api-docs` (default `<PORT>` is `3000` per `.env.example`). Adjust the proxy or service port as needed.
87+
88+
**community-app**
89+
90+
- Doesn't use
91+
92+
**work-manager**
93+
94+
- Work Manager does not call this API directly. It loads billing account options and selections through the Projects API, e.g.:
95+
- `GET {PROJECTS_API_URL}/{projectId}/billingAccounts`
96+
- `GET {PROJECTS_API_URL}/{projectId}/billingAccount`
97+
- Key references in the Work Manager codebase:
98+
- `work-manager/src/services/projects.js`
99+
- UI wiring in containers/components under `work-manager/src/containers/Challenges` and `work-manager/src/components/`
100+
- If/when Work Manager migrates to call this service directly, equivalent v6 endpoints include:
101+
- Search/list: `GET /v6/billing-accounts?{filters}` (supports `userId`, `clientId`, `status`, and date range filters)
102+
- Detail: `GET /v6/billing-accounts/{id}`
103+
- Access check: `GET /v6/billing-accounts/{id}/users/{userId}/access`

node_modules/.bin/pino

Lines changed: 0 additions & 21 deletions
This file was deleted.

node_modules/.bin/prisma

Lines changed: 0 additions & 21 deletions
This file was deleted.

node_modules/.bin/rimraf

Lines changed: 0 additions & 21 deletions
This file was deleted.

node_modules/.bin/ts-node

Lines changed: 0 additions & 21 deletions
This file was deleted.

node_modules/.bin/ts-node-cwd

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)