fix: remove nested .git folders, re-add as normal directories
This commit is contained in:
-1
Submodule api deleted from 2f17f24b3b
@@ -0,0 +1,37 @@
|
|||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
pgsql:
|
||||||
|
image: postgres:17
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: optima
|
||||||
|
POSTGRES_PASSWORD: 123web123
|
||||||
|
POSTGRES_DB: optima
|
||||||
|
volumes:
|
||||||
|
- ./postgres:/var/lib/postgresql/data
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:6.2-alpine
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "6379:6379"
|
||||||
|
command: redis-server --save 20 1 --loglevel warning --requirepass iamatotallysecurepassworddonttestmebrox
|
||||||
|
volumes:
|
||||||
|
- ./redis:/data
|
||||||
|
|
||||||
|
adminer:
|
||||||
|
image: adminer
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
depends_on:
|
||||||
|
- pgsql
|
||||||
|
redisinsight:
|
||||||
|
image: redis/redisinsight:latest
|
||||||
|
container_name: redisinsight
|
||||||
|
ports:
|
||||||
|
- "5540:5540"
|
||||||
|
restart: unless-stopped
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"action": "created",
|
||||||
|
"release": {
|
||||||
|
"tag_name": "v0.0.0-test"
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+227
@@ -0,0 +1,227 @@
|
|||||||
|
# Copilot / AI Agent Instructions for optima-api
|
||||||
|
|
||||||
|
Purpose: make AI coding agents immediately productive in this repository by describing architecture, conventions, workflows, and helpful code pointers.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Big picture
|
||||||
|
|
||||||
|
This is a TypeScript API service (runs on **Bun**) using the **Hono** framework. The HTTP surface is implemented in `src/api` where small route-handler files are mounted on a versioned router in `src/api/server.ts` (see the `/v1` mount). The typical request flow is:
|
||||||
|
|
||||||
|
```
|
||||||
|
server.ts → routers/<domain>Router.ts → api/<domain>/*.ts (route handlers) → managers/<domain>.ts → controllers (domain models) / modules / generated/prisma
|
||||||
|
```
|
||||||
|
|
||||||
|
Keep each layer focused:
|
||||||
|
|
||||||
|
- **Route handler files** (`src/api/<domain>/*.ts`) — define individual endpoints using the `createRoute()` utility, handle request validation with Zod, call managers, and return `apiResponse.*` results.
|
||||||
|
- **Routers** (`src/api/routers/*`) — aggregate route handler files from a domain's `index.ts` and re-mount them under a single prefix. Mounted in `src/api/server.ts`.
|
||||||
|
- **Managers** (`src/managers/*`) — thin domain/persistence layers that wrap `generated/prisma` calls and other I/O. Managers instantiate and return **controller** instances as domain objects.
|
||||||
|
- **Controllers** (`src/controllers/*`) — **domain model classes** (e.g., `CompanyController`, `CredentialController`, `UserController`) that encapsulate entity state and domain methods. They are NOT request handlers. Managers create and return controller instances.
|
||||||
|
- **Modules** (`src/modules/*`) — shared utilities, external API clients (ConnectWise, UniFi, Microsoft), credential helpers, permission utilities, and tools.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Runtime / tooling
|
||||||
|
|
||||||
|
The project runs on **Bun** exclusively — **always use `bun` commands, never `npm`, `npx`, or `yarn`**. DB tooling uses **Prisma**; the generated client lives under `generated/prisma` (do NOT edit generated files). Test preloads are configured in `bunfig.toml` so bare `bun test` works. Key scripts in `package.json`:
|
||||||
|
|
||||||
|
- `dev` — `NODE_ENV=development bun --watch src/index.ts` (start dev server with hot reload)
|
||||||
|
- `test` — `bun test` (runs all tests with preload from `bunfig.toml`)
|
||||||
|
- `db:gen` — `prisma generate`
|
||||||
|
- `db:push` — `prisma migrate dev --skip-generate`
|
||||||
|
- `utils:dev` — `docker compose -f .docker/docker-compose.yml up --build`
|
||||||
|
- `utils:gen_private_keys` — `bun ./utils/genPrivateKeys`
|
||||||
|
- `utils:create_admin_role` — `bun ./utils/createAdminRole`
|
||||||
|
- `utils:assign_user_role` — `bun ./utils/assignUserRole`
|
||||||
|
|
||||||
|
## Data layer
|
||||||
|
|
||||||
|
Prisma schema is at `prisma/schema.prisma`. The app imports the generated Prisma client from `generated/prisma/client.ts` (or `generated/prisma/browser.ts` for browser type contexts). The shared `prisma` instance is exported from `src/constants.ts`. Always run `bun run db:gen` after updating `schema.prisma`.
|
||||||
|
|
||||||
|
## Shared constants (`src/constants.ts`)
|
||||||
|
|
||||||
|
This file exports critical shared instances used across the codebase:
|
||||||
|
|
||||||
|
- `prisma` — the PrismaClient instance (via `@prisma/adapter-pg`)
|
||||||
|
- `PORT`, session/token durations, private/public keys for JWT signing
|
||||||
|
- `msalClient` — Microsoft MSAL client for OAuth
|
||||||
|
- `connectWiseApi` — Axios instance for ConnectWise API
|
||||||
|
- `unifi` — `UnifiClient` instance for UniFi controller interaction
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Route handler pattern (`createRoute`)
|
||||||
|
|
||||||
|
Every route handler file uses the `createRoute()` utility from `src/modules/api-utils/createRoute.ts`. It creates a self-contained Hono sub-app for a single endpoint:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export default createRoute(
|
||||||
|
"get", // HTTP method
|
||||||
|
["/companies"], // path(s)
|
||||||
|
async (c) => {
|
||||||
|
/* handler */
|
||||||
|
}, // request handler
|
||||||
|
authMiddleware({ permissions: ["company.fetch.many"] }), // middleware (spread)
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
Route files live in `src/api/<domain>/*.ts`. Each domain folder has an `index.ts` that re-exports all route modules. Router files (`src/api/routers/<domain>Router.ts`) import from the domain's index and auto-mount all routes:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import * as companyRoutes from "../companies";
|
||||||
|
const companyRouter = new Hono();
|
||||||
|
Object.values(companyRoutes).map((r) => companyRouter.route("/", r));
|
||||||
|
export default companyRouter;
|
||||||
|
```
|
||||||
|
|
||||||
|
`src/api/server.ts` then mounts each router under `/v1`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
v1.route("/company", require("./routers/companyRouter").default);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Routing & domain organization
|
||||||
|
|
||||||
|
The `server.ts` file mounts these routers under `/v1`:
|
||||||
|
|
||||||
|
- `/teapot` — health check
|
||||||
|
- `/auth` — Microsoft OAuth flow (`src/api/auth/*`)
|
||||||
|
- `/user` — user routes (`src/api/user/*`) including `@me` sub-routes
|
||||||
|
- `/company` — company routes (`src/api/companies/*`)
|
||||||
|
- `/credential` — credential routes (`src/api/credentials/*`)
|
||||||
|
- `/credential-type` — credential type routes (`src/api/credential-types/*`)
|
||||||
|
- `/role` — role management (`src/api/roles/*`)
|
||||||
|
- `/permissions` — permission node queries (`src/api/permissions/*`)
|
||||||
|
- `/unifi` — UniFi integration (`src/api/unifi/*` with `sites/` and `site/` sub-folders)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## API layout & conventions (how to add a new endpoint)
|
||||||
|
|
||||||
|
1. **Add route handler files**: Create `src/api/<domain>/<action>.ts` files, each exporting a default `createRoute(...)` call. Validate input with Zod inside the handler, call managers for business logic, and return responses via `apiResponse.*`.
|
||||||
|
2. **Add domain index**: Create `src/api/<domain>/index.ts` that re-exports all route modules from the folder.
|
||||||
|
3. **Add router**: Create `src/api/routers/<domain>Router.ts` that imports all routes from the domain's index and mounts them. Mount it in `src/api/server.ts` under `v1`.
|
||||||
|
4. **Add manager**: Create `src/managers/<domains>.ts` (plural filename) for persistence/domain logic. Use the `prisma` instance from `src/constants.ts`; do not import Prisma directly in route handlers. Managers should instantiate and return controller instances when the domain warrants it.
|
||||||
|
5. **Add controller** (if needed): Create `src/controllers/<Domain>Controller.ts` (singular filename) as a **class** that encapsulates entity state, domain methods, and a `toJson()` serializer. Controllers are domain model objects — they do NOT handle HTTP requests.
|
||||||
|
6. **Add modules/types**: If needed, add helpers to `src/modules/*` and runtime types to `src/types/*`.
|
||||||
|
7. **Middleware & auth**: Use `authMiddleware()` from `src/api/middleware/authorization.ts` as the last argument to `createRoute()`. It accepts `{ permissions?: string[], scopes?: string[], forbiddenAuthTypes?: string[] }`. Follow existing token/session patterns from `src/controllers/SessionController.ts` and `src/Errors/*`.
|
||||||
|
8. **Error handling**: Throw repository-specific errors from `src/Errors/*` (include `status`, `name`, `message`, optional `cause`) and let `src/api/server.ts` map them via `apiResponse.error`.
|
||||||
|
9. **Naming conventions**: plural manager filenames (`companies.ts`), singular controller class names (`CompanyController.ts`), descriptive route handler filenames (`fetchAll.ts`, `create.ts`, `update.ts`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Examples & notable files
|
||||||
|
|
||||||
|
- `src/api/server.ts` — mounts `v1`, registers `cors`, central `onError` handler and `notFound` response.
|
||||||
|
- `src/api/companies/fetchAll.ts` — canonical example of a route handler file using `createRoute()`, `authMiddleware()`, managers, and `apiResponse`.
|
||||||
|
- `src/api/credentials/create.ts` — example of Zod validation inside a route handler.
|
||||||
|
- `src/api/routers/companyRouter.ts` — canonical router that auto-mounts all route modules from a domain folder.
|
||||||
|
- `src/api/user/@me/*` — nested sub-route example (user's own profile endpoints).
|
||||||
|
- `src/controllers/CompanyController.ts` — example domain model class with methods like `refreshFromCW()`, `fetchCwData()`, and `toJson()`.
|
||||||
|
- `src/controllers/CredentialController.ts` — example of a richer domain model class with field validation, secure value handling, and sub-credential support.
|
||||||
|
- `src/managers/companies.ts` — example manager calling Prisma and returning `CompanyController` instances.
|
||||||
|
- `src/modules/api-utils/createRoute.ts` — the `createRoute()` utility used by every route handler.
|
||||||
|
- `src/modules/cw-utils/*` — external ConnectWise API integrations; keep interfaces stable and return domain objects consumed by managers.
|
||||||
|
- `src/modules/unifi-api/UnifiClient.ts` — UniFi controller API client class with methods for sites, WLANs, devices, networks, etc.
|
||||||
|
- `src/modules/credentials/*` — credential field validation, secure value encryption/decryption, and type definitions.
|
||||||
|
- `src/constants.ts` — shared instances (`prisma`, API clients, keys, durations).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Validation & errors
|
||||||
|
|
||||||
|
Zod is used for input validation **inside route handler files** (not controllers). Zod errors are handled centrally in `src/api/server.ts` via `apiResponse.zodError`. Application errors use custom error classes in `src/Errors/*` (e.g., `AuthenticationError.ts`, `GenericError.ts`, `AuthorizationError.ts`, `InsufficientPermission.ts`). When creating errors, follow the shape used in existing errors (include `status`, `name`, `message`, and optional `cause`).
|
||||||
|
|
||||||
|
## Response pattern
|
||||||
|
|
||||||
|
Use the `apiResponse` helpers in `src/modules/api-utils/apiResponse.ts` for formatting all HTTP responses:
|
||||||
|
|
||||||
|
- `apiResponse.successful(message, data?, meta?)` — 200
|
||||||
|
- `apiResponse.created(message, data?)` — 201
|
||||||
|
- `apiResponse.error(err)` — reads `status` from the error
|
||||||
|
- `apiResponse.internalError()` — 500
|
||||||
|
- `apiResponse.zodError(err)` — 400
|
||||||
|
|
||||||
|
## Auth & external integrations
|
||||||
|
|
||||||
|
Microsoft OAuth flow is under `src/api/auth/*` and `src/modules/fetchMicrosoftUser.ts`. If touching authentication, follow existing redirect/refresh patterns in `src/api/auth` and preserve token-refresh semantics.
|
||||||
|
|
||||||
|
## ConnectWise integration
|
||||||
|
|
||||||
|
Utilities for ConnectWise interactions live in `src/modules/cw-utils/*` (e.g., `configurations/fetchCompanyConfigurations.ts`, `fetchCompany.ts`, `fetchAllCompanies.ts`). These modules call external APIs via the `connectWiseApi` Axios instance from `src/constants.ts` and return domain data; preserve the module contracts (input types and returned shapes) when refactoring.
|
||||||
|
|
||||||
|
## UniFi integration
|
||||||
|
|
||||||
|
The `UnifiClient` class in `src/modules/unifi-api/UnifiClient.ts` wraps all UniFi controller API interactions (login, sites, WLANs, devices, networks, AP groups, WLAN groups, speed profiles, PPSKs). The shared instance is exported from `src/constants.ts` as `unifi`. UniFi route handlers live in `src/api/unifi/` with `sites/` (multi-site operations) and `site/` (single-site operations) sub-folders.
|
||||||
|
|
||||||
|
## Generated files and CI
|
||||||
|
|
||||||
|
`generated/` is a build artifact. Do not modify. When updating Prisma models, run `npm run db:gen` and commit changes to `generated/prisma` only if that's the established workflow.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Coding conventions & patterns specific to this repo
|
||||||
|
|
||||||
|
- Prefer the existing layered architecture: route handlers → managers → controllers (domain models) / modules.
|
||||||
|
- Use the `createRoute()` utility for all route handler files.
|
||||||
|
- Use the `apiResponse` helpers for all HTTP responses.
|
||||||
|
- Throw or propagate repository-specific custom errors (from `src/Errors/*`) rather than returning bare objects.
|
||||||
|
- Keep TypeScript types in `src/types/*` and use Zod for runtime checks inside route handlers.
|
||||||
|
- **Avoid `else` statements** — prefer ternary operators, early returns, or other control flow patterns. Only use `else` if there is absolutely no other way.
|
||||||
|
- ES module syntax (`export default`, `import`) is used throughout. The `require()` calls in `server.ts` are for lazy loading but all modules use `export default`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Local dev / quick checks
|
||||||
|
|
||||||
|
- Start dev server: `bun run dev`
|
||||||
|
- Run tests: `bun test`
|
||||||
|
- Regenerate Prisma client: `bun run db:gen`
|
||||||
|
- Apply DB migrations locally: `bun run db:push`
|
||||||
|
- Docker dev utilities: `bun run utils:dev`
|
||||||
|
- Generate private keys: `bun run utils:gen_private_keys`
|
||||||
|
- Create admin role: `bun run utils:create_admin_role`
|
||||||
|
- Assign user role: `bun run utils:assign_user_role`
|
||||||
|
|
||||||
|
## When editing generated or infra files
|
||||||
|
|
||||||
|
If you need to change `generated/prisma/*` (rare), explain why in the PR and show commands used to regenerate.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Documentation sync (IMPORTANT)
|
||||||
|
|
||||||
|
Whenever you add, remove, or modify API routes or permission nodes, you **must** update all three of the following files to keep them in sync:
|
||||||
|
|
||||||
|
1. `src/types/PermissionNodes.ts` — the single source of truth for all permission node definitions, categories, descriptions, and `usedIn` references.
|
||||||
|
2. `PERMISSIONS.md` — human-readable documentation of all permission nodes; must strictly reflect the data in `PermissionNodes.ts`.
|
||||||
|
3. `API_ROUTES.md` — comprehensive documentation of all API routes, including method, path, auth requirements, permissions, request/response examples.
|
||||||
|
|
||||||
|
Additionally, whenever you add, remove, or modify **caching logic** (TTL algorithms, cache key patterns, background refresh mechanics, retry settings, or invalidation behavior), you **must** update:
|
||||||
|
|
||||||
|
4. `CACHING.md` — comprehensive documentation of the Redis-backed opportunity cache, TTL algorithms, background refresh mechanics, retry logic, and debugging tools.
|
||||||
|
|
||||||
|
Always verify that new routes have their required permissions listed in `PermissionNodes.ts`, that `PERMISSIONS.md` tables match the TS file exactly, that `API_ROUTES.md` includes full documentation for every mounted route, and that `CACHING.md` accurately reflects any caching changes. Run through all relevant files at the end of any route, permission, or caching change to catch discrepancies.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Field-level permission gating (`processObjectValuePerms`)
|
||||||
|
|
||||||
|
Some routes use `processObjectValuePerms` from `src/modules/permission-utils/processObjectPermissions.ts` to filter response objects on a per-field basis. When this pattern is used, every key of the response object becomes a permission node in the form `<scope>.<field>` (e.g., `unifi.site.wifi.read.passphrase`). Only fields whose corresponding permission the user holds are included in the response.
|
||||||
|
|
||||||
|
There is also `processObjectPermMap` in the same file, which returns a `Record<key, boolean>` indicating which fields the user has permission for (useful for UI gating).
|
||||||
|
|
||||||
|
**When documenting a route that uses field-level gating, you must:**
|
||||||
|
|
||||||
|
1. Note in `API_ROUTES.md` that the route uses field-level gating, explain the behaviour, and list every `<scope>.<field>` permission node in a collapsible table.
|
||||||
|
2. Add a `unifi.site.wifi.read`-style parent permission node in `PermissionNodes.ts` with a `fieldLevelPermissions` array listing every `<scope>.<field>` node.
|
||||||
|
3. Add matching rows/notes to `PERMISSIONS.md` including the full list of field-level nodes.
|
||||||
|
|
||||||
|
**Current routes using field-level gating:**
|
||||||
|
|
||||||
|
- `GET /v1/unifi/site/:id/wifi` — scope `unifi.site.wifi.read`, gates every field on the `WlanConf` object.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
If anything here is unclear or you'd like more examples (e.g., a walk-through adding a route handler + manager + controller), tell me which area to expand and I'll iterate.
|
||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
name: Build and Publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Bun
|
||||||
|
uses: oven-sh/setup-bun@v2
|
||||||
|
with:
|
||||||
|
bun-version: "1.3.6"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: bun install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Generate Prisma client
|
||||||
|
run: DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy" bunx prisma generate
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: bun test --preload ./tests/setup.ts
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
needs: [test]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push the Docker image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
target: runtime
|
||||||
|
tags: |
|
||||||
|
ghcr.io/project-optima/ttscm-api:latest
|
||||||
|
ghcr.io/project-optima/ttscm-api:${{ github.event.release.tag_name }}
|
||||||
|
|
||||||
|
- name: Build and push the migration image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
target: migration
|
||||||
|
tags: |
|
||||||
|
ghcr.io/project-optima/ttscm-api-migrate:latest
|
||||||
|
ghcr.io/project-optima/ttscm-api-migrate:${{ github.event.release.tag_name }}
|
||||||
|
|
||||||
|
migrate:
|
||||||
|
name: Run Migrations
|
||||||
|
needs: [build]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set the Kubernetes context
|
||||||
|
uses: azure/k8s-set-context@v2
|
||||||
|
with:
|
||||||
|
method: kubeconfig
|
||||||
|
kubeconfig: ${{ secrets.KUBECONFIG }}
|
||||||
|
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Delete previous migration job if exists
|
||||||
|
run: kubectl delete job -n optima -l app=prisma-migrate --ignore-not-found
|
||||||
|
|
||||||
|
- name: Apply migration job
|
||||||
|
run: |
|
||||||
|
TAG=${{ github.event.release.tag_name }}
|
||||||
|
sed "s/RELEASE_TAG/${TAG}/g" kubernetes/migration-job.yaml | kubectl apply -f -
|
||||||
|
|
||||||
|
- name: Wait for migration to complete
|
||||||
|
run: |
|
||||||
|
TAG=${{ github.event.release.tag_name }}
|
||||||
|
kubectl wait --for=condition=complete --timeout=120s -n optima job/prisma-migrate-${TAG}
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
name: Deploy
|
||||||
|
needs: [migrate]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set the Kubernetes context
|
||||||
|
uses: azure/k8s-set-context@v2
|
||||||
|
with:
|
||||||
|
method: kubeconfig
|
||||||
|
kubeconfig: ${{ secrets.KUBECONFIG }}
|
||||||
|
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Lint Kubernetes manifests
|
||||||
|
uses: azure/k8s-lint@v3
|
||||||
|
with:
|
||||||
|
lintType: dryrun
|
||||||
|
manifests: |
|
||||||
|
kubernetes/deployment.yaml
|
||||||
|
kubernetes/ingress.yaml
|
||||||
|
namespace: optima
|
||||||
|
|
||||||
|
- name: Deploy to the Kubernetes cluster
|
||||||
|
uses: azure/k8s-deploy@v5
|
||||||
|
with:
|
||||||
|
namespace: optima
|
||||||
|
force: true
|
||||||
|
skip-tls-verify: true
|
||||||
|
manifests: |
|
||||||
|
kubernetes/deployment.yaml
|
||||||
|
kubernetes/ingress.yaml
|
||||||
|
images: |
|
||||||
|
ghcr.io/project-optima/ttscm-api:${{ github.event.release.tag_name }}
|
||||||
Vendored
+27
@@ -0,0 +1,27 @@
|
|||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["**"]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Bun
|
||||||
|
uses: oven-sh/setup-bun@v2
|
||||||
|
with:
|
||||||
|
bun-version: "1.3.6"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: bun install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Generate Prisma client
|
||||||
|
run: DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy" bunx prisma generate
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: bun test --preload ./tests/setup.ts
|
||||||
+154
@@ -0,0 +1,154 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
*.jsonl
|
||||||
|
cw-api-logs/
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Sveltekit cache directory
|
||||||
|
.svelte-kit/
|
||||||
|
|
||||||
|
# vitepress build output
|
||||||
|
**/.vitepress/dist
|
||||||
|
|
||||||
|
# vitepress cache directory
|
||||||
|
**/.vitepress/cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# Firebase cache directory
|
||||||
|
.firebase/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# yarn v3
|
||||||
|
.pnp.*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/sdks
|
||||||
|
!.yarn/versions
|
||||||
|
|
||||||
|
# Vite logs files
|
||||||
|
vite.config.js.timestamp-*
|
||||||
|
vite.config.ts.timestamp-*
|
||||||
|
|
||||||
|
.permissions.key
|
||||||
|
.refreshToken.key
|
||||||
|
.secureValues.key
|
||||||
|
.accessToken.key
|
||||||
|
|
||||||
|
public-keys/
|
||||||
|
production-keys/
|
||||||
|
|
||||||
|
microsoft-oauth.json
|
||||||
|
|
||||||
|
.docker/postgres
|
||||||
|
.docker/redis
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"chat.tools.terminal.autoApprove": {
|
||||||
|
"bun": true
|
||||||
|
}
|
||||||
|
}
|
||||||
+6505
File diff suppressed because it is too large
Load Diff
+399
@@ -0,0 +1,399 @@
|
|||||||
|
# Caching Architecture
|
||||||
|
|
||||||
|
This document describes the caching layer used in the Optima API, covering the Redis-backed opportunity cache, TTL algorithms, background refresh mechanics, retry logic, and debugging tools.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
The API caches expensive ConnectWise (CW) API responses in **Redis** to reduce latency and avoid CW rate limits. The primary cache layer is the **opportunity cache** (`src/modules/cache/opportunityCache.ts`), which is proactively warmed by workers on a background interval.
|
||||||
|
|
||||||
|
The API also maintains a Redis-backed **sales member metrics cache** (`src/modules/cache/salesOpportunityMetricsCache.ts`) refreshed every 5 minutes. It precomputes per-member dashboard/reporting figures (pipeline revenue, won/lost counts, win rate, avg days to close, and related metrics) for fast reads from `/v1/sales/opportunities/metrics`.
|
||||||
|
|
||||||
|
### Key design principles
|
||||||
|
|
||||||
|
- **Adaptive TTLs** — cache durations are computed dynamically based on how "hot" an opportunity is (recently updated = shorter TTL = fresher data).
|
||||||
|
- **Background refresh** — a 20-minute interval runs a unified opportunity refresh pass (collector-first full sync + cache warm across active and archived opportunities).
|
||||||
|
- **Bounded concurrency** — CW API calls are throttled via thunk-based batching to prevent overwhelming the upstream API.
|
||||||
|
- **Graceful degradation** — transient CW errors (timeouts, network failures) are caught, logged, and retried on the next cycle rather than crashing the process.
|
||||||
|
- **Priority ordering** — most recently updated opportunities are refreshed first so active deals get fresh data before stale ones.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## What is cached
|
||||||
|
|
||||||
|
Each opportunity can have up to 7 cached payloads in Redis:
|
||||||
|
|
||||||
|
| Cache Key Pattern | Data | Source |
|
||||||
|
| ----------------------------------- | ------------------------------------ | --------------------------------------------------------------------- |
|
||||||
|
| `opp:cw-data:{cwOpportunityId}` | Raw CW opportunity response | `GET /sales/opportunities/:id` |
|
||||||
|
| `opp:activities:{cwOpportunityId}` | CW activities array | `GET /sales/activities?conditions=opportunity/id=:id` |
|
||||||
|
| `opp:notes:{cwOpportunityId}` | CW notes array | `GET /sales/opportunities/:id/notes` |
|
||||||
|
| `opp:contacts:{cwOpportunityId}` | CW contacts array | `GET /sales/opportunities/:id/contacts` |
|
||||||
|
| `opp:products:{cwOpportunityId}` | Forecast + procurement products blob | `GET /sales/opportunities/:id/forecast` + `GET /procurement/products` |
|
||||||
|
| `opp:company-cw:{cw_CompanyId}` | Hydrated company + contacts blob | `GET /company/companies/:id` + contacts endpoints |
|
||||||
|
| `opp:site:{cwCompanyId}:{cwSiteId}` | Company site data | `GET /company/companies/:id/sites/:siteId` |
|
||||||
|
|
||||||
|
Inventory-adjustment-driven catalog sync adds a targeted product cache:
|
||||||
|
|
||||||
|
| Cache Key Pattern | Data | Source |
|
||||||
|
| ------------------------ | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||||
|
| `catalog:item:cw:{cwId}` | Full CW catalog item + computed `onHand` + DB row snapshot | `GET /procurement/adjustments` + `GET /procurement/catalog/:id` + catalog inventory endpoint |
|
||||||
|
|
||||||
|
Sales opportunity metrics caching adds member-focused keys:
|
||||||
|
|
||||||
|
| Cache Key Pattern | Data | Source |
|
||||||
|
| ------------------------------------- | -------------------------------------- | ------------------------------------------------------------------------------------- |
|
||||||
|
| `sales:metrics:members:all` | Envelope of all active-member metrics | Precomputed from active CW members + assigned opportunities + products cache/CW fetch |
|
||||||
|
| `sales:metrics:member:{cwIdentifier}` | One member's computed metrics snapshot | Same as above |
|
||||||
|
| `sales:metrics:oppRevenue:{cwOppId}` | Per-opportunity computed revenue blob | Metrics refresh lookups (products cache-first, then manager/controller fallback) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## TTL Algorithms
|
||||||
|
|
||||||
|
Three algorithms compute cache TTLs. All share the same input signals:
|
||||||
|
|
||||||
|
- `closedFlag` — whether the opportunity is closed
|
||||||
|
- `closedDate` — when it was closed
|
||||||
|
- `expectedCloseDate` — projected close date (forward-looking signal)
|
||||||
|
- `lastUpdated` — last CW modification date (backward-looking signal)
|
||||||
|
|
||||||
|
### Primary TTL (`computeCacheTTL`)
|
||||||
|
|
||||||
|
**File:** `src/modules/algorithms/computeCacheTTL.ts`
|
||||||
|
|
||||||
|
Used for: opportunity CW data, activities, company CW data.
|
||||||
|
|
||||||
|
| # | Condition | TTL | Human |
|
||||||
|
| --- | ------------------------------------------------------- | ---------- | ------------ |
|
||||||
|
| 1a | Closed > 30 days ago | `null` | Do not cache |
|
||||||
|
| 1b | Closed within 30 days | 900,000 ms | 15 minutes |
|
||||||
|
| 2 | `expectedCloseDate` or `lastUpdated` within **5 days** | 30,000 ms | 30 seconds |
|
||||||
|
| 3 | `expectedCloseDate` or `lastUpdated` within **14 days** | 60,000 ms | 60 seconds |
|
||||||
|
| 4 | Everything else | 900,000 ms | 15 minutes |
|
||||||
|
|
||||||
|
Rules are evaluated top-to-bottom; first match wins.
|
||||||
|
|
||||||
|
### Sub-Resource TTL (`computeSubResourceCacheTTL`)
|
||||||
|
|
||||||
|
**File:** `src/modules/algorithms/computeSubResourceCacheTTL.ts`
|
||||||
|
|
||||||
|
Used for: notes, contacts.
|
||||||
|
|
||||||
|
| # | Condition | TTL | Human |
|
||||||
|
| --- | --------------------- | ---------- | ------------ |
|
||||||
|
| 1a | Closed > 30 days ago | `null` | Do not cache |
|
||||||
|
| 1b | Closed within 30 days | 300,000 ms | 5 minutes |
|
||||||
|
| 2 | Within **5 days** | 60,000 ms | 60 seconds |
|
||||||
|
| 3 | Within **14 days** | 120,000 ms | 2 minutes |
|
||||||
|
| 4 | Everything else | 300,000 ms | 5 minutes |
|
||||||
|
|
||||||
|
### Products TTL (`computeProductsCacheTTL`)
|
||||||
|
|
||||||
|
**File:** `src/modules/algorithms/computeProductsCacheTTL.ts`
|
||||||
|
|
||||||
|
Used for: forecast + procurement products.
|
||||||
|
|
||||||
|
| # | Condition | TTL | Human |
|
||||||
|
| --- | ------------------------------------------- | ------------ | ---------- |
|
||||||
|
| 1 | Status is Won/Lost/Pending Won/Pending Lost | `null` | No cache |
|
||||||
|
| 2 | Main cache TTL is `null` | `null` | No cache |
|
||||||
|
| 3 | `lastUpdated` within **3 days** | 15,000 ms | 15 seconds |
|
||||||
|
| 4 | Everything else | 1,200,000 ms | 20 minutes |
|
||||||
|
|
||||||
|
Products on terminal-status opportunities are never proactively cached. Non-hot products use a **lazy on-demand** cache — they're fetched when requested and cached for 20 minutes.
|
||||||
|
|
||||||
|
### Site TTL
|
||||||
|
|
||||||
|
Sites use a fixed TTL of **20 minutes** (1,200,000 ms). Site/address data rarely changes. Sites are **not** proactively warmed by the background refresh — they are populated lazily on the first detail-view request.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Background Refresh
|
||||||
|
|
||||||
|
**Worker path:** `enqueueActiveOpportunityRefreshJob()` in `src/index.ts` → `src/workert.ts` → `refreshActiveOpportunitiesWorker()` in `src/modules/workers/cache/refreshActiveOpportunities.ts`
|
||||||
|
|
||||||
|
**Interval:** Every 20 minutes, triggered from `src/index.ts`.
|
||||||
|
|
||||||
|
### Refresh cycle
|
||||||
|
|
||||||
|
1. **Full sync first** — worker runs `refreshOpportunities()` with collector-first strategy (`fetchOpportunities` collector call, CW fallback) to keep DB opportunity records current.
|
||||||
|
2. **Collector cache seeding** — when collector data is used, Redis keys for opportunity CW data, activities, notes, contacts, and products are seeded directly from collector payload before cache warm planning.
|
||||||
|
3. **Query DB** — fetch all opportunities ordered by `cwLastUpdated DESC`.
|
||||||
|
4. **Compute TTL per opportunity** — adaptive TTL for active/recent opportunities, and `TTL_ARCHIVED_MS` (24h) for archived opportunities where adaptive TTL resolves to `null`.
|
||||||
|
5. **Batch EXISTS check** — use a single Redis pipeline to check which cache keys already exist (5 EXISTS commands per opportunity: oppCwData, activities, notes, contacts, products).
|
||||||
|
6. **Build thunk list** — for each opportunity with missing keys, push a **thunk** (lazy function) into the task list. No HTTP requests fire at this point.
|
||||||
|
7. **Execute with bounded concurrency** — process thunks through a worker pool (`ACTIVE_REFRESH_CONCURRENCY`, default **12**) and progress logging (`ACTIVE_REFRESH_PROGRESS_EVERY`, default **50**).
|
||||||
|
8. **Emit events** — `cache:opportunities:refresh:started` and `cache:opportunities:refresh:completed` events are emitted for the event debugger.
|
||||||
|
|
||||||
|
### Inventory-adjustment listener cycle
|
||||||
|
|
||||||
|
**Function:** `listenInventoryAdjustments()` in `src/modules/cw-utils/procurement/listenInventoryAdjustments.ts`
|
||||||
|
|
||||||
|
**Interval:** Every 60 seconds, triggered from `src/index.ts`.
|
||||||
|
|
||||||
|
1. Fetch `GET /procurement/adjustments?pageSize=1000`.
|
||||||
|
2. Build a normalized snapshot of tracked inventory rows (`cwCatalogId`, `onHand`, `inventory`) per adjustment.
|
||||||
|
3. Compare to previous snapshot; extract only changed product IDs.
|
||||||
|
4. For each changed product ID, fetch fresh CW catalog item + current on-hand.
|
||||||
|
5. Upsert `CatalogItem` in Postgres and write Redis key `catalog:item:cw:{cwId}` with a 20-minute TTL.
|
||||||
|
|
||||||
|
Guardrails to prevent request storms:
|
||||||
|
|
||||||
|
- Diffing is computed at **product state** level (grouped by `cwCatalogId`), not raw adjustment-row churn.
|
||||||
|
- Per-cycle syncs are capped (`CW_ADJUSTMENT_SYNC_MAX_PER_CYCLE`, default `50`).
|
||||||
|
- Product resync cooldown is enforced (`CW_ADJUSTMENT_SYNC_COOLDOWN_MS`, default `600000` ms / 10 min).
|
||||||
|
|
||||||
|
This avoids full-catalog sweeps for small inventory movements and updates only the products implicated by adjustments.
|
||||||
|
|
||||||
|
### Full procurement catalog refresh
|
||||||
|
|
||||||
|
**Function:** `refreshCatalog()` in `src/modules/cw-utils/procurement/refreshCatalog.ts`
|
||||||
|
|
||||||
|
**Interval:** Every 30 minutes, triggered from `src/index.ts`.
|
||||||
|
|
||||||
|
The full catalog cache/DB sync uses the same slow-parallel thunk strategy as opportunity cache refreshes:
|
||||||
|
|
||||||
|
- Build arrays of thunk tasks (`() => Promise<void>`) for CW item fetches, inventory fetches, and DB upserts.
|
||||||
|
- Execute with bounded concurrency (`CONCURRENCY=6`).
|
||||||
|
- Pause between batches (`BATCH_DELAY_MS=250`) to avoid CW burst pressure.
|
||||||
|
- Log task failures and retry naturally on the next cycle.
|
||||||
|
|
||||||
|
This keeps full-catalog refresh conservative while inventory-adjustment listener handles near-real-time targeted updates.
|
||||||
|
|
||||||
|
### Full inventory sweep fallback
|
||||||
|
|
||||||
|
`refreshInventory()` remains as a safety net but is intentionally infrequent:
|
||||||
|
|
||||||
|
- Runs every **6 hours** from `src/index.ts` (no startup-time full sweep).
|
||||||
|
- Uses the same slow-parallel pattern (`CONCURRENCY=6`, `BATCH_DELAY_MS=250`) to avoid burst traffic.
|
||||||
|
|
||||||
|
Most on-hand freshness now comes from the 60-second adjustment listener plus 30-minute full catalog refresh.
|
||||||
|
|
||||||
|
### Concurrency control
|
||||||
|
|
||||||
|
The thunk pattern is critical. Previously, tasks were pushed as already-executing promises (`refreshTasks.push(fetchAndCache(...))`), which meant all HTTP requests fired simultaneously regardless of the batching loop. The fix was changing the array type from `Promise<void>[]` to `(() => Promise<void>)[]` so requests only start when explicitly invoked: `batch.map((fn) => fn())`.
|
||||||
|
|
||||||
|
### Current tuning
|
||||||
|
|
||||||
|
| Parameter | Value | Effect |
|
||||||
|
| ------------------------------- | ---------- | ------------------------------------------ |
|
||||||
|
| `ACTIVE_REFRESH_CONCURRENCY` | 12 | Max simultaneous CW API requests |
|
||||||
|
| `ACTIVE_REFRESH_PROGRESS_EVERY` | 50 | Task completion cadence for progress logs |
|
||||||
|
| Refresh interval | 20 minutes | How often the unified sweep runs |
|
||||||
|
|
||||||
|
At these settings, a full sweep of ~500 expired keys completes in ~1-2 minutes with zero CW errors and ~230ms median latency.
|
||||||
|
|
||||||
|
### Archived opportunities in unified refresh
|
||||||
|
|
||||||
|
Archived opportunities are those returned `null` by `computeCacheTTL` — specifically opportunities with `closedFlag = true` AND `closedDate` older than 30 days (or `closedDate = null`).
|
||||||
|
|
||||||
|
In the unified 20-minute refresh pass, these rows are no longer skipped. Instead, cache writes use `TTL_ARCHIVED_MS = 86,400,000 ms` (**24 hours**) while still using the same missing-key EXISTS strategy as active opportunities.
|
||||||
|
|
||||||
|
### Sales metrics refresh job
|
||||||
|
|
||||||
|
**Function:** `refreshSalesOpportunityMetricsCache()` in `src/modules/cache/salesOpportunityMetricsCache.ts`
|
||||||
|
|
||||||
|
**Interval:** Every 5 minutes, triggered from `src/index.ts`.
|
||||||
|
|
||||||
|
**Startup behavior:** On app startup, the refresh is invoked once with `forceColdLoad=true`, which clears metrics-owned Redis keys and bypasses metrics/product cache reuse for that initial rebuild. Subsequent interval runs use the normal warm path.
|
||||||
|
|
||||||
|
Refresh flow:
|
||||||
|
|
||||||
|
1. Fetch all active CW members (`inactiveFlag=false`).
|
||||||
|
Source: local `CwMember` table (kept in sync by the existing members refresh job).
|
||||||
|
2. Query DB opportunities assigned to those members (primary or secondary rep), scoped to open opportunities plus YTD-closed opportunities.
|
||||||
|
3. For each opportunity, compute revenue cache-first from `sales:metrics:oppRevenue:{cwOppId}` then `opp:products:{cwOpportunityId}`, and fallback through the manager/controller path (`opportunities.fetchRecord(...).fetchProducts()`) on miss.
|
||||||
|
4. Aggregate member metrics (pipeline revenue, won/lost MTD+YTD counts, avg days to close, weighted pipeline, win/loss rates, and related KPIs).
|
||||||
|
5. Write per-opportunity revenue blobs plus all-member and per-member snapshots to Redis with a 10-minute TTL.
|
||||||
|
|
||||||
|
Safety controls:
|
||||||
|
|
||||||
|
- **Single-flight lock** prevents overlapping refresh runs if a prior run is still in progress.
|
||||||
|
- **Per-opportunity timeout guard** ensures slow CW product lookups degrade to zero-revenue fallback instead of stalling the full refresh.
|
||||||
|
- **Force-cold-load mode** clears `sales:metrics:*` runtime state owned by the metrics cache before rebuilding startup data.
|
||||||
|
|
||||||
|
This cache-first model prioritizes metrics-owned opportunity revenue keys first, then opportunity product cache entries, and only reaches CW when needed.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Retry Logic (`withCwRetry`)
|
||||||
|
|
||||||
|
**File:** `src/modules/cw-utils/withCwRetry.ts`
|
||||||
|
|
||||||
|
Wraps CW API calls with exponential backoff retry on transient errors.
|
||||||
|
|
||||||
|
### Retryable errors
|
||||||
|
|
||||||
|
- `ECONNABORTED` (timeout)
|
||||||
|
- `ECONNRESET`
|
||||||
|
- `ETIMEDOUT`
|
||||||
|
- `ECONNREFUSED`
|
||||||
|
- `ERR_NETWORK`
|
||||||
|
- `ENETUNREACH`
|
||||||
|
- HTTP 5xx server errors
|
||||||
|
|
||||||
|
### Default configuration
|
||||||
|
|
||||||
|
| Parameter | Default | Description |
|
||||||
|
| ------------- | ------- | ----------------------------------------------------------- |
|
||||||
|
| `maxAttempts` | 3 | Total attempts including the first |
|
||||||
|
| `baseDelayMs` | 1,000 | Delay before first retry (doubles each retry: 1s → 2s → 4s) |
|
||||||
|
| `label` | — | Optional tag for log messages |
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { withCwRetry } from "./withCwRetry";
|
||||||
|
|
||||||
|
const response = await withCwRetry(
|
||||||
|
() => connectWiseApi.get(`/company/companies/${id}`),
|
||||||
|
{ label: `fetchCompany#${id}`, maxAttempts: 3, baseDelayMs: 1_500 },
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
Non-transient errors (404, 400, etc.) are re-thrown immediately without retry.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## CW API Logger
|
||||||
|
|
||||||
|
**File:** `src/modules/cw-utils/cwApiLogger.ts`
|
||||||
|
|
||||||
|
Axios interceptor that logs every CW API call to a JSONL file. Logging is **opt-in** — set the `LOG_CW_API` environment variable to enable it. Each process start creates a new timestamped file in the `cw-api-logs/` directory (e.g., `cw-api-logs/2026-03-02T14-30-05.123Z.jsonl`).
|
||||||
|
|
||||||
|
### Enabling logging
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Via the dev:log shorthand script
|
||||||
|
bun run dev:log
|
||||||
|
|
||||||
|
# Or manually with any command
|
||||||
|
LOG_CW_API=1 bun run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Log entry fields
|
||||||
|
|
||||||
|
| Field | Type | Description |
|
||||||
|
| ------------ | ----------------- | ----------------------------------- |
|
||||||
|
| `timestamp` | string (ISO-8601) | When the request completed |
|
||||||
|
| `method` | string | HTTP method |
|
||||||
|
| `url` | string | Request URL (relative or absolute) |
|
||||||
|
| `baseURL` | string | Axios baseURL |
|
||||||
|
| `status` | number \| null | HTTP status (null on network error) |
|
||||||
|
| `durationMs` | number | Wall-clock time in milliseconds |
|
||||||
|
| `error` | string \| null | Error code + message, if any |
|
||||||
|
| `timeout` | number | Configured timeout in ms |
|
||||||
|
|
||||||
|
### Analysis
|
||||||
|
|
||||||
|
Run the analyzer script to analyze the most recent log file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bun run utils:analyze_cw
|
||||||
|
```
|
||||||
|
|
||||||
|
Or specify a particular file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 debug-scripts/analyze-cw-calls.py cw-api-logs/2026-03-02T14-30-05.123Z.jsonl
|
||||||
|
```
|
||||||
|
|
||||||
|
This executes `debug-scripts/analyze-cw-calls.py` which produces:
|
||||||
|
|
||||||
|
- Overview (total calls, error rate, time span)
|
||||||
|
- Duration statistics (min, max, mean, p50, p90, p95, p99, distribution histogram)
|
||||||
|
- Error breakdown by type and endpoint
|
||||||
|
- Top 20 slowest calls
|
||||||
|
- Per-endpoint stats (count, errors, mean, p50, p95, max, total time)
|
||||||
|
- Timeline (per-minute throughput and errors)
|
||||||
|
- Concurrency hotspot detection
|
||||||
|
- Summary with recommendations
|
||||||
|
|
||||||
|
To clear all logs:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rm -rf cw-api-logs/
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Cache Invalidation
|
||||||
|
|
||||||
|
Mutation endpoints invalidate the relevant cache keys so the next read fetches fresh data from CW:
|
||||||
|
|
||||||
|
| Mutation | Cache invalidated |
|
||||||
|
| ------------------------------ | ---------------------------------------------------------------- |
|
||||||
|
| Create/update/delete note | `opp:notes:{cwOpportunityId}` via `invalidateNotesCache()` |
|
||||||
|
| Create/update/delete contact | `opp:contacts:{cwOpportunityId}` via `invalidateContactsCache()` |
|
||||||
|
| Add/update/resequence products | `opp:products:{cwOpportunityId}` via `invalidateProductsCache()` |
|
||||||
|
| Refresh opportunity | All keys for that opportunity (via re-fetch) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ConnectWise API Configuration
|
||||||
|
|
||||||
|
The shared Axios instance (`connectWiseApi`) is configured in `src/constants.ts`:
|
||||||
|
|
||||||
|
| Setting | Value | Purpose |
|
||||||
|
| --------- | ---------------------------------------------------- | ------------------------------ |
|
||||||
|
| `baseURL` | `https://ttscw.totaltech.net/v4_6_release/apis/3.0/` | CW API base |
|
||||||
|
| `timeout` | 30,000 ms (30s) | Per-request timeout |
|
||||||
|
| Logger | `attachCwApiLogger()` | Writes to `cw-api-calls.jsonl` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Architecture diagram
|
||||||
|
|
||||||
|
```
|
||||||
|
src/index.ts
|
||||||
|
│
|
||||||
|
├─ setInterval(enqueueActiveOpportunityRefreshJob, 20m)
|
||||||
|
│
|
||||||
|
└─► src/workert.ts (REFRESH_ACTIVE_OPPORTUNITIES worker)
|
||||||
|
│
|
||||||
|
├─ refreshOpportunities() // collector-first full DB sync
|
||||||
|
│
|
||||||
|
└─► refreshActiveOpportunitiesWorker()
|
||||||
|
│
|
||||||
|
├─ prisma.opportunity.findMany(orderBy: cwLastUpdated DESC)
|
||||||
|
├─ redis.pipeline().exists(...) ← batch key check
|
||||||
|
│
|
||||||
|
├─ Build thunk list (lazy functions)
|
||||||
|
│
|
||||||
|
└─ Execute thunks with ACTIVE_REFRESH_CONCURRENCY
|
||||||
|
│
|
||||||
|
├─► fetchAndCacheOppCwData() ─► opportunityCw.fetch()
|
||||||
|
├─► fetchAndCacheActivities() ─► activityCw.fetchByOpportunityDirect()
|
||||||
|
├─► fetchAndCacheNotes() ─► opportunityCw.fetchNotes()
|
||||||
|
├─► fetchAndCacheContacts() ─► opportunityCw.fetchContacts()
|
||||||
|
├─► fetchAndCacheProducts() ─► opportunityCw.fetchProducts() + fetchProcurementProducts()
|
||||||
|
├─► fetchAndCacheCompanyCwData() ─► fetchCwCompanyById() + contacts
|
||||||
|
└─► fetchAndCacheSite() ─► fetchCompanySite() (lazy only)
|
||||||
|
│
|
||||||
|
└─► connectWiseApi.get(...) ← withCwRetry + cwApiLogger interceptors
|
||||||
|
│
|
||||||
|
└─► Redis SET with computed TTL
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## File reference
|
||||||
|
|
||||||
|
| File | Purpose |
|
||||||
|
| ---------------------------------------------------------------- | ------------------------------------------------------------- |
|
||||||
|
| `src/modules/cache/opportunityCache.ts` | Cache read/write helpers and key utilities |
|
||||||
|
| `src/modules/workers/cache/refreshActiveOpportunities.ts` | Unified opportunity cache refresh worker (active + archived) |
|
||||||
|
| `src/workert.ts` | Queue wiring and collector-first full refresh orchestration |
|
||||||
|
| `src/modules/algorithms/computeCacheTTL.ts` | Primary adaptive TTL algorithm |
|
||||||
|
| `src/modules/algorithms/computeSubResourceCacheTTL.ts` | Sub-resource (notes, contacts) TTL algorithm |
|
||||||
|
| `src/modules/algorithms/computeProductsCacheTTL.ts` | Products TTL algorithm |
|
||||||
|
| `src/modules/cw-utils/withCwRetry.ts` | Retry wrapper with exponential backoff |
|
||||||
|
| `src/modules/cw-utils/cwApiLogger.ts` | Axios interceptor for JSONL call logging |
|
||||||
|
| `src/modules/cw-utils/fetchCompany.ts` | Company fetch with retry |
|
||||||
|
| `src/modules/cw-utils/procurement/listenInventoryAdjustments.ts` | Adjustment listener for targeted catalog-item cache + DB sync |
|
||||||
|
| `src/modules/cache/salesOpportunityMetricsCache.ts` | 5-minute active-member opportunity metrics cache |
|
||||||
|
| `src/constants.ts` | CW Axios instance config (timeout, logger) |
|
||||||
|
| `src/index.ts` | Refresh interval registration and worker job enqueueing |
|
||||||
|
| `debug-scripts/analyze-cw-calls.py` | CW API call analysis script |
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
# ---- Stage 1: Install dependencies ----
|
||||||
|
FROM oven/bun:1 AS deps
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json bun.lock ./
|
||||||
|
RUN bun install --frozen-lockfile --production
|
||||||
|
|
||||||
|
# ---- Stage 2: Build ----
|
||||||
|
FROM oven/bun:1 AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy dependency manifests and install all deps (including dev)
|
||||||
|
COPY package.json bun.lock ./
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copy source code and supporting files
|
||||||
|
COPY src/ src/
|
||||||
|
COPY prisma/ prisma/
|
||||||
|
COPY prisma.config.ts tsconfig.json ./
|
||||||
|
|
||||||
|
# Generate Prisma client (dummy URL — generate only needs the schema, not a real DB)
|
||||||
|
RUN DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy" bunx prisma generate
|
||||||
|
|
||||||
|
# Compile to a standalone executable
|
||||||
|
RUN NODE_ENV=production bun build src/index.ts \
|
||||||
|
--compile \
|
||||||
|
--minify \
|
||||||
|
--target=bun-linux-x64 \
|
||||||
|
--outfile=server
|
||||||
|
|
||||||
|
# ---- Stage 3: Production image ----
|
||||||
|
FROM ubuntu:22.04 AS runtime
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install minimal runtime dependencies (CA certs for HTTPS calls)
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends ca-certificates && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy the compiled binary from the build stage
|
||||||
|
COPY --from=build /app/server ./server
|
||||||
|
|
||||||
|
# Quote PDF branding asset loaded at runtime by pdf generation
|
||||||
|
COPY logo.png ./logo.png
|
||||||
|
|
||||||
|
# Sales tax lookup data loaded by expectedSalesTax at runtime
|
||||||
|
COPY --from=build /app/src/modules/sales-utils/salesTaxRates.json ./salesTaxRates.json
|
||||||
|
|
||||||
|
# Copy Prisma artifacts needed at runtime
|
||||||
|
COPY --from=build /app/generated/ ./generated/
|
||||||
|
COPY --from=build /app/prisma/ ./prisma/
|
||||||
|
COPY --from=build /app/prisma.config.ts ./prisma.config.ts
|
||||||
|
|
||||||
|
# Copy production node_modules (Prisma adapter needs native bindings)
|
||||||
|
COPY --from=deps /app/node_modules/ ./node_modules/
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["./server"]
|
||||||
|
|
||||||
|
# ---- Stage 4: Migration runner ----
|
||||||
|
FROM oven/bun:1 AS migration
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json bun.lock ./
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
|
COPY prisma/ prisma/
|
||||||
|
COPY prisma.config.ts ./
|
||||||
|
|
||||||
|
COPY prisma/migrate-entrypoint.sh ./prisma/migrate-entrypoint.sh
|
||||||
|
RUN chmod +x prisma/migrate-entrypoint.sh
|
||||||
|
|
||||||
|
CMD ["sh", "prisma/migrate-entrypoint.sh"]
|
||||||
+674
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
setInternalReview - The quote is ready to be review before it is ready to be sent.
|
||||||
|
setInternalApproved - The quote has been approved and is ready to be sent out.
|
||||||
|
setQuoteSent - The Quote has been sent to the customer.
|
||||||
|
setQuoteConfirmed - The quote has been recieved by the customer.
|
||||||
|
setRevisionNeeded - The quote needs to be revised and is set to stage revision
|
||||||
|
setFinalized - This locks any non-admins from modifying the quote saying that is the final iteration of the quote.
|
||||||
|
convert - This converts the quote to a ticket. It will also update all the necessary fields.
|
||||||
|
|
||||||
|
addTime(activityId, user: string)
|
||||||
|
|
||||||
|
fetchProducts
|
||||||
|
updateProduct
|
||||||
|
addProduct
|
||||||
|
|
||||||
|
fetchNotes
|
||||||
|
addNotes(note: string, user: string)
|
||||||
|
|
||||||
|
# Cat/SubCat/Bucket
|
||||||
|
|
||||||
|
## Ecosystems vs Categories
|
||||||
|
|
||||||
|
## Ecosystem Tree
|
||||||
|
|
||||||
|
- Networking
|
||||||
|
- Manufacturer: Ubiquiti
|
||||||
|
- Category: Technology
|
||||||
|
- Subcategory: Network-\*
|
||||||
|
- Manufacturer: TP-Link
|
||||||
|
- Category: Technology
|
||||||
|
- Subcategory: Network-\*
|
||||||
|
- Video Surveillance
|
||||||
|
- Manufacturer: Uniview
|
||||||
|
- Category: Field
|
||||||
|
- Subcategory: Surveillance-\*
|
||||||
|
- Manufacturer: Hikvision
|
||||||
|
- Category: Field
|
||||||
|
- Subcategory: Surveillance-\*
|
||||||
|
- Manufacturer: Alarm.com
|
||||||
|
- Category: Field
|
||||||
|
- Subcategory: Surveillance-\*
|
||||||
|
- Burg/Alarm
|
||||||
|
- Manufacturer: Qolsys
|
||||||
|
- Category: Field
|
||||||
|
- Subcategory: AlarmBurg-\*
|
||||||
|
- DSC
|
||||||
|
- Category: Field
|
||||||
|
- Subcategory: AlarmBurg-\*
|
||||||
|
|
||||||
|
## Category Tree
|
||||||
|
|
||||||
|
- Technology
|
||||||
|
- GeneralEquip
|
||||||
|
- Home Entertainment
|
||||||
|
- Monitor
|
||||||
|
- Printers
|
||||||
|
- Storage
|
||||||
|
- Network
|
||||||
|
- Network-Other
|
||||||
|
- Network-Router
|
||||||
|
- Network-Switch
|
||||||
|
- Network-Wireless
|
||||||
|
- Computer
|
||||||
|
- Computer-Components
|
||||||
|
- Computer-Desktop
|
||||||
|
- Computer-Laptop
|
||||||
|
- Recurring
|
||||||
|
- Recurring - Online
|
||||||
|
- Recurring - Other
|
||||||
|
- Recurring - Protection
|
||||||
|
- Recurring - Telephone
|
||||||
|
- Telephone
|
||||||
|
- Tele-HSet-Digital
|
||||||
|
- Tele-HSet-IP
|
||||||
|
- Tele-HSet-SLT
|
||||||
|
- Tele-Misc
|
||||||
|
- Tele-Paging
|
||||||
|
- Tele-SystemCards
|
||||||
|
- Tele-Systems
|
||||||
|
- General
|
||||||
|
- Batteries
|
||||||
|
- Battery Backups
|
||||||
|
- BulkWire
|
||||||
|
- Cables
|
||||||
|
- Cables-Adapters
|
||||||
|
- Cables-HDMI
|
||||||
|
- Cables-Network
|
||||||
|
- Cables-Other
|
||||||
|
- Cables-USB
|
||||||
|
- Cables-VGA
|
||||||
|
- Elec Cords & Adapters
|
||||||
|
- Enclosures
|
||||||
|
- PowerSupply
|
||||||
|
- RackEquip
|
||||||
|
- RackEquip-Rack
|
||||||
|
- RackEquip-Shelves
|
||||||
|
- Field
|
||||||
|
- Conduit
|
||||||
|
- Electric
|
||||||
|
- GateControl
|
||||||
|
- Locksets
|
||||||
|
- Other
|
||||||
|
- Relays
|
||||||
|
- AccessControl
|
||||||
|
- AccessControl-Controllers
|
||||||
|
- AccessControl-Credential
|
||||||
|
- AccessControl-LockDevices
|
||||||
|
- AccessControl-Other
|
||||||
|
- AccessControl-Readers
|
||||||
|
- AccessControl-VideoEntry
|
||||||
|
- AlarmBurg
|
||||||
|
- AlarmBurg-Communicators
|
||||||
|
- AlarmBurg-Keypads
|
||||||
|
- AlarmBurg-Modules
|
||||||
|
- AlarmBurg-Other
|
||||||
|
- AlarmBurg-Panels
|
||||||
|
- AlarmBurg-Sensors
|
||||||
|
- AlarmBurg-Sensors-Wireless
|
||||||
|
- AlarmBurg-Sensors-Wired
|
||||||
|
- AlarmBurg-Siren
|
||||||
|
- AlarmFire
|
||||||
|
- AlarmFire-Communicators
|
||||||
|
- AlarmFire-Devices
|
||||||
|
- AlarmFire-Modules
|
||||||
|
- AlarmFire-Other
|
||||||
|
- AlarmFire-Panels
|
||||||
|
- AlarmFire-Sensors
|
||||||
|
- Automation
|
||||||
|
- Automation-General
|
||||||
|
- Automation-HVAC
|
||||||
|
- Automation-Lights
|
||||||
|
- Automation-Locks
|
||||||
|
- Automation-Thermostat
|
||||||
|
- AV
|
||||||
|
- AV-Adapters&Cables
|
||||||
|
- AV-Components
|
||||||
|
- AV-Mounts
|
||||||
|
- AV-Other
|
||||||
|
- AV-Speakers
|
||||||
|
- AV-Television
|
||||||
|
- StrCbl?
|
||||||
|
- StrCbl-Jacks
|
||||||
|
- StrCbl-PatchPanel
|
||||||
|
- StrCbl-Plates
|
||||||
|
- Surveillance
|
||||||
|
- Surveillance-Accs
|
||||||
|
- Surveillance-CamerasAnalog
|
||||||
|
- Surveillance-CamerasIP
|
||||||
|
- Surveillance-NVR
|
||||||
@@ -0,0 +1,459 @@
|
|||||||
|
# Permission Nodes
|
||||||
|
|
||||||
|
This document lists all known permission nodes in the optima-api application, categorized by resource type.
|
||||||
|
|
||||||
|
## Permission System Overview
|
||||||
|
|
||||||
|
The permission system uses a dot-notation format: `resource.action[.modifier]`
|
||||||
|
|
||||||
|
### Special Tokens
|
||||||
|
|
||||||
|
The permission validator supports special tokens for flexible permission management:
|
||||||
|
|
||||||
|
- **Asterisk (\*)**: Matches the token and all following tokens (e.g., `credential.*` grants all credential permissions)
|
||||||
|
- **Question Mark (?)**: Matches only the specific token (single character wildcard)
|
||||||
|
- **Inclusive List ([a,b,c])**: Matches only the tokens in the list
|
||||||
|
- **Exclusive List (<a,b,c>)**: Matches all tokens except those in the list
|
||||||
|
|
||||||
|
### Global Permissions
|
||||||
|
|
||||||
|
- `*` - Full access to all resources and actions (typically assigned to administrator role)
|
||||||
|
|
||||||
|
## Permission Nodes by Resource
|
||||||
|
|
||||||
|
### Company Permissions
|
||||||
|
|
||||||
|
| Permission Node | Description | Used In |
|
||||||
|
| ------------------------------ | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
||||||
|
| `company.fetch` | Fetch a single company | [src/api/companies/[id]/fetch.ts](src/api/companies/[id]/fetch.ts) |
|
||||||
|
| `company.fetch.address` | View company address information (requires `company.fetch` as well) | [src/api/companies/[id]/fetch.ts](src/api/companies/[id]/fetch.ts) |
|
||||||
|
| `company.fetch.contacts` | View all company contacts (requires `company.fetch` as well) | [src/api/companies/[id]/fetch.ts](src/api/companies/[id]/fetch.ts) |
|
||||||
|
| `company.fetch.many` | Fetch multiple companies | [src/api/companies/fetchAll.ts](src/api/companies/fetchAll.ts) |
|
||||||
|
| `company.fetch.configurations` | Fetch company configurations (requires `company.fetch` as well) | [src/api/companies/[id]/configurations.ts](src/api/companies/[id]/configurations.ts) |
|
||||||
|
| `company.fetch.sites` | Fetch company sites from ConnectWise (requires `company.fetch` as well) | [src/api/companies/[id]/sites.ts](src/api/companies/[id]/sites.ts) |
|
||||||
|
|
||||||
|
### Credential Permissions
|
||||||
|
|
||||||
|
| Permission Node | Description | Used In |
|
||||||
|
| ----------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `credential.create` | Create a new credential | [src/api/credentials/create.ts](src/api/credentials/create.ts) |
|
||||||
|
| `credential.fetch` | Fetch a single credential | [src/api/credentials/fetch.ts](src/api/credentials/fetch.ts) |
|
||||||
|
| `credential.fetch.many` | Fetch multiple credentials | [src/api/credentials/fetchByCompany.ts](src/api/credentials/fetchByCompany.ts) |
|
||||||
|
| `credential.update` | Update a credential | [src/api/credentials/update.ts](src/api/credentials/update.ts) |
|
||||||
|
| `credential.delete` | Delete a credential | [src/api/credentials/delete.ts](src/api/credentials/delete.ts) |
|
||||||
|
| `credential.fields.fetch` | Fetch credential fields (requires `credential.fetch` as well) | [src/api/credentials/fetchFields.ts](src/api/credentials/fetchFields.ts) |
|
||||||
|
| `credential.fields.update` | Update credential fields (requires `credential.update` as well) | [src/api/credentials/updateFields.ts](src/api/credentials/updateFields.ts) |
|
||||||
|
| `credential.secure_values.read` | Read secure values of a credential (requires `credential.fetch` as well) | [src/api/credentials/readSecureValues.ts](src/api/credentials/readSecureValues.ts), [src/api/credentials/readSecureValue.ts](src/api/credentials/readSecureValue.ts) |
|
||||||
|
| `credential.sub_credentials.fetch` | Fetch sub-credentials of a parent credential (requires `credential.fetch` as well) | [src/api/credentials/fetchSubCredentials.ts](src/api/credentials/fetchSubCredentials.ts) |
|
||||||
|
| `credential.sub_credentials.create` | Create a sub-credential on a parent credential (requires `credential.fetch` as well) | [src/api/credentials/addSubCredential.ts](src/api/credentials/addSubCredential.ts) |
|
||||||
|
| `credential.sub_credentials.delete` | Remove a sub-credential from a parent credential (requires `credential.fetch` as well) | [src/api/credentials/removeSubCredential.ts](src/api/credentials/removeSubCredential.ts) |
|
||||||
|
|
||||||
|
### Credential Type Permissions
|
||||||
|
|
||||||
|
| Permission Node | Description | Used In |
|
||||||
|
| ---------------------------- | ------------------------------- | ---------------------------------------------------------------------------- |
|
||||||
|
| `credential_type.create` | Create a new credential type | [src/api/credential-types/create.ts](src/api/credential-types/create.ts) |
|
||||||
|
| `credential_type.fetch` | Fetch a single credential type | [src/api/credential-types/fetch.ts](src/api/credential-types/fetch.ts) |
|
||||||
|
| `credential_type.fetch.many` | Fetch multiple credential types | [src/api/credential-types/fetchAll.ts](src/api/credential-types/fetchAll.ts) |
|
||||||
|
| `credential_type.update` | Update a credential type | [src/api/credential-types/update.ts](src/api/credential-types/update.ts) |
|
||||||
|
| `credential_type.delete` | Delete a credential type | [src/api/credential-types/delete.ts](src/api/credential-types/delete.ts) |
|
||||||
|
|
||||||
|
### Role Permissions
|
||||||
|
|
||||||
|
| Permission Node | Description | Used In | Dependencies |
|
||||||
|
| --------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------ |
|
||||||
|
| `role.create` | Create a new role | [src/api/roles/create.ts](src/api/roles/create.ts) | |
|
||||||
|
| `role.read` | Fetch a single role or view role information | [src/api/roles/fetch.ts](src/api/roles/fetch.ts) | |
|
||||||
|
| `role.list` | Fetch all roles | [src/api/roles/fetchAll.ts](src/api/roles/fetchAll.ts) | `role.read` |
|
||||||
|
| `role.modify` | Update role properties or manage role permissions | [src/api/roles/update.ts](src/api/roles/update.ts), [src/api/roles/addPermissions.ts](src/api/roles/addPermissions.ts), [src/api/roles/removePermissions.ts](src/api/roles/removePermissions.ts) | |
|
||||||
|
| `role.delete` | Delete a role | [src/api/roles/delete.ts](src/api/roles/delete.ts) | |
|
||||||
|
| `user.read` | View users assigned to a role | [src/api/roles/getUsers.ts](src/api/roles/getUsers.ts) | `role.read` |
|
||||||
|
|
||||||
|
### User Permissions
|
||||||
|
|
||||||
|
| Permission Node | Description | Used In | Dependencies |
|
||||||
|
| ------------------------ | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
|
||||||
|
| `user.read` | Read user information | [src/api/user/@me/fetch.ts](src/api/user/@me/fetch.ts) | |
|
||||||
|
| `user.write` | Update user information | [src/api/user/@me/update.ts](src/api/user/@me/update.ts) | |
|
||||||
|
| `user.read.other` | Read other users' information | [src/api/user/fetch.ts](src/api/user/fetch.ts), [src/api/user/fetchRoles.ts](src/api/user/fetchRoles.ts), [src/api/user/checkPermission.ts](src/api/user/checkPermission.ts) | |
|
||||||
|
| `user.list.other` | List all users | [src/api/user/fetchAll.ts](src/api/user/fetchAll.ts) | `user.read.other` |
|
||||||
|
| `user.write.other` | Update other users' information | [src/api/user/update.ts](src/api/user/update.ts) | |
|
||||||
|
| `user.roles.other` | Modify roles assigned to other users | [src/api/user/update.ts](src/api/user/update.ts) | `user.write.other` |
|
||||||
|
| `user.permissions.other` | Modify direct permissions assigned to other users | [src/api/user/update.ts](src/api/user/update.ts) | `user.write.other` |
|
||||||
|
| `user.delete.other` | Delete other users | [src/api/user/delete.ts](src/api/user/delete.ts) | |
|
||||||
|
|
||||||
|
### Permission Routes
|
||||||
|
|
||||||
|
Permissions required for accessing the permission node definitions API.
|
||||||
|
|
||||||
|
| Permission Node | Description | Used In |
|
||||||
|
| --------------- | ------------------------------------------------ | -------------------------------------------------------------------------------- |
|
||||||
|
| `role.read` | Fetch all permission nodes organized by category | [src/api/permissions/fetchAll.ts](src/api/permissions/fetchAll.ts) |
|
||||||
|
| `role.read` | Fetch a flat list of all permission nodes | [src/api/permissions/fetchNodes.ts](src/api/permissions/fetchNodes.ts) |
|
||||||
|
| `role.read` | Fetch permission nodes by category | [src/api/permissions/fetchByCategory.ts](src/api/permissions/fetchByCategory.ts) |
|
||||||
|
|
||||||
|
### UI Navigation Permissions
|
||||||
|
|
||||||
|
Permissions for controlling navigation visibility on the frontend.
|
||||||
|
|
||||||
|
| Permission Node | Description | Usage Pattern |
|
||||||
|
| ---------------------- | -------------------------------------------------------------------- | ------------------------------------------------- |
|
||||||
|
| `ui.navigation.*.view` | View specific navigation sections (e.g., `ui.navigation.admin.view`) | Control which navigation menu items are displayed |
|
||||||
|
|
||||||
|
### Admin UI Permissions
|
||||||
|
|
||||||
|
Admin-specific UI permissions that control visibility and data loading for admin sub-tabs.
|
||||||
|
|
||||||
|
| Permission Node | Description | Usage Pattern |
|
||||||
|
| ----------------------------- | ------------------------------------------------ | ------------------------------------------ |
|
||||||
|
| `admin.users.view` | Show the Users tab and load user data | Show/hide users tab, allow user list fetch |
|
||||||
|
| `admin.roles.view` | Show the Roles tab and load role data | Show/hide roles tab, allow role list fetch |
|
||||||
|
| `admin.credential-types.view` | Show the Credential Types tab and load type data | Show/hide types tab, allow type list fetch |
|
||||||
|
|
||||||
|
#### Notes on UI Permissions
|
||||||
|
|
||||||
|
- **Client-side validation is not secure**: Always enforce permissions on the API level. UI permissions only control visibility and user experience.
|
||||||
|
- **Combine with API permissions**: A user with an admin UI permission should also have the corresponding API permission (e.g., `role.list`) to actually load data.
|
||||||
|
- **Use wildcards for flexibility**: Grant `ui.navigation.*.view` to allow all navigation sections.
|
||||||
|
|
||||||
|
### Procurement Permissions
|
||||||
|
|
||||||
|
| Permission Node | Description | Used In | Dependencies |
|
||||||
|
| --------------------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
|
||||||
|
| `procurement.catalog.fetch` | Fetch a single catalog item | [src/api/procurement/[id]/fetch.ts](src/api/procurement/[id]/fetch.ts) | |
|
||||||
|
| `procurement.catalog.fetch.many` | Fetch multiple catalog items, count, categories/ecosystems, or filter values | [src/api/procurement/fetchAll.ts](src/api/procurement/fetchAll.ts), [src/api/procurement/count.ts](src/api/procurement/count.ts), [src/api/procurement/categories.ts](src/api/procurement/categories.ts), [src/api/procurement/filters.ts](src/api/procurement/filters.ts) | |
|
||||||
|
| `procurement.catalog.inventory.refresh` | Refresh on-hand inventory for a catalog item from ConnectWise | [src/api/procurement/[id]/refreshInventory.ts](src/api/procurement/[id]/refreshInventory.ts) | `procurement.catalog.fetch` |
|
||||||
|
| `procurement.catalog.link` | Link or unlink catalog items to each other | [src/api/procurement/[id]/link.ts](src/api/procurement/[id]/link.ts), [src/api/procurement/[id]/unlink.ts](src/api/procurement/[id]/unlink.ts) | `procurement.catalog.fetch` |
|
||||||
|
|
||||||
|
### ConnectWise Routes
|
||||||
|
|
||||||
|
`GET /v1/cw/members` requires only authentication (any logged-in user) and does **not** require a specific permission node.
|
||||||
|
|
||||||
|
`POST /v1/cw/callback/:secret/:resource` is intentionally unauthenticated for inbound ConnectWise callbacks and does **not** require a permission node.
|
||||||
|
|
||||||
|
| Permission Node | Description | Used In | Dependencies |
|
||||||
|
| --------------- | ------------------------------------------------------------------------------- | -------------------------------------------------------- | ------------ |
|
||||||
|
| _None_ | Fetch CW members (auth only) | [src/api/cw/fetchMembers.ts](src/api/cw/fetchMembers.ts) | N/A |
|
||||||
|
| _None_ | Inbound callback route; secured operationally (network controls / source trust) | [src/api/cw/callback.ts](src/api/cw/callback.ts) | N/A |
|
||||||
|
|
||||||
|
### Sales Permissions
|
||||||
|
|
||||||
|
Permissions for accessing and managing sales opportunities. Opportunities are synced from ConnectWise and stored locally; sub-resources (products, notes, contacts) are fetched live from CW.
|
||||||
|
|
||||||
|
**WebSocket note:** The `/secure` socket event chain `opp:live_quote_preview` and `opp:live_quote_preview:<id>:data` is gated by `sales.opportunity.fetch`.
|
||||||
|
|
||||||
|
| Permission Node | Description | Used In | Dependencies |
|
||||||
|
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------ |
|
||||||
|
| `sales.opportunity.fetch` | Fetch a single opportunity and its CW sub-resources (products, notes, contacts) | [src/api/sales/opportunities/[id]/fetch.ts](src/api/sales/opportunities/[id]/fetch.ts), [src/api/sales/opportunities/[id]/products/fetchAll.ts](src/api/sales/opportunities/[id]/products/fetchAll.ts), [src/api/sales/opportunities/[id]/notes/fetchAll.ts](src/api/sales/opportunities/[id]/notes/fetchAll.ts), [src/api/sales/opportunities/[id]/notes/fetch.ts](src/api/sales/opportunities/[id]/notes/fetch.ts), [src/api/sales/opportunities/[id]/contacts/fetchAll.ts](src/api/sales/opportunities/[id]/contacts/fetchAll.ts), [src/api/sockets/events/liveQuotePreview.ts](src/api/sockets/events/liveQuotePreview.ts) | |
|
||||||
|
| `sales.opportunity.fetch.many` | Fetch multiple opportunities (paginated/searchable), count, or opportunity types | [src/api/sales/opportunities/fetchAll.ts](src/api/sales/opportunities/fetchAll.ts), [src/api/sales/opportunities/count.ts](src/api/sales/opportunities/count.ts), [src/api/sales/opportunities/fetchTypes.ts](src/api/sales/opportunities/fetchTypes.ts) | |
|
||||||
|
| `sales.opportunity.fetch.@me` | View the personal sales dashboard showing opportunities assigned to the current user | UI-only (client-side gate) | |
|
||||||
|
| `sales.opportunity.fetch.all` | View all opportunities across all users (All Opportunities tab and View All button in the sales dashboard) | UI-only (client-side gate) | `sales.opportunity.fetch.many` |
|
||||||
|
| `sales.opportunity.metrics.all` | Allow `scope=all` on sales opportunity metrics endpoint to read cached metrics for all active members | [src/api/sales/opportunities/metrics.ts](src/api/sales/opportunities/metrics.ts) | `sales.opportunity.fetch.many` |
|
||||||
|
| `sales.opportunity.metrics.identifier.override` | Allow `identifier=<cwIdentifier>` override on sales opportunity metrics endpoint for querying another member | [src/api/sales/opportunities/metrics.ts](src/api/sales/opportunities/metrics.ts) | `sales.opportunity.fetch.many` |
|
||||||
|
| `sales.opportunity.refresh` | Refresh a single opportunity's local data from ConnectWise | [src/api/sales/opportunities/[id]/refresh.ts](src/api/sales/opportunities/[id]/refresh.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.update` | Update an opportunity's fields (rating, sales rep, company, contact, site, description, etc.) in ConnectWise | [src/api/sales/opportunities/[id]/update.ts](src/api/sales/opportunities/[id]/update.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.create` | Create a new opportunity in ConnectWise | [src/api/sales/opportunities/create.ts](src/api/sales/opportunities/create.ts) | |
|
||||||
|
| `sales.opportunity.delete` | Delete an opportunity from ConnectWise and the local database | [src/api/sales/opportunities/[id]/delete.ts](src/api/sales/opportunities/[id]/delete.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.note.create` | Create a new note on an opportunity | [src/api/sales/opportunities/[id]/notes/create.ts](src/api/sales/opportunities/[id]/notes/create.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.note.update` | Update an existing note on an opportunity | [src/api/sales/opportunities/[id]/notes/update.ts](src/api/sales/opportunities/[id]/notes/update.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.note.delete` | Delete a note from an opportunity | [src/api/sales/opportunities/[id]/notes/delete.ts](src/api/sales/opportunities/[id]/notes/delete.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.product.update` | Update products (forecast items) on an opportunity, including resequencing | [src/api/sales/opportunities/[id]/products/resequence.ts](src/api/sales/opportunities/[id]/products/resequence.ts), [src/api/sales/opportunities/[id]/products/update.ts](src/api/sales/opportunities/[id]/products/update.ts), [src/api/sales/opportunities/[id]/products/cancel.ts](src/api/sales/opportunities/[id]/products/cancel.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.product.delete` | Delete a product (forecast item) from an opportunity | [src/api/sales/opportunities/[id]/products/delete.ts](src/api/sales/opportunities/[id]/products/delete.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.product.add` | Add a new product (forecast item) to an opportunity. Individual fields gated by `sales.opportunity.product.field.<field>` permissions. | [src/api/sales/opportunities/[id]/products/add.ts](src/api/sales/opportunities/[id]/products/add.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.product.add.specialOrder` | Add one or more "SPECIAL ORDER" products via the dedicated special-order route. | [src/api/sales/opportunities/[id]/products/addSpecialOrder.ts](src/api/sales/opportunities/[id]/products/addSpecialOrder.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.product.add.labor` | Add labor products via the dedicated labor route with Field/Tech catalog selection and labor pricing inputs. | [src/api/sales/opportunities/[id]/products/addLabor.ts](src/api/sales/opportunities/[id]/products/addLabor.ts), [src/api/sales/opportunities/[id]/products/laborOptions.ts](src/api/sales/opportunities/[id]/products/laborOptions.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.quote.fetch` | Fetch all committed quotes for an opportunity. | [src/api/sales/opportunities/[id]/quotes/fetchAll.ts](src/api/sales/opportunities/[id]/quotes/fetchAll.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.quote.commit` | Generate and store a finalized quote PDF for an opportunity with regeneration metadata and creator attribution. | [src/api/sales/opportunities/[id]/quotes/commit.ts](src/api/sales/opportunities/[id]/quotes/commit.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.quote.preview` | Generate a preview-stamped quote PDF for an opportunity without storing it. | [src/api/sales/opportunities/[id]/quotes/preview.ts](src/api/sales/opportunities/[id]/quotes/preview.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.quote.download` | Download a committed quote PDF. Each download is recorded with timestamp and user info. | [src/api/sales/opportunities/[id]/quotes/download.ts](src/api/sales/opportunities/[id]/quotes/download.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.quote.fetch_downloads` | Fetch download/print history for all quotes on an opportunity. Admin-level permission. | [src/api/sales/opportunities/[id]/quotes/fetchDownloads.ts](src/api/sales/opportunities/[id]/quotes/fetchDownloads.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.view_margin` | View margin and markup data on opportunity products. Controls visibility of margin %, markup %, and related progress bars in the UI. | UI-only (client-side gate) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.view_cost` | View cost data on opportunity products. Controls visibility of unit cost, total cost, and recurring cost in the UI. | UI-only (client-side gate) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.view_profit` | View profit data on opportunity products. Controls visibility of profit values in the UI. | UI-only (client-side gate) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.workflow` | Execute opportunity workflow actions (status transitions, review decisions, quote sending, etc.). Base gate for the workflow dispatch endpoint. | [dispatch.ts](src/api/sales/opportunities/[id]/workflow/dispatch.ts) | `sales.opportunity.fetch` |
|
||||||
|
| `sales.opportunity.finalize` | Finalize an opportunity as Won or Lost. Without this permission, win/lose actions route to PendingWon/PendingLost instead. | [src/workflows/wf.opportunity.ts](src/workflows/wf.opportunity.ts), [dispatch.ts](src/api/sales/opportunities/[id]/workflow/dispatch.ts) | `sales.opportunity.workflow` |
|
||||||
|
| `sales.opportunity.cancel` | Cancel an opportunity. Required to transition any eligible opportunity to the Canceled status. | [src/workflows/wf.opportunity.ts](src/workflows/wf.opportunity.ts), [dispatch.ts](src/api/sales/opportunities/[id]/workflow/dispatch.ts) | `sales.opportunity.workflow` |
|
||||||
|
| `sales.opportunity.review` | Submit an opportunity for internal review. Required to transition an opportunity into the InternalReview status. | [src/workflows/wf.opportunity.ts](src/workflows/wf.opportunity.ts) | `sales.opportunity.workflow` |
|
||||||
|
| `sales.opportunity.send` | Send a quote to the customer. Required to transition an opportunity to QuoteSent (and compound transitions like immediate won/lost/confirmed). | [src/workflows/wf.opportunity.ts](src/workflows/wf.opportunity.ts) | `sales.opportunity.workflow` |
|
||||||
|
| `sales.opportunity.reopen` | Re-open a cancelled opportunity. Required to transition an opportunity from Canceled back to Active. | [src/workflows/wf.opportunity.ts](src/workflows/wf.opportunity.ts) | `sales.opportunity.workflow` |
|
||||||
|
| `sales.opportunity.win` | Mark an opportunity as won (or pending won). Gates the win button in the UI. Required for finalize(won), sendQuote(won), and transitionToPending(won). | [src/workflows/wf.opportunity.ts](src/workflows/wf.opportunity.ts) | `sales.opportunity.workflow` |
|
||||||
|
| `sales.opportunity.lose` | Mark an opportunity as lost (or pending lost). Gates the lose button in the UI. Required for finalize(lost), sendQuote(lost), and transitionToPending(lost). | [src/workflows/wf.opportunity.ts](src/workflows/wf.opportunity.ts) | `sales.opportunity.workflow` |
|
||||||
|
| `sales.isRepresentative` | Designates the user as a sales representative; used for reporting and filtering purposes. | _(not yet used in routes)_ | |
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Field-level permissions for <code>sales.opportunity.product.add</code></strong></summary>
|
||||||
|
|
||||||
|
Each submitted field is gated by a `sales.opportunity.product.field.<field>` permission node. Only fields the user has permission for are forwarded to ConnectWise.
|
||||||
|
|
||||||
|
| Field Permission Node | Description |
|
||||||
|
| ----------------------------------------------------- | -------------------------------------------------------- |
|
||||||
|
| `sales.opportunity.product.field.catalogItem` | Set the catalog item reference |
|
||||||
|
| `sales.opportunity.product.field.forecastDescription` | Set the forecast description |
|
||||||
|
| `sales.opportunity.product.field.productDescription` | Set the product description |
|
||||||
|
| `sales.opportunity.product.field.quantity` | Set the quantity |
|
||||||
|
| `sales.opportunity.product.field.status` | Set the status reference |
|
||||||
|
| `sales.opportunity.product.field.productClass` | Set the product class (e.g. Product, Service, Agreement) |
|
||||||
|
| `sales.opportunity.product.field.forecastType` | Set the forecast type |
|
||||||
|
| `sales.opportunity.product.field.revenue` | Set the revenue amount |
|
||||||
|
| `sales.opportunity.product.field.cost` | Set the cost amount |
|
||||||
|
| `sales.opportunity.product.field.includeFlag` | Set the include flag |
|
||||||
|
| `sales.opportunity.product.field.linkFlag` | Set the link flag |
|
||||||
|
| `sales.opportunity.product.field.recurringFlag` | Set the recurring flag |
|
||||||
|
| `sales.opportunity.product.field.taxableFlag` | Set the taxable flag |
|
||||||
|
| `sales.opportunity.product.field.recurringRevenue` | Set the recurring revenue amount |
|
||||||
|
| `sales.opportunity.product.field.recurringCost` | Set the recurring cost amount |
|
||||||
|
| `sales.opportunity.product.field.cycles` | Set the number of recurring cycles |
|
||||||
|
| `sales.opportunity.product.field.sequenceNumber` | Set the sequence number (display order) |
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### UniFi Permissions
|
||||||
|
|
||||||
|
Permissions for accessing and managing UniFi network infrastructure. The `unifi.access` permission is a gate permission required for **all** UniFi routes.
|
||||||
|
|
||||||
|
| Permission Node | Description | Used In | Dependencies |
|
||||||
|
| ------------------------------ | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------- |
|
||||||
|
| `unifi.access` | Gate permission for the entire UniFi API — required for all | [src/api/unifi/sites/fetchAll.ts](src/api/unifi/sites/fetchAll.ts), [src/api/unifi/sites/sync.ts](src/api/unifi/sites/sync.ts), [src/api/unifi/site/fetch.ts](src/api/unifi/site/fetch.ts), [src/api/unifi/site/overview.ts](src/api/unifi/site/overview.ts), [src/api/unifi/site/devices.ts](src/api/unifi/site/devices.ts), [src/api/unifi/site/wifi/fetchAll.ts](src/api/unifi/site/wifi/fetchAll.ts), [src/api/unifi/site/wifi/update.ts](src/api/unifi/site/wifi/update.ts), [src/api/unifi/site/networks.ts](src/api/unifi/site/networks.ts), [src/api/unifi/site/link.ts](src/api/unifi/site/link.ts), [src/api/unifi/site/unlink.ts](src/api/unifi/site/unlink.ts), [src/api/companies/[id]/unifiSites.ts](src/api/companies/[id]/unifiSites.ts), [src/api/unifi/sites/create.ts](src/api/unifi/sites/create.ts) | |
|
||||||
|
| `unifi.sites.create` | Create a new site on the UniFi controller | [src/api/unifi/sites/create.ts](src/api/unifi/sites/create.ts) | `unifi.access` |
|
||||||
|
| `unifi.sites.fetch` | Fetch a single UniFi site | [src/api/unifi/site/fetch.ts](src/api/unifi/site/fetch.ts) | `unifi.access` |
|
||||||
|
| `unifi.sites.fetch.many` | Fetch all UniFi sites | [src/api/unifi/sites/fetchAll.ts](src/api/unifi/sites/fetchAll.ts) | `unifi.access` |
|
||||||
|
| `unifi.sites.sync` | Sync sites from the UniFi controller into the database | [src/api/unifi/sites/sync.ts](src/api/unifi/sites/sync.ts) | `unifi.access` |
|
||||||
|
| `unifi.sites.link` | Link or unlink a UniFi site to/from a company | [src/api/unifi/site/link.ts](src/api/unifi/site/link.ts), [src/api/unifi/site/unlink.ts](src/api/unifi/site/unlink.ts) | `unifi.access` |
|
||||||
|
| `unifi.site.overview` | View live site overview from the UniFi controller | [src/api/unifi/site/overview.ts](src/api/unifi/site/overview.ts) | `unifi.access` |
|
||||||
|
| `unifi.site.devices` | View live device list from the UniFi controller | [src/api/unifi/site/devices.ts](src/api/unifi/site/devices.ts) | `unifi.access` |
|
||||||
|
| `unifi.site.wifi` | View WiFi networks (WLANs) from the UniFi controller | [src/api/unifi/site/wifi/fetchAll.ts](src/api/unifi/site/wifi/fetchAll.ts) | `unifi.access` |
|
||||||
|
| `unifi.site.wifi.read` | Field-level gate for WiFi response data (see note below) | [src/api/unifi/site/wifi/fetchAll.ts](src/api/unifi/site/wifi/fetchAll.ts) | `unifi.access`, `unifi.site.wifi` |
|
||||||
|
| `unifi.site.wifi.read.<field>` | Read a specific field from WiFi response (e.g. `unifi.site.wifi.read.passphrase`) | [src/api/unifi/site/wifi/fetchAll.ts](src/api/unifi/site/wifi/fetchAll.ts) | `unifi.access`, `unifi.site.wifi`, `unifi.site.wifi.read` |
|
||||||
|
| `unifi.site.wifi.update` | Update a WiFi network on the UniFi controller | [src/api/unifi/site/wifi/update.ts](src/api/unifi/site/wifi/update.ts) | `unifi.access`, `unifi.site.wifi` |
|
||||||
|
|
||||||
|
#### Field-Level Permission Gating (`unifi.site.wifi.read`)
|
||||||
|
|
||||||
|
The WiFi fetch route uses `processObjectValuePerms` to filter each WLAN object on a per-field basis. For every key on the `WlanConf` response object, the system checks `unifi.site.wifi.read.<key>`. Only fields the user has permission for are included in the response. Use `unifi.site.wifi.read.*` to grant access to all fields.
|
||||||
|
|
||||||
|
**Available field-level nodes:**
|
||||||
|
|
||||||
|
`unifi.site.wifi.read.id`, `unifi.site.wifi.read.name`, `unifi.site.wifi.read.siteId`, `unifi.site.wifi.read.enabled`, `unifi.site.wifi.read.security`, `unifi.site.wifi.read.wpaMode`, `unifi.site.wifi.read.wpaEnc`, `unifi.site.wifi.read.wpa3Support`, `unifi.site.wifi.read.wpa3Transition`, `unifi.site.wifi.read.wpa3FastRoaming`, `unifi.site.wifi.read.wpa3Enhanced192`, `unifi.site.wifi.read.passphrase`, `unifi.site.wifi.read.passphraseAutogenerated`, `unifi.site.wifi.read.hideSSID`, `unifi.site.wifi.read.isGuest`, `unifi.site.wifi.read.band`, `unifi.site.wifi.read.bands`, `unifi.site.wifi.read.networkconfId`, `unifi.site.wifi.read.usergroupId`, `unifi.site.wifi.read.apGroupIds`, `unifi.site.wifi.read.apGroupMode`, `unifi.site.wifi.read.pmfMode`, `unifi.site.wifi.read.groupRekey`, `unifi.site.wifi.read.dtimMode`, `unifi.site.wifi.read.dtimNg`, `unifi.site.wifi.read.dtimNa`, `unifi.site.wifi.read.dtim6e`, `unifi.site.wifi.read.l2Isolation`, `unifi.site.wifi.read.fastRoamingEnabled`, `unifi.site.wifi.read.bssTransition`, `unifi.site.wifi.read.uapsdEnabled`, `unifi.site.wifi.read.iappEnabled`, `unifi.site.wifi.read.proxyArp`, `unifi.site.wifi.read.mcastenhanceEnabled`, `unifi.site.wifi.read.macFilterEnabled`, `unifi.site.wifi.read.macFilterPolicy`, `unifi.site.wifi.read.macFilterList`, `unifi.site.wifi.read.radiusDasEnabled`, `unifi.site.wifi.read.radiusMacAuthEnabled`, `unifi.site.wifi.read.radiusMacaclFormat`, `unifi.site.wifi.read.minrateSettingPreference`, `unifi.site.wifi.read.minrateNgEnabled`, `unifi.site.wifi.read.minrateNgDataRateKbps`, `unifi.site.wifi.read.minrateNgAdvertisingRates`, `unifi.site.wifi.read.minrateNaEnabled`, `unifi.site.wifi.read.minrateNaDataRateKbps`, `unifi.site.wifi.read.minrateNaAdvertisingRates`, `unifi.site.wifi.read.settingPreference`, `unifi.site.wifi.read.no2ghzOui`, `unifi.site.wifi.read.privatePreSharedKeysEnabled`, `unifi.site.wifi.read.privatePreSharedKeys`, `unifi.site.wifi.read.saeGroups`, `unifi.site.wifi.read.saePsk`, `unifi.site.wifi.read.schedule`, `unifi.site.wifi.read.scheduleWithDuration`, `unifi.site.wifi.read.bcFilterList`, `unifi.site.wifi.read.externalId`
|
||||||
|
| `unifi.site.networks` | View network configurations from the UniFi controller | [src/api/unifi/site/networks.ts](src/api/unifi/site/networks.ts) | `unifi.access` |
|
||||||
|
| `unifi.site.wlan-groups` | View WLAN groups (AP broadcasting groups) from the UniFi controller for a site | [src/api/unifi/site/wlanGroups.ts](src/api/unifi/site/wlanGroups.ts), [src/api/unifi/site/wlanGroupsCreate.ts](src/api/unifi/site/wlanGroupsCreate.ts) | `unifi.access` |
|
||||||
|
| `unifi.site.wlan-groups.create` | Create a new WLAN group (AP broadcasting group) on the UniFi controller | [src/api/unifi/site/wlanGroupsCreate.ts](src/api/unifi/site/wlanGroupsCreate.ts) | `unifi.access`, `unifi.site.wlan-groups` |
|
||||||
|
| `unifi.site.access-points` | View access points (UAPs only) from the UniFi controller for a site | [src/api/unifi/site/accessPoints.ts](src/api/unifi/site/accessPoints.ts) | `unifi.access` |
|
||||||
|
| `unifi.site.ap-groups` | View AP groups — shows which APs are grouped together for SSID broadcasting | [src/api/unifi/site/apGroups.ts](src/api/unifi/site/apGroups.ts) | `unifi.access` |
|
||||||
|
| `unifi.site.wifi-limits` | View WiFi SSID limits per AP per radio band | [src/api/unifi/site/wifiLimits.ts](src/api/unifi/site/wifiLimits.ts) | `unifi.access` |
|
||||||
|
| `unifi.site.speed-profiles` | View speed limit profiles (user groups) from the UniFi controller | [src/api/unifi/site/speedProfilesFetchAll.ts](src/api/unifi/site/speedProfilesFetchAll.ts), [src/api/unifi/site/speedProfilesCreate.ts](src/api/unifi/site/speedProfilesCreate.ts) | `unifi.access` |
|
||||||
|
| `unifi.site.speed-profiles.create` | Create a new speed limit profile (user group) on the UniFi controller | [src/api/unifi/site/speedProfilesCreate.ts](src/api/unifi/site/speedProfilesCreate.ts) | `unifi.access`, `unifi.site.speed-profiles` |
|
||||||
|
| `unifi.site.wifi.ppsk` | View private pre-shared keys (PPSKs) for a specific WiFi network | [src/api/unifi/site/wifi/ppskFetchAll.ts](src/api/unifi/site/wifi/ppskFetchAll.ts), [src/api/unifi/site/wifi/ppskCreate.ts](src/api/unifi/site/wifi/ppskCreate.ts) | `unifi.access`, `unifi.site.wifi` |
|
||||||
|
| `unifi.site.wifi.ppsk.create` | Create a private pre-shared key on a specific WiFi network | [src/api/unifi/site/wifi/ppskCreate.ts](src/api/unifi/site/wifi/ppskCreate.ts) | `unifi.access`, `unifi.site.wifi`, `unifi.site.wifi.ppsk` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Object Type Permissions (Field-Level Gating)
|
||||||
|
|
||||||
|
All fetch and fetchAll routes gate response object keys using `processObjectValuePerms`. For each object type, only fields whose corresponding `<scope>.<field>` permission the user holds are included in the response. Grant `<scope>.*` to allow all fields on that object type.
|
||||||
|
|
||||||
|
### Company (`obj.company`)
|
||||||
|
|
||||||
|
| Field Permission | Description |
|
||||||
|
| --------------------------- | ----------------------------------------- |
|
||||||
|
| `obj.company.id` | View company ID |
|
||||||
|
| `obj.company.name` | View company name |
|
||||||
|
| `obj.company.cw_Identifier` | View ConnectWise identifier |
|
||||||
|
| `obj.company.cw_CompanyId` | View ConnectWise company ID |
|
||||||
|
| `obj.company.cw_Data` | View ConnectWise data (address, contacts) |
|
||||||
|
| `obj.company.createdAt` | View creation timestamp |
|
||||||
|
| `obj.company.updatedAt` | View last-updated timestamp |
|
||||||
|
|
||||||
|
**Used in:** [src/api/companies/[id]/fetch.ts](src/api/companies/[id]/fetch.ts), [src/api/companies/fetchAll.ts](src/api/companies/fetchAll.ts)
|
||||||
|
|
||||||
|
### Credential (`obj.credential`)
|
||||||
|
|
||||||
|
| Field Permission | Description |
|
||||||
|
| ---------------------------------- | ----------------------------- |
|
||||||
|
| `obj.credential.id` | View credential ID |
|
||||||
|
| `obj.credential.name` | View credential name |
|
||||||
|
| `obj.credential.notes` | View credential notes |
|
||||||
|
| `obj.credential.typeId` | View credential type ID |
|
||||||
|
| `obj.credential.companyId` | View linked company ID |
|
||||||
|
| `obj.credential.subCredentialOfId` | View parent credential ID |
|
||||||
|
| `obj.credential.fields` | View credential field values |
|
||||||
|
| `obj.credential.type` | View credential type object |
|
||||||
|
| `obj.credential.company` | View linked company object |
|
||||||
|
| `obj.credential.subCredentials` | View sub-credentials array |
|
||||||
|
| `obj.credential.secureFieldIds` | View secure field identifiers |
|
||||||
|
| `obj.credential.createdAt` | View creation timestamp |
|
||||||
|
| `obj.credential.updatedAt` | View last-updated timestamp |
|
||||||
|
|
||||||
|
**Used in:** [src/api/credentials/fetch.ts](src/api/credentials/fetch.ts), [src/api/credentials/fetchByCompany.ts](src/api/credentials/fetchByCompany.ts), [src/api/credentials/fetchSubCredentials.ts](src/api/credentials/fetchSubCredentials.ts), [src/api/credential-types/fetchCredentials.ts](src/api/credential-types/fetchCredentials.ts)
|
||||||
|
|
||||||
|
### Credential Type (`obj.credentialType`)
|
||||||
|
|
||||||
|
| Field Permission | Description |
|
||||||
|
| ------------------------------------ | ----------------------------------------- |
|
||||||
|
| `obj.credentialType.id` | View credential type ID |
|
||||||
|
| `obj.credentialType.name` | View credential type name |
|
||||||
|
| `obj.credentialType.permissionScope` | View permission scope |
|
||||||
|
| `obj.credentialType.icon` | View icon |
|
||||||
|
| `obj.credentialType.fields` | View field definitions |
|
||||||
|
| `obj.credentialType.credentialCount` | View count of credentials using this type |
|
||||||
|
| `obj.credentialType.createdAt` | View creation timestamp |
|
||||||
|
| `obj.credentialType.updatedAt` | View last-updated timestamp |
|
||||||
|
|
||||||
|
**Used in:** [src/api/credential-types/fetch.ts](src/api/credential-types/fetch.ts), [src/api/credential-types/fetchAll.ts](src/api/credential-types/fetchAll.ts)
|
||||||
|
|
||||||
|
### User (`obj.user`)
|
||||||
|
|
||||||
|
| Field Permission | Description |
|
||||||
|
| ---------------------- | -------------------------------- |
|
||||||
|
| `obj.user.id` | View user ID |
|
||||||
|
| `obj.user.name` | View user display name |
|
||||||
|
| `obj.user.roles` | View assigned role monikers |
|
||||||
|
| `obj.user.permissions` | View aggregated permission nodes |
|
||||||
|
| `obj.user.login` | View login identifier |
|
||||||
|
| `obj.user.email` | View email address |
|
||||||
|
| `obj.user.image` | View profile image URL |
|
||||||
|
| `obj.user.createdAt` | View creation timestamp |
|
||||||
|
| `obj.user.updatedAt` | View last-updated timestamp |
|
||||||
|
|
||||||
|
**Used in:** [src/api/user/@me/fetch.ts](src/api/user/@me/fetch.ts), [src/api/user/fetch.ts](src/api/user/fetch.ts), [src/api/user/fetchAll.ts](src/api/user/fetchAll.ts), [src/api/roles/getUsers.ts](src/api/roles/getUsers.ts)
|
||||||
|
|
||||||
|
### Role (`obj.role`)
|
||||||
|
|
||||||
|
| Field Permission | Description |
|
||||||
|
| ---------------------- | -------------------------------- |
|
||||||
|
| `obj.role.id` | View role ID |
|
||||||
|
| `obj.role.title` | View role title |
|
||||||
|
| `obj.role.moniker` | View role moniker |
|
||||||
|
| `obj.role.permissions` | View role permission nodes |
|
||||||
|
| `obj.role.users` | View users assigned to this role |
|
||||||
|
| `obj.role.createdAt` | View creation timestamp |
|
||||||
|
| `obj.role.updatedAt` | View last-updated timestamp |
|
||||||
|
|
||||||
|
**Used in:** [src/api/roles/fetch.ts](src/api/roles/fetch.ts), [src/api/roles/fetchAll.ts](src/api/roles/fetchAll.ts), [src/api/user/fetchRoles.ts](src/api/user/fetchRoles.ts)
|
||||||
|
|
||||||
|
### Catalog Item (`obj.catalogItem`)
|
||||||
|
|
||||||
|
| Field Permission | Description |
|
||||||
|
| ------------------------------------- | -------------------------------- |
|
||||||
|
| `obj.catalogItem.id` | View catalog item ID |
|
||||||
|
| `obj.catalogItem.cwCatalogId` | View ConnectWise catalog ID |
|
||||||
|
| `obj.catalogItem.identifier` | View item identifier |
|
||||||
|
| `obj.catalogItem.name` | View item name |
|
||||||
|
| `obj.catalogItem.description` | View description |
|
||||||
|
| `obj.catalogItem.customerDescription` | View customer-facing description |
|
||||||
|
| `obj.catalogItem.internalNotes` | View internal notes |
|
||||||
|
| `obj.catalogItem.manufacturer` | View manufacturer name |
|
||||||
|
| `obj.catalogItem.manufactureCwId` | View manufacturer ConnectWise ID |
|
||||||
|
| `obj.catalogItem.partNumber` | View part number |
|
||||||
|
| `obj.catalogItem.vendorName` | View vendor name |
|
||||||
|
| `obj.catalogItem.vendorSku` | View vendor SKU |
|
||||||
|
| `obj.catalogItem.vendorCwId` | View vendor ConnectWise ID |
|
||||||
|
| `obj.catalogItem.price` | View price |
|
||||||
|
| `obj.catalogItem.cost` | View cost |
|
||||||
|
| `obj.catalogItem.inactive` | View inactive flag |
|
||||||
|
| `obj.catalogItem.salesTaxable` | View sales-taxable flag |
|
||||||
|
| `obj.catalogItem.onHand` | View on-hand inventory count |
|
||||||
|
| `obj.catalogItem.cwLastUpdated` | View CW last-updated timestamp |
|
||||||
|
| `obj.catalogItem.linkedItems` | View linked catalog items |
|
||||||
|
| `obj.catalogItem.createdAt` | View creation timestamp |
|
||||||
|
| `obj.catalogItem.updatedAt` | View last-updated timestamp |
|
||||||
|
|
||||||
|
**Used in:** [src/api/procurement/fetchAll.ts](src/api/procurement/fetchAll.ts), [src/api/procurement/[id]/fetch.ts](src/api/procurement/[id]/fetch.ts), [src/api/procurement/[id]/fetchLinked.ts](src/api/procurement/[id]/fetchLinked.ts)
|
||||||
|
|
||||||
|
### Opportunity (`obj.opportunity`)
|
||||||
|
|
||||||
|
| Field Permission | Description |
|
||||||
|
| ------------------------------------ | ------------------------------- |
|
||||||
|
| `obj.opportunity.id` | View opportunity ID |
|
||||||
|
| `obj.opportunity.cwOpportunityId` | View ConnectWise opportunity ID |
|
||||||
|
| `obj.opportunity.name` | View opportunity name |
|
||||||
|
| `obj.opportunity.notes` | View notes |
|
||||||
|
| `obj.opportunity.type` | View opportunity type |
|
||||||
|
| `obj.opportunity.stage` | View stage |
|
||||||
|
| `obj.opportunity.status` | View status |
|
||||||
|
| `obj.opportunity.priority` | View priority |
|
||||||
|
| `obj.opportunity.rating` | View rating |
|
||||||
|
| `obj.opportunity.source` | View source |
|
||||||
|
| `obj.opportunity.campaign` | View campaign |
|
||||||
|
| `obj.opportunity.primarySalesRep` | View primary sales rep |
|
||||||
|
| `obj.opportunity.secondarySalesRep` | View secondary sales rep |
|
||||||
|
| `obj.opportunity.company` | View company |
|
||||||
|
| `obj.opportunity.contact` | View contact |
|
||||||
|
| `obj.opportunity.site` | View site |
|
||||||
|
| `obj.opportunity.customerPO` | View customer PO |
|
||||||
|
| `obj.opportunity.totalSalesTax` | View total sales tax |
|
||||||
|
| `obj.opportunity.probability` | View probability percentage |
|
||||||
|
| `obj.opportunity.location` | View location |
|
||||||
|
| `obj.opportunity.department` | View department |
|
||||||
|
| `obj.opportunity.expectedCloseDate` | View expected close date |
|
||||||
|
| `obj.opportunity.pipelineChangeDate` | View pipeline change date |
|
||||||
|
| `obj.opportunity.dateBecameLead` | View date became lead |
|
||||||
|
| `obj.opportunity.closedDate` | View closed date |
|
||||||
|
| `obj.opportunity.closedFlag` | View closed flag |
|
||||||
|
| `obj.opportunity.closedBy` | View closed-by member |
|
||||||
|
| `obj.opportunity.companyId` | View linked company ID |
|
||||||
|
| `obj.opportunity.cwLastUpdated` | View CW last-updated timestamp |
|
||||||
|
| `obj.opportunity.createdAt` | View creation timestamp |
|
||||||
|
| `obj.opportunity.updatedAt` | View last-updated timestamp |
|
||||||
|
|
||||||
|
**Used in:** [src/api/sales/fetchAll.ts](src/api/sales/fetchAll.ts), [src/api/sales/[id]/fetch.ts](src/api/sales/[id]/fetch.ts)
|
||||||
|
|
||||||
|
### UniFi Site (`obj.unifiSite`)
|
||||||
|
|
||||||
|
| Field Permission | Description |
|
||||||
|
| ------------------------- | ----------------------------- |
|
||||||
|
| `obj.unifiSite.id` | View site internal ID |
|
||||||
|
| `obj.unifiSite.name` | View site name |
|
||||||
|
| `obj.unifiSite.siteId` | View UniFi controller site ID |
|
||||||
|
| `obj.unifiSite.companyId` | View linked company ID |
|
||||||
|
| `obj.unifiSite.company` | View linked company object |
|
||||||
|
| `obj.unifiSite.createdAt` | View creation timestamp |
|
||||||
|
| `obj.unifiSite.updatedAt` | View last-updated timestamp |
|
||||||
|
|
||||||
|
**Used in:** [src/api/unifi/sites/fetchAll.ts](src/api/unifi/sites/fetchAll.ts), [src/api/unifi/site/fetch.ts](src/api/unifi/site/fetch.ts), [src/api/companies/[id]/unifiSites.ts](src/api/companies/[id]/unifiSites.ts)
|
||||||
|
|
||||||
|
### WiFi Network (`unifi.site.wifi.read`)
|
||||||
|
|
||||||
|
See **UniFi Permissions > Field-Level Permission Gating** above for the full list of `unifi.site.wifi.read.<field>` nodes.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Permission Issuers
|
||||||
|
|
||||||
|
Permissions can be issued by different sources:
|
||||||
|
|
||||||
|
- `roles` - Permissions granted through role assignment
|
||||||
|
- `user` - Permissions granted directly to a user
|
||||||
|
- `api_key` - Permissions associated with an API key
|
||||||
|
|
||||||
|
## Permission Validation
|
||||||
|
|
||||||
|
The authorization middleware ([src/api/middleware/authorization.ts](src/api/middleware/authorization.ts)) enforces permissions by:
|
||||||
|
|
||||||
|
1. Extracting the authorization header (Bearer token or API Key)
|
||||||
|
2. Validating the session/token
|
||||||
|
3. Checking if the user has all required permissions for the route
|
||||||
|
4. Throwing an `InsufficentPermission` error (403) if any required permission is missing
|
||||||
|
|
||||||
|
## Usage Example
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Require single permission
|
||||||
|
authMiddleware({ permissions: ["credential.fetch"] })
|
||||||
|
|
||||||
|
// Require multiple permissions (all must be satisfied)
|
||||||
|
authMiddleware({
|
||||||
|
permissions: ["credential.fetch", "credential.secure_values.read"]
|
||||||
|
})
|
||||||
|
|
||||||
|
// Administrator role with wildcard permission
|
||||||
|
{
|
||||||
|
moniker: "administrator",
|
||||||
|
permissions: ["*"] // Grants all permissions
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- Multiple permissions in a single route require **all** permissions to be satisfied (AND logic)
|
||||||
|
- The `*` wildcard permission grants access to everything in the application
|
||||||
|
- Permissions are signed using JWT with a private key for integrity
|
||||||
|
- Permission validation supports pattern matching for flexible permission management
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# ttsci-api
|
||||||
|
The Api for the TTS Credentials Manager
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
meta {
|
||||||
|
name: Check User Permission
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{baseUrl}}/v1/user/@me/check-permission
|
||||||
|
body: json
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
headers {
|
||||||
|
Content-Type: application/json
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"permissions": ["user.read", "company.create", "credential.write"]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
meta {
|
||||||
|
name: Fetch Company Pages.
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url:
|
||||||
|
body: none
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
settings {
|
||||||
|
encodeUrl: true
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
meta {
|
||||||
|
name: Teapot
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: http://localhost:3000/v1/teapot
|
||||||
|
body: none
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
settings {
|
||||||
|
encodeUrl: true
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"version": "1",
|
||||||
|
"name": "optima",
|
||||||
|
"type": "collection",
|
||||||
|
"ignore": [
|
||||||
|
"node_modules",
|
||||||
|
".git"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"version": "1",
|
||||||
|
"name": "optima",
|
||||||
|
"type": "collection",
|
||||||
|
"ignore": ["node_modules", ".git"]
|
||||||
|
}
|
||||||
+511
@@ -0,0 +1,511 @@
|
|||||||
|
{
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"configVersion": 1,
|
||||||
|
"workspaces": {
|
||||||
|
"": {
|
||||||
|
"name": "ttscm-api",
|
||||||
|
"dependencies": {
|
||||||
|
"@azure/msal-node": "^5.0.2",
|
||||||
|
"@discordjs/collection": "^2.1.1",
|
||||||
|
"@duxcore/eventra": "^1.1.0",
|
||||||
|
"@prisma/adapter-pg": "^7.3.0",
|
||||||
|
"@prisma/client": "^7.3.0",
|
||||||
|
"@socket.io/bun-engine": "^0.1.0",
|
||||||
|
"axios": "^1.13.3",
|
||||||
|
"blakets": "^0.1.12",
|
||||||
|
"cors": "^2.8.6",
|
||||||
|
"cuid": "^3.0.0",
|
||||||
|
"hono": "^4.11.5",
|
||||||
|
"ioredis": "^5.10.0",
|
||||||
|
"jsonwebtoken": "^9.0.3",
|
||||||
|
"keypair": "^1.0.4",
|
||||||
|
"pdf-lib": "^1.17.1",
|
||||||
|
"pdfmake": "^0.3.5",
|
||||||
|
"pg-boss": "^12.14.0",
|
||||||
|
"prisma": "^7.3.0",
|
||||||
|
"socket.io": "^4.8.3",
|
||||||
|
"socket.io-client": "^4.8.3",
|
||||||
|
"zod": "^4.3.6",
|
||||||
|
"zon": "^1.0.3",
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/bun": "latest",
|
||||||
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"typescript": "^5",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"@azure/msal-common": ["@azure/msal-common@16.0.2", "", {}, "sha512-ZJ/UR7lyqIntURrIJCyvScwJFanM9QhJYcJCheB21jZofGKpP9QxWgvADANo7UkresHKzV+6YwoeZYP7P7HvUg=="],
|
||||||
|
|
||||||
|
"@azure/msal-node": ["@azure/msal-node@5.0.2", "", { "dependencies": { "@azure/msal-common": "16.0.2", "jsonwebtoken": "^9.0.0", "uuid": "^8.3.0" } }, "sha512-3tHeJghckgpTX98TowJoXOjKGuds0L+FKfeHJtoZFl2xvwE6RF65shZJzMQ5EQZWXzh3sE1i9gE+m3aRMachjA=="],
|
||||||
|
|
||||||
|
"@chevrotain/cst-dts-gen": ["@chevrotain/cst-dts-gen@10.5.0", "", { "dependencies": { "@chevrotain/gast": "10.5.0", "@chevrotain/types": "10.5.0", "lodash": "4.17.21" } }, "sha512-lhmC/FyqQ2o7pGK4Om+hzuDrm9rhFYIJ/AXoQBeongmn870Xeb0L6oGEiuR8nohFNL5sMaQEJWCxr1oIVIVXrw=="],
|
||||||
|
|
||||||
|
"@chevrotain/gast": ["@chevrotain/gast@10.5.0", "", { "dependencies": { "@chevrotain/types": "10.5.0", "lodash": "4.17.21" } }, "sha512-pXdMJ9XeDAbgOWKuD1Fldz4ieCs6+nLNmyVhe2gZVqoO7v8HXuHYs5OV2EzUtbuai37TlOAQHrTDvxMnvMJz3A=="],
|
||||||
|
|
||||||
|
"@chevrotain/types": ["@chevrotain/types@10.5.0", "", {}, "sha512-f1MAia0x/pAVPWH/T73BJVyO2XU5tI4/iE7cnxb7tqdNTNhQI3Uq3XkqcoteTmD4t1aM0LbHCJOhgIDn07kl2A=="],
|
||||||
|
|
||||||
|
"@chevrotain/utils": ["@chevrotain/utils@10.5.0", "", {}, "sha512-hBzuU5+JjB2cqNZyszkDHZgOSrUUT8V3dhgRl8Q9Gp6dAj/H5+KILGjbhDpc3Iy9qmqlm/akuOI2ut9VUtzJxQ=="],
|
||||||
|
|
||||||
|
"@discordjs/collection": ["@discordjs/collection@2.1.1", "", {}, "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg=="],
|
||||||
|
|
||||||
|
"@duxcore/eventra": ["@duxcore/eventra@1.1.0", "", {}, "sha512-XYLksXvOjr3uGw9oh0wgKVF0POiz1Gjk/Ety8chEQdEwzDAiyydztB8TtjF/Pfr+vdM/ceMV/OOQliBZLnfONA=="],
|
||||||
|
|
||||||
|
"@electric-sql/pglite": ["@electric-sql/pglite@0.3.15", "", {}, "sha512-Cj++n1Mekf9ETfdc16TlDi+cDDQF0W7EcbyRHYOAeZdsAe8M/FJg18itDTSwyHfar2WIezawM9o0EKaRGVKygQ=="],
|
||||||
|
|
||||||
|
"@electric-sql/pglite-socket": ["@electric-sql/pglite-socket@0.0.20", "", { "peerDependencies": { "@electric-sql/pglite": "0.3.15" }, "bin": { "pglite-server": "dist/scripts/server.js" } }, "sha512-J5nLGsicnD9wJHnno9r+DGxfcZWh+YJMCe0q/aCgtG6XOm9Z7fKeite8IZSNXgZeGltSigM9U/vAWZQWdgcSFg=="],
|
||||||
|
|
||||||
|
"@electric-sql/pglite-tools": ["@electric-sql/pglite-tools@0.2.20", "", { "peerDependencies": { "@electric-sql/pglite": "0.3.15" } }, "sha512-BK50ZnYa3IG7ztXhtgYf0Q7zijV32Iw1cYS8C+ThdQlwx12V5VZ9KRJ42y82Hyb4PkTxZQklVQA9JHyUlex33A=="],
|
||||||
|
|
||||||
|
"@hono/node-server": ["@hono/node-server@1.19.9", "", { "peerDependencies": { "hono": "^4" } }, "sha512-vHL6w3ecZsky+8P5MD+eFfaGTyCeOHUIFYMGpQGbrBTSmNNoxv0if69rEZ5giu36weC5saFuznL411gRX7bJDw=="],
|
||||||
|
|
||||||
|
"@ioredis/commands": ["@ioredis/commands@1.5.1", "", {}, "sha512-JH8ZL/ywcJyR9MmJ5BNqZllXNZQqQbnVZOqpPQqE1vHiFgAw4NHbvE0FOduNU8IX9babitBT46571OnPTT0Zcw=="],
|
||||||
|
|
||||||
|
"@mrleebo/prisma-ast": ["@mrleebo/prisma-ast@0.13.1", "", { "dependencies": { "chevrotain": "^10.5.0", "lilconfig": "^2.1.0" } }, "sha512-XyroGQXcHrZdvmrGJvsA9KNeOOgGMg1Vg9OlheUsBOSKznLMDl+YChxbkboRHvtFYJEMRYmlV3uoo/njCw05iw=="],
|
||||||
|
|
||||||
|
"@pdf-lib/standard-fonts": ["@pdf-lib/standard-fonts@1.0.0", "", { "dependencies": { "pako": "^1.0.6" } }, "sha512-hU30BK9IUN/su0Mn9VdlVKsWBS6GyhVfqjwl1FjZN4TxP6cCw0jP2w7V3Hf5uX7M0AZJ16vey9yE0ny7Sa59ZA=="],
|
||||||
|
|
||||||
|
"@pdf-lib/upng": ["@pdf-lib/upng@1.0.1", "", { "dependencies": { "pako": "^1.0.10" } }, "sha512-dQK2FUMQtowVP00mtIksrlZhdFXQZPC+taih1q4CvPZ5vqdxR/LKBaFg0oAfzd1GlHZXXSPdQfzQnt+ViGvEIQ=="],
|
||||||
|
|
||||||
|
"@prisma/adapter-pg": ["@prisma/adapter-pg@7.3.0", "", { "dependencies": { "@prisma/driver-adapter-utils": "7.3.0", "pg": "^8.16.3", "postgres-array": "3.0.4" } }, "sha512-iuYQMbIPO6i9O45Fv8TB7vWu00BXhCaNAShenqF7gLExGDbnGp5BfFB4yz1K59zQ59jF6tQ9YHrg0P6/J3OoLg=="],
|
||||||
|
|
||||||
|
"@prisma/client": ["@prisma/client@7.3.0", "", { "dependencies": { "@prisma/client-runtime-utils": "7.3.0" }, "peerDependencies": { "prisma": "*", "typescript": ">=5.4.0" }, "optionalPeers": ["prisma", "typescript"] }, "sha512-FXBIxirqQfdC6b6HnNgxGmU7ydCPEPk7maHMOduJJfnTP+MuOGa15X4omjR/zpPUUpm8ef/mEFQjJudOGkXFcQ=="],
|
||||||
|
|
||||||
|
"@prisma/client-runtime-utils": ["@prisma/client-runtime-utils@7.3.0", "", {}, "sha512-dG/ceD9c+tnXATPk8G+USxxYM9E6UdMTnQeQ+1SZUDxTz7SgQcfxEqafqIQHcjdlcNK/pvmmLfSwAs3s2gYwUw=="],
|
||||||
|
|
||||||
|
"@prisma/config": ["@prisma/config@7.3.0", "", { "dependencies": { "c12": "3.1.0", "deepmerge-ts": "7.1.5", "effect": "3.18.4", "empathic": "2.0.0" } }, "sha512-QyMV67+eXF7uMtKxTEeQqNu/Be7iH+3iDZOQZW5ttfbSwBamCSdwPszA0dum+Wx27I7anYTPLmRmMORKViSW1A=="],
|
||||||
|
|
||||||
|
"@prisma/debug": ["@prisma/debug@7.3.0", "", {}, "sha512-yh/tHhraCzYkffsI1/3a7SHX8tpgbJu1NPnuxS4rEpJdWAUDHUH25F1EDo6PPzirpyLNkgPPZdhojQK804BGtg=="],
|
||||||
|
|
||||||
|
"@prisma/dev": ["@prisma/dev@0.20.0", "", { "dependencies": { "@electric-sql/pglite": "0.3.15", "@electric-sql/pglite-socket": "0.0.20", "@electric-sql/pglite-tools": "0.2.20", "@hono/node-server": "1.19.9", "@mrleebo/prisma-ast": "0.13.1", "@prisma/get-platform": "7.2.0", "@prisma/query-plan-executor": "7.2.0", "foreground-child": "3.3.1", "get-port-please": "3.2.0", "hono": "4.11.4", "http-status-codes": "2.3.0", "pathe": "2.0.3", "proper-lockfile": "4.1.2", "remeda": "2.33.4", "std-env": "3.10.0", "valibot": "1.2.0", "zeptomatch": "2.1.0" } }, "sha512-ovlBYwWor0OzG+yH4J3Ot+AneD818BttLA+Ii7wjbcLHUrnC4tbUPVGyNd3c/+71KETPKZfjhkTSpdS15dmXNQ=="],
|
||||||
|
|
||||||
|
"@prisma/driver-adapter-utils": ["@prisma/driver-adapter-utils@7.3.0", "", { "dependencies": { "@prisma/debug": "7.3.0" } }, "sha512-Wdlezh1ck0Rq2dDINkfSkwbR53q53//Eo1vVqVLwtiZ0I6fuWDGNPxwq+SNAIHnsU+FD/m3aIJKevH3vF13U3w=="],
|
||||||
|
|
||||||
|
"@prisma/engines": ["@prisma/engines@7.3.0", "", { "dependencies": { "@prisma/debug": "7.3.0", "@prisma/engines-version": "7.3.0-16.9d6ad21cbbceab97458517b147a6a09ff43aa735", "@prisma/fetch-engine": "7.3.0", "@prisma/get-platform": "7.3.0" } }, "sha512-cWRQoPDXPtR6stOWuWFZf9pHdQ/o8/QNWn0m0zByxf5Kd946Q875XdEJ52pEsX88vOiXUmjuPG3euw82mwQNMg=="],
|
||||||
|
|
||||||
|
"@prisma/engines-version": ["@prisma/engines-version@7.3.0-16.9d6ad21cbbceab97458517b147a6a09ff43aa735", "", {}, "sha512-IH2va2ouUHihyiTTRW889LjKAl1CusZOvFfZxCDNpjSENt7g2ndFsK0vdIw/72v7+jCN6YgkHmdAP/BI7SDgyg=="],
|
||||||
|
|
||||||
|
"@prisma/fetch-engine": ["@prisma/fetch-engine@7.3.0", "", { "dependencies": { "@prisma/debug": "7.3.0", "@prisma/engines-version": "7.3.0-16.9d6ad21cbbceab97458517b147a6a09ff43aa735", "@prisma/get-platform": "7.3.0" } }, "sha512-Mm0F84JMqM9Vxk70pzfNpGJ1lE4hYjOeLMu7nOOD1i83nvp8MSAcFYBnHqLvEZiA6onUR+m8iYogtOY4oPO5lQ=="],
|
||||||
|
|
||||||
|
"@prisma/get-platform": ["@prisma/get-platform@7.2.0", "", { "dependencies": { "@prisma/debug": "7.2.0" } }, "sha512-k1V0l0Td1732EHpAfi2eySTezyllok9dXb6UQanajkJQzPUGi3vO2z7jdkz67SypFTdmbnyGYxvEvYZdZsMAVA=="],
|
||||||
|
|
||||||
|
"@prisma/query-plan-executor": ["@prisma/query-plan-executor@7.2.0", "", {}, "sha512-EOZmNzcV8uJ0mae3DhTsiHgoNCuu1J9mULQpGCh62zN3PxPTd+qI9tJvk5jOst8WHKQNwJWR3b39t0XvfBB0WQ=="],
|
||||||
|
|
||||||
|
"@prisma/studio-core": ["@prisma/studio-core@0.13.1", "", { "peerDependencies": { "@types/react": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" } }, "sha512-agdqaPEePRHcQ7CexEfkX1RvSH9uWDb6pXrZnhCRykhDFAV0/0P3d07WtfiY8hZWb7oRU4v+NkT4cGFHkQJIPg=="],
|
||||||
|
|
||||||
|
"@prokopschield/argv": ["@prokopschield/argv@0.1.3", "", { "bin": { "argv": "lib/cli.js" } }, "sha512-4/yMUKdaFIKBUOOu5+qhC2kMuAECk7FaKamo5NSu4iAzuw36hj6E3UY3CYVKXPnA5dldwiwW60Ss5Ss5QdxVCw=="],
|
||||||
|
|
||||||
|
"@socket.io/bun-engine": ["@socket.io/bun-engine@0.1.0", "", { "peerDependencies": { "typescript": "^5" } }, "sha512-B1z6GuAxZlfvjgaa3BHZBOfqHJNfnpebTw15p+Un1HuBL4YM7wUxO9sJa7K4NDTe7XbUBeqLIwTDA5tOOjffog=="],
|
||||||
|
|
||||||
|
"@socket.io/component-emitter": ["@socket.io/component-emitter@3.1.2", "", {}, "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA=="],
|
||||||
|
|
||||||
|
"@standard-schema/spec": ["@standard-schema/spec@1.1.0", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
|
||||||
|
|
||||||
|
"@swc/helpers": ["@swc/helpers@0.5.19", "", { "dependencies": { "tslib": "^2.8.0" } }, "sha512-QamiFeIK3txNjgUTNppE6MiG3p7TdninpZu0E0PbqVh1a9FNLT2FRhisaa4NcaX52XVhA5l7Pk58Ft7Sqi/2sA=="],
|
||||||
|
|
||||||
|
"@types/bun": ["@types/bun@1.3.6", "", { "dependencies": { "bun-types": "1.3.6" } }, "sha512-uWCv6FO/8LcpREhenN1d1b6fcspAB+cefwD7uti8C8VffIv0Um08TKMn98FynpTiU38+y2dUO55T11NgDt8VAA=="],
|
||||||
|
|
||||||
|
"@types/cors": ["@types/cors@2.8.19", "", { "dependencies": { "@types/node": "*" } }, "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg=="],
|
||||||
|
|
||||||
|
"@types/jsonwebtoken": ["@types/jsonwebtoken@9.0.10", "", { "dependencies": { "@types/ms": "*", "@types/node": "*" } }, "sha512-asx5hIG9Qmf/1oStypjanR7iKTv0gXQ1Ov/jfrX6kS/EO0OFni8orbmGCn0672NHR3kXHwpAwR+B368ZGN/2rA=="],
|
||||||
|
|
||||||
|
"@types/ms": ["@types/ms@2.1.0", "", {}, "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA=="],
|
||||||
|
|
||||||
|
"@types/node": ["@types/node@25.0.10", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-zWW5KPngR/yvakJgGOmZ5vTBemDoSqF3AcV/LrO5u5wTWyEAVVh+IT39G4gtyAkh3CtTZs8aX/yRM82OfzHJRg=="],
|
||||||
|
|
||||||
|
"@types/react": ["@types/react@19.2.9", "", { "dependencies": { "csstype": "^3.2.2" } }, "sha512-Lpo8kgb/igvMIPeNV2rsYKTgaORYdO1XGVZ4Qz3akwOj0ySGYMPlQWa8BaLn0G63D1aSaAQ5ldR06wCpChQCjA=="],
|
||||||
|
|
||||||
|
"accepts": ["accepts@1.3.8", "", { "dependencies": { "mime-types": "~2.1.34", "negotiator": "0.6.3" } }, "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw=="],
|
||||||
|
|
||||||
|
"asynckit": ["asynckit@0.4.0", "", {}, "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="],
|
||||||
|
|
||||||
|
"aws-ssl-profiles": ["aws-ssl-profiles@1.1.2", "", {}, "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g=="],
|
||||||
|
|
||||||
|
"axios": ["axios@1.13.3", "", { "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, "sha512-ERT8kdX7DZjtUm7IitEyV7InTHAF42iJuMArIiDIV5YtPanJkgw4hw5Dyg9fh0mihdWNn1GKaeIWErfe56UQ1g=="],
|
||||||
|
|
||||||
|
"base64-js": ["base64-js@0.0.8", "", {}, "sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw=="],
|
||||||
|
|
||||||
|
"base64id": ["base64id@2.0.0", "", {}, "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog=="],
|
||||||
|
|
||||||
|
"blakets": ["blakets@0.1.12", "", { "dependencies": { "@prokopschield/argv": "^0.1.0-2" }, "bin": { "blake": "lib/demo.js", "blake2b": "lib/cli.js", "blake2s": "lib/cli.js", "blakejs": "lib/demo.js", "blakets": "lib/demo.js" } }, "sha512-ReOnLTDRlbExlTXbJZoA2xkvhzauJ7ldpvhKnb1cUNw8gdAHWHWOWG8XMjwpxQmmEZCDAR7VZiM5BYTUSOLVrw=="],
|
||||||
|
|
||||||
|
"brotli": ["brotli@1.3.3", "", { "dependencies": { "base64-js": "^1.1.2" } }, "sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg=="],
|
||||||
|
|
||||||
|
"buffer-equal-constant-time": ["buffer-equal-constant-time@1.0.1", "", {}, "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="],
|
||||||
|
|
||||||
|
"bun-types": ["bun-types@1.3.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ=="],
|
||||||
|
|
||||||
|
"c12": ["c12@3.1.0", "", { "dependencies": { "chokidar": "^4.0.3", "confbox": "^0.2.2", "defu": "^6.1.4", "dotenv": "^16.6.1", "exsolve": "^1.0.7", "giget": "^2.0.0", "jiti": "^2.4.2", "ohash": "^2.0.11", "pathe": "^2.0.3", "perfect-debounce": "^1.0.0", "pkg-types": "^2.2.0", "rc9": "^2.1.2" }, "peerDependencies": { "magicast": "^0.3.5" }, "optionalPeers": ["magicast"] }, "sha512-uWoS8OU1MEIsOv8p/5a82c3H31LsWVR5qiyXVfBNOzfffjUWtPnhAb4BYI2uG2HfGmZmFjCtui5XNWaps+iFuw=="],
|
||||||
|
|
||||||
|
"call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
|
||||||
|
|
||||||
|
"chevrotain": ["chevrotain@10.5.0", "", { "dependencies": { "@chevrotain/cst-dts-gen": "10.5.0", "@chevrotain/gast": "10.5.0", "@chevrotain/types": "10.5.0", "@chevrotain/utils": "10.5.0", "lodash": "4.17.21", "regexp-to-ast": "0.5.0" } }, "sha512-Pkv5rBY3+CsHOYfV5g/Vs5JY9WTHHDEKOlohI2XeygaZhUeqhAlldZ8Hz9cRmxu709bvS08YzxHdTPHhffc13A=="],
|
||||||
|
|
||||||
|
"chokidar": ["chokidar@4.0.3", "", { "dependencies": { "readdirp": "^4.0.1" } }, "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA=="],
|
||||||
|
|
||||||
|
"citty": ["citty@0.1.6", "", { "dependencies": { "consola": "^3.2.3" } }, "sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ=="],
|
||||||
|
|
||||||
|
"clone": ["clone@2.1.2", "", {}, "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w=="],
|
||||||
|
|
||||||
|
"cluster-key-slot": ["cluster-key-slot@1.1.2", "", {}, "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA=="],
|
||||||
|
|
||||||
|
"combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
|
||||||
|
|
||||||
|
"confbox": ["confbox@0.2.2", "", {}, "sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ=="],
|
||||||
|
|
||||||
|
"consola": ["consola@3.4.2", "", {}, "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA=="],
|
||||||
|
|
||||||
|
"cookie": ["cookie@0.7.2", "", {}, "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w=="],
|
||||||
|
|
||||||
|
"cors": ["cors@2.8.6", "", { "dependencies": { "object-assign": "^4", "vary": "^1" } }, "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw=="],
|
||||||
|
|
||||||
|
"cron-parser": ["cron-parser@5.5.0", "", { "dependencies": { "luxon": "^3.7.1" } }, "sha512-oML4lKUXxizYswqmxuOCpgFS8BNUJpIu6k/2HVHyaL8Ynnf3wdf9tkns0yRdJLSIjkJ+b0DXHMZEHGpMwjnPww=="],
|
||||||
|
|
||||||
|
"cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
|
||||||
|
|
||||||
|
"crypto-js": ["crypto-js@4.2.0", "", {}, "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="],
|
||||||
|
|
||||||
|
"csstype": ["csstype@3.2.3", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="],
|
||||||
|
|
||||||
|
"cuid": ["cuid@3.0.0", "", {}, "sha512-WZYYkHdIDnaxdeP8Misq3Lah5vFjJwGuItJuV+tvMafosMzw0nF297T7mrm8IOWiPJkV6gc7sa8pzx27+w25Zg=="],
|
||||||
|
|
||||||
|
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
||||||
|
|
||||||
|
"deepmerge-ts": ["deepmerge-ts@7.1.5", "", {}, "sha512-HOJkrhaYsweh+W+e74Yn7YStZOilkoPb6fycpwNLKzSPtruFs48nYis0zy5yJz1+ktUhHxoRDJ27RQAWLIJVJw=="],
|
||||||
|
|
||||||
|
"defu": ["defu@6.1.4", "", {}, "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg=="],
|
||||||
|
|
||||||
|
"delayed-stream": ["delayed-stream@1.0.0", "", {}, "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="],
|
||||||
|
|
||||||
|
"denque": ["denque@2.1.0", "", {}, "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw=="],
|
||||||
|
|
||||||
|
"destr": ["destr@2.0.5", "", {}, "sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA=="],
|
||||||
|
|
||||||
|
"dfa": ["dfa@1.2.0", "", {}, "sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q=="],
|
||||||
|
|
||||||
|
"dotenv": ["dotenv@16.6.1", "", {}, "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow=="],
|
||||||
|
|
||||||
|
"dunder-proto": ["dunder-proto@1.0.1", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="],
|
||||||
|
|
||||||
|
"ecdsa-sig-formatter": ["ecdsa-sig-formatter@1.0.11", "", { "dependencies": { "safe-buffer": "^5.0.1" } }, "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ=="],
|
||||||
|
|
||||||
|
"effect": ["effect@3.18.4", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "fast-check": "^3.23.1" } }, "sha512-b1LXQJLe9D11wfnOKAk3PKxuqYshQ0Heez+y5pnkd3jLj1yx9QhM72zZ9uUrOQyNvrs2GZZd/3maL0ZV18YuDA=="],
|
||||||
|
|
||||||
|
"empathic": ["empathic@2.0.0", "", {}, "sha512-i6UzDscO/XfAcNYD75CfICkmfLedpyPDdozrLMmQc5ORaQcdMoc21OnlEylMIqI7U8eniKrPMxxtj8k0vhmJhA=="],
|
||||||
|
|
||||||
|
"engine.io": ["engine.io@6.6.5", "", { "dependencies": { "@types/cors": "^2.8.12", "@types/node": ">=10.0.0", "accepts": "~1.3.4", "base64id": "2.0.0", "cookie": "~0.7.2", "cors": "~2.8.5", "debug": "~4.4.1", "engine.io-parser": "~5.2.1", "ws": "~8.18.3" } }, "sha512-2RZdgEbXmp5+dVbRm0P7HQUImZpICccJy7rN7Tv+SFa55pH+lxnuw6/K1ZxxBfHoYpSkHLAO92oa8O4SwFXA2A=="],
|
||||||
|
|
||||||
|
"engine.io-client": ["engine.io-client@6.6.4", "", { "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.4.1", "engine.io-parser": "~5.2.1", "ws": "~8.18.3", "xmlhttprequest-ssl": "~2.1.1" } }, "sha512-+kjUJnZGwzewFDw951CDWcwj35vMNf2fcj7xQWOctq1F2i1jkDdVvdFG9kM/BEChymCH36KgjnW0NsL58JYRxw=="],
|
||||||
|
|
||||||
|
"engine.io-parser": ["engine.io-parser@5.2.3", "", {}, "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q=="],
|
||||||
|
|
||||||
|
"es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
|
||||||
|
|
||||||
|
"es-errors": ["es-errors@1.3.0", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="],
|
||||||
|
|
||||||
|
"es-object-atoms": ["es-object-atoms@1.1.1", "", { "dependencies": { "es-errors": "^1.3.0" } }, "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA=="],
|
||||||
|
|
||||||
|
"es-set-tostringtag": ["es-set-tostringtag@2.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "get-intrinsic": "^1.2.6", "has-tostringtag": "^1.0.2", "hasown": "^2.0.2" } }, "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA=="],
|
||||||
|
|
||||||
|
"exsolve": ["exsolve@1.0.8", "", {}, "sha512-LmDxfWXwcTArk8fUEnOfSZpHOJ6zOMUJKOtFLFqJLoKJetuQG874Uc7/Kki7zFLzYybmZhp1M7+98pfMqeX8yA=="],
|
||||||
|
|
||||||
|
"fast-check": ["fast-check@3.23.2", "", { "dependencies": { "pure-rand": "^6.1.0" } }, "sha512-h5+1OzzfCC3Ef7VbtKdcv7zsstUQwUDlYpUTvjeUsJAssPgLn7QzbboPtL5ro04Mq0rPOsMzl7q5hIbRs2wD1A=="],
|
||||||
|
|
||||||
|
"fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="],
|
||||||
|
|
||||||
|
"follow-redirects": ["follow-redirects@1.15.11", "", {}, "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ=="],
|
||||||
|
|
||||||
|
"fontkit": ["fontkit@2.0.4", "", { "dependencies": { "@swc/helpers": "^0.5.12", "brotli": "^1.3.2", "clone": "^2.1.2", "dfa": "^1.2.0", "fast-deep-equal": "^3.1.3", "restructure": "^3.0.0", "tiny-inflate": "^1.0.3", "unicode-properties": "^1.4.0", "unicode-trie": "^2.0.0" } }, "sha512-syetQadaUEDNdxdugga9CpEYVaQIxOwk7GlwZWWZ19//qW4zE5bknOKeMBDYAASwnpaSHKJITRLMF9m1fp3s6g=="],
|
||||||
|
|
||||||
|
"foreground-child": ["foreground-child@3.3.1", "", { "dependencies": { "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" } }, "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw=="],
|
||||||
|
|
||||||
|
"form-data": ["form-data@4.0.5", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w=="],
|
||||||
|
|
||||||
|
"function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
|
||||||
|
|
||||||
|
"generate-function": ["generate-function@2.3.1", "", { "dependencies": { "is-property": "^1.0.2" } }, "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ=="],
|
||||||
|
|
||||||
|
"get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
|
||||||
|
|
||||||
|
"get-port-please": ["get-port-please@3.2.0", "", {}, "sha512-I9QVvBw5U/hw3RmWpYKRumUeaDgxTPd401x364rLmWBJcOQ753eov1eTgzDqRG9bqFIfDc7gfzcQEWrUri3o1A=="],
|
||||||
|
|
||||||
|
"get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="],
|
||||||
|
|
||||||
|
"giget": ["giget@2.0.0", "", { "dependencies": { "citty": "^0.1.6", "consola": "^3.4.0", "defu": "^6.1.4", "node-fetch-native": "^1.6.6", "nypm": "^0.6.0", "pathe": "^2.0.3" }, "bin": { "giget": "dist/cli.mjs" } }, "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA=="],
|
||||||
|
|
||||||
|
"gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
|
||||||
|
|
||||||
|
"graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
|
||||||
|
|
||||||
|
"grammex": ["grammex@3.1.12", "", {}, "sha512-6ufJOsSA7LcQehIJNCO7HIBykfM7DXQual0Ny780/DEcJIpBlHRvcqEBWGPYd7hrXL2GJ3oJI1MIhaXjWmLQOQ=="],
|
||||||
|
|
||||||
|
"graphmatch": ["graphmatch@1.1.0", "", {}, "sha512-0E62MaTW5rPZVRLyIJZG/YejmdA/Xr1QydHEw3Vt+qOKkMIOE8WDLc9ZX2bmAjtJFZcId4lEdrdmASsEy7D1QA=="],
|
||||||
|
|
||||||
|
"has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
|
||||||
|
|
||||||
|
"has-tostringtag": ["has-tostringtag@1.0.2", "", { "dependencies": { "has-symbols": "^1.0.3" } }, "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw=="],
|
||||||
|
|
||||||
|
"hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
|
||||||
|
|
||||||
|
"hono": ["hono@4.11.5", "", {}, "sha512-WemPi9/WfyMwZs+ZUXdiwcCh9Y+m7L+8vki9MzDw3jJ+W9Lc+12HGsd368Qc1vZi1xwW8BWMMsnK5efYKPdt4g=="],
|
||||||
|
|
||||||
|
"http-status-codes": ["http-status-codes@2.3.0", "", {}, "sha512-RJ8XvFvpPM/Dmc5SV+dC4y5PCeOhT3x1Hq0NU3rjGeg5a/CqlhZ7uudknPwZFz4aeAXDcbAyaeP7GAo9lvngtA=="],
|
||||||
|
|
||||||
|
"iconv-lite": ["iconv-lite@0.7.2", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw=="],
|
||||||
|
|
||||||
|
"ioredis": ["ioredis@5.10.0", "", { "dependencies": { "@ioredis/commands": "1.5.1", "cluster-key-slot": "^1.1.0", "debug": "^4.3.4", "denque": "^2.1.0", "lodash.defaults": "^4.2.0", "lodash.isarguments": "^3.1.0", "redis-errors": "^1.2.0", "redis-parser": "^3.0.0", "standard-as-callback": "^2.1.0" } }, "sha512-HVBe9OFuqs+Z6n64q09PQvP1/R4Bm+30PAyyD4wIEqssh3v9L21QjCVk4kRLucMBcDokJTcLjsGeVRlq/nH6DA=="],
|
||||||
|
|
||||||
|
"is-property": ["is-property@1.0.2", "", {}, "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g=="],
|
||||||
|
|
||||||
|
"isexe": ["isexe@2.0.0", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="],
|
||||||
|
|
||||||
|
"jiti": ["jiti@2.6.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="],
|
||||||
|
|
||||||
|
"jpeg-exif": ["jpeg-exif@1.1.4", "", {}, "sha512-a+bKEcCjtuW5WTdgeXFzswSrdqi0jk4XlEtZlx5A94wCoBpFjfFTbo/Tra5SpNCl/YFZPvcV1dJc+TAYeg6ROQ=="],
|
||||||
|
|
||||||
|
"jsonwebtoken": ["jsonwebtoken@9.0.3", "", { "dependencies": { "jws": "^4.0.1", "lodash.includes": "^4.3.0", "lodash.isboolean": "^3.0.3", "lodash.isinteger": "^4.0.4", "lodash.isnumber": "^3.0.3", "lodash.isplainobject": "^4.0.6", "lodash.isstring": "^4.0.1", "lodash.once": "^4.0.0", "ms": "^2.1.1", "semver": "^7.5.4" } }, "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g=="],
|
||||||
|
|
||||||
|
"jwa": ["jwa@2.0.1", "", { "dependencies": { "buffer-equal-constant-time": "^1.0.1", "ecdsa-sig-formatter": "1.0.11", "safe-buffer": "^5.0.1" } }, "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg=="],
|
||||||
|
|
||||||
|
"jws": ["jws@4.0.1", "", { "dependencies": { "jwa": "^2.0.1", "safe-buffer": "^5.0.1" } }, "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA=="],
|
||||||
|
|
||||||
|
"keypair": ["keypair@1.0.4", "", {}, "sha512-zwhgOhhniaL7oxMgUMKKw5219PWWABMO+dgMnzJOQ2/5L3XJtTJGhW2PEXlxXj9zaccdReZJZ83+4NPhVfNVDg=="],
|
||||||
|
|
||||||
|
"lilconfig": ["lilconfig@2.1.0", "", {}, "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ=="],
|
||||||
|
|
||||||
|
"linebreak": ["linebreak@1.1.0", "", { "dependencies": { "base64-js": "0.0.8", "unicode-trie": "^2.0.0" } }, "sha512-MHp03UImeVhB7XZtjd0E4n6+3xr5Dq/9xI/5FptGk5FrbDR3zagPa2DS6U8ks/3HjbKWG9Q1M2ufOzxV2qLYSQ=="],
|
||||||
|
|
||||||
|
"lodash": ["lodash@4.17.21", "", {}, "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="],
|
||||||
|
|
||||||
|
"lodash.defaults": ["lodash.defaults@4.2.0", "", {}, "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ=="],
|
||||||
|
|
||||||
|
"lodash.includes": ["lodash.includes@4.3.0", "", {}, "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="],
|
||||||
|
|
||||||
|
"lodash.isarguments": ["lodash.isarguments@3.1.0", "", {}, "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg=="],
|
||||||
|
|
||||||
|
"lodash.isboolean": ["lodash.isboolean@3.0.3", "", {}, "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="],
|
||||||
|
|
||||||
|
"lodash.isinteger": ["lodash.isinteger@4.0.4", "", {}, "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA=="],
|
||||||
|
|
||||||
|
"lodash.isnumber": ["lodash.isnumber@3.0.3", "", {}, "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw=="],
|
||||||
|
|
||||||
|
"lodash.isplainobject": ["lodash.isplainobject@4.0.6", "", {}, "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="],
|
||||||
|
|
||||||
|
"lodash.isstring": ["lodash.isstring@4.0.1", "", {}, "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw=="],
|
||||||
|
|
||||||
|
"lodash.once": ["lodash.once@4.1.1", "", {}, "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="],
|
||||||
|
|
||||||
|
"long": ["long@5.3.2", "", {}, "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA=="],
|
||||||
|
|
||||||
|
"lru.min": ["lru.min@1.1.3", "", {}, "sha512-Lkk/vx6ak3rYkRR0Nhu4lFUT2VDnQSxBe8Hbl7f36358p6ow8Bnvr8lrLt98H8J1aGxfhbX4Fs5tYg2+FTwr5Q=="],
|
||||||
|
|
||||||
|
"luxon": ["luxon@3.7.2", "", {}, "sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew=="],
|
||||||
|
|
||||||
|
"math-intrinsics": ["math-intrinsics@1.1.0", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="],
|
||||||
|
|
||||||
|
"mime-db": ["mime-db@1.52.0", "", {}, "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="],
|
||||||
|
|
||||||
|
"mime-types": ["mime-types@2.1.35", "", { "dependencies": { "mime-db": "1.52.0" } }, "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw=="],
|
||||||
|
|
||||||
|
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||||
|
|
||||||
|
"mysql2": ["mysql2@3.15.3", "", { "dependencies": { "aws-ssl-profiles": "^1.1.1", "denque": "^2.1.0", "generate-function": "^2.3.1", "iconv-lite": "^0.7.0", "long": "^5.2.1", "lru.min": "^1.0.0", "named-placeholders": "^1.1.3", "seq-queue": "^0.0.5", "sqlstring": "^2.3.2" } }, "sha512-FBrGau0IXmuqg4haEZRBfHNWB5mUARw6hNwPDXXGg0XzVJ50mr/9hb267lvpVMnhZ1FON3qNd4Xfcez1rbFwSg=="],
|
||||||
|
|
||||||
|
"named-placeholders": ["named-placeholders@1.1.6", "", { "dependencies": { "lru.min": "^1.1.0" } }, "sha512-Tz09sEL2EEuv5fFowm419c1+a/jSMiBjI9gHxVLrVdbUkkNUUfjsVYs9pVZu5oCon/kmRh9TfLEObFtkVxmY0w=="],
|
||||||
|
|
||||||
|
"negotiator": ["negotiator@0.6.3", "", {}, "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg=="],
|
||||||
|
|
||||||
|
"node-fetch-native": ["node-fetch-native@1.6.7", "", {}, "sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q=="],
|
||||||
|
|
||||||
|
"non-error": ["non-error@0.1.0", "", {}, "sha512-TMB1uHiGsHRGv1uYclfhivcnf0/PdFp2pNqRxXjncaAsjYMoisaQJI+SSZCqRq+VliwRTC8tsMQfmrWjDMhkPQ=="],
|
||||||
|
|
||||||
|
"nypm": ["nypm@0.6.4", "", { "dependencies": { "citty": "^0.2.0", "pathe": "^2.0.3", "tinyexec": "^1.0.2" }, "bin": { "nypm": "dist/cli.mjs" } }, "sha512-1TvCKjZyyklN+JJj2TS3P4uSQEInrM/HkkuSXsEzm1ApPgBffOn8gFguNnZf07r/1X6vlryfIqMUkJKQMzlZiw=="],
|
||||||
|
|
||||||
|
"object-assign": ["object-assign@4.1.1", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="],
|
||||||
|
|
||||||
|
"ohash": ["ohash@2.0.11", "", {}, "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ=="],
|
||||||
|
|
||||||
|
"pako": ["pako@1.0.11", "", {}, "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="],
|
||||||
|
|
||||||
|
"path-key": ["path-key@3.1.1", "", {}, "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="],
|
||||||
|
|
||||||
|
"pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
|
||||||
|
|
||||||
|
"pdf-lib": ["pdf-lib@1.17.1", "", { "dependencies": { "@pdf-lib/standard-fonts": "^1.0.0", "@pdf-lib/upng": "^1.0.1", "pako": "^1.0.11", "tslib": "^1.11.1" } }, "sha512-V/mpyJAoTsN4cnP31vc0wfNA1+p20evqqnap0KLoRUN0Yk/p3wN52DOEsL4oBFcLdb76hlpKPtzJIgo67j/XLw=="],
|
||||||
|
|
||||||
|
"pdfkit": ["pdfkit@0.17.2", "", { "dependencies": { "crypto-js": "^4.2.0", "fontkit": "^2.0.4", "jpeg-exif": "^1.1.4", "linebreak": "^1.1.0", "png-js": "^1.0.0" } }, "sha512-UnwF5fXy08f0dnp4jchFYAROKMNTaPqb/xgR8GtCzIcqoTnbOqtp3bwKvO4688oHI6vzEEs8Q6vqqEnC5IUELw=="],
|
||||||
|
|
||||||
|
"pdfmake": ["pdfmake@0.3.5", "", { "dependencies": { "linebreak": "^1.1.0", "pdfkit": "^0.17.2", "xmldoc": "^2.0.3" } }, "sha512-DR7jRrK4lk7UiRT6pi+NeWhW1ToTsL2Y8CH+bFKNYz3M7agIVgeCtwARveEORhCAqoG3AUDrN318xU/lkOr1Bg=="],
|
||||||
|
|
||||||
|
"perfect-debounce": ["perfect-debounce@1.0.0", "", {}, "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA=="],
|
||||||
|
|
||||||
|
"pg": ["pg@8.17.2", "", { "dependencies": { "pg-connection-string": "^2.10.1", "pg-pool": "^3.11.0", "pg-protocol": "^1.11.0", "pg-types": "2.2.0", "pgpass": "1.0.5" }, "optionalDependencies": { "pg-cloudflare": "^1.3.0" }, "peerDependencies": { "pg-native": ">=3.0.1" }, "optionalPeers": ["pg-native"] }, "sha512-vjbKdiBJRqzcYw1fNU5KuHyYvdJ1qpcQg1CeBrHFqV1pWgHeVR6j/+kX0E1AAXfyuLUGY1ICrN2ELKA/z2HWzw=="],
|
||||||
|
|
||||||
|
"pg-boss": ["pg-boss@12.14.0", "", { "dependencies": { "cron-parser": "^5.5.0", "pg": "^8.19.0", "serialize-error": "^13.0.1" }, "bin": { "pg-boss": "dist/cli.js" } }, "sha512-sxF+Y5w6uRRkFCen3LM6BOcSG5gdMM3/hs+WiycAHHX8EuP5Zod5eTo79IlmegXFzIgtYWs7Bcjjhid4TRLlvg=="],
|
||||||
|
|
||||||
|
"pg-cloudflare": ["pg-cloudflare@1.3.0", "", {}, "sha512-6lswVVSztmHiRtD6I8hw4qP/nDm1EJbKMRhf3HCYaqud7frGysPv7FYJ5noZQdhQtN2xJnimfMtvQq21pdbzyQ=="],
|
||||||
|
|
||||||
|
"pg-connection-string": ["pg-connection-string@2.10.1", "", {}, "sha512-iNzslsoeSH2/gmDDKiyMqF64DATUCWj3YJ0wP14kqcsf2TUklwimd+66yYojKwZCA7h2yRNLGug71hCBA2a4sw=="],
|
||||||
|
|
||||||
|
"pg-int8": ["pg-int8@1.0.1", "", {}, "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw=="],
|
||||||
|
|
||||||
|
"pg-pool": ["pg-pool@3.11.0", "", { "peerDependencies": { "pg": ">=8.0" } }, "sha512-MJYfvHwtGp870aeusDh+hg9apvOe2zmpZJpyt+BMtzUWlVqbhFmMK6bOBXLBUPd7iRtIF9fZplDc7KrPN3PN7w=="],
|
||||||
|
|
||||||
|
"pg-protocol": ["pg-protocol@1.11.0", "", {}, "sha512-pfsxk2M9M3BuGgDOfuy37VNRRX3jmKgMjcvAcWqNDpZSf4cUmv8HSOl5ViRQFsfARFn0KuUQTgLxVMbNq5NW3g=="],
|
||||||
|
|
||||||
|
"pg-types": ["pg-types@2.2.0", "", { "dependencies": { "pg-int8": "1.0.1", "postgres-array": "~2.0.0", "postgres-bytea": "~1.0.0", "postgres-date": "~1.0.4", "postgres-interval": "^1.1.0" } }, "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA=="],
|
||||||
|
|
||||||
|
"pgpass": ["pgpass@1.0.5", "", { "dependencies": { "split2": "^4.1.0" } }, "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug=="],
|
||||||
|
|
||||||
|
"pkg-types": ["pkg-types@2.3.0", "", { "dependencies": { "confbox": "^0.2.2", "exsolve": "^1.0.7", "pathe": "^2.0.3" } }, "sha512-SIqCzDRg0s9npO5XQ3tNZioRY1uK06lA41ynBC1YmFTmnY6FjUjVt6s4LoADmwoig1qqD0oK8h1p/8mlMx8Oig=="],
|
||||||
|
|
||||||
|
"png-js": ["png-js@1.0.0", "", {}, "sha512-k+YsbhpA9e+EFfKjTCH3VW6aoKlyNYI6NYdTfDL4CIvFnvsuO84ttonmZE7rc+v23SLTH8XX+5w/Ak9v0xGY4g=="],
|
||||||
|
|
||||||
|
"postgres": ["postgres@3.4.7", "", {}, "sha512-Jtc2612XINuBjIl/QTWsV5UvE8UHuNblcO3vVADSrKsrc6RqGX6lOW1cEo3CM2v0XG4Nat8nI+YM7/f26VxXLw=="],
|
||||||
|
|
||||||
|
"postgres-array": ["postgres-array@3.0.4", "", {}, "sha512-nAUSGfSDGOaOAEGwqsRY27GPOea7CNipJPOA7lPbdEpx5Kg3qzdP0AaWC5MlhTWV9s4hFX39nomVZ+C4tnGOJQ=="],
|
||||||
|
|
||||||
|
"postgres-bytea": ["postgres-bytea@1.0.1", "", {}, "sha512-5+5HqXnsZPE65IJZSMkZtURARZelel2oXUEO8rH83VS/hxH5vv1uHquPg5wZs8yMAfdv971IU+kcPUczi7NVBQ=="],
|
||||||
|
|
||||||
|
"postgres-date": ["postgres-date@1.0.7", "", {}, "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q=="],
|
||||||
|
|
||||||
|
"postgres-interval": ["postgres-interval@1.2.0", "", { "dependencies": { "xtend": "^4.0.0" } }, "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ=="],
|
||||||
|
|
||||||
|
"prisma": ["prisma@7.3.0", "", { "dependencies": { "@prisma/config": "7.3.0", "@prisma/dev": "0.20.0", "@prisma/engines": "7.3.0", "@prisma/studio-core": "0.13.1", "mysql2": "3.15.3", "postgres": "3.4.7" }, "peerDependencies": { "better-sqlite3": ">=9.0.0", "typescript": ">=5.4.0" }, "optionalPeers": ["better-sqlite3", "typescript"], "bin": { "prisma": "build/index.js" } }, "sha512-ApYSOLHfMN8WftJA+vL6XwAPOh/aZ0BgUyyKPwUFgjARmG6EBI9LzDPf6SWULQMSAxydV9qn5gLj037nPNlg2w=="],
|
||||||
|
|
||||||
|
"proper-lockfile": ["proper-lockfile@4.1.2", "", { "dependencies": { "graceful-fs": "^4.2.4", "retry": "^0.12.0", "signal-exit": "^3.0.2" } }, "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA=="],
|
||||||
|
|
||||||
|
"proxy-from-env": ["proxy-from-env@1.1.0", "", {}, "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="],
|
||||||
|
|
||||||
|
"pure-rand": ["pure-rand@6.1.0", "", {}, "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA=="],
|
||||||
|
|
||||||
|
"rc9": ["rc9@2.1.2", "", { "dependencies": { "defu": "^6.1.4", "destr": "^2.0.3" } }, "sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg=="],
|
||||||
|
|
||||||
|
"react": ["react@19.2.3", "", {}, "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA=="],
|
||||||
|
|
||||||
|
"react-dom": ["react-dom@19.2.3", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.3" } }, "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg=="],
|
||||||
|
|
||||||
|
"readdirp": ["readdirp@4.1.2", "", {}, "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg=="],
|
||||||
|
|
||||||
|
"redis-errors": ["redis-errors@1.2.0", "", {}, "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w=="],
|
||||||
|
|
||||||
|
"redis-parser": ["redis-parser@3.0.0", "", { "dependencies": { "redis-errors": "^1.0.0" } }, "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A=="],
|
||||||
|
|
||||||
|
"regexp-to-ast": ["regexp-to-ast@0.5.0", "", {}, "sha512-tlbJqcMHnPKI9zSrystikWKwHkBqu2a/Sgw01h3zFjvYrMxEDYHzzoMZnUrbIfpTFEsoRnnviOXNCzFiSc54Qw=="],
|
||||||
|
|
||||||
|
"remeda": ["remeda@2.33.4", "", {}, "sha512-ygHswjlc/opg2VrtiYvUOPLjxjtdKvjGz1/plDhkG66hjNjFr1xmfrs2ClNFo/E6TyUFiwYNh53bKV26oBoMGQ=="],
|
||||||
|
|
||||||
|
"restructure": ["restructure@3.0.2", "", {}, "sha512-gSfoiOEA0VPE6Tukkrr7I0RBdE0s7H1eFCDBk05l1KIQT1UIKNc5JZy6jdyW6eYH3aR3g5b3PuL77rq0hvwtAw=="],
|
||||||
|
|
||||||
|
"retry": ["retry@0.12.0", "", {}, "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow=="],
|
||||||
|
|
||||||
|
"safe-buffer": ["safe-buffer@5.2.1", "", {}, "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="],
|
||||||
|
|
||||||
|
"safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
|
||||||
|
|
||||||
|
"sax": ["sax@1.5.0", "", {}, "sha512-21IYA3Q5cQf089Z6tgaUTr7lDAyzoTPx5HRtbhsME8Udispad8dC/+sziTNugOEx54ilvatQ9YCzl4KQLPcRHA=="],
|
||||||
|
|
||||||
|
"scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
|
||||||
|
|
||||||
|
"semver": ["semver@7.7.3", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q=="],
|
||||||
|
|
||||||
|
"seq-queue": ["seq-queue@0.0.5", "", {}, "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q=="],
|
||||||
|
|
||||||
|
"serialize-error": ["serialize-error@13.0.1", "", { "dependencies": { "non-error": "^0.1.0", "type-fest": "^5.4.1" } }, "sha512-bBZaRwLH9PN5HbLCjPId4dP5bNGEtumcErgOX952IsvOhVPrm3/AeK1y0UHA/QaPG701eg0yEnOKsCOC6X/kaA=="],
|
||||||
|
|
||||||
|
"shebang-command": ["shebang-command@2.0.0", "", { "dependencies": { "shebang-regex": "^3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="],
|
||||||
|
|
||||||
|
"shebang-regex": ["shebang-regex@3.0.0", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="],
|
||||||
|
|
||||||
|
"signal-exit": ["signal-exit@4.1.0", "", {}, "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="],
|
||||||
|
|
||||||
|
"socket.io": ["socket.io@4.8.3", "", { "dependencies": { "accepts": "~1.3.4", "base64id": "~2.0.0", "cors": "~2.8.5", "debug": "~4.4.1", "engine.io": "~6.6.0", "socket.io-adapter": "~2.5.2", "socket.io-parser": "~4.2.4" } }, "sha512-2Dd78bqzzjE6KPkD5fHZmDAKRNe3J15q+YHDrIsy9WEkqttc7GY+kT9OBLSMaPbQaEd0x1BjcmtMtXkfpc+T5A=="],
|
||||||
|
|
||||||
|
"socket.io-adapter": ["socket.io-adapter@2.5.6", "", { "dependencies": { "debug": "~4.4.1", "ws": "~8.18.3" } }, "sha512-DkkO/dz7MGln0dHn5bmN3pPy+JmywNICWrJqVWiVOyvXjWQFIv9c2h24JrQLLFJ2aQVQf/Cvl1vblnd4r2apLQ=="],
|
||||||
|
|
||||||
|
"socket.io-client": ["socket.io-client@4.8.3", "", { "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.4.1", "engine.io-client": "~6.6.1", "socket.io-parser": "~4.2.4" } }, "sha512-uP0bpjWrjQmUt5DTHq9RuoCBdFJF10cdX9X+a368j/Ft0wmaVgxlrjvK3kjvgCODOMMOz9lcaRzxmso0bTWZ/g=="],
|
||||||
|
|
||||||
|
"socket.io-parser": ["socket.io-parser@4.2.5", "", { "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.4.1" } }, "sha512-bPMmpy/5WWKHea5Y/jYAP6k74A+hvmRCQaJuJB6I/ML5JZq/KfNieUVo/3Mh7SAqn7TyFdIo6wqYHInG1MU1bQ=="],
|
||||||
|
|
||||||
|
"split2": ["split2@4.2.0", "", {}, "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg=="],
|
||||||
|
|
||||||
|
"sqlstring": ["sqlstring@2.3.3", "", {}, "sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg=="],
|
||||||
|
|
||||||
|
"standard-as-callback": ["standard-as-callback@2.1.0", "", {}, "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A=="],
|
||||||
|
|
||||||
|
"std-env": ["std-env@3.10.0", "", {}, "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg=="],
|
||||||
|
|
||||||
|
"tagged-tag": ["tagged-tag@1.0.0", "", {}, "sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng=="],
|
||||||
|
|
||||||
|
"tiny-inflate": ["tiny-inflate@1.0.3", "", {}, "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw=="],
|
||||||
|
|
||||||
|
"tinyexec": ["tinyexec@1.0.2", "", {}, "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg=="],
|
||||||
|
|
||||||
|
"tslib": ["tslib@1.14.1", "", {}, "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="],
|
||||||
|
|
||||||
|
"type-fest": ["type-fest@5.4.4", "", { "dependencies": { "tagged-tag": "^1.0.0" } }, "sha512-JnTrzGu+zPV3aXIUhnyWJj4z/wigMsdYajGLIYakqyOW1nPllzXEJee0QQbHj+CTIQtXGlAjuK0UY+2xTyjVAw=="],
|
||||||
|
|
||||||
|
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
||||||
|
|
||||||
|
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
||||||
|
|
||||||
|
"unicode-properties": ["unicode-properties@1.4.1", "", { "dependencies": { "base64-js": "^1.3.0", "unicode-trie": "^2.0.0" } }, "sha512-CLjCCLQ6UuMxWnbIylkisbRj31qxHPAurvena/0iwSVbQ2G1VY5/HjV0IRabOEbDHlzZlRdCrD4NhB0JtU40Pg=="],
|
||||||
|
|
||||||
|
"unicode-trie": ["unicode-trie@2.0.0", "", { "dependencies": { "pako": "^0.2.5", "tiny-inflate": "^1.0.0" } }, "sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ=="],
|
||||||
|
|
||||||
|
"uuid": ["uuid@8.3.2", "", { "bin": { "uuid": "dist/bin/uuid" } }, "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="],
|
||||||
|
|
||||||
|
"valibot": ["valibot@1.2.0", "", { "peerDependencies": { "typescript": ">=5" }, "optionalPeers": ["typescript"] }, "sha512-mm1rxUsmOxzrwnX5arGS+U4T25RdvpPjPN4yR0u9pUBov9+zGVtO84tif1eY4r6zWxVxu3KzIyknJy3rxfRZZg=="],
|
||||||
|
|
||||||
|
"vary": ["vary@1.1.2", "", {}, "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="],
|
||||||
|
|
||||||
|
"which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="],
|
||||||
|
|
||||||
|
"ws": ["ws@8.18.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg=="],
|
||||||
|
|
||||||
|
"xmldoc": ["xmldoc@2.0.3", "", { "dependencies": { "sax": "^1.4.3" } }, "sha512-6gRk4NY/Jvg67xn7OzJuxLRsGgiXBaPUQplVJ/9l99uIugxh4FTOewYz5ic8WScj7Xx/2WvhENiQKwkK9RpE4w=="],
|
||||||
|
|
||||||
|
"xmlhttprequest-ssl": ["xmlhttprequest-ssl@2.1.2", "", {}, "sha512-TEU+nJVUUnA4CYJFLvK5X9AOeH4KvDvhIfm0vV1GaQRtchnG0hgK5p8hw/xjv8cunWYCsiPCSDzObPyhEwq3KQ=="],
|
||||||
|
|
||||||
|
"xtend": ["xtend@4.0.2", "", {}, "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="],
|
||||||
|
|
||||||
|
"zeptomatch": ["zeptomatch@2.1.0", "", { "dependencies": { "grammex": "^3.1.11", "graphmatch": "^1.1.0" } }, "sha512-KiGErG2J0G82LSpniV0CtIzjlJ10E04j02VOudJsPyPwNZgGnRKQy7I1R7GMyg/QswnE4l7ohSGrQbQbjXPPDA=="],
|
||||||
|
|
||||||
|
"zod": ["zod@4.3.6", "", {}, "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg=="],
|
||||||
|
|
||||||
|
"zon": ["zon@1.0.3", "", {}, "sha512-FKLlkaI8bU0ORFgZIzbqgvT7ei7aHob2jvhDPLgkwxccDurBRviDlD2eC2px6kEox0VlW0rK3VBwjsvtGV6g0w=="],
|
||||||
|
|
||||||
|
"@prisma/dev/hono": ["hono@4.11.4", "", {}, "sha512-U7tt8JsyrxSRKspfhtLET79pU8K+tInj5QZXs1jSugO1Vq5dFj3kmZsRldo29mTBfcjDRVRXrEZ6LS63Cog9ZA=="],
|
||||||
|
|
||||||
|
"@prisma/engines/@prisma/get-platform": ["@prisma/get-platform@7.3.0", "", { "dependencies": { "@prisma/debug": "7.3.0" } }, "sha512-N7c6m4/I0Q6JYmWKP2RCD/sM9eWiyCPY98g5c0uEktObNSZnugW2U/PO+pwL0UaqzxqTXt7gTsYsb0FnMnJNbg=="],
|
||||||
|
|
||||||
|
"@prisma/fetch-engine/@prisma/get-platform": ["@prisma/get-platform@7.3.0", "", { "dependencies": { "@prisma/debug": "7.3.0" } }, "sha512-N7c6m4/I0Q6JYmWKP2RCD/sM9eWiyCPY98g5c0uEktObNSZnugW2U/PO+pwL0UaqzxqTXt7gTsYsb0FnMnJNbg=="],
|
||||||
|
|
||||||
|
"@prisma/get-platform/@prisma/debug": ["@prisma/debug@7.2.0", "", {}, "sha512-YSGTiSlBAVJPzX4ONZmMotL+ozJwQjRmZweQNIq/ER0tQJKJynNkRB3kyvt37eOfsbMCXk3gnLF6J9OJ4QWftw=="],
|
||||||
|
|
||||||
|
"@swc/helpers/tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
||||||
|
|
||||||
|
"brotli/base64-js": ["base64-js@1.5.1", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="],
|
||||||
|
|
||||||
|
"nypm/citty": ["citty@0.2.0", "", {}, "sha512-8csy5IBFI2ex2hTVpaHN2j+LNE199AgiI7y4dMintrr8i0lQiFn+0AWMZrWdHKIgMOer65f8IThysYhoReqjWA=="],
|
||||||
|
|
||||||
|
"pg-boss/pg": ["pg@8.20.0", "", { "dependencies": { "pg-connection-string": "^2.12.0", "pg-pool": "^3.13.0", "pg-protocol": "^1.13.0", "pg-types": "2.2.0", "pgpass": "1.0.5" }, "optionalDependencies": { "pg-cloudflare": "^1.3.0" }, "peerDependencies": { "pg-native": ">=3.0.1" }, "optionalPeers": ["pg-native"] }, "sha512-ldhMxz2r8fl/6QkXnBD3CR9/xg694oT6DZQ2s6c/RI28OjtSOpxnPrUCGOBJ46RCUxcWdx3p6kw/xnDHjKvaRA=="],
|
||||||
|
|
||||||
|
"pg-types/postgres-array": ["postgres-array@2.0.0", "", {}, "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA=="],
|
||||||
|
|
||||||
|
"proper-lockfile/signal-exit": ["signal-exit@3.0.7", "", {}, "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="],
|
||||||
|
|
||||||
|
"unicode-properties/base64-js": ["base64-js@1.5.1", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="],
|
||||||
|
|
||||||
|
"unicode-trie/pako": ["pako@0.2.9", "", {}, "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA=="],
|
||||||
|
|
||||||
|
"pg-boss/pg/pg-connection-string": ["pg-connection-string@2.12.0", "", {}, "sha512-U7qg+bpswf3Cs5xLzRqbXbQl85ng0mfSV/J0nnA31MCLgvEaAo7CIhmeyrmJpOr7o+zm0rXK+hNnT5l9RHkCkQ=="],
|
||||||
|
|
||||||
|
"pg-boss/pg/pg-pool": ["pg-pool@3.13.0", "", { "peerDependencies": { "pg": ">=8.0" } }, "sha512-gB+R+Xud1gLFuRD/QgOIgGOBE2KCQPaPwkzBBGC9oG69pHTkhQeIuejVIk3/cnDyX39av2AxomQiyPT13WKHQA=="],
|
||||||
|
|
||||||
|
"pg-boss/pg/pg-protocol": ["pg-protocol@1.13.0", "", {}, "sha512-zzdvXfS6v89r6v7OcFCHfHlyG/wvry1ALxZo4LqgUoy7W9xhBDMaqOuMiF3qEV45VqsN6rdlcehHrfDtlCPc8w=="],
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[test]
|
||||||
|
preload = ["./tests/setup.ts"]
|
||||||
@@ -0,0 +1,307 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Analyze ConnectWise API call logs.
|
||||||
|
|
||||||
|
Looks for the most recent log file in cw-api-logs/ by default,
|
||||||
|
or accepts an explicit path as an argument.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python3 analyze-cw-calls.py # latest file in cw-api-logs/
|
||||||
|
python3 analyze-cw-calls.py cw-api-logs/specific.jsonl
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import glob
|
||||||
|
import statistics
|
||||||
|
from collections import Counter, defaultdict
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
# ── Colours ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
RED = "\033[91m"
|
||||||
|
GREEN = "\033[92m"
|
||||||
|
YELLOW = "\033[93m"
|
||||||
|
CYAN = "\033[96m"
|
||||||
|
BOLD = "\033[1m"
|
||||||
|
DIM = "\033[2m"
|
||||||
|
RESET = "\033[0m"
|
||||||
|
|
||||||
|
def colour_duration(ms: float) -> str:
|
||||||
|
if ms >= 10_000:
|
||||||
|
return f"{RED}{ms:,.0f}ms{RESET}"
|
||||||
|
if ms >= 5_000:
|
||||||
|
return f"{YELLOW}{ms:,.0f}ms{RESET}"
|
||||||
|
return f"{GREEN}{ms:,.0f}ms{RESET}"
|
||||||
|
|
||||||
|
def header(title: str) -> str:
|
||||||
|
return f"\n{BOLD}{CYAN}{'─' * 60}\n {title}\n{'─' * 60}{RESET}"
|
||||||
|
|
||||||
|
# ── Resolve log file ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
def find_latest_log() -> str:
|
||||||
|
"""Find the most recent .jsonl file in cw-api-logs/."""
|
||||||
|
log_dir = os.path.join(os.getcwd(), "cw-api-logs")
|
||||||
|
files = sorted(glob.glob(os.path.join(log_dir, "*.jsonl")))
|
||||||
|
if not files:
|
||||||
|
print(f"{RED}No log files found in cw-api-logs/{RESET}")
|
||||||
|
print(f"Run {BOLD}bun run dev:log{RESET} to start logging CW API calls.")
|
||||||
|
sys.exit(1)
|
||||||
|
return files[-1]
|
||||||
|
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
log_path = sys.argv[1]
|
||||||
|
else:
|
||||||
|
log_path = find_latest_log()
|
||||||
|
|
||||||
|
print(f"{DIM}Reading: {log_path}{RESET}")
|
||||||
|
|
||||||
|
entries = []
|
||||||
|
parse_errors = 0
|
||||||
|
with open(log_path) as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
entries.append(json.loads(line))
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
parse_errors += 1
|
||||||
|
|
||||||
|
if not entries:
|
||||||
|
print("No entries found. Check the log file path.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# ── Derived fields ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
durations = [e["durationMs"] for e in entries]
|
||||||
|
errors = [e for e in entries if e.get("error")]
|
||||||
|
successes = [e for e in entries if not e.get("error")]
|
||||||
|
timestamps = [datetime.fromisoformat(e["timestamp"].replace("Z", "+00:00")) for e in entries]
|
||||||
|
|
||||||
|
time_span = (timestamps[-1] - timestamps[0]) if len(timestamps) > 1 else timedelta(0)
|
||||||
|
|
||||||
|
# Normalise the URL to a route pattern for grouping
|
||||||
|
def normalise_url(url: str) -> str:
|
||||||
|
parts = url.split("?")[0].rstrip("/").split("/")
|
||||||
|
normalised = []
|
||||||
|
for p in parts:
|
||||||
|
if p.isdigit():
|
||||||
|
normalised.append(":id")
|
||||||
|
else:
|
||||||
|
normalised.append(p)
|
||||||
|
return "/".join(normalised)
|
||||||
|
|
||||||
|
# ── 1. Overview ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
print(header("OVERVIEW"))
|
||||||
|
print(f" Log file : {log_path}")
|
||||||
|
print(f" Total calls : {BOLD}{len(entries):,}{RESET}")
|
||||||
|
print(f" Successes : {GREEN}{len(successes):,}{RESET}")
|
||||||
|
print(f" Failures : {RED}{len(errors):,}{RESET} ({len(errors)/len(entries)*100:.1f}%)")
|
||||||
|
print(f" Time span : {time_span}")
|
||||||
|
if time_span.total_seconds() > 0:
|
||||||
|
rps = len(entries) / time_span.total_seconds()
|
||||||
|
print(f" Avg req/sec : {rps:.2f}")
|
||||||
|
if parse_errors:
|
||||||
|
print(f" Parse errors : {YELLOW}{parse_errors}{RESET}")
|
||||||
|
|
||||||
|
# ── 2. Duration stats ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
print(header("DURATION STATS (all calls)"))
|
||||||
|
sorted_dur = sorted(durations)
|
||||||
|
p50 = sorted_dur[len(sorted_dur) * 50 // 100]
|
||||||
|
p90 = sorted_dur[len(sorted_dur) * 90 // 100]
|
||||||
|
p95 = sorted_dur[len(sorted_dur) * 95 // 100]
|
||||||
|
p99 = sorted_dur[len(sorted_dur) * 99 // 100]
|
||||||
|
|
||||||
|
print(f" Min : {colour_duration(min(durations))}")
|
||||||
|
print(f" Max : {colour_duration(max(durations))}")
|
||||||
|
print(f" Mean : {colour_duration(statistics.mean(durations))}")
|
||||||
|
print(f" Median (p50) : {colour_duration(p50)}")
|
||||||
|
print(f" p90 : {colour_duration(p90)}")
|
||||||
|
print(f" p95 : {colour_duration(p95)}")
|
||||||
|
print(f" p99 : {colour_duration(p99)}")
|
||||||
|
print(f" Std dev : {statistics.stdev(durations):,.0f}ms" if len(durations) > 1 else "")
|
||||||
|
|
||||||
|
# Duration buckets
|
||||||
|
buckets = {"<500ms": 0, "500ms-1s": 0, "1-3s": 0, "3-5s": 0, "5-10s": 0, "10-20s": 0, "20s+": 0}
|
||||||
|
for d in durations:
|
||||||
|
if d < 500: buckets["<500ms"] += 1
|
||||||
|
elif d < 1000: buckets["500ms-1s"] += 1
|
||||||
|
elif d < 3000: buckets["1-3s"] += 1
|
||||||
|
elif d < 5000: buckets["3-5s"] += 1
|
||||||
|
elif d < 10000: buckets["5-10s"] += 1
|
||||||
|
elif d < 20000: buckets["10-20s"] += 1
|
||||||
|
else: buckets["20s+"] += 1
|
||||||
|
|
||||||
|
print(f"\n {BOLD}Distribution:{RESET}")
|
||||||
|
max_bar = 40
|
||||||
|
max_count = max(buckets.values()) if buckets else 1
|
||||||
|
for label, count in buckets.items():
|
||||||
|
bar_len = int(count / max_count * max_bar) if max_count else 0
|
||||||
|
pct = count / len(durations) * 100
|
||||||
|
bar = "█" * bar_len
|
||||||
|
clr = GREEN if "500" in label or "<" in label else (YELLOW if "1-3" in label or "3-5" in label else RED)
|
||||||
|
print(f" {label:>10s} {clr}{bar}{RESET} {count:>5,} ({pct:5.1f}%)")
|
||||||
|
|
||||||
|
# ── 3. Errors breakdown ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
print(header("ERROR BREAKDOWN"))
|
||||||
|
if not errors:
|
||||||
|
print(f" {GREEN}No errors! 🎉{RESET}")
|
||||||
|
else:
|
||||||
|
error_codes = Counter()
|
||||||
|
for e in errors:
|
||||||
|
err_str = e.get("error", "unknown")
|
||||||
|
code = err_str.split(":")[0] if ":" in err_str else err_str
|
||||||
|
error_codes[code] += 1
|
||||||
|
|
||||||
|
for code, count in error_codes.most_common():
|
||||||
|
print(f" {RED}{code:<30s}{RESET} {count:>5,} ({count/len(entries)*100:.1f}%)")
|
||||||
|
|
||||||
|
# Errored URLs
|
||||||
|
errored_urls = Counter(normalise_url(e["url"]) for e in errors)
|
||||||
|
print(f"\n {BOLD}Top errored endpoints:{RESET}")
|
||||||
|
for url, count in errored_urls.most_common(10):
|
||||||
|
print(f" {count:>5,} {url}")
|
||||||
|
|
||||||
|
# ── 4. Slowest individual calls ─────────────────────────────────────────────
|
||||||
|
|
||||||
|
print(header("TOP 20 SLOWEST CALLS"))
|
||||||
|
slowest = sorted(entries, key=lambda e: e["durationMs"], reverse=True)[:20]
|
||||||
|
for i, e in enumerate(slowest, 1):
|
||||||
|
status = e.get("status") or f"{RED}ERR{RESET}"
|
||||||
|
err_tag = f" {RED}[{e['error'].split(':')[0]}]{RESET}" if e.get("error") else ""
|
||||||
|
print(f" {i:>2}. {colour_duration(e['durationMs']):>20s} {e['method']:>4s} {e['url'][:60]:<60s} {DIM}{status}{RESET}{err_tag}")
|
||||||
|
|
||||||
|
# ── 5. Per-endpoint stats ───────────────────────────────────────────────────
|
||||||
|
|
||||||
|
print(header("PER-ENDPOINT STATS (by route pattern)"))
|
||||||
|
by_route = defaultdict(list)
|
||||||
|
for e in entries:
|
||||||
|
route = normalise_url(e["url"])
|
||||||
|
by_route[route].append(e)
|
||||||
|
|
||||||
|
# Sort by total time spent descending (most impactful)
|
||||||
|
route_stats = []
|
||||||
|
for route, calls in by_route.items():
|
||||||
|
durs = [c["durationMs"] for c in calls]
|
||||||
|
errs = sum(1 for c in calls if c.get("error"))
|
||||||
|
sorted_d = sorted(durs)
|
||||||
|
route_stats.append({
|
||||||
|
"route": route,
|
||||||
|
"count": len(calls),
|
||||||
|
"errors": errs,
|
||||||
|
"total_ms": sum(durs),
|
||||||
|
"mean": statistics.mean(durs),
|
||||||
|
"p50": sorted_d[len(sorted_d) * 50 // 100],
|
||||||
|
"p95": sorted_d[len(sorted_d) * 95 // 100],
|
||||||
|
"max": max(durs),
|
||||||
|
})
|
||||||
|
|
||||||
|
route_stats.sort(key=lambda r: r["total_ms"], reverse=True)
|
||||||
|
|
||||||
|
print(f" {'Route':<55s} {'Count':>6s} {'Errs':>5s} {'Mean':>8s} {'p50':>8s} {'p95':>8s} {'Max':>8s} {'Total':>10s}")
|
||||||
|
print(f" {'─' * 55} {'─' * 6} {'─' * 5} {'─' * 8} {'─' * 8} {'─' * 8} {'─' * 8} {'─' * 10}")
|
||||||
|
for r in route_stats[:25]:
|
||||||
|
err_str = f"{RED}{r['errors']}{RESET}" if r['errors'] else f"{DIM}0{RESET}"
|
||||||
|
print(
|
||||||
|
f" {r['route']:<55s} {r['count']:>6,} {err_str:>14s} "
|
||||||
|
f"{r['mean']:>7,.0f}ms {r['p50']:>7,.0f}ms {r['p95']:>7,.0f}ms "
|
||||||
|
f"{r['max']:>7,.0f}ms {r['total_ms']/1000:>8,.1f}s"
|
||||||
|
)
|
||||||
|
|
||||||
|
# ── 6. HTTP method breakdown ────────────────────────────────────────────────
|
||||||
|
|
||||||
|
print(header("BY HTTP METHOD"))
|
||||||
|
by_method = defaultdict(list)
|
||||||
|
for e in entries:
|
||||||
|
by_method[e["method"]].append(e["durationMs"])
|
||||||
|
|
||||||
|
print(f" {'Method':<8s} {'Count':>7s} {'Mean':>9s} {'p95':>9s} {'Max':>9s}")
|
||||||
|
print(f" {'─' * 8} {'─' * 7} {'─' * 9} {'─' * 9} {'─' * 9}")
|
||||||
|
for method in sorted(by_method.keys()):
|
||||||
|
durs = by_method[method]
|
||||||
|
sd = sorted(durs)
|
||||||
|
print(
|
||||||
|
f" {method:<8s} {len(durs):>7,} "
|
||||||
|
f"{statistics.mean(durs):>8,.0f}ms "
|
||||||
|
f"{sd[len(sd)*95//100]:>8,.0f}ms "
|
||||||
|
f"{max(durs):>8,.0f}ms"
|
||||||
|
)
|
||||||
|
|
||||||
|
# ── 7. Timeline (calls per minute) ──────────────────────────────────────────
|
||||||
|
|
||||||
|
if time_span.total_seconds() > 60:
|
||||||
|
print(header("TIMELINE (per-minute throughput & errors)"))
|
||||||
|
by_minute = defaultdict(lambda: {"count": 0, "errors": 0, "dur_sum": 0})
|
||||||
|
for e in entries:
|
||||||
|
ts = e["timestamp"][:16] # YYYY-MM-DDTHH:MM
|
||||||
|
by_minute[ts]["count"] += 1
|
||||||
|
by_minute[ts]["dur_sum"] += e["durationMs"]
|
||||||
|
if e.get("error"):
|
||||||
|
by_minute[ts]["errors"] += 1
|
||||||
|
|
||||||
|
for minute in sorted(by_minute.keys()):
|
||||||
|
m = by_minute[minute]
|
||||||
|
avg = m["dur_sum"] / m["count"] if m["count"] else 0
|
||||||
|
err_part = f" {RED}({m['errors']} errs){RESET}" if m["errors"] else ""
|
||||||
|
bar = "▓" * min(m["count"] // 5, 50)
|
||||||
|
avg_clr = colour_duration(avg)
|
||||||
|
print(f" {minute} {m['count']:>5,} reqs avg {avg_clr:>20s} {bar}{err_part}")
|
||||||
|
|
||||||
|
# ── 8. Concurrency hotspots ─────────────────────────────────────────────────
|
||||||
|
|
||||||
|
print(header("CONCURRENCY HOTSPOTS (calls starting within 100ms of each other)"))
|
||||||
|
ts_ms = [int(t.timestamp() * 1000) for t in timestamps]
|
||||||
|
bursts = []
|
||||||
|
i = 0
|
||||||
|
while i < len(ts_ms):
|
||||||
|
j = i
|
||||||
|
while j < len(ts_ms) - 1 and ts_ms[j + 1] - ts_ms[j] < 100:
|
||||||
|
j += 1
|
||||||
|
burst_size = j - i + 1
|
||||||
|
if burst_size >= 5:
|
||||||
|
burst_entries = entries[i:j + 1]
|
||||||
|
avg_dur = statistics.mean(e["durationMs"] for e in burst_entries)
|
||||||
|
bursts.append((burst_size, entries[i]["timestamp"], avg_dur, burst_entries))
|
||||||
|
i = j + 1
|
||||||
|
|
||||||
|
bursts.sort(key=lambda b: b[0], reverse=True)
|
||||||
|
if bursts:
|
||||||
|
print(f" Found {len(bursts)} burst(s) of ≥5 concurrent requests\n")
|
||||||
|
for size, ts, avg, _ in bursts[:10]:
|
||||||
|
print(f" {YELLOW}{size:>3} concurrent{RESET} at {ts} avg {colour_duration(avg)}")
|
||||||
|
else:
|
||||||
|
print(f" {GREEN}No major concurrency bursts detected.{RESET}")
|
||||||
|
|
||||||
|
# ── 9. Summary / recommendations ────────────────────────────────────────────
|
||||||
|
|
||||||
|
print(header("SUMMARY"))
|
||||||
|
err_rate = len(errors) / len(entries) * 100
|
||||||
|
slow_5s = sum(1 for d in durations if d >= 5000)
|
||||||
|
slow_pct = slow_5s / len(entries) * 100
|
||||||
|
|
||||||
|
if err_rate > 5:
|
||||||
|
print(f" {RED}⚠ Error rate is {err_rate:.1f}% — CW API is struggling{RESET}")
|
||||||
|
elif err_rate > 1:
|
||||||
|
print(f" {YELLOW}⚠ Error rate is {err_rate:.1f}% — some instability{RESET}")
|
||||||
|
else:
|
||||||
|
print(f" {GREEN}✓ Error rate is {err_rate:.1f}% — acceptable{RESET}")
|
||||||
|
|
||||||
|
if slow_pct > 10:
|
||||||
|
print(f" {RED}⚠ {slow_5s:,} calls ({slow_pct:.1f}%) took >5s — CW is slow or rate-limiting{RESET}")
|
||||||
|
elif slow_pct > 2:
|
||||||
|
print(f" {YELLOW}⚠ {slow_5s:,} calls ({slow_pct:.1f}%) took >5s{RESET}")
|
||||||
|
else:
|
||||||
|
print(f" {GREEN}✓ Only {slow_5s:,} calls ({slow_pct:.1f}%) over 5s{RESET}")
|
||||||
|
|
||||||
|
if bursts:
|
||||||
|
max_burst = max(b[0] for b in bursts)
|
||||||
|
print(f" {YELLOW}⚠ Max concurrency burst: {max_burst} simultaneous requests — consider lowering CONCURRENCY{RESET}")
|
||||||
|
|
||||||
|
total_time_s = sum(durations) / 1000
|
||||||
|
print(f"\n Total wall-clock time spent waiting on CW: {BOLD}{total_time_s:,.1f}s{RESET} ({total_time_s/60:,.1f} min)")
|
||||||
|
print()
|
||||||
@@ -0,0 +1,441 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
from collections import Counter, defaultdict
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
|
def parse_iso(value: str | None) -> datetime | None:
|
||||||
|
if not value:
|
||||||
|
return None
|
||||||
|
normalized = value.replace("Z", "+00:00")
|
||||||
|
try:
|
||||||
|
return datetime.fromisoformat(normalized)
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def first_non_empty(*values: Any) -> str:
|
||||||
|
for value in values:
|
||||||
|
if value is None:
|
||||||
|
continue
|
||||||
|
if isinstance(value, str) and value.strip() == "":
|
||||||
|
continue
|
||||||
|
return str(value)
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
|
|
||||||
|
def top_lines(counter: Counter[str], limit: int) -> list[str]:
|
||||||
|
return [f"{k}: {v}" for k, v in counter.most_common(limit)]
|
||||||
|
|
||||||
|
|
||||||
|
def fmt_pct(part: int, total: int) -> str:
|
||||||
|
if total == 0:
|
||||||
|
return "0.0%"
|
||||||
|
return f"{(part / total) * 100:.1f}%"
|
||||||
|
|
||||||
|
|
||||||
|
def human_duration(start: datetime | None, end: datetime | None) -> str:
|
||||||
|
if start is None or end is None:
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
|
delta = end - start
|
||||||
|
total_seconds = int(delta.total_seconds())
|
||||||
|
hours, remainder = divmod(total_seconds, 3600)
|
||||||
|
minutes, seconds = divmod(remainder, 60)
|
||||||
|
return f"{hours}h {minutes}m {seconds}s"
|
||||||
|
|
||||||
|
|
||||||
|
def truncate(value: str, max_len: int = 90) -> str:
|
||||||
|
if len(value) <= max_len:
|
||||||
|
return value
|
||||||
|
return value[: max_len - 1] + "…"
|
||||||
|
|
||||||
|
|
||||||
|
def add_section(lines: list[str], title: str) -> None:
|
||||||
|
lines.append("")
|
||||||
|
lines.append(title)
|
||||||
|
lines.append("-" * len(title))
|
||||||
|
|
||||||
|
|
||||||
|
def supports_color(enabled: bool) -> bool:
|
||||||
|
return enabled
|
||||||
|
|
||||||
|
|
||||||
|
def paint(text: str, code: str, use_color: bool) -> str:
|
||||||
|
if not use_color:
|
||||||
|
return text
|
||||||
|
return f"\033[{code}m{text}\033[0m"
|
||||||
|
|
||||||
|
|
||||||
|
def good_bad_neutral(value: str, state: str, use_color: bool) -> str:
|
||||||
|
if state == "good":
|
||||||
|
return paint(value, "32", use_color)
|
||||||
|
if state == "bad":
|
||||||
|
return paint(value, "31", use_color)
|
||||||
|
return paint(value, "36", use_color)
|
||||||
|
|
||||||
|
|
||||||
|
def add_ranked_counter(
|
||||||
|
lines: list[str],
|
||||||
|
title: str,
|
||||||
|
counter: Counter[str],
|
||||||
|
top_n: int,
|
||||||
|
total: int,
|
||||||
|
truncate_labels: bool = False,
|
||||||
|
) -> None:
|
||||||
|
lines.append(f"• {title}")
|
||||||
|
items = counter.most_common(top_n)
|
||||||
|
if not items:
|
||||||
|
lines.append(" (no data)")
|
||||||
|
return
|
||||||
|
|
||||||
|
for index, (key, count) in enumerate(items, start=1):
|
||||||
|
label = truncate(key) if truncate_labels else key
|
||||||
|
lines.append(f" {index:>2}. {label:<90} {count:>4} {fmt_pct(count, total):>6}")
|
||||||
|
|
||||||
|
|
||||||
|
def stream_row_summary(row: dict[str, Any], use_color: bool, max_path: int) -> str:
|
||||||
|
request = row.get("request") or {}
|
||||||
|
response = row.get("response") or {}
|
||||||
|
body_parsed = request.get("bodyParsed") or {}
|
||||||
|
entity_parsed = request.get("entityParsed") or {}
|
||||||
|
summary = request.get("summary") or {}
|
||||||
|
|
||||||
|
timestamp = parse_iso(row.get("timestamp"))
|
||||||
|
time_label = timestamp.astimezone(timezone.utc).strftime("%H:%M:%S") if timestamp else "--:--:--"
|
||||||
|
|
||||||
|
method = first_non_empty(request.get("method"))
|
||||||
|
path = first_non_empty(request.get("path"))
|
||||||
|
endpoint = path.split("?", 1)[0]
|
||||||
|
status_code = first_non_empty(response.get("status"))
|
||||||
|
|
||||||
|
event_type = first_non_empty(body_parsed.get("Type"), summary.get("type"))
|
||||||
|
action = first_non_empty(
|
||||||
|
body_parsed.get("Action"),
|
||||||
|
summary.get("action"),
|
||||||
|
request.get("query", {}).get("params", {}).get("action"),
|
||||||
|
)
|
||||||
|
item_id = first_non_empty(body_parsed.get("ID"), summary.get("id"), request.get("query", {}).get("inferredId"))
|
||||||
|
actor = first_non_empty(
|
||||||
|
request.get("query", {}).get("params", {}).get("memberId"),
|
||||||
|
summary.get("entityUpdatedBy"),
|
||||||
|
entity_parsed.get("UpdatedBy"),
|
||||||
|
)
|
||||||
|
entity_status = first_non_empty(entity_parsed.get("StatusName"), summary.get("entityStatus"))
|
||||||
|
|
||||||
|
endpoint_label = truncate(endpoint, max_path)
|
||||||
|
status_state = "good" if status_code.startswith("2") else "bad"
|
||||||
|
status_colored = good_bad_neutral(status_code, status_state, use_color)
|
||||||
|
event_colored = paint(f"{event_type}.{action}", "36", use_color)
|
||||||
|
endpoint_colored = paint(endpoint_label, "94", use_color)
|
||||||
|
|
||||||
|
return (
|
||||||
|
f"[{time_label}] {method:<4} {endpoint_colored:<20} "
|
||||||
|
f"{status_colored:>3} {event_colored:<22} "
|
||||||
|
f"id={item_id:<7} actor={truncate(actor, 16):<16} status={truncate(entity_status, 22)}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def endpoint_stream_summary(log_path: Path, use_color: bool, max_path: int) -> str:
|
||||||
|
lines: list[str] = []
|
||||||
|
lines.append(paint("ENDPOINT STREAM (chronological)", "1;95", use_color))
|
||||||
|
lines.append(paint("────────────────────────────────────────────────────────────────────────────────────────────", "90", use_color))
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
invalid = 0
|
||||||
|
with log_path.open("r", encoding="utf-8") as handle:
|
||||||
|
for raw_line in handle:
|
||||||
|
line = raw_line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
row = json.loads(line)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
invalid += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
lines.append(stream_row_summary(row, use_color=use_color, max_path=max_path))
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
lines.append(paint("────────────────────────────────────────────────────────────────────────────────────────────", "90", use_color))
|
||||||
|
lines.append(
|
||||||
|
f"events={count} invalid={good_bad_neutral(str(invalid), 'good' if invalid == 0 else 'bad', use_color)}"
|
||||||
|
)
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class LogStats:
|
||||||
|
total_rows: int = 0
|
||||||
|
parsed_rows: int = 0
|
||||||
|
invalid_rows: int = 0
|
||||||
|
earliest: datetime | None = None
|
||||||
|
latest: datetime | None = None
|
||||||
|
|
||||||
|
methods: Counter[str] = None # type: ignore[assignment]
|
||||||
|
paths: Counter[str] = None # type: ignore[assignment]
|
||||||
|
endpoint_roots: Counter[str] = None # type: ignore[assignment]
|
||||||
|
response_statuses: Counter[str] = None # type: ignore[assignment]
|
||||||
|
event_types: Counter[str] = None # type: ignore[assignment]
|
||||||
|
actions: Counter[str] = None # type: ignore[assignment]
|
||||||
|
type_action_combo: Counter[str] = None # type: ignore[assignment]
|
||||||
|
company_ids: Counter[str] = None # type: ignore[assignment]
|
||||||
|
|
||||||
|
source_members: Counter[str] = None # type: ignore[assignment]
|
||||||
|
actor_members: Counter[str] = None # type: ignore[assignment]
|
||||||
|
entity_updated_by: Counter[str] = None # type: ignore[assignment]
|
||||||
|
|
||||||
|
requests_by_hour: Counter[str] = None # type: ignore[assignment]
|
||||||
|
requests_by_minute: Counter[str] = None # type: ignore[assignment]
|
||||||
|
endpoint_by_hour: dict[str, Counter[str]] = None # type: ignore[assignment]
|
||||||
|
|
||||||
|
def __post_init__(self) -> None:
|
||||||
|
self.methods = Counter()
|
||||||
|
self.paths = Counter()
|
||||||
|
self.endpoint_roots = Counter()
|
||||||
|
self.response_statuses = Counter()
|
||||||
|
self.event_types = Counter()
|
||||||
|
self.actions = Counter()
|
||||||
|
self.type_action_combo = Counter()
|
||||||
|
self.company_ids = Counter()
|
||||||
|
|
||||||
|
self.source_members = Counter()
|
||||||
|
self.actor_members = Counter()
|
||||||
|
self.entity_updated_by = Counter()
|
||||||
|
|
||||||
|
self.requests_by_hour = Counter()
|
||||||
|
self.requests_by_minute = Counter()
|
||||||
|
self.endpoint_by_hour = defaultdict(Counter)
|
||||||
|
|
||||||
|
def add_timestamp(self, timestamp: datetime | None) -> None:
|
||||||
|
if timestamp is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.earliest = timestamp if self.earliest is None else min(self.earliest, timestamp)
|
||||||
|
self.latest = timestamp if self.latest is None else max(self.latest, timestamp)
|
||||||
|
|
||||||
|
hour_bucket = timestamp.astimezone(timezone.utc).strftime("%Y-%m-%d %H:00 UTC")
|
||||||
|
minute_bucket = timestamp.astimezone(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
|
||||||
|
self.requests_by_hour[hour_bucket] += 1
|
||||||
|
self.requests_by_minute[minute_bucket] += 1
|
||||||
|
|
||||||
|
def summarize(self, top_n: int, busiest_n: int, use_color: bool) -> str:
|
||||||
|
duration_line = human_duration(self.earliest, self.latest)
|
||||||
|
time_range_line = "unknown"
|
||||||
|
if self.earliest and self.latest:
|
||||||
|
time_range_line = f"{self.earliest.isoformat()} → {self.latest.isoformat()}"
|
||||||
|
|
||||||
|
total_requests = self.parsed_rows
|
||||||
|
success_count = self.response_statuses.get("200", 0)
|
||||||
|
success_pct = fmt_pct(success_count, sum(self.response_statuses.values()))
|
||||||
|
invalid_state = "good" if self.invalid_rows == 0 else "bad"
|
||||||
|
|
||||||
|
top_endpoints = self.endpoint_roots.most_common(2)
|
||||||
|
top_users = self.actor_members.most_common(3)
|
||||||
|
top_minutes = self.requests_by_minute.most_common(busiest_n)
|
||||||
|
|
||||||
|
lines: list[str] = []
|
||||||
|
lines.append(paint("WEBHOOK SNAPSHOT", "1;95", use_color))
|
||||||
|
lines.append(paint("────────────────────────────────────────────────────────", "90", use_color))
|
||||||
|
lines.append(
|
||||||
|
" "
|
||||||
|
+ paint("Rows", "1;97", use_color)
|
||||||
|
+ f": {self.total_rows:<4} "
|
||||||
|
+ paint("Parsed", "1;97", use_color)
|
||||||
|
+ f": {self.parsed_rows:<4} "
|
||||||
|
+ paint("Invalid", "1;97", use_color)
|
||||||
|
+ f": {good_bad_neutral(str(self.invalid_rows), invalid_state, use_color)}"
|
||||||
|
)
|
||||||
|
lines.append(
|
||||||
|
" "
|
||||||
|
+ paint("Window", "1;97", use_color)
|
||||||
|
+ f": {duration_line:<12} "
|
||||||
|
+ paint("Success", "1;97", use_color)
|
||||||
|
+ f": {good_bad_neutral(success_pct, 'good' if success_count else 'neutral', use_color)}"
|
||||||
|
)
|
||||||
|
lines.append(" " + paint("UTC Range", "1;97", use_color) + f": {time_range_line}")
|
||||||
|
|
||||||
|
lines.append("")
|
||||||
|
lines.append(paint("Top Endpoints", "1;94", use_color))
|
||||||
|
if top_endpoints:
|
||||||
|
for endpoint, count in top_endpoints:
|
||||||
|
lines.append(f" • {endpoint:<14} {count:>4} ({fmt_pct(count, total_requests)})")
|
||||||
|
if not top_endpoints:
|
||||||
|
lines.append(" • (no data)")
|
||||||
|
|
||||||
|
lines.append("")
|
||||||
|
lines.append(paint("Most Active Users (query memberId)", "1;94", use_color))
|
||||||
|
if top_users:
|
||||||
|
for user, count in top_users:
|
||||||
|
lines.append(f" • {user:<18} {count:>4} ({fmt_pct(count, total_requests)})")
|
||||||
|
if not top_users:
|
||||||
|
lines.append(" • (no data)")
|
||||||
|
|
||||||
|
lines.append("")
|
||||||
|
lines.append(paint("Busiest Minutes", "1;94", use_color))
|
||||||
|
if top_minutes:
|
||||||
|
for minute, count in top_minutes:
|
||||||
|
lines.append(f" • {minute:<22} {count:>3}")
|
||||||
|
if not top_minutes:
|
||||||
|
lines.append(" • (no data)")
|
||||||
|
|
||||||
|
lines.append("")
|
||||||
|
lines.append(paint("Request Mix", "1;94", use_color))
|
||||||
|
method_line = ", ".join([f"{k}:{v}" for k, v in self.methods.most_common(3)]) or "(no data)"
|
||||||
|
event_line = ", ".join([f"{k}:{v}" for k, v in self.event_types.most_common(3)]) or "(no data)"
|
||||||
|
action_line = ", ".join([f"{k}:{v}" for k, v in self.actions.most_common(3)]) or "(no data)"
|
||||||
|
lines.append(f" • Methods : {method_line}")
|
||||||
|
lines.append(f" • Types : {event_line}")
|
||||||
|
lines.append(f" • Actions : {action_line}")
|
||||||
|
|
||||||
|
lines.append("")
|
||||||
|
lines.append(paint("Status Codes", "1;94", use_color))
|
||||||
|
if self.response_statuses:
|
||||||
|
status_total = sum(self.response_statuses.values())
|
||||||
|
for status, count in self.response_statuses.most_common(5):
|
||||||
|
state = "good" if status.startswith("2") else "bad"
|
||||||
|
status_label = good_bad_neutral(status, state, use_color)
|
||||||
|
lines.append(f" • {status_label}: {count} ({fmt_pct(count, status_total)})")
|
||||||
|
if not self.response_statuses:
|
||||||
|
lines.append(" • (no data)")
|
||||||
|
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def update_stats(stats: LogStats, row: dict[str, Any]) -> None:
|
||||||
|
timestamp = parse_iso(row.get("timestamp"))
|
||||||
|
stats.add_timestamp(timestamp)
|
||||||
|
|
||||||
|
request = row.get("request") or {}
|
||||||
|
response = row.get("response") or {}
|
||||||
|
body_parsed = request.get("bodyParsed") or {}
|
||||||
|
entity_parsed = request.get("entityParsed") or {}
|
||||||
|
|
||||||
|
method = first_non_empty(request.get("method"))
|
||||||
|
path = first_non_empty(request.get("path"))
|
||||||
|
endpoint_root = path.split("?", 1)[0]
|
||||||
|
status = first_non_empty(response.get("status"))
|
||||||
|
|
||||||
|
event_type = first_non_empty(
|
||||||
|
body_parsed.get("Type"),
|
||||||
|
request.get("summary", {}).get("type"),
|
||||||
|
)
|
||||||
|
action = first_non_empty(
|
||||||
|
body_parsed.get("Action"),
|
||||||
|
request.get("summary", {}).get("action"),
|
||||||
|
request.get("query", {}).get("params", {}).get("action"),
|
||||||
|
)
|
||||||
|
combo = f"{event_type}:{action}"
|
||||||
|
|
||||||
|
source_member = first_non_empty(
|
||||||
|
body_parsed.get("MemberId"),
|
||||||
|
request.get("summary", {}).get("memberId"),
|
||||||
|
)
|
||||||
|
actor_member = first_non_empty(
|
||||||
|
request.get("query", {}).get("params", {}).get("memberId"),
|
||||||
|
request.get("summary", {}).get("entityUpdatedBy"),
|
||||||
|
)
|
||||||
|
updated_by = first_non_empty(
|
||||||
|
entity_parsed.get("UpdatedBy"),
|
||||||
|
request.get("summary", {}).get("entityUpdatedBy"),
|
||||||
|
)
|
||||||
|
company_id = first_non_empty(body_parsed.get("CompanyId"), request.get("headers", {}).get("companyname"))
|
||||||
|
|
||||||
|
stats.methods[method] += 1
|
||||||
|
stats.paths[path] += 1
|
||||||
|
stats.endpoint_roots[endpoint_root] += 1
|
||||||
|
stats.response_statuses[status] += 1
|
||||||
|
stats.event_types[event_type] += 1
|
||||||
|
stats.actions[action] += 1
|
||||||
|
stats.type_action_combo[combo] += 1
|
||||||
|
stats.company_ids[company_id] += 1
|
||||||
|
|
||||||
|
stats.source_members[source_member] += 1
|
||||||
|
stats.actor_members[actor_member] += 1
|
||||||
|
stats.entity_updated_by[updated_by] += 1
|
||||||
|
|
||||||
|
if timestamp:
|
||||||
|
bucket = timestamp.astimezone(timezone.utc).strftime("%Y-%m-%d %H:00 UTC")
|
||||||
|
stats.endpoint_by_hour[endpoint_root][bucket] += 1
|
||||||
|
|
||||||
|
|
||||||
|
def analyze_file(log_path: Path) -> LogStats:
|
||||||
|
stats = LogStats()
|
||||||
|
|
||||||
|
with log_path.open("r", encoding="utf-8") as handle:
|
||||||
|
for raw_line in handle:
|
||||||
|
line = raw_line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
|
||||||
|
stats.total_rows += 1
|
||||||
|
try:
|
||||||
|
row = json.loads(line)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
stats.invalid_rows += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
stats.parsed_rows += 1
|
||||||
|
update_stats(stats, row)
|
||||||
|
|
||||||
|
return stats
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Analyze webhook JSONL logs by users, time, and request types."
|
||||||
|
)
|
||||||
|
parser.add_argument("log_file", help="Path to JSONL log file")
|
||||||
|
parser.add_argument("--top", type=int, default=10, help="Top N entries per section (default: 10)")
|
||||||
|
parser.add_argument(
|
||||||
|
"--busiest-minutes",
|
||||||
|
type=int,
|
||||||
|
default=5,
|
||||||
|
help="How many top minute buckets to show (default: 5)",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--no-color",
|
||||||
|
action="store_true",
|
||||||
|
help="Disable ANSI colors",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--endpoint-stream",
|
||||||
|
action="store_true",
|
||||||
|
help="Show chronological one-line summary per webhook, similar to live test webserver logs",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--max-path",
|
||||||
|
type=int,
|
||||||
|
default=18,
|
||||||
|
help="Max endpoint width in stream mode before truncation (default: 18)",
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
log_path = Path(args.log_file)
|
||||||
|
if not log_path.exists() or not log_path.is_file():
|
||||||
|
raise SystemExit(f"Log file not found: {log_path}")
|
||||||
|
|
||||||
|
use_color = supports_color(not args.no_color)
|
||||||
|
|
||||||
|
if args.endpoint_stream:
|
||||||
|
print(endpoint_stream_summary(log_path, use_color=use_color, max_path=max(args.max_path, 10)))
|
||||||
|
return
|
||||||
|
|
||||||
|
stats = analyze_file(log_path)
|
||||||
|
print(
|
||||||
|
stats.summarize(
|
||||||
|
top_n=max(args.top, 1),
|
||||||
|
busiest_n=max(args.busiest_minutes, 1),
|
||||||
|
use_color=use_color,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,900 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Generate a print-friendly PDF report from the latest test-webserver log file.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python3 generate_log_report.py [optional_log_file_path]
|
||||||
|
|
||||||
|
If no path is given, the script finds the latest test-webserver-*.jsonl
|
||||||
|
file in ../cw-api-logs/.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import glob
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
from collections import Counter, defaultdict
|
||||||
|
|
||||||
|
from reportlab.lib import colors
|
||||||
|
from reportlab.lib.pagesizes import LETTER
|
||||||
|
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
||||||
|
from reportlab.lib.units import inch
|
||||||
|
from reportlab.lib.enums import TA_CENTER, TA_LEFT
|
||||||
|
from reportlab.platypus import (
|
||||||
|
SimpleDocTemplate,
|
||||||
|
Paragraph,
|
||||||
|
Spacer,
|
||||||
|
Table,
|
||||||
|
TableStyle,
|
||||||
|
PageBreak,
|
||||||
|
HRFlowable,
|
||||||
|
KeepTogether,
|
||||||
|
)
|
||||||
|
from reportlab.graphics.shapes import Drawing, String
|
||||||
|
from reportlab.graphics.charts.piecharts import Pie
|
||||||
|
from reportlab.graphics.charts.barcharts import VerticalBarChart
|
||||||
|
|
||||||
|
# ─── Print-friendly color palette ─────────────────────────────────────────────
|
||||||
|
# Minimal ink: white backgrounds, thin borders, dark text, subtle accents
|
||||||
|
HEADER_BG = colors.HexColor("#2c3e50") # Dark header (used sparingly)
|
||||||
|
ACCENT = colors.HexColor("#2980b9") # Muted blue
|
||||||
|
ACCENT_2 = colors.HexColor("#27ae60") # Muted green
|
||||||
|
ACCENT_3 = colors.HexColor("#8e44ad") # Muted purple
|
||||||
|
WHITE = colors.white
|
||||||
|
GRAY_50 = colors.HexColor("#fafafa")
|
||||||
|
GRAY_100 = colors.HexColor("#f5f5f5")
|
||||||
|
GRAY_200 = colors.HexColor("#e0e0e0")
|
||||||
|
GRAY_400 = colors.HexColor("#bdbdbd")
|
||||||
|
GRAY_600 = colors.HexColor("#757575")
|
||||||
|
GRAY_800 = colors.HexColor("#424242")
|
||||||
|
GRAY_900 = colors.HexColor("#212121")
|
||||||
|
|
||||||
|
# Pie/chart fills — muted, distinguishable in B&W too
|
||||||
|
PIE_COLORS = [
|
||||||
|
colors.HexColor("#5b9bd5"), # steel blue
|
||||||
|
colors.HexColor("#ed7d31"), # soft orange
|
||||||
|
colors.HexColor("#a5a5a5"), # gray
|
||||||
|
colors.HexColor("#ffc000"), # amber
|
||||||
|
colors.HexColor("#70ad47"), # olive green
|
||||||
|
colors.HexColor("#4472c4"), # darker blue
|
||||||
|
colors.HexColor("#c55a11"), # brown
|
||||||
|
colors.HexColor("#7030a0"), # purple
|
||||||
|
]
|
||||||
|
|
||||||
|
# ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
def find_latest_log(base_dir):
|
||||||
|
pattern = os.path.join(base_dir, "test-webserver-*.jsonl")
|
||||||
|
files = sorted(glob.glob(pattern))
|
||||||
|
if not files:
|
||||||
|
raise FileNotFoundError(f"No test-webserver log files found in {base_dir}")
|
||||||
|
return files[-1]
|
||||||
|
|
||||||
|
|
||||||
|
def parse_log(path):
|
||||||
|
entries = []
|
||||||
|
with open(path, "r") as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
entries.append(json.loads(line))
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
continue
|
||||||
|
return entries
|
||||||
|
|
||||||
|
|
||||||
|
def fmt_ts(iso_str):
|
||||||
|
try:
|
||||||
|
dt = datetime.fromisoformat(iso_str.replace("Z", "+00:00"))
|
||||||
|
return dt.strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||||
|
except Exception:
|
||||||
|
return str(iso_str)
|
||||||
|
|
||||||
|
|
||||||
|
def duration_str(seconds):
|
||||||
|
if seconds < 60:
|
||||||
|
return f"{seconds:.1f}s"
|
||||||
|
minutes = seconds / 60
|
||||||
|
if minutes < 60:
|
||||||
|
return f"{minutes:.1f}m"
|
||||||
|
hours = minutes / 60
|
||||||
|
return f"{hours:.1f}h"
|
||||||
|
|
||||||
|
|
||||||
|
def truncate(s, max_len=50):
|
||||||
|
s = str(s)
|
||||||
|
return s if len(s) <= max_len else s[: max_len - 3] + "..."
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_actor(entry):
|
||||||
|
"""
|
||||||
|
Derive the actor exactly like testWebserver.ts does:
|
||||||
|
entityUpdatedBy ?? query.params.memberId ?? summary.memberId ?? "-"
|
||||||
|
The summary is already stored in request.summary in the log.
|
||||||
|
"""
|
||||||
|
req = entry.get("request", {})
|
||||||
|
summary = req.get("summary") or {}
|
||||||
|
query = req.get("query") or {}
|
||||||
|
params = query.get("params") or {}
|
||||||
|
|
||||||
|
return str(
|
||||||
|
summary.get("entityUpdatedBy")
|
||||||
|
or params.get("memberId")
|
||||||
|
or summary.get("memberId")
|
||||||
|
or "-"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ─── Analysis ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
def analyze(entries):
|
||||||
|
stats = {}
|
||||||
|
|
||||||
|
timestamps = []
|
||||||
|
for e in entries:
|
||||||
|
ts = e.get("timestamp")
|
||||||
|
if ts:
|
||||||
|
try:
|
||||||
|
timestamps.append(datetime.fromisoformat(ts.replace("Z", "+00:00")))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
timestamps.sort()
|
||||||
|
stats["total_entries"] = len(entries)
|
||||||
|
stats["first_ts"] = timestamps[0] if timestamps else None
|
||||||
|
stats["last_ts"] = timestamps[-1] if timestamps else None
|
||||||
|
stats["duration_seconds"] = (
|
||||||
|
(timestamps[-1] - timestamps[0]).total_seconds() if len(timestamps) >= 2 else 0
|
||||||
|
)
|
||||||
|
|
||||||
|
# Global counters
|
||||||
|
methods = Counter()
|
||||||
|
paths = Counter()
|
||||||
|
statuses = Counter()
|
||||||
|
actions = Counter()
|
||||||
|
types = Counter()
|
||||||
|
actors = Counter()
|
||||||
|
companies = Counter()
|
||||||
|
entity_ids = set()
|
||||||
|
stages = Counter()
|
||||||
|
ratings = Counter()
|
||||||
|
hourly_buckets = Counter()
|
||||||
|
minute_buckets = Counter()
|
||||||
|
|
||||||
|
for e in entries:
|
||||||
|
req = e.get("request", {})
|
||||||
|
resp = e.get("response", {})
|
||||||
|
bp = req.get("bodyParsed") or {}
|
||||||
|
entity = req.get("entityParsed") or bp.get("Entity") or {}
|
||||||
|
|
||||||
|
methods[req.get("method", "?")] += 1
|
||||||
|
raw_path = req.get("path", "?").split("?")[0]
|
||||||
|
paths[raw_path] += 1
|
||||||
|
statuses[resp.get("status", "?")] += 1
|
||||||
|
actions[bp.get("Action", "?")] += 1
|
||||||
|
types[bp.get("Type", "?")] += 1
|
||||||
|
|
||||||
|
actor = resolve_actor(e)
|
||||||
|
actors[actor] += 1
|
||||||
|
|
||||||
|
if isinstance(entity, dict):
|
||||||
|
cn = entity.get("CompanyName")
|
||||||
|
if cn:
|
||||||
|
companies[cn] += 1
|
||||||
|
eid = entity.get("Id")
|
||||||
|
if eid is not None:
|
||||||
|
entity_ids.add(eid)
|
||||||
|
stage = entity.get("StageName")
|
||||||
|
if stage:
|
||||||
|
stages[stage] += 1
|
||||||
|
rating = entity.get("Rating")
|
||||||
|
if rating:
|
||||||
|
ratings[rating] += 1
|
||||||
|
|
||||||
|
ts_str = e.get("timestamp")
|
||||||
|
if ts_str:
|
||||||
|
try:
|
||||||
|
dt = datetime.fromisoformat(ts_str.replace("Z", "+00:00"))
|
||||||
|
hourly_buckets[dt.strftime("%H:00")] += 1
|
||||||
|
minute_buckets[dt.strftime("%H:%M")] += 1
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# ── Per-actor deep stats ──
|
||||||
|
actor_details = defaultdict(lambda: {
|
||||||
|
"count": 0,
|
||||||
|
"actions": Counter(),
|
||||||
|
"types": Counter(),
|
||||||
|
"companies": Counter(),
|
||||||
|
"entity_ids": set(),
|
||||||
|
"stages": Counter(),
|
||||||
|
"ratings": Counter(),
|
||||||
|
"timestamps": [],
|
||||||
|
"statuses": Counter(),
|
||||||
|
"paths": Counter(),
|
||||||
|
"member_ids": Counter(),
|
||||||
|
"sales_reps": Counter(),
|
||||||
|
"total_estimated": 0.0,
|
||||||
|
})
|
||||||
|
|
||||||
|
for e in entries:
|
||||||
|
req = e.get("request", {})
|
||||||
|
resp = e.get("response", {})
|
||||||
|
bp = req.get("bodyParsed") or {}
|
||||||
|
entity = req.get("entityParsed") or bp.get("Entity") or {}
|
||||||
|
summary = req.get("summary") or {}
|
||||||
|
|
||||||
|
actor = resolve_actor(e)
|
||||||
|
ad = actor_details[actor]
|
||||||
|
ad["count"] += 1
|
||||||
|
ad["actions"][bp.get("Action", "?")] += 1
|
||||||
|
ad["types"][bp.get("Type", "?")] += 1
|
||||||
|
ad["statuses"][resp.get("status", "?")] += 1
|
||||||
|
raw_path = req.get("path", "?").split("?")[0]
|
||||||
|
ad["paths"][raw_path] += 1
|
||||||
|
|
||||||
|
# Track which MemberIds triggered callbacks for this actor
|
||||||
|
mid = bp.get("MemberId")
|
||||||
|
if mid:
|
||||||
|
ad["member_ids"][mid] += 1
|
||||||
|
|
||||||
|
ts_str = e.get("timestamp")
|
||||||
|
if ts_str:
|
||||||
|
try:
|
||||||
|
ad["timestamps"].append(datetime.fromisoformat(ts_str.replace("Z", "+00:00")))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if isinstance(entity, dict):
|
||||||
|
cn = entity.get("CompanyName")
|
||||||
|
if cn:
|
||||||
|
ad["companies"][cn] += 1
|
||||||
|
eid = entity.get("Id")
|
||||||
|
if eid is not None:
|
||||||
|
ad["entity_ids"].add(eid)
|
||||||
|
stage = entity.get("StageName")
|
||||||
|
if stage:
|
||||||
|
ad["stages"][stage] += 1
|
||||||
|
rating = entity.get("Rating")
|
||||||
|
if rating:
|
||||||
|
ad["ratings"][rating] += 1
|
||||||
|
et = entity.get("EstimatedTotal")
|
||||||
|
if et is not None:
|
||||||
|
ad["total_estimated"] += float(et)
|
||||||
|
pr = entity.get("PrimarySalesRep")
|
||||||
|
if pr:
|
||||||
|
ad["sales_reps"][pr] += 1
|
||||||
|
|
||||||
|
# Compute per-actor derived stats
|
||||||
|
for aid, ad in actor_details.items():
|
||||||
|
ad["timestamps"].sort()
|
||||||
|
if len(ad["timestamps"]) >= 2:
|
||||||
|
dur = (ad["timestamps"][-1] - ad["timestamps"][0]).total_seconds()
|
||||||
|
ad["duration_seconds"] = dur
|
||||||
|
ad["events_per_minute"] = ad["count"] / (dur / 60) if dur > 0 else ad["count"]
|
||||||
|
else:
|
||||||
|
ad["duration_seconds"] = 0
|
||||||
|
ad["events_per_minute"] = ad["count"]
|
||||||
|
ad["first_ts"] = ad["timestamps"][0] if ad["timestamps"] else None
|
||||||
|
ad["last_ts"] = ad["timestamps"][-1] if ad["timestamps"] else None
|
||||||
|
|
||||||
|
stats["actor_details"] = dict(actor_details)
|
||||||
|
stats["methods"] = methods
|
||||||
|
stats["paths"] = paths
|
||||||
|
stats["statuses"] = statuses
|
||||||
|
stats["actions"] = actions
|
||||||
|
stats["types"] = types
|
||||||
|
stats["actors"] = actors
|
||||||
|
stats["companies"] = companies
|
||||||
|
stats["entity_ids"] = entity_ids
|
||||||
|
stats["stages"] = stages
|
||||||
|
stats["ratings"] = ratings
|
||||||
|
stats["hourly_buckets"] = hourly_buckets
|
||||||
|
stats["minute_buckets"] = minute_buckets
|
||||||
|
|
||||||
|
if stats["duration_seconds"] > 0:
|
||||||
|
stats["events_per_minute"] = len(entries) / (stats["duration_seconds"] / 60)
|
||||||
|
else:
|
||||||
|
stats["events_per_minute"] = len(entries)
|
||||||
|
|
||||||
|
return stats
|
||||||
|
|
||||||
|
|
||||||
|
# ─── PDF building ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
def build_styles():
|
||||||
|
ss = getSampleStyleSheet()
|
||||||
|
ss.add(ParagraphStyle(
|
||||||
|
"ReportTitle", parent=ss["Title"], fontSize=24, textColor=WHITE,
|
||||||
|
spaceAfter=4, fontName="Helvetica-Bold", alignment=TA_CENTER,
|
||||||
|
))
|
||||||
|
ss.add(ParagraphStyle(
|
||||||
|
"ReportSubtitle", parent=ss["Normal"], fontSize=11, textColor=GRAY_400,
|
||||||
|
spaceAfter=2, fontName="Helvetica", alignment=TA_CENTER,
|
||||||
|
))
|
||||||
|
ss.add(ParagraphStyle(
|
||||||
|
"SectionHeader", parent=ss["Heading1"], fontSize=16, textColor=GRAY_900,
|
||||||
|
spaceBefore=14, spaceAfter=6, fontName="Helvetica-Bold",
|
||||||
|
))
|
||||||
|
ss.add(ParagraphStyle(
|
||||||
|
"SubHeader", parent=ss["Heading2"], fontSize=12, textColor=GRAY_800,
|
||||||
|
spaceBefore=10, spaceAfter=4, fontName="Helvetica-Bold",
|
||||||
|
))
|
||||||
|
ss.add(ParagraphStyle(
|
||||||
|
"BodyText2", parent=ss["Normal"], fontSize=9, textColor=GRAY_800,
|
||||||
|
spaceAfter=3, fontName="Helvetica", leading=13,
|
||||||
|
))
|
||||||
|
ss.add(ParagraphStyle(
|
||||||
|
"SmallGray", parent=ss["Normal"], fontSize=8, textColor=GRAY_600,
|
||||||
|
spaceAfter=2, fontName="Helvetica",
|
||||||
|
))
|
||||||
|
ss.add(ParagraphStyle(
|
||||||
|
"KPIValue", parent=ss["Normal"], fontSize=20, textColor=GRAY_900,
|
||||||
|
fontName="Helvetica-Bold", alignment=TA_CENTER, leading=24,
|
||||||
|
))
|
||||||
|
ss.add(ParagraphStyle(
|
||||||
|
"KPILabel", parent=ss["Normal"], fontSize=8, textColor=GRAY_600,
|
||||||
|
fontName="Helvetica", alignment=TA_CENTER, spaceAfter=2,
|
||||||
|
))
|
||||||
|
ss.add(ParagraphStyle(
|
||||||
|
"BannerText", parent=ss["Normal"], fontSize=9, textColor=WHITE,
|
||||||
|
fontName="Helvetica-Bold", spaceAfter=1,
|
||||||
|
))
|
||||||
|
return ss
|
||||||
|
|
||||||
|
|
||||||
|
def make_header_banner(ss, log_path, stats):
|
||||||
|
elements = []
|
||||||
|
fname = os.path.basename(log_path)
|
||||||
|
banner_data = [[
|
||||||
|
Paragraph("Webhook Log Report", ss["ReportTitle"]),
|
||||||
|
], [
|
||||||
|
Paragraph(fname, ss["ReportSubtitle"]),
|
||||||
|
], [
|
||||||
|
Paragraph(
|
||||||
|
f"Generated {datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M UTC')}",
|
||||||
|
ss["ReportSubtitle"],
|
||||||
|
),
|
||||||
|
]]
|
||||||
|
banner = Table(banner_data, colWidths=[7.0 * inch])
|
||||||
|
banner.setStyle(TableStyle([
|
||||||
|
("BACKGROUND", (0, 0), (-1, -1), HEADER_BG),
|
||||||
|
("ALIGN", (0, 0), (-1, -1), "CENTER"),
|
||||||
|
("TOPPADDING", (0, 0), (0, 0), 20),
|
||||||
|
("BOTTOMPADDING", (0, -1), (-1, -1), 16),
|
||||||
|
("LEFTPADDING", (0, 0), (-1, -1), 20),
|
||||||
|
("RIGHTPADDING", (0, 0), (-1, -1), 20),
|
||||||
|
]))
|
||||||
|
elements.append(banner)
|
||||||
|
elements.append(Spacer(1, 14))
|
||||||
|
return elements
|
||||||
|
|
||||||
|
|
||||||
|
def make_kpi_card(label, value):
|
||||||
|
ss = build_styles()
|
||||||
|
card_data = [[
|
||||||
|
Paragraph(str(value), ss["KPIValue"]),
|
||||||
|
], [
|
||||||
|
Paragraph(label, ss["KPILabel"]),
|
||||||
|
]]
|
||||||
|
card = Table(card_data, colWidths=[1.6 * inch], rowHeights=[28, 16])
|
||||||
|
card.setStyle(TableStyle([
|
||||||
|
("BACKGROUND", (0, 0), (-1, -1), GRAY_100),
|
||||||
|
("ALIGN", (0, 0), (-1, -1), "CENTER"),
|
||||||
|
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
|
||||||
|
("TOPPADDING", (0, 0), (-1, -1), 6),
|
||||||
|
("BOTTOMPADDING", (0, 0), (-1, -1), 4),
|
||||||
|
("BOX", (0, 0), (-1, -1), 0.5, GRAY_200),
|
||||||
|
]))
|
||||||
|
return card
|
||||||
|
|
||||||
|
|
||||||
|
def make_kpi_row(cards_data):
|
||||||
|
cards = [make_kpi_card(label, value) for label, value in cards_data]
|
||||||
|
row = Table([cards], colWidths=[1.75 * inch] * len(cards))
|
||||||
|
row.setStyle(TableStyle([
|
||||||
|
("ALIGN", (0, 0), (-1, -1), "CENTER"),
|
||||||
|
("VALIGN", (0, 0), (-1, -1), "TOP"),
|
||||||
|
]))
|
||||||
|
return row
|
||||||
|
|
||||||
|
|
||||||
|
def make_table(title, counter, ss, max_rows=15):
|
||||||
|
"""Generic table from a Counter — light styling for print."""
|
||||||
|
elements = []
|
||||||
|
elements.append(Paragraph(title, ss["SubHeader"]))
|
||||||
|
|
||||||
|
items = counter.most_common(max_rows)
|
||||||
|
if not items:
|
||||||
|
elements.append(Paragraph("<i>No data</i>", ss["BodyText2"]))
|
||||||
|
return elements
|
||||||
|
|
||||||
|
total = sum(counter.values())
|
||||||
|
header = ["Item", "Count", "%"]
|
||||||
|
rows = [header]
|
||||||
|
for name, count in items:
|
||||||
|
pct = (count / total * 100) if total else 0
|
||||||
|
rows.append([truncate(str(name), 45), f"{count:,}", f"{pct:.1f}%"])
|
||||||
|
|
||||||
|
t = Table(rows, colWidths=[3.6 * inch, 1.0 * inch, 0.8 * inch])
|
||||||
|
t.setStyle(TableStyle([
|
||||||
|
("BACKGROUND", (0, 0), (-1, 0), GRAY_800),
|
||||||
|
("TEXTCOLOR", (0, 0), (-1, 0), WHITE),
|
||||||
|
("FONTNAME", (0, 0), (-1, 0), "Helvetica-Bold"),
|
||||||
|
("FONTSIZE", (0, 0), (-1, 0), 9),
|
||||||
|
("FONTSIZE", (0, 1), (-1, -1), 9),
|
||||||
|
("FONTNAME", (0, 1), (-1, -1), "Helvetica"),
|
||||||
|
("BOTTOMPADDING", (0, 0), (-1, 0), 6),
|
||||||
|
("TOPPADDING", (0, 0), (-1, 0), 6),
|
||||||
|
("GRID", (0, 0), (-1, -1), 0.4, GRAY_200),
|
||||||
|
("ROWBACKGROUNDS", (0, 1), (-1, -1), [WHITE, GRAY_50]),
|
||||||
|
("ALIGN", (1, 0), (2, -1), "CENTER"),
|
||||||
|
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
|
||||||
|
("LEFTPADDING", (0, 0), (-1, -1), 8),
|
||||||
|
("RIGHTPADDING", (0, 0), (-1, -1), 8),
|
||||||
|
("TOPPADDING", (0, 1), (-1, -1), 3),
|
||||||
|
("BOTTOMPADDING", (0, 1), (-1, -1), 3),
|
||||||
|
]))
|
||||||
|
elements.append(t)
|
||||||
|
return elements
|
||||||
|
|
||||||
|
|
||||||
|
def make_pie_chart(title, counter, width=280, height=190):
|
||||||
|
items = counter.most_common(8)
|
||||||
|
if not items:
|
||||||
|
return Spacer(1, 1)
|
||||||
|
|
||||||
|
d = Drawing(width, height)
|
||||||
|
d.add(String(width / 2, height - 12, title,
|
||||||
|
fontSize=10, fontName="Helvetica-Bold",
|
||||||
|
fillColor=GRAY_900, textAnchor="middle"))
|
||||||
|
|
||||||
|
pie = Pie()
|
||||||
|
pie.x = 50
|
||||||
|
pie.y = 10
|
||||||
|
pie.width = 110
|
||||||
|
pie.height = 110
|
||||||
|
pie.data = [v for _, v in items]
|
||||||
|
pie.labels = [truncate(str(k), 18) for k, _ in items]
|
||||||
|
pie.sideLabels = True
|
||||||
|
pie.slices.strokeWidth = 0.5
|
||||||
|
pie.slices.strokeColor = WHITE
|
||||||
|
|
||||||
|
for i in range(len(items)):
|
||||||
|
pie.slices[i].fillColor = PIE_COLORS[i % len(PIE_COLORS)]
|
||||||
|
pie.slices[i].fontName = "Helvetica"
|
||||||
|
pie.slices[i].fontSize = 7
|
||||||
|
pie.slices[i].labelRadius = 1.35
|
||||||
|
|
||||||
|
d.add(pie)
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
def make_timeline_chart(minute_buckets, width=500, height=150):
|
||||||
|
if not minute_buckets:
|
||||||
|
return Spacer(1, 1)
|
||||||
|
|
||||||
|
sorted_keys = sorted(minute_buckets.keys())
|
||||||
|
if len(sorted_keys) > 40:
|
||||||
|
step = max(1, len(sorted_keys) // 40)
|
||||||
|
sampled_keys = sorted_keys[::step]
|
||||||
|
else:
|
||||||
|
sampled_keys = sorted_keys
|
||||||
|
|
||||||
|
values = [minute_buckets[k] for k in sampled_keys]
|
||||||
|
|
||||||
|
d = Drawing(width, height)
|
||||||
|
d.add(String(width / 2, height - 10, "Event Timeline (by minute)",
|
||||||
|
fontSize=10, fontName="Helvetica-Bold",
|
||||||
|
fillColor=GRAY_900, textAnchor="middle"))
|
||||||
|
|
||||||
|
chart = VerticalBarChart()
|
||||||
|
chart.x = 50
|
||||||
|
chart.y = 25
|
||||||
|
chart.width = width - 80
|
||||||
|
chart.height = height - 50
|
||||||
|
chart.data = [values]
|
||||||
|
chart.categoryAxis.categoryNames = sampled_keys
|
||||||
|
chart.categoryAxis.labels.angle = 45
|
||||||
|
chart.categoryAxis.labels.fontSize = 6
|
||||||
|
chart.categoryAxis.labels.fontName = "Helvetica"
|
||||||
|
chart.categoryAxis.labels.dy = -5
|
||||||
|
chart.valueAxis.labels.fontSize = 7
|
||||||
|
chart.valueAxis.labels.fontName = "Helvetica"
|
||||||
|
chart.valueAxis.valueMin = 0
|
||||||
|
chart.bars[0].fillColor = GRAY_600
|
||||||
|
chart.bars[0].strokeColor = None
|
||||||
|
chart.barWidth = max(2, int((width - 100) / len(values) * 0.7))
|
||||||
|
|
||||||
|
d.add(chart)
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
def build_actor_activity_section(stats, ss):
|
||||||
|
"""Per-actor deep-dive. Actor = entityUpdatedBy ?? query.memberId ?? summary.memberId."""
|
||||||
|
elements = []
|
||||||
|
elements.append(PageBreak())
|
||||||
|
elements.append(Paragraph("Actor Activity Deep Dive", ss["SectionHeader"]))
|
||||||
|
elements.append(HRFlowable(width="100%", thickness=1, color=GRAY_400, spaceAfter=4))
|
||||||
|
elements.append(Paragraph(
|
||||||
|
'The <b>actor</b> is resolved as: <i>entityUpdatedBy → query.memberId → summary.memberId</i>. '
|
||||||
|
'This is the person or system that caused the change in ConnectWise.',
|
||||||
|
ss["SmallGray"],
|
||||||
|
))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
|
||||||
|
actor_details = stats.get("actor_details", {})
|
||||||
|
if not actor_details:
|
||||||
|
elements.append(Paragraph("<i>No actor data available.</i>", ss["BodyText2"]))
|
||||||
|
return elements
|
||||||
|
|
||||||
|
sorted_actors = sorted(actor_details.items(), key=lambda x: -x[1]["count"])
|
||||||
|
|
||||||
|
# Actor distribution pie chart
|
||||||
|
actor_counter = Counter({aid: ad["count"] for aid, ad in sorted_actors})
|
||||||
|
elements.append(make_pie_chart("Events by Actor", actor_counter, width=350, height=210))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
|
||||||
|
for idx, (aid, ad) in enumerate(sorted_actors):
|
||||||
|
# Actor header — slim dark bar
|
||||||
|
banner_data = [[
|
||||||
|
Paragraph(
|
||||||
|
f'<font size="12"><b>{aid}</b></font>'
|
||||||
|
f' '
|
||||||
|
f'<font size="9" color="#cccccc">{ad["count"]:,} events</font>',
|
||||||
|
ss["BannerText"],
|
||||||
|
),
|
||||||
|
]]
|
||||||
|
banner = Table(banner_data, colWidths=[7.0 * inch])
|
||||||
|
banner.setStyle(TableStyle([
|
||||||
|
("BACKGROUND", (0, 0), (-1, -1), HEADER_BG),
|
||||||
|
("TOPPADDING", (0, 0), (-1, -1), 7),
|
||||||
|
("BOTTOMPADDING", (0, 0), (-1, -1), 7),
|
||||||
|
("LEFTPADDING", (0, 0), (-1, -1), 12),
|
||||||
|
]))
|
||||||
|
elements.append(banner)
|
||||||
|
|
||||||
|
# KPI row
|
||||||
|
kpi = make_kpi_row([
|
||||||
|
("Events", f"{ad['count']:,}"),
|
||||||
|
("Entities", f"{len(ad['entity_ids']):,}"),
|
||||||
|
("Companies", f"{len(ad['companies']):,}"),
|
||||||
|
("Evts/Min", f"{ad['events_per_minute']:.1f}"),
|
||||||
|
])
|
||||||
|
elements.append(kpi)
|
||||||
|
elements.append(Spacer(1, 4))
|
||||||
|
|
||||||
|
# Info grid
|
||||||
|
first_str = ad["first_ts"].strftime("%Y-%m-%d %H:%M:%S") if ad["first_ts"] else "—"
|
||||||
|
last_str = ad["last_ts"].strftime("%Y-%m-%d %H:%M:%S") if ad["last_ts"] else "—"
|
||||||
|
dur = duration_str(ad["duration_seconds"])
|
||||||
|
est = ad["total_estimated"]
|
||||||
|
|
||||||
|
mid_str = ", ".join(f"{k} ({v})" for k, v in ad["member_ids"].most_common(5)) if ad["member_ids"] else "—"
|
||||||
|
sr_str = ", ".join(f"{k} ({v})" for k, v in ad["sales_reps"].most_common(5)) if ad["sales_reps"] else "—"
|
||||||
|
|
||||||
|
info_rows = [
|
||||||
|
[
|
||||||
|
Paragraph('<font color="#757575">First Event</font>', ss["BodyText2"]),
|
||||||
|
Paragraph(f'<b>{first_str}</b>', ss["BodyText2"]),
|
||||||
|
Paragraph('<font color="#757575">Last Event</font>', ss["BodyText2"]),
|
||||||
|
Paragraph(f'<b>{last_str}</b>', ss["BodyText2"]),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
Paragraph('<font color="#757575">Active Duration</font>', ss["BodyText2"]),
|
||||||
|
Paragraph(f'<b>{dur}</b>', ss["BodyText2"]),
|
||||||
|
Paragraph('<font color="#757575">Total Est. Value</font>', ss["BodyText2"]),
|
||||||
|
Paragraph(f'<b>${est:,.2f}</b>', ss["BodyText2"]),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
Paragraph('<font color="#757575">Callback Members</font>', ss["BodyText2"]),
|
||||||
|
Paragraph(f'{truncate(mid_str, 40)}', ss["BodyText2"]),
|
||||||
|
Paragraph('<font color="#757575">Sales Reps</font>', ss["BodyText2"]),
|
||||||
|
Paragraph(f'{truncate(sr_str, 40)}', ss["BodyText2"]),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
info_table = Table(info_rows, colWidths=[1.3 * inch, 2.1 * inch, 1.3 * inch, 2.1 * inch])
|
||||||
|
info_table.setStyle(TableStyle([
|
||||||
|
("BACKGROUND", (0, 0), (-1, -1), GRAY_50),
|
||||||
|
("TOPPADDING", (0, 0), (-1, -1), 4),
|
||||||
|
("BOTTOMPADDING", (0, 0), (-1, -1), 4),
|
||||||
|
("LEFTPADDING", (0, 0), (-1, -1), 8),
|
||||||
|
("GRID", (0, 0), (-1, -1), 0.3, GRAY_200),
|
||||||
|
]))
|
||||||
|
elements.append(info_table)
|
||||||
|
elements.append(Spacer(1, 6))
|
||||||
|
|
||||||
|
# Breakdown tables
|
||||||
|
if ad["types"]:
|
||||||
|
elements.extend(make_table(f"{aid} — Entity Types", ad["types"], ss, max_rows=8))
|
||||||
|
elements.append(Spacer(1, 6))
|
||||||
|
|
||||||
|
if ad["companies"]:
|
||||||
|
elements.extend(make_table(f"{aid} — Companies", ad["companies"], ss, max_rows=10))
|
||||||
|
elements.append(Spacer(1, 6))
|
||||||
|
|
||||||
|
if ad["stages"]:
|
||||||
|
elements.extend(make_table(f"{aid} — Stages", ad["stages"], ss, max_rows=8))
|
||||||
|
elements.append(Spacer(1, 6))
|
||||||
|
|
||||||
|
if ad["ratings"]:
|
||||||
|
elements.extend(make_table(f"{aid} — Ratings", ad["ratings"], ss, max_rows=8))
|
||||||
|
elements.append(Spacer(1, 6))
|
||||||
|
|
||||||
|
# Entity IDs
|
||||||
|
if ad["entity_ids"]:
|
||||||
|
id_list = sorted(ad["entity_ids"])
|
||||||
|
id_str = ", ".join(str(i) for i in id_list[:30])
|
||||||
|
if len(id_list) > 30:
|
||||||
|
id_str += f" ... (+{len(id_list) - 30} more)"
|
||||||
|
elements.append(Paragraph(f"{aid} — Entity IDs Touched", ss["SubHeader"]))
|
||||||
|
elements.append(Paragraph(f'<font size="8">{id_str}</font>', ss["BodyText2"]))
|
||||||
|
elements.append(Spacer(1, 6))
|
||||||
|
|
||||||
|
# Divider
|
||||||
|
if idx < len(sorted_actors) - 1:
|
||||||
|
elements.append(Spacer(1, 4))
|
||||||
|
elements.append(HRFlowable(width="100%", thickness=0.5, color=GRAY_200, spaceAfter=4))
|
||||||
|
elements.append(Spacer(1, 4))
|
||||||
|
|
||||||
|
return elements
|
||||||
|
|
||||||
|
|
||||||
|
def build_summary_log_table(entries, ss, max_rows=30):
|
||||||
|
elements = []
|
||||||
|
elements.append(PageBreak())
|
||||||
|
elements.append(Paragraph("Event Summary", ss["SectionHeader"]))
|
||||||
|
elements.append(HRFlowable(width="100%", thickness=1, color=GRAY_400, spaceAfter=6))
|
||||||
|
elements.append(Paragraph(
|
||||||
|
f"Aggregated view of {len(entries):,} webhook events — grouped by entity.",
|
||||||
|
ss["SmallGray"],
|
||||||
|
))
|
||||||
|
elements.append(Spacer(1, 8))
|
||||||
|
|
||||||
|
entity_groups = defaultdict(lambda: {
|
||||||
|
"count": 0, "name": "—", "company": "—",
|
||||||
|
"actions": Counter(), "actors": set(),
|
||||||
|
"est_total": None,
|
||||||
|
})
|
||||||
|
|
||||||
|
for e in entries:
|
||||||
|
req = e.get("request", {})
|
||||||
|
bp = req.get("bodyParsed") or {}
|
||||||
|
entity = req.get("entityParsed") or bp.get("Entity") or {}
|
||||||
|
if not isinstance(entity, dict):
|
||||||
|
continue
|
||||||
|
eid = entity.get("Id")
|
||||||
|
if eid is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
eg = entity_groups[eid]
|
||||||
|
eg["count"] += 1
|
||||||
|
eg["name"] = entity.get("OpportunityName") or entity.get("CompanyName") or eg["name"]
|
||||||
|
eg["company"] = entity.get("CompanyName") or eg["company"]
|
||||||
|
eg["actions"][bp.get("Action", "?")] += 1
|
||||||
|
actor = resolve_actor(e)
|
||||||
|
eg["actors"].add(actor)
|
||||||
|
et = entity.get("EstimatedTotal")
|
||||||
|
if et is not None:
|
||||||
|
eg["est_total"] = et
|
||||||
|
|
||||||
|
sorted_entities = sorted(entity_groups.items(), key=lambda x: -x[1]["count"])
|
||||||
|
|
||||||
|
header = ["ID", "Entity Name", "Company", "Events", "Actions", "Actors", "Est. Total"]
|
||||||
|
rows = [header]
|
||||||
|
|
||||||
|
for eid, eg in sorted_entities[:max_rows]:
|
||||||
|
actions_str = ", ".join(f"{a}({c})" for a, c in eg["actions"].most_common(3))
|
||||||
|
actors_str = ", ".join(sorted(eg["actors"]))
|
||||||
|
total_str = f"${eg['est_total']:,.2f}" if eg["est_total"] is not None else "—"
|
||||||
|
rows.append([
|
||||||
|
str(eid),
|
||||||
|
truncate(eg["name"], 28),
|
||||||
|
truncate(eg["company"], 18),
|
||||||
|
f"{eg['count']:,}",
|
||||||
|
truncate(actions_str, 24),
|
||||||
|
truncate(actors_str, 18),
|
||||||
|
total_str,
|
||||||
|
])
|
||||||
|
|
||||||
|
t = Table(rows, colWidths=[0.45 * inch, 1.7 * inch, 1.1 * inch, 0.55 * inch, 1.2 * inch, 1.0 * inch, 0.8 * inch])
|
||||||
|
t.setStyle(TableStyle([
|
||||||
|
("BACKGROUND", (0, 0), (-1, 0), GRAY_800),
|
||||||
|
("TEXTCOLOR", (0, 0), (-1, 0), WHITE),
|
||||||
|
("FONTNAME", (0, 0), (-1, 0), "Helvetica-Bold"),
|
||||||
|
("FONTSIZE", (0, 0), (-1, 0), 8),
|
||||||
|
("FONTSIZE", (0, 1), (-1, -1), 8),
|
||||||
|
("FONTNAME", (0, 1), (-1, -1), "Helvetica"),
|
||||||
|
("GRID", (0, 0), (-1, -1), 0.3, GRAY_200),
|
||||||
|
("ROWBACKGROUNDS", (0, 1), (-1, -1), [WHITE, GRAY_50]),
|
||||||
|
("ALIGN", (0, 0), (0, -1), "CENTER"),
|
||||||
|
("ALIGN", (3, 0), (3, -1), "CENTER"),
|
||||||
|
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
|
||||||
|
("LEFTPADDING", (0, 0), (-1, -1), 5),
|
||||||
|
("RIGHTPADDING", (0, 0), (-1, -1), 5),
|
||||||
|
("TOPPADDING", (0, 1), (-1, -1), 2),
|
||||||
|
("BOTTOMPADDING", (0, 1), (-1, -1), 2),
|
||||||
|
]))
|
||||||
|
elements.append(t)
|
||||||
|
|
||||||
|
if len(sorted_entities) > max_rows:
|
||||||
|
elements.append(Spacer(1, 4))
|
||||||
|
elements.append(Paragraph(
|
||||||
|
f'Showing top {max_rows} of {len(sorted_entities)} entities.',
|
||||||
|
ss["SmallGray"],
|
||||||
|
))
|
||||||
|
|
||||||
|
return elements
|
||||||
|
|
||||||
|
|
||||||
|
def add_page_number(canvas, doc):
|
||||||
|
canvas.saveState()
|
||||||
|
canvas.setFillColor(GRAY_800)
|
||||||
|
canvas.rect(0, 0, LETTER[0], 22, fill=1, stroke=0)
|
||||||
|
canvas.setFillColor(WHITE)
|
||||||
|
canvas.setFont("Helvetica", 7)
|
||||||
|
canvas.drawCentredString(LETTER[0] / 2, 8, f"Page {doc.page}")
|
||||||
|
canvas.setFillColor(GRAY_400)
|
||||||
|
canvas.setFont("Helvetica", 7)
|
||||||
|
canvas.drawString(30, 8, "Optima API · Webhook Log Report")
|
||||||
|
canvas.drawRightString(LETTER[0] - 30, 8, datetime.now(timezone.utc).strftime("%Y-%m-%d"))
|
||||||
|
canvas.restoreState()
|
||||||
|
|
||||||
|
|
||||||
|
# ─── Main ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
def main():
|
||||||
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
log_dir = os.path.join(script_dir, "..", "cw-api-logs")
|
||||||
|
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
log_path = sys.argv[1]
|
||||||
|
else:
|
||||||
|
log_path = find_latest_log(log_dir)
|
||||||
|
|
||||||
|
print(f"📄 Reading log: {log_path}")
|
||||||
|
entries = parse_log(log_path)
|
||||||
|
print(f" → {len(entries)} entries parsed")
|
||||||
|
|
||||||
|
stats = analyze(entries)
|
||||||
|
ss = build_styles()
|
||||||
|
|
||||||
|
log_basename = os.path.splitext(os.path.basename(log_path))[0]
|
||||||
|
out_path = os.path.join(script_dir, "..", "cw-api-logs", f"{log_basename}-report.pdf")
|
||||||
|
|
||||||
|
doc = SimpleDocTemplate(
|
||||||
|
out_path,
|
||||||
|
pagesize=LETTER,
|
||||||
|
leftMargin=0.6 * inch,
|
||||||
|
rightMargin=0.6 * inch,
|
||||||
|
topMargin=0.5 * inch,
|
||||||
|
bottomMargin=0.5 * inch,
|
||||||
|
)
|
||||||
|
|
||||||
|
elements = []
|
||||||
|
|
||||||
|
# ── Title Banner ──
|
||||||
|
elements.extend(make_header_banner(ss, log_path, stats))
|
||||||
|
|
||||||
|
# ── Overview ──
|
||||||
|
elements.append(Paragraph("Overview", ss["SectionHeader"]))
|
||||||
|
elements.append(HRFlowable(width="100%", thickness=1, color=GRAY_400, spaceAfter=10))
|
||||||
|
|
||||||
|
elements.append(make_kpi_row([
|
||||||
|
("Total Events", f"{stats['total_entries']:,}"),
|
||||||
|
("Unique Entities", f"{len(stats['entity_ids']):,}"),
|
||||||
|
("Companies", f"{len(stats['companies']):,}"),
|
||||||
|
("Duration", duration_str(stats["duration_seconds"])),
|
||||||
|
]))
|
||||||
|
elements.append(Spacer(1, 8))
|
||||||
|
elements.append(make_kpi_row([
|
||||||
|
("Events / Min", f"{stats['events_per_minute']:.1f}"),
|
||||||
|
("HTTP Methods", f"{len(stats['methods']):,}"),
|
||||||
|
("Action Types", f"{len(stats['actions']):,}"),
|
||||||
|
("Actors", f"{len(stats['actors']):,}"),
|
||||||
|
]))
|
||||||
|
elements.append(Spacer(1, 12))
|
||||||
|
|
||||||
|
# Time range
|
||||||
|
if stats["first_ts"] and stats["last_ts"]:
|
||||||
|
info = [
|
||||||
|
[
|
||||||
|
Paragraph('<font color="#757575">First Event</font>', ss["BodyText2"]),
|
||||||
|
Paragraph(f'<b>{stats["first_ts"].strftime("%Y-%m-%d %H:%M:%S UTC")}</b>', ss["BodyText2"]),
|
||||||
|
Paragraph('<font color="#757575">Last Event</font>', ss["BodyText2"]),
|
||||||
|
Paragraph(f'<b>{stats["last_ts"].strftime("%Y-%m-%d %H:%M:%S UTC")}</b>', ss["BodyText2"]),
|
||||||
|
]
|
||||||
|
]
|
||||||
|
ti = Table(info, colWidths=[1.2 * inch, 2.4 * inch, 1.2 * inch, 2.4 * inch])
|
||||||
|
ti.setStyle(TableStyle([
|
||||||
|
("BACKGROUND", (0, 0), (-1, -1), GRAY_50),
|
||||||
|
("TOPPADDING", (0, 0), (-1, -1), 5),
|
||||||
|
("BOTTOMPADDING", (0, 0), (-1, -1), 5),
|
||||||
|
("LEFTPADDING", (0, 0), (-1, -1), 8),
|
||||||
|
("BOX", (0, 0), (-1, -1), 0.4, GRAY_200),
|
||||||
|
]))
|
||||||
|
elements.append(ti)
|
||||||
|
elements.append(Spacer(1, 14))
|
||||||
|
|
||||||
|
# ── Charts ──
|
||||||
|
elements.append(Paragraph("Visual Breakdown", ss["SectionHeader"]))
|
||||||
|
elements.append(HRFlowable(width="100%", thickness=1, color=GRAY_400, spaceAfter=10))
|
||||||
|
|
||||||
|
elements.append(make_timeline_chart(stats["minute_buckets"]))
|
||||||
|
elements.append(Spacer(1, 12))
|
||||||
|
|
||||||
|
pie_row = [[
|
||||||
|
make_pie_chart("By Action", stats["actions"]),
|
||||||
|
make_pie_chart("By Type", stats["types"]),
|
||||||
|
]]
|
||||||
|
pt = Table(pie_row, colWidths=[3.5 * inch, 3.5 * inch])
|
||||||
|
pt.setStyle(TableStyle([
|
||||||
|
("ALIGN", (0, 0), (-1, -1), "CENTER"),
|
||||||
|
("VALIGN", (0, 0), (-1, -1), "TOP"),
|
||||||
|
]))
|
||||||
|
elements.append(pt)
|
||||||
|
elements.append(Spacer(1, 6))
|
||||||
|
|
||||||
|
if len(stats["stages"]) > 1 or len(stats["ratings"]) > 1:
|
||||||
|
pie_row2 = [[
|
||||||
|
make_pie_chart("By Stage", stats["stages"]),
|
||||||
|
make_pie_chart("By Rating", stats["ratings"]),
|
||||||
|
]]
|
||||||
|
pt2 = Table(pie_row2, colWidths=[3.5 * inch, 3.5 * inch])
|
||||||
|
pt2.setStyle(TableStyle([
|
||||||
|
("ALIGN", (0, 0), (-1, -1), "CENTER"),
|
||||||
|
("VALIGN", (0, 0), (-1, -1), "TOP"),
|
||||||
|
]))
|
||||||
|
elements.append(pt2)
|
||||||
|
|
||||||
|
# Actor pie chart
|
||||||
|
elements.append(Spacer(1, 6))
|
||||||
|
elements.append(make_pie_chart("By Actor", stats["actors"], width=350, height=210))
|
||||||
|
|
||||||
|
# ── General Information ──
|
||||||
|
elements.append(PageBreak())
|
||||||
|
elements.append(Paragraph("General Information", ss["SectionHeader"]))
|
||||||
|
elements.append(HRFlowable(width="100%", thickness=1, color=GRAY_400, spaceAfter=10))
|
||||||
|
|
||||||
|
elements.extend(make_table("Response Status Codes", stats["statuses"], ss))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
elements.extend(make_table("HTTP Methods", stats["methods"], ss))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
elements.extend(make_table("Webhook Actions", stats["actions"], ss))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
elements.extend(make_table("Entity Types", stats["types"], ss))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
elements.extend(make_table("Request Paths", stats["paths"], ss))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
elements.extend(make_table("Actors", stats["actors"], ss))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
|
||||||
|
if stats["companies"]:
|
||||||
|
elements.extend(make_table("Companies", stats["companies"], ss))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
if stats["stages"]:
|
||||||
|
elements.extend(make_table("Opportunity Stages", stats["stages"], ss))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
if stats["ratings"]:
|
||||||
|
elements.extend(make_table("Opportunity Ratings", stats["ratings"], ss))
|
||||||
|
elements.append(Spacer(1, 10))
|
||||||
|
|
||||||
|
elements.extend(make_table("Hourly Distribution", stats["hourly_buckets"], ss))
|
||||||
|
|
||||||
|
# ── Actor Deep Dive ──
|
||||||
|
elements.extend(build_actor_activity_section(stats, ss))
|
||||||
|
|
||||||
|
# ── Entity Summary ──
|
||||||
|
elements.extend(build_summary_log_table(entries, ss, max_rows=30))
|
||||||
|
|
||||||
|
# Build
|
||||||
|
doc.build(elements, onFirstPage=add_page_number, onLaterPages=add_page_number)
|
||||||
|
print(f"✅ Report generated: {out_path}")
|
||||||
|
print(f" File size: {os.path.getsize(out_path) / 1024:.1f} KB")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
|
||||||
|
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
||||||
|
/* eslint-disable */
|
||||||
|
// biome-ignore-all lint: generated file
|
||||||
|
// @ts-nocheck
|
||||||
|
/*
|
||||||
|
* This file should be your main import to use Prisma-related types and utilities in a browser.
|
||||||
|
* Use it to get access to models, enums, and input types.
|
||||||
|
*
|
||||||
|
* This file does not contain a `PrismaClient` class, nor several other helpers that are intended as server-side only.
|
||||||
|
* See `client.ts` for the standard, server-side entry point.
|
||||||
|
*
|
||||||
|
* 🟢 You can import this file directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as Prisma from './internal/prismaNamespaceBrowser.ts'
|
||||||
|
export { Prisma }
|
||||||
|
export * as $Enums from './enums.ts'
|
||||||
|
export * from './enums.ts';
|
||||||
|
/**
|
||||||
|
* Model Session
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type Session = Prisma.SessionModel
|
||||||
|
/**
|
||||||
|
* Model User
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type User = Prisma.UserModel
|
||||||
|
/**
|
||||||
|
* Model Role
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type Role = Prisma.RoleModel
|
||||||
|
/**
|
||||||
|
* Model UnifiSite
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type UnifiSite = Prisma.UnifiSiteModel
|
||||||
|
/**
|
||||||
|
* Model Company
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type Company = Prisma.CompanyModel
|
||||||
|
/**
|
||||||
|
* Model CatalogItem
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type CatalogItem = Prisma.CatalogItemModel
|
||||||
|
/**
|
||||||
|
* Model Opportunity
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type Opportunity = Prisma.OpportunityModel
|
||||||
|
/**
|
||||||
|
* Model CredentialType
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type CredentialType = Prisma.CredentialTypeModel
|
||||||
|
/**
|
||||||
|
* Model SecureValue
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type SecureValue = Prisma.SecureValueModel
|
||||||
|
/**
|
||||||
|
* Model Credential
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type Credential = Prisma.CredentialModel
|
||||||
|
/**
|
||||||
|
* Model GeneratedQuotes
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type GeneratedQuotes = Prisma.GeneratedQuotesModel
|
||||||
|
/**
|
||||||
|
* Model CwMember
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type CwMember = Prisma.CwMemberModel
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
|
||||||
|
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
||||||
|
/* eslint-disable */
|
||||||
|
// biome-ignore-all lint: generated file
|
||||||
|
// @ts-nocheck
|
||||||
|
/*
|
||||||
|
* This file should be your main import to use Prisma. Through it you get access to all the models, enums, and input types.
|
||||||
|
* If you're looking for something you can import in the client-side of your application, please refer to the `browser.ts` file instead.
|
||||||
|
*
|
||||||
|
* 🟢 You can import this file directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as process from 'node:process'
|
||||||
|
import * as path from 'node:path'
|
||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
|
globalThis['__dirname'] = path.dirname(fileURLToPath(import.meta.url))
|
||||||
|
|
||||||
|
import * as runtime from "@prisma/client/runtime/client"
|
||||||
|
import * as $Enums from "./enums.ts"
|
||||||
|
import * as $Class from "./internal/class.ts"
|
||||||
|
import * as Prisma from "./internal/prismaNamespace.ts"
|
||||||
|
|
||||||
|
export * as $Enums from './enums.ts'
|
||||||
|
export * from "./enums.ts"
|
||||||
|
/**
|
||||||
|
* ## Prisma Client
|
||||||
|
*
|
||||||
|
* Type-safe database client for TypeScript
|
||||||
|
* @example
|
||||||
|
* ```
|
||||||
|
* const prisma = new PrismaClient()
|
||||||
|
* // Fetch zero or more Sessions
|
||||||
|
* const sessions = await prisma.session.findMany()
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Read more in our [docs](https://pris.ly/d/client).
|
||||||
|
*/
|
||||||
|
export const PrismaClient = $Class.getPrismaClientClass()
|
||||||
|
export type PrismaClient<LogOpts extends Prisma.LogLevel = never, OmitOpts extends Prisma.PrismaClientOptions["omit"] = Prisma.PrismaClientOptions["omit"], ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = $Class.PrismaClient<LogOpts, OmitOpts, ExtArgs>
|
||||||
|
export { Prisma }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model Session
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type Session = Prisma.SessionModel
|
||||||
|
/**
|
||||||
|
* Model User
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type User = Prisma.UserModel
|
||||||
|
/**
|
||||||
|
* Model Role
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type Role = Prisma.RoleModel
|
||||||
|
/**
|
||||||
|
* Model UnifiSite
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type UnifiSite = Prisma.UnifiSiteModel
|
||||||
|
/**
|
||||||
|
* Model Company
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type Company = Prisma.CompanyModel
|
||||||
|
/**
|
||||||
|
* Model CatalogItem
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type CatalogItem = Prisma.CatalogItemModel
|
||||||
|
/**
|
||||||
|
* Model Opportunity
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type Opportunity = Prisma.OpportunityModel
|
||||||
|
/**
|
||||||
|
* Model CredentialType
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type CredentialType = Prisma.CredentialTypeModel
|
||||||
|
/**
|
||||||
|
* Model SecureValue
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type SecureValue = Prisma.SecureValueModel
|
||||||
|
/**
|
||||||
|
* Model Credential
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type Credential = Prisma.CredentialModel
|
||||||
|
/**
|
||||||
|
* Model GeneratedQuotes
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type GeneratedQuotes = Prisma.GeneratedQuotesModel
|
||||||
|
/**
|
||||||
|
* Model CwMember
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type CwMember = Prisma.CwMemberModel
|
||||||
@@ -0,0 +1,558 @@
|
|||||||
|
|
||||||
|
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
||||||
|
/* eslint-disable */
|
||||||
|
// biome-ignore-all lint: generated file
|
||||||
|
// @ts-nocheck
|
||||||
|
/*
|
||||||
|
* This file exports various common sort, input & filter types that are not directly linked to a particular model.
|
||||||
|
*
|
||||||
|
* 🟢 You can import this file directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type * as runtime from "@prisma/client/runtime/client"
|
||||||
|
import * as $Enums from "./enums.ts"
|
||||||
|
import type * as Prisma from "./internal/prismaNamespace.ts"
|
||||||
|
|
||||||
|
|
||||||
|
export type StringFilter<$PrismaModel = never> = {
|
||||||
|
equals?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel>
|
||||||
|
lt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
lte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
mode?: Prisma.QueryMode
|
||||||
|
not?: Prisma.NestedStringFilter<$PrismaModel> | string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DateTimeFilter<$PrismaModel = never> = {
|
||||||
|
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedDateTimeFilter<$PrismaModel> | Date | string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BoolFilter<$PrismaModel = never> = {
|
||||||
|
equals?: boolean | Prisma.BooleanFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedBoolFilter<$PrismaModel> | boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DateTimeNullableFilter<$PrismaModel = never> = {
|
||||||
|
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> | Date | string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SortOrderInput = {
|
||||||
|
sort: Prisma.SortOrder
|
||||||
|
nulls?: Prisma.NullsOrder
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StringWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel>
|
||||||
|
lt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
lte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
mode?: Prisma.QueryMode
|
||||||
|
not?: Prisma.NestedStringWithAggregatesFilter<$PrismaModel> | string
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedStringFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedStringFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DateTimeWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedDateTimeWithAggregatesFilter<$PrismaModel> | Date | string
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedDateTimeFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedDateTimeFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BoolWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: boolean | Prisma.BooleanFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedBoolWithAggregatesFilter<$PrismaModel> | boolean
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedBoolFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedBoolFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DateTimeNullableWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedDateTimeNullableWithAggregatesFilter<$PrismaModel> | Date | string | null
|
||||||
|
_count?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedDateTimeNullableFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedDateTimeNullableFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StringNullableFilter<$PrismaModel = never> = {
|
||||||
|
equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
lte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
mode?: Prisma.QueryMode
|
||||||
|
not?: Prisma.NestedStringNullableFilter<$PrismaModel> | string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StringNullableWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
lte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
mode?: Prisma.QueryMode
|
||||||
|
not?: Prisma.NestedStringNullableWithAggregatesFilter<$PrismaModel> | string | null
|
||||||
|
_count?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedStringNullableFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedStringNullableFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type IntFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||||
|
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedIntFilter<$PrismaModel> | number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type IntWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||||
|
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedIntWithAggregatesFilter<$PrismaModel> | number
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_avg?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||||
|
_sum?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type IntNullableFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.IntFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedIntNullableFilter<$PrismaModel> | number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FloatFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||||
|
lt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedFloatFilter<$PrismaModel> | number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type IntNullableWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.IntFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedIntNullableWithAggregatesFilter<$PrismaModel> | number | null
|
||||||
|
_count?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
_avg?: Prisma.NestedFloatNullableFilter<$PrismaModel>
|
||||||
|
_sum?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FloatWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||||
|
lt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedFloatWithAggregatesFilter<$PrismaModel> | number
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_avg?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||||
|
_sum?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type JsonFilter<$PrismaModel = never> =
|
||||||
|
| Prisma.PatchUndefined<
|
||||||
|
Prisma.Either<Required<JsonFilterBase<$PrismaModel>>, Exclude<keyof Required<JsonFilterBase<$PrismaModel>>, 'path'>>,
|
||||||
|
Required<JsonFilterBase<$PrismaModel>>
|
||||||
|
>
|
||||||
|
| Prisma.OptionalFlat<Omit<Required<JsonFilterBase<$PrismaModel>>, 'path'>>
|
||||||
|
|
||||||
|
export type JsonFilterBase<$PrismaModel = never> = {
|
||||||
|
equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||||
|
path?: string[]
|
||||||
|
mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel>
|
||||||
|
string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||||
|
array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||||
|
array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||||
|
}
|
||||||
|
|
||||||
|
export type JsonWithAggregatesFilter<$PrismaModel = never> =
|
||||||
|
| Prisma.PatchUndefined<
|
||||||
|
Prisma.Either<Required<JsonWithAggregatesFilterBase<$PrismaModel>>, Exclude<keyof Required<JsonWithAggregatesFilterBase<$PrismaModel>>, 'path'>>,
|
||||||
|
Required<JsonWithAggregatesFilterBase<$PrismaModel>>
|
||||||
|
>
|
||||||
|
| Prisma.OptionalFlat<Omit<Required<JsonWithAggregatesFilterBase<$PrismaModel>>, 'path'>>
|
||||||
|
|
||||||
|
export type JsonWithAggregatesFilterBase<$PrismaModel = never> = {
|
||||||
|
equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||||
|
path?: string[]
|
||||||
|
mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel>
|
||||||
|
string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||||
|
array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||||
|
array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedJsonFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedJsonFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BytesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: runtime.Bytes | Prisma.BytesFieldRefInput<$PrismaModel>
|
||||||
|
in?: runtime.Bytes[] | Prisma.ListBytesFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: runtime.Bytes[] | Prisma.ListBytesFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedBytesFilter<$PrismaModel> | runtime.Bytes
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BytesWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: runtime.Bytes | Prisma.BytesFieldRefInput<$PrismaModel>
|
||||||
|
in?: runtime.Bytes[] | Prisma.ListBytesFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: runtime.Bytes[] | Prisma.ListBytesFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedBytesWithAggregatesFilter<$PrismaModel> | runtime.Bytes
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedBytesFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedBytesFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedStringFilter<$PrismaModel = never> = {
|
||||||
|
equals?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel>
|
||||||
|
lt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
lte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedStringFilter<$PrismaModel> | string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedDateTimeFilter<$PrismaModel = never> = {
|
||||||
|
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedDateTimeFilter<$PrismaModel> | Date | string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedBoolFilter<$PrismaModel = never> = {
|
||||||
|
equals?: boolean | Prisma.BooleanFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedBoolFilter<$PrismaModel> | boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedDateTimeNullableFilter<$PrismaModel = never> = {
|
||||||
|
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> | Date | string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedStringWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel>
|
||||||
|
lt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
lte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedStringWithAggregatesFilter<$PrismaModel> | string
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedStringFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedStringFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedIntFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||||
|
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedIntFilter<$PrismaModel> | number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedDateTimeWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedDateTimeWithAggregatesFilter<$PrismaModel> | Date | string
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedDateTimeFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedDateTimeFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedBoolWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: boolean | Prisma.BooleanFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedBoolWithAggregatesFilter<$PrismaModel> | boolean
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedBoolFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedBoolFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedDateTimeNullableWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedDateTimeNullableWithAggregatesFilter<$PrismaModel> | Date | string | null
|
||||||
|
_count?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedDateTimeNullableFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedDateTimeNullableFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedIntNullableFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.IntFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedIntNullableFilter<$PrismaModel> | number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedStringNullableFilter<$PrismaModel = never> = {
|
||||||
|
equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
lte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedStringNullableFilter<$PrismaModel> | string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedStringNullableWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
lte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gt?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
gte?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedStringNullableWithAggregatesFilter<$PrismaModel> | string | null
|
||||||
|
_count?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedStringNullableFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedStringNullableFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedIntWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||||
|
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedIntWithAggregatesFilter<$PrismaModel> | number
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_avg?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||||
|
_sum?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedFloatFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||||
|
lt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedFloatFilter<$PrismaModel> | number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedIntNullableWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.IntFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedIntNullableWithAggregatesFilter<$PrismaModel> | number | null
|
||||||
|
_count?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
_avg?: Prisma.NestedFloatNullableFilter<$PrismaModel>
|
||||||
|
_sum?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedFloatNullableFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.FloatFieldRefInput<$PrismaModel> | null
|
||||||
|
in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel> | null
|
||||||
|
notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedFloatNullableFilter<$PrismaModel> | number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedFloatWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||||
|
lt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
lte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
gt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
gte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedFloatWithAggregatesFilter<$PrismaModel> | number
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_avg?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||||
|
_sum?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedJsonFilter<$PrismaModel = never> =
|
||||||
|
| Prisma.PatchUndefined<
|
||||||
|
Prisma.Either<Required<NestedJsonFilterBase<$PrismaModel>>, Exclude<keyof Required<NestedJsonFilterBase<$PrismaModel>>, 'path'>>,
|
||||||
|
Required<NestedJsonFilterBase<$PrismaModel>>
|
||||||
|
>
|
||||||
|
| Prisma.OptionalFlat<Omit<Required<NestedJsonFilterBase<$PrismaModel>>, 'path'>>
|
||||||
|
|
||||||
|
export type NestedJsonFilterBase<$PrismaModel = never> = {
|
||||||
|
equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||||
|
path?: string[]
|
||||||
|
mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel>
|
||||||
|
string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||||
|
array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||||
|
array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||||
|
array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||||
|
lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||||
|
not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedBytesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: runtime.Bytes | Prisma.BytesFieldRefInput<$PrismaModel>
|
||||||
|
in?: runtime.Bytes[] | Prisma.ListBytesFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: runtime.Bytes[] | Prisma.ListBytesFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedBytesFilter<$PrismaModel> | runtime.Bytes
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NestedBytesWithAggregatesFilter<$PrismaModel = never> = {
|
||||||
|
equals?: runtime.Bytes | Prisma.BytesFieldRefInput<$PrismaModel>
|
||||||
|
in?: runtime.Bytes[] | Prisma.ListBytesFieldRefInput<$PrismaModel>
|
||||||
|
notIn?: runtime.Bytes[] | Prisma.ListBytesFieldRefInput<$PrismaModel>
|
||||||
|
not?: Prisma.NestedBytesWithAggregatesFilter<$PrismaModel> | runtime.Bytes
|
||||||
|
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||||
|
_min?: Prisma.NestedBytesFilter<$PrismaModel>
|
||||||
|
_max?: Prisma.NestedBytesFilter<$PrismaModel>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
||||||
|
/* eslint-disable */
|
||||||
|
// biome-ignore-all lint: generated file
|
||||||
|
// @ts-nocheck
|
||||||
|
/*
|
||||||
|
* This file exports all enum related types from the schema.
|
||||||
|
*
|
||||||
|
* 🟢 You can import this file directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// This file is empty because there are no enums in the schema.
|
||||||
|
export {}
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,350 @@
|
|||||||
|
|
||||||
|
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
||||||
|
/* eslint-disable */
|
||||||
|
// biome-ignore-all lint: generated file
|
||||||
|
// @ts-nocheck
|
||||||
|
/*
|
||||||
|
* WARNING: This is an internal file that is subject to change!
|
||||||
|
*
|
||||||
|
* 🛑 Under no circumstances should you import this file directly! 🛑
|
||||||
|
*
|
||||||
|
* All exports from this file are wrapped under a `Prisma` namespace object in the browser.ts file.
|
||||||
|
* While this enables partial backward compatibility, it is not part of the stable public API.
|
||||||
|
*
|
||||||
|
* If you are looking for your Models, Enums, and Input Types, please import them from the respective
|
||||||
|
* model files in the `model` directory!
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as runtime from "@prisma/client/runtime/index-browser"
|
||||||
|
|
||||||
|
export type * from '../models.ts'
|
||||||
|
export type * from './prismaNamespace.ts'
|
||||||
|
|
||||||
|
export const Decimal = runtime.Decimal
|
||||||
|
|
||||||
|
|
||||||
|
export const NullTypes = {
|
||||||
|
DbNull: runtime.NullTypes.DbNull as (new (secret: never) => typeof runtime.DbNull),
|
||||||
|
JsonNull: runtime.NullTypes.JsonNull as (new (secret: never) => typeof runtime.JsonNull),
|
||||||
|
AnyNull: runtime.NullTypes.AnyNull as (new (secret: never) => typeof runtime.AnyNull),
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Helper for filtering JSON entries that have `null` on the database (empty on the db)
|
||||||
|
*
|
||||||
|
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
||||||
|
*/
|
||||||
|
export const DbNull = runtime.DbNull
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for filtering JSON entries that have JSON `null` values (not empty on the db)
|
||||||
|
*
|
||||||
|
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
||||||
|
*/
|
||||||
|
export const JsonNull = runtime.JsonNull
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for filtering JSON entries that are `Prisma.DbNull` or `Prisma.JsonNull`
|
||||||
|
*
|
||||||
|
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
||||||
|
*/
|
||||||
|
export const AnyNull = runtime.AnyNull
|
||||||
|
|
||||||
|
|
||||||
|
export const ModelName = {
|
||||||
|
Session: 'Session',
|
||||||
|
User: 'User',
|
||||||
|
Role: 'Role',
|
||||||
|
UnifiSite: 'UnifiSite',
|
||||||
|
Company: 'Company',
|
||||||
|
CatalogItem: 'CatalogItem',
|
||||||
|
Opportunity: 'Opportunity',
|
||||||
|
CredentialType: 'CredentialType',
|
||||||
|
SecureValue: 'SecureValue',
|
||||||
|
Credential: 'Credential',
|
||||||
|
GeneratedQuotes: 'GeneratedQuotes',
|
||||||
|
CwMember: 'CwMember'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enums
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const TransactionIsolationLevel = runtime.makeStrictEnum({
|
||||||
|
ReadUncommitted: 'ReadUncommitted',
|
||||||
|
ReadCommitted: 'ReadCommitted',
|
||||||
|
RepeatableRead: 'RepeatableRead',
|
||||||
|
Serializable: 'Serializable'
|
||||||
|
} as const)
|
||||||
|
|
||||||
|
export type TransactionIsolationLevel = (typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel]
|
||||||
|
|
||||||
|
|
||||||
|
export const SessionScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
sessionKey: 'sessionKey',
|
||||||
|
userId: 'userId',
|
||||||
|
expires: 'expires',
|
||||||
|
refreshTokenGenerated: 'refreshTokenGenerated',
|
||||||
|
refreshedAt: 'refreshedAt',
|
||||||
|
invalidatedAt: 'invalidatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type SessionScalarFieldEnum = (typeof SessionScalarFieldEnum)[keyof typeof SessionScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const UserScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
permissions: 'permissions',
|
||||||
|
login: 'login',
|
||||||
|
name: 'name',
|
||||||
|
email: 'email',
|
||||||
|
emailVerified: 'emailVerified',
|
||||||
|
image: 'image',
|
||||||
|
cwIdentifier: 'cwIdentifier',
|
||||||
|
userId: 'userId',
|
||||||
|
token: 'token',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type UserScalarFieldEnum = (typeof UserScalarFieldEnum)[keyof typeof UserScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const RoleScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
title: 'title',
|
||||||
|
moniker: 'moniker',
|
||||||
|
permissions: 'permissions',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type RoleScalarFieldEnum = (typeof RoleScalarFieldEnum)[keyof typeof RoleScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const UnifiSiteScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
name: 'name',
|
||||||
|
siteId: 'siteId',
|
||||||
|
companyId: 'companyId',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type UnifiSiteScalarFieldEnum = (typeof UnifiSiteScalarFieldEnum)[keyof typeof UnifiSiteScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const CompanyScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
name: 'name',
|
||||||
|
cw_CompanyId: 'cw_CompanyId',
|
||||||
|
cw_Identifier: 'cw_Identifier',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type CompanyScalarFieldEnum = (typeof CompanyScalarFieldEnum)[keyof typeof CompanyScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const CatalogItemScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
cwCatalogId: 'cwCatalogId',
|
||||||
|
identifier: 'identifier',
|
||||||
|
name: 'name',
|
||||||
|
description: 'description',
|
||||||
|
customerDescription: 'customerDescription',
|
||||||
|
internalNotes: 'internalNotes',
|
||||||
|
category: 'category',
|
||||||
|
categoryCwId: 'categoryCwId',
|
||||||
|
subcategory: 'subcategory',
|
||||||
|
subcategoryCwId: 'subcategoryCwId',
|
||||||
|
manufacturer: 'manufacturer',
|
||||||
|
manufactureCwId: 'manufactureCwId',
|
||||||
|
partNumber: 'partNumber',
|
||||||
|
vendorName: 'vendorName',
|
||||||
|
vendorSku: 'vendorSku',
|
||||||
|
vendorCwId: 'vendorCwId',
|
||||||
|
price: 'price',
|
||||||
|
cost: 'cost',
|
||||||
|
inactive: 'inactive',
|
||||||
|
salesTaxable: 'salesTaxable',
|
||||||
|
onHand: 'onHand',
|
||||||
|
cwLastUpdated: 'cwLastUpdated',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type CatalogItemScalarFieldEnum = (typeof CatalogItemScalarFieldEnum)[keyof typeof CatalogItemScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const OpportunityScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
cwOpportunityId: 'cwOpportunityId',
|
||||||
|
name: 'name',
|
||||||
|
notes: 'notes',
|
||||||
|
typeName: 'typeName',
|
||||||
|
typeCwId: 'typeCwId',
|
||||||
|
stageName: 'stageName',
|
||||||
|
stageCwId: 'stageCwId',
|
||||||
|
statusName: 'statusName',
|
||||||
|
statusCwId: 'statusCwId',
|
||||||
|
priorityName: 'priorityName',
|
||||||
|
priorityCwId: 'priorityCwId',
|
||||||
|
ratingName: 'ratingName',
|
||||||
|
ratingCwId: 'ratingCwId',
|
||||||
|
source: 'source',
|
||||||
|
campaignName: 'campaignName',
|
||||||
|
campaignCwId: 'campaignCwId',
|
||||||
|
primarySalesRepName: 'primarySalesRepName',
|
||||||
|
primarySalesRepIdentifier: 'primarySalesRepIdentifier',
|
||||||
|
primarySalesRepCwId: 'primarySalesRepCwId',
|
||||||
|
secondarySalesRepName: 'secondarySalesRepName',
|
||||||
|
secondarySalesRepIdentifier: 'secondarySalesRepIdentifier',
|
||||||
|
secondarySalesRepCwId: 'secondarySalesRepCwId',
|
||||||
|
companyCwId: 'companyCwId',
|
||||||
|
companyName: 'companyName',
|
||||||
|
contactCwId: 'contactCwId',
|
||||||
|
contactName: 'contactName',
|
||||||
|
siteCwId: 'siteCwId',
|
||||||
|
siteName: 'siteName',
|
||||||
|
customerPO: 'customerPO',
|
||||||
|
totalSalesTax: 'totalSalesTax',
|
||||||
|
probability: 'probability',
|
||||||
|
locationName: 'locationName',
|
||||||
|
locationCwId: 'locationCwId',
|
||||||
|
departmentName: 'departmentName',
|
||||||
|
departmentCwId: 'departmentCwId',
|
||||||
|
expectedCloseDate: 'expectedCloseDate',
|
||||||
|
pipelineChangeDate: 'pipelineChangeDate',
|
||||||
|
dateBecameLead: 'dateBecameLead',
|
||||||
|
closedDate: 'closedDate',
|
||||||
|
closedFlag: 'closedFlag',
|
||||||
|
closedByName: 'closedByName',
|
||||||
|
closedByCwId: 'closedByCwId',
|
||||||
|
companyId: 'companyId',
|
||||||
|
productSequence: 'productSequence',
|
||||||
|
cwLastUpdated: 'cwLastUpdated',
|
||||||
|
cwDateEntered: 'cwDateEntered',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type OpportunityScalarFieldEnum = (typeof OpportunityScalarFieldEnum)[keyof typeof OpportunityScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const CredentialTypeScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
name: 'name',
|
||||||
|
permissionScope: 'permissionScope',
|
||||||
|
icon: 'icon',
|
||||||
|
fields: 'fields',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type CredentialTypeScalarFieldEnum = (typeof CredentialTypeScalarFieldEnum)[keyof typeof CredentialTypeScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const SecureValueScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
name: 'name',
|
||||||
|
content: 'content',
|
||||||
|
hash: 'hash',
|
||||||
|
credentialId: 'credentialId',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type SecureValueScalarFieldEnum = (typeof SecureValueScalarFieldEnum)[keyof typeof SecureValueScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const CredentialScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
name: 'name',
|
||||||
|
notes: 'notes',
|
||||||
|
subCredentialOfId: 'subCredentialOfId',
|
||||||
|
typeId: 'typeId',
|
||||||
|
fields: 'fields',
|
||||||
|
companyId: 'companyId',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type CredentialScalarFieldEnum = (typeof CredentialScalarFieldEnum)[keyof typeof CredentialScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const GeneratedQuotesScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
quoteRegenData: 'quoteRegenData',
|
||||||
|
quoteRegenParams: 'quoteRegenParams',
|
||||||
|
quoteRegenHash: 'quoteRegenHash',
|
||||||
|
downloads: 'downloads',
|
||||||
|
quoteFile: 'quoteFile',
|
||||||
|
quoteFileName: 'quoteFileName',
|
||||||
|
opportunityId: 'opportunityId',
|
||||||
|
createdById: 'createdById',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type GeneratedQuotesScalarFieldEnum = (typeof GeneratedQuotesScalarFieldEnum)[keyof typeof GeneratedQuotesScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const CwMemberScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
cwMemberId: 'cwMemberId',
|
||||||
|
identifier: 'identifier',
|
||||||
|
firstName: 'firstName',
|
||||||
|
lastName: 'lastName',
|
||||||
|
officeEmail: 'officeEmail',
|
||||||
|
inactiveFlag: 'inactiveFlag',
|
||||||
|
apiKey: 'apiKey',
|
||||||
|
cwLastUpdated: 'cwLastUpdated',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type CwMemberScalarFieldEnum = (typeof CwMemberScalarFieldEnum)[keyof typeof CwMemberScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const SortOrder = {
|
||||||
|
asc: 'asc',
|
||||||
|
desc: 'desc'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder]
|
||||||
|
|
||||||
|
|
||||||
|
export const JsonNullValueInput = {
|
||||||
|
JsonNull: JsonNull
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type JsonNullValueInput = (typeof JsonNullValueInput)[keyof typeof JsonNullValueInput]
|
||||||
|
|
||||||
|
|
||||||
|
export const QueryMode = {
|
||||||
|
default: 'default',
|
||||||
|
insensitive: 'insensitive'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type QueryMode = (typeof QueryMode)[keyof typeof QueryMode]
|
||||||
|
|
||||||
|
|
||||||
|
export const NullsOrder = {
|
||||||
|
first: 'first',
|
||||||
|
last: 'last'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder]
|
||||||
|
|
||||||
|
|
||||||
|
export const JsonNullValueFilter = {
|
||||||
|
DbNull: DbNull,
|
||||||
|
JsonNull: JsonNull,
|
||||||
|
AnyNull: AnyNull
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type JsonNullValueFilter = (typeof JsonNullValueFilter)[keyof typeof JsonNullValueFilter]
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
||||||
|
/* eslint-disable */
|
||||||
|
// biome-ignore-all lint: generated file
|
||||||
|
// @ts-nocheck
|
||||||
|
/*
|
||||||
|
* This is a barrel export file for all models and their related types.
|
||||||
|
*
|
||||||
|
* 🟢 You can import this file directly.
|
||||||
|
*/
|
||||||
|
export type * from './models/Session.ts'
|
||||||
|
export type * from './models/User.ts'
|
||||||
|
export type * from './models/Role.ts'
|
||||||
|
export type * from './models/UnifiSite.ts'
|
||||||
|
export type * from './models/Company.ts'
|
||||||
|
export type * from './models/CatalogItem.ts'
|
||||||
|
export type * from './models/Opportunity.ts'
|
||||||
|
export type * from './models/CredentialType.ts'
|
||||||
|
export type * from './models/SecureValue.ts'
|
||||||
|
export type * from './models/Credential.ts'
|
||||||
|
export type * from './models/GeneratedQuotes.ts'
|
||||||
|
export type * from './models/CwMember.ts'
|
||||||
|
export type * from './commonInputTypes.ts'
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: optima-api
|
||||||
|
namespace: optima
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: optima-api
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: optima-api
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: optima-api
|
||||||
|
image: ghcr.io/project-optima/ttscm-api:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: api-env-secret
|
||||||
|
- secretRef:
|
||||||
|
name: optima-keys-secret
|
||||||
|
ports:
|
||||||
|
- containerPort: 3000
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: github-container-registry
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: optima-api-ingress
|
||||||
|
namespace: optima
|
||||||
|
annotations:
|
||||||
|
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||||
|
traefik.ingress.kubernetes.io/router.tls: "true"
|
||||||
|
spec:
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- opt-api.osdci.net
|
||||||
|
secretName: osdci-net-cert
|
||||||
|
rules:
|
||||||
|
- host: opt-api.osdci.net
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: optima-api
|
||||||
|
port:
|
||||||
|
number: 3000
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: optima-api
|
||||||
|
namespace: optima
|
||||||
|
labels:
|
||||||
|
app: optima-api
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
ports:
|
||||||
|
- port: 3000
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
app: optima-api
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: prisma-migrate-RELEASE_TAG
|
||||||
|
namespace: optima
|
||||||
|
labels:
|
||||||
|
app: prisma-migrate
|
||||||
|
spec:
|
||||||
|
backoffLimit: 3
|
||||||
|
ttlSecondsAfterFinished: 300
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: migrate
|
||||||
|
image: ghcr.io/project-optima/ttscm-api-migrate:RELEASE_TAG
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: api-env-secret
|
||||||
|
- secretRef:
|
||||||
|
name: optima-keys-secret
|
||||||
|
restartPolicy: Never
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: github-container-registry
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"name": "api",
|
||||||
|
"homepage": "https://totaltech.net",
|
||||||
|
"version": "v0.1.0",
|
||||||
|
"author": {
|
||||||
|
"name": "Jackson Roberts",
|
||||||
|
"email": "jackson.roberts@totaltech.net",
|
||||||
|
"url": "https://totaltech.net"
|
||||||
|
},
|
||||||
|
"module": "src/index.ts",
|
||||||
|
"type": "module",
|
||||||
|
"private": true,
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/bun": "latest",
|
||||||
|
"@types/jsonwebtoken": "^9.0.10"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"typescript": "^5"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"dev": "NODE_ENV=development bun --watch src/index.ts",
|
||||||
|
"dev:worker": "NODE_ENV=development bun --watch src/workert.ts",
|
||||||
|
"dev:log": "LOG_CW_API=1 NODE_ENV=development bun --watch src/index.ts",
|
||||||
|
"test": "bun test --preload ./tests/setup.ts",
|
||||||
|
"db:gen": "prisma generate",
|
||||||
|
"db:push": "prisma migrate dev --skip-generate",
|
||||||
|
"db:deploy": "prisma migrate deploy",
|
||||||
|
"utils:dev": "docker compose -f .docker/docker-compose.yml up --build",
|
||||||
|
"utils:gen_private_keys": "bun ./utils/genPrivateKeys",
|
||||||
|
"utils:create_admin_role": "bun ./utils/createAdminRole",
|
||||||
|
"utils:assign_user_role": "bun ./utils/assignUserRole",
|
||||||
|
"utils:test_webserver": "bun ./utils/testWebserver.ts",
|
||||||
|
"utils:test_adjustments_poll": "bun ./utils/testAdjustmentsPoll.ts",
|
||||||
|
"utils:analyze_cw": "python3 debug-scripts/analyze-cw-calls.py",
|
||||||
|
"db:check": "bunx prisma migrate diff --from-migrations prisma/migrations --to-schema prisma/schema.prisma --shadow-database-url $DATABASE_URL --exit-code"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@azure/msal-node": "^5.0.2",
|
||||||
|
"@discordjs/collection": "^2.1.1",
|
||||||
|
"@duxcore/eventra": "^1.1.0",
|
||||||
|
"@prisma/adapter-pg": "^7.3.0",
|
||||||
|
"@prisma/client": "^7.3.0",
|
||||||
|
"@socket.io/bun-engine": "^0.1.0",
|
||||||
|
"axios": "^1.13.3",
|
||||||
|
"blakets": "^0.1.12",
|
||||||
|
"cors": "^2.8.6",
|
||||||
|
"cuid": "^3.0.0",
|
||||||
|
"hono": "^4.11.5",
|
||||||
|
"ioredis": "^5.10.0",
|
||||||
|
"jsonwebtoken": "^9.0.3",
|
||||||
|
"keypair": "^1.0.4",
|
||||||
|
"pdf-lib": "^1.17.1",
|
||||||
|
"pdfmake": "^0.3.5",
|
||||||
|
"pg-boss": "^12.14.0",
|
||||||
|
"prisma": "^7.3.0",
|
||||||
|
"socket.io": "^4.8.3",
|
||||||
|
"socket.io-client": "^4.8.3",
|
||||||
|
"zod": "^4.3.6",
|
||||||
|
"zon": "^1.0.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import 'dotenv/config'
|
||||||
|
import { defineConfig, env } from 'prisma/config'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
schema: 'prisma/schema.prisma',
|
||||||
|
migrations: {
|
||||||
|
path: 'prisma/migrations',
|
||||||
|
},
|
||||||
|
datasource: {
|
||||||
|
url: env('DATABASE_URL'),
|
||||||
|
},
|
||||||
|
})
|
||||||
Executable
+23
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 1. Resolve any previously failed migrations so deploy can proceed.
|
||||||
|
# Only migrations explicitly marked as "Failed" in the status output are
|
||||||
|
# resolved. We grep for lines containing "Failed" and extract the name.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
echo "[migrate] Checking for failed migrations..."
|
||||||
|
STATUS_OUTPUT=$(bunx prisma migrate status 2>&1 || true)
|
||||||
|
echo "$STATUS_OUTPUT"
|
||||||
|
|
||||||
|
# Only resolve migrations whose status line explicitly says "Failed"
|
||||||
|
echo "$STATUS_OUTPUT" | grep -i "failed" | grep -oE '[0-9]{14}_[a-zA-Z_]+' | while read -r MIGRATION; do
|
||||||
|
echo "[migrate] Resolving failed migration: $MIGRATION"
|
||||||
|
bunx prisma migrate resolve --rolled-back "$MIGRATION" || true
|
||||||
|
done
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 2. Deploy all pending migrations from the migrations directory.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
echo "[migrate] Running prisma migrate deploy..."
|
||||||
|
bunx prisma migrate deploy
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Session" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"sessionKey" TEXT NOT NULL,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"expires" TIMESTAMP(3) NOT NULL,
|
||||||
|
"refreshTokenGenerated" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"refreshedAt" TIMESTAMP(3),
|
||||||
|
"invalidatedAt" TIMESTAMP(3),
|
||||||
|
|
||||||
|
CONSTRAINT "Session_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "User" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"permissions" TEXT,
|
||||||
|
"login" TEXT NOT NULL,
|
||||||
|
"name" TEXT,
|
||||||
|
"email" TEXT NOT NULL,
|
||||||
|
"emailVerified" TIMESTAMP(3),
|
||||||
|
"image" TEXT,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"token" TEXT,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Role" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"title" TEXT NOT NULL,
|
||||||
|
"moniker" TEXT NOT NULL,
|
||||||
|
"permissions" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Role_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "_RoleToUser" (
|
||||||
|
"A" TEXT NOT NULL,
|
||||||
|
"B" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "_RoleToUser_AB_pkey" PRIMARY KEY ("A","B")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Session_sessionKey_key" ON "Session"("sessionKey");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "User_login_key" ON "User"("login");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "User_userId_key" ON "User"("userId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Role_moniker_key" ON "Role"("moniker");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "_RoleToUser_B_index" ON "_RoleToUser"("B");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "_RoleToUser" ADD CONSTRAINT "_RoleToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Role"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "_RoleToUser" ADD CONSTRAINT "_RoleToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Company" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"cw_CompanyId" INTEGER NOT NULL,
|
||||||
|
"cw_Identifier" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Company_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "CredentialType" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"permissionScope" TEXT NOT NULL,
|
||||||
|
"icon" TEXT,
|
||||||
|
"fields" JSONB NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "CredentialType_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "SecureValue" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"content" TEXT NOT NULL,
|
||||||
|
"hash" TEXT NOT NULL,
|
||||||
|
"credentialId" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "SecureValue_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Credential" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"notes" TEXT,
|
||||||
|
"subCredentialOfId" TEXT,
|
||||||
|
"typeId" TEXT NOT NULL,
|
||||||
|
"fields" JSONB NOT NULL,
|
||||||
|
"companyId" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Credential_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Company_cw_CompanyId_key" ON "Company"("cw_CompanyId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Company_cw_Identifier_key" ON "Company"("cw_Identifier");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "CredentialType_name_key" ON "CredentialType"("name");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "SecureValue" ADD CONSTRAINT "SecureValue_credentialId_fkey" FOREIGN KEY ("credentialId") REFERENCES "Credential"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Credential" ADD CONSTRAINT "Credential_subCredentialOfId_fkey" FOREIGN KEY ("subCredentialOfId") REFERENCES "Credential"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Credential" ADD CONSTRAINT "Credential_typeId_fkey" FOREIGN KEY ("typeId") REFERENCES "CredentialType"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Credential" ADD CONSTRAINT "Credential_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "UnifiSite" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"siteId" TEXT NOT NULL,
|
||||||
|
"companyId" TEXT,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "UnifiSite_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "CatalogItem" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"cwCatalogId" INTEGER NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"description" TEXT,
|
||||||
|
"customerDescription" TEXT,
|
||||||
|
"internalNotes" TEXT,
|
||||||
|
"manufacturer" TEXT,
|
||||||
|
"manufactureCwId" INTEGER,
|
||||||
|
"partNumber" TEXT,
|
||||||
|
"vendorName" TEXT,
|
||||||
|
"vendorSku" TEXT,
|
||||||
|
"vendorCwId" INTEGER,
|
||||||
|
"price" DOUBLE PRECISION NOT NULL,
|
||||||
|
"cost" DOUBLE PRECISION NOT NULL,
|
||||||
|
"inactive" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"salesTaxable" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"onHand" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"cwLastUpdated" TIMESTAMP(3),
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "CatalogItem_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "_LinkedItems" (
|
||||||
|
"A" TEXT NOT NULL,
|
||||||
|
"B" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "_LinkedItems_AB_pkey" PRIMARY KEY ("A","B")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "UnifiSite_siteId_key" ON "UnifiSite"("siteId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "CatalogItem_cwCatalogId_key" ON "CatalogItem"("cwCatalogId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "_LinkedItems_B_index" ON "_LinkedItems"("B");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "UnifiSite" ADD CONSTRAINT "UnifiSite_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "_LinkedItems" ADD CONSTRAINT "_LinkedItems_A_fkey" FOREIGN KEY ("A") REFERENCES "CatalogItem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "_LinkedItems" ADD CONSTRAINT "_LinkedItems_B_fkey" FOREIGN KEY ("B") REFERENCES "CatalogItem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Opportunity" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"cwOpportunityId" INTEGER NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"notes" TEXT,
|
||||||
|
"typeName" TEXT,
|
||||||
|
"typeCwId" INTEGER,
|
||||||
|
"stageName" TEXT,
|
||||||
|
"stageCwId" INTEGER,
|
||||||
|
"statusName" TEXT,
|
||||||
|
"statusCwId" INTEGER,
|
||||||
|
"priorityName" TEXT,
|
||||||
|
"priorityCwId" INTEGER,
|
||||||
|
"ratingName" TEXT,
|
||||||
|
"ratingCwId" INTEGER,
|
||||||
|
"source" TEXT,
|
||||||
|
"campaignName" TEXT,
|
||||||
|
"campaignCwId" INTEGER,
|
||||||
|
"primarySalesRepName" TEXT,
|
||||||
|
"primarySalesRepIdentifier" TEXT,
|
||||||
|
"primarySalesRepCwId" INTEGER,
|
||||||
|
"secondarySalesRepName" TEXT,
|
||||||
|
"secondarySalesRepIdentifier" TEXT,
|
||||||
|
"secondarySalesRepCwId" INTEGER,
|
||||||
|
"companyCwId" INTEGER,
|
||||||
|
"companyName" TEXT,
|
||||||
|
"contactCwId" INTEGER,
|
||||||
|
"contactName" TEXT,
|
||||||
|
"siteCwId" INTEGER,
|
||||||
|
"siteName" TEXT,
|
||||||
|
"customerPO" TEXT,
|
||||||
|
"totalSalesTax" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||||
|
"locationName" TEXT,
|
||||||
|
"locationCwId" INTEGER,
|
||||||
|
"departmentName" TEXT,
|
||||||
|
"departmentCwId" INTEGER,
|
||||||
|
"expectedCloseDate" TIMESTAMP(3),
|
||||||
|
"pipelineChangeDate" TIMESTAMP(3),
|
||||||
|
"dateBecameLead" TIMESTAMP(3),
|
||||||
|
"closedDate" TIMESTAMP(3),
|
||||||
|
"closedFlag" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"closedByName" TEXT,
|
||||||
|
"closedByCwId" INTEGER,
|
||||||
|
"companyId" TEXT,
|
||||||
|
"cwLastUpdated" TIMESTAMP(3),
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Opportunity_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Opportunity_cwOpportunityId_key" ON "Opportunity"("cwOpportunityId");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Opportunity" ADD CONSTRAINT "Opportunity_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "CatalogItem" ADD COLUMN "identifier" TEXT;
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "CatalogItem_identifier_key" ON "CatalogItem"("identifier");
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
-- AlterTable: User
|
||||||
|
ALTER TABLE "User" ADD COLUMN "cwIdentifier" TEXT;
|
||||||
|
|
||||||
|
-- AlterTable: CatalogItem
|
||||||
|
ALTER TABLE "CatalogItem" ADD COLUMN "category" TEXT;
|
||||||
|
ALTER TABLE "CatalogItem" ADD COLUMN "categoryCwId" INTEGER;
|
||||||
|
ALTER TABLE "CatalogItem" ADD COLUMN "subcategory" TEXT;
|
||||||
|
ALTER TABLE "CatalogItem" ADD COLUMN "subcategoryCwId" INTEGER;
|
||||||
|
|
||||||
|
-- AlterTable: Opportunity
|
||||||
|
ALTER TABLE "Opportunity" ADD COLUMN "productSequence" INTEGER[] DEFAULT ARRAY[]::INTEGER[];
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "GeneratedQuotes" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"quoteFile" BYTEA NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "GeneratedQuotes_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- Added the required column `opportunityId` to the `GeneratedQuotes` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `quoteFileName` to the `GeneratedQuotes` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `quoteRegenData` to the `GeneratedQuotes` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "GeneratedQuotes" ADD COLUMN "createdById" TEXT,
|
||||||
|
ADD COLUMN "opportunityId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "quoteFileName" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "quoteRegenData" JSONB NOT NULL;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "GeneratedQuotes" ADD CONSTRAINT "GeneratedQuotes_opportunityId_fkey" FOREIGN KEY ("opportunityId") REFERENCES "Opportunity"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "GeneratedQuotes" ADD CONSTRAINT "GeneratedQuotes_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable: Opportunity
|
||||||
|
ALTER TABLE "Opportunity" ADD COLUMN "probability" DOUBLE PRECISION NOT NULL DEFAULT 0;
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
-- AlterTable: GeneratedQuotes — add columns missing from prior db push
|
||||||
|
ALTER TABLE "GeneratedQuotes" ADD COLUMN "quoteRegenParams" JSONB NOT NULL DEFAULT '{}';
|
||||||
|
ALTER TABLE "GeneratedQuotes" ADD COLUMN "quoteRegenHash" TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE "GeneratedQuotes" ADD COLUMN "downloads" JSONB NOT NULL DEFAULT '[]';
|
||||||
|
|
||||||
|
-- AlterTable: GeneratedQuotes — set default on existing quoteRegenData column
|
||||||
|
ALTER TABLE "GeneratedQuotes" ALTER COLUMN "quoteRegenData" SET DEFAULT '{}';
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "GeneratedQuotes_quoteRegenHash_key" ON "GeneratedQuotes"("quoteRegenHash");
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "CwMember" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"cwMemberId" INTEGER NOT NULL,
|
||||||
|
"identifier" TEXT NOT NULL,
|
||||||
|
"firstName" TEXT NOT NULL,
|
||||||
|
"lastName" TEXT NOT NULL,
|
||||||
|
"officeEmail" TEXT,
|
||||||
|
"inactiveFlag" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"apiKey" TEXT,
|
||||||
|
"cwLastUpdated" TIMESTAMP(3),
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "CwMember_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "CwMember_cwMemberId_key" ON "CwMember"("cwMemberId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "CwMember_identifier_key" ON "CwMember"("identifier");
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Opportunity" ADD COLUMN "cwDateEntered" TIMESTAMP(3);
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Please do not edit this file manually
|
||||||
|
# It should be added in your version-control system (e.g., Git)
|
||||||
|
provider = "postgresql"
|
||||||
@@ -0,0 +1,290 @@
|
|||||||
|
// This is your Prisma schema file,
|
||||||
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||||
|
|
||||||
|
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||||
|
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||||
|
|
||||||
|
generator client {
|
||||||
|
provider = "prisma-client"
|
||||||
|
output = "../generated/prisma"
|
||||||
|
}
|
||||||
|
|
||||||
|
datasource db {
|
||||||
|
provider = "postgresql"
|
||||||
|
}
|
||||||
|
|
||||||
|
model Session {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
sessionKey String @unique @default(cuid())
|
||||||
|
userId String
|
||||||
|
expires DateTime
|
||||||
|
refreshTokenGenerated Boolean @default(false)
|
||||||
|
refreshedAt DateTime?
|
||||||
|
invalidatedAt DateTime?
|
||||||
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
|
}
|
||||||
|
|
||||||
|
model User {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
roles Role[]
|
||||||
|
permissions String?
|
||||||
|
login String @unique
|
||||||
|
name String?
|
||||||
|
email String @unique
|
||||||
|
emailVerified DateTime?
|
||||||
|
image String?
|
||||||
|
|
||||||
|
cwIdentifier String?
|
||||||
|
|
||||||
|
userId String @unique
|
||||||
|
token String?
|
||||||
|
|
||||||
|
sessions Session[]
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
generatedQuotes GeneratedQuotes[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Role {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
title String
|
||||||
|
moniker String @unique // e.g. admin, super_admin, moderator
|
||||||
|
|
||||||
|
permissions String
|
||||||
|
users User[]
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
model UnifiSite {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
name String
|
||||||
|
|
||||||
|
siteId String @unique
|
||||||
|
|
||||||
|
companyId String?
|
||||||
|
company Company? @relation(fields: [companyId], references: [id])
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
model Company {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
name String
|
||||||
|
|
||||||
|
cw_CompanyId Int @unique
|
||||||
|
cw_Identifier String @unique
|
||||||
|
|
||||||
|
credentials Credential[]
|
||||||
|
unifiSites UnifiSite[]
|
||||||
|
opportunities Opportunity[]
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
model CatalogItem {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
cwCatalogId Int @unique
|
||||||
|
identifier String? @unique
|
||||||
|
name String
|
||||||
|
description String?
|
||||||
|
customerDescription String?
|
||||||
|
internalNotes String?
|
||||||
|
|
||||||
|
linkedItems CatalogItem[] @relation("LinkedItems")
|
||||||
|
linkedTo CatalogItem[] @relation("LinkedItems")
|
||||||
|
|
||||||
|
category String?
|
||||||
|
categoryCwId Int?
|
||||||
|
subcategory String?
|
||||||
|
subcategoryCwId Int?
|
||||||
|
|
||||||
|
manufacturer String?
|
||||||
|
manufactureCwId Int?
|
||||||
|
|
||||||
|
partNumber String?
|
||||||
|
|
||||||
|
vendorName String?
|
||||||
|
vendorSku String?
|
||||||
|
vendorCwId Int?
|
||||||
|
|
||||||
|
price Float
|
||||||
|
cost Float
|
||||||
|
|
||||||
|
inactive Boolean @default(false)
|
||||||
|
salesTaxable Boolean @default(true)
|
||||||
|
|
||||||
|
onHand Int @default(0)
|
||||||
|
cwLastUpdated DateTime?
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
model Opportunity {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
cwOpportunityId Int @unique
|
||||||
|
name String
|
||||||
|
notes String?
|
||||||
|
|
||||||
|
generatedQuotes GeneratedQuotes[]
|
||||||
|
|
||||||
|
// Stage / status / priority / type / rating stored as JSON references
|
||||||
|
// so we don't need separate lookup tables for CW enums
|
||||||
|
typeName String?
|
||||||
|
typeCwId Int?
|
||||||
|
stageName String?
|
||||||
|
stageCwId Int?
|
||||||
|
statusName String?
|
||||||
|
statusCwId Int?
|
||||||
|
priorityName String?
|
||||||
|
priorityCwId Int?
|
||||||
|
ratingName String?
|
||||||
|
ratingCwId Int?
|
||||||
|
source String?
|
||||||
|
campaignName String?
|
||||||
|
campaignCwId Int?
|
||||||
|
|
||||||
|
// Sales rep references
|
||||||
|
primarySalesRepName String?
|
||||||
|
primarySalesRepIdentifier String?
|
||||||
|
primarySalesRepCwId Int?
|
||||||
|
secondarySalesRepName String?
|
||||||
|
secondarySalesRepIdentifier String?
|
||||||
|
secondarySalesRepCwId Int?
|
||||||
|
|
||||||
|
// Company / contact / site
|
||||||
|
companyCwId Int?
|
||||||
|
companyName String?
|
||||||
|
contactCwId Int?
|
||||||
|
contactName String?
|
||||||
|
siteCwId Int?
|
||||||
|
siteName String?
|
||||||
|
customerPO String?
|
||||||
|
|
||||||
|
// Financials
|
||||||
|
totalSalesTax Float @default(0)
|
||||||
|
probability Float @default(0)
|
||||||
|
|
||||||
|
// Location / department
|
||||||
|
locationName String?
|
||||||
|
locationCwId Int?
|
||||||
|
departmentName String?
|
||||||
|
departmentCwId Int?
|
||||||
|
|
||||||
|
// Dates
|
||||||
|
expectedCloseDate DateTime?
|
||||||
|
pipelineChangeDate DateTime?
|
||||||
|
dateBecameLead DateTime?
|
||||||
|
closedDate DateTime?
|
||||||
|
closedFlag Boolean @default(false)
|
||||||
|
closedByName String?
|
||||||
|
closedByCwId Int?
|
||||||
|
|
||||||
|
// Internal relation to Company (optional, linked by cwCompanyId)
|
||||||
|
companyId String?
|
||||||
|
company Company? @relation(fields: [companyId], references: [id])
|
||||||
|
|
||||||
|
// Local product sequence — array of CW forecast item IDs in display order.
|
||||||
|
// When present, fetchProducts() uses this order instead of CW sequenceNumber.
|
||||||
|
productSequence Int[] @default([])
|
||||||
|
|
||||||
|
cwLastUpdated DateTime?
|
||||||
|
cwDateEntered DateTime?
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
model CredentialType {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
name String @unique
|
||||||
|
|
||||||
|
permissionScope String
|
||||||
|
icon String?
|
||||||
|
fields Json
|
||||||
|
|
||||||
|
credentials Credential[]
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
model SecureValue {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
name String
|
||||||
|
|
||||||
|
content String // Encrypted content
|
||||||
|
hash String // Hash of the original content for integrity verification and Search
|
||||||
|
|
||||||
|
credentialId String
|
||||||
|
credential Credential @relation(fields: [credentialId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
model Credential {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
name String
|
||||||
|
notes String?
|
||||||
|
subCredentialOfId String?
|
||||||
|
subCredentialOf Credential? @relation("SubCredentials", fields: [subCredentialOfId], references: [id], onDelete: Cascade)
|
||||||
|
subCredentials Credential[] @relation("SubCredentials")
|
||||||
|
|
||||||
|
typeId String
|
||||||
|
type CredentialType @relation(fields: [typeId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
fields Json
|
||||||
|
|
||||||
|
companyId String
|
||||||
|
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
securevalues SecureValue[]
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
model GeneratedQuotes {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
|
||||||
|
quoteRegenData Json @default("{}") // Store any additional data needed for quote regeneration, such as product details, pricing, etc.
|
||||||
|
quoteRegenParams Json @default("{}") // Store parameters used for quote regeneration, such as template ID, formatting options, etc.
|
||||||
|
quoteRegenHash String @unique @default("")
|
||||||
|
|
||||||
|
downloads Json @default("[]") // Array of download records with timestamp and user info
|
||||||
|
|
||||||
|
quoteFile Bytes
|
||||||
|
quoteFileName String
|
||||||
|
|
||||||
|
opportunityId String
|
||||||
|
opportunity Opportunity @relation(fields: [opportunityId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
createdById String?
|
||||||
|
createdBy User? @relation(fields: [createdById], references: [id], onDelete: SetNull)
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
model CwMember {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
|
||||||
|
cwMemberId Int @unique
|
||||||
|
identifier String @unique
|
||||||
|
firstName String
|
||||||
|
lastName String
|
||||||
|
officeEmail String?
|
||||||
|
inactiveFlag Boolean @default(false)
|
||||||
|
|
||||||
|
apiKey String?
|
||||||
|
|
||||||
|
cwLastUpdated DateTime?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
export default class AuthenticationError extends Error {
|
||||||
|
constructor(message: string, cause?: string) {
|
||||||
|
super();
|
||||||
|
this.name = "AuthenticationError";
|
||||||
|
this.message = message;
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export default class AuthorizationError extends Error {
|
||||||
|
public status: number;
|
||||||
|
|
||||||
|
constructor(message: string, cause?: string, status?: number) {
|
||||||
|
super();
|
||||||
|
this.name = "AuthorizationError";
|
||||||
|
this.status = status ?? 401;
|
||||||
|
this.message = message;
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export default class BodyError extends Error {
|
||||||
|
constructor(message: string, cause?: string) {
|
||||||
|
super();
|
||||||
|
this.name = "BodyError";
|
||||||
|
this.message = message;
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export default class ExpiredAccessTokenError extends Error {
|
||||||
|
constructor(cause?: string) {
|
||||||
|
super();
|
||||||
|
this.name = "ExpiredAccessTokenError";
|
||||||
|
this.message = "The provided access token has expired.";
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export default class ExpiredRefreshTokenError extends Error {
|
||||||
|
constructor(cause?: string) {
|
||||||
|
super();
|
||||||
|
this.name = "ExpiredRefreshTokenError";
|
||||||
|
this.message = "The provided refresh token has expired.";
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
export default class GenericError extends Error {
|
||||||
|
public status: number;
|
||||||
|
|
||||||
|
constructor(info: {
|
||||||
|
name: string;
|
||||||
|
message: string;
|
||||||
|
cause?: string;
|
||||||
|
status?: number;
|
||||||
|
}) {
|
||||||
|
super();
|
||||||
|
this.name = info.name;
|
||||||
|
this.status = info.status ?? 400;
|
||||||
|
this.message = info.message;
|
||||||
|
this.cause = info.cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export default class InsufficientPermission extends Error {
|
||||||
|
public status: number;
|
||||||
|
|
||||||
|
constructor(message: string, cause?: string) {
|
||||||
|
super();
|
||||||
|
this.name = "InsufficientPermission";
|
||||||
|
this.status = 403;
|
||||||
|
this.message = message;
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export default class MissingBodyValue extends Error {
|
||||||
|
constructor(valueName: string) {
|
||||||
|
super();
|
||||||
|
this.name = "MissingBodyValue";
|
||||||
|
this.message = `Value '${valueName}' is missing from the body.`;
|
||||||
|
this.cause =
|
||||||
|
"A value that was required by the body of this request is missing.";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export default class PermissionsVerificationError extends Error {
|
||||||
|
constructor(message: string, cause?: string) {
|
||||||
|
super();
|
||||||
|
this.name = "PermissionsVerificationError";
|
||||||
|
this.message = message;
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export default class RoleError extends Error {
|
||||||
|
constructor(message: string, cause?: string) {
|
||||||
|
super();
|
||||||
|
this.name = "RoleError";
|
||||||
|
this.message = message;
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export default class SessionError extends Error {
|
||||||
|
constructor(message: string, cause?: string) {
|
||||||
|
super();
|
||||||
|
this.name = "SessionError";
|
||||||
|
this.message = message;
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export default class SessionTokenError extends Error {
|
||||||
|
constructor(message: string, cause?: string) {
|
||||||
|
super();
|
||||||
|
this.name = "SessionTokenError";
|
||||||
|
this.message = message;
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export default class UserError extends Error {
|
||||||
|
constructor(message: string, cause?: string) {
|
||||||
|
super();
|
||||||
|
this.name = "UserError";
|
||||||
|
this.message = message;
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export { default as redirect } from "./redirect";
|
||||||
|
export { default as refresh } from "./refresh";
|
||||||
|
export { default as uri } from "./uri";
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import * as msal from "@azure/msal-node";
|
||||||
|
import { API_BASE_URL, io, msalClient } from "../../constants";
|
||||||
|
import { users } from "../../managers/users";
|
||||||
|
|
||||||
|
/* /v1/auth/redirect */
|
||||||
|
export default createRoute("get", ["/redirect"], async (c) => {
|
||||||
|
c.status(200);
|
||||||
|
|
||||||
|
const tokenRequest: msal.AuthorizationCodeRequest = {
|
||||||
|
code: c.req.query().code as string,
|
||||||
|
scopes: ["user.read"],
|
||||||
|
redirectUri: `${API_BASE_URL}/v1/auth/redirect`,
|
||||||
|
};
|
||||||
|
|
||||||
|
const authResult = await msalClient.acquireTokenByCode(tokenRequest);
|
||||||
|
const callbackKey = c.req.query().state as string;
|
||||||
|
const tokens = await users.authenticate(authResult);
|
||||||
|
|
||||||
|
io.of(`/auth_callback`).emit(`auth:login:callback:${callbackKey}`, {
|
||||||
|
accessToken: tokens.accessToken,
|
||||||
|
refreshToken: tokens.refreshToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close the window because duh
|
||||||
|
return c.html(
|
||||||
|
`<script>
|
||||||
|
window.close();
|
||||||
|
</script>`,
|
||||||
|
);
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
status: 200,
|
||||||
|
message: "Auth Redirect Endpoint",
|
||||||
|
data: authResult,
|
||||||
|
successful: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { sessions } from "../../managers/sessions";
|
||||||
|
|
||||||
|
/* /v1/auth/refresh */
|
||||||
|
export default createRoute("post", ["/refresh"], async (c) => {
|
||||||
|
c.status(201);
|
||||||
|
|
||||||
|
const refreshToken = c.req.header("x-refresh-token") || "";
|
||||||
|
|
||||||
|
const session = await sessions.fetch({
|
||||||
|
refreshToken: refreshToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
const newAccessToken = await session.refresh(refreshToken);
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
status: 201,
|
||||||
|
message: "Token refreshed successfully!",
|
||||||
|
data: {
|
||||||
|
accessToken: newAccessToken,
|
||||||
|
refreshToken,
|
||||||
|
},
|
||||||
|
successful: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { API_BASE_URL } from "../../constants";
|
||||||
|
import cuid from "cuid";
|
||||||
|
|
||||||
|
/* /v1/auth/uri */
|
||||||
|
export default createRoute("get", ["/uri"], (c) => {
|
||||||
|
c.status(200);
|
||||||
|
|
||||||
|
const callbackKey = cuid();
|
||||||
|
const redirectUri = encodeURIComponent(`${API_BASE_URL}/v1/auth/redirect`);
|
||||||
|
const msUri = `https://login.microsoftonline.com/${process.env.MICROSOFT_TENANT_ID}/oauth2/v2.0/authorize?client_id=${process.env.MICROSOFT_CLIENT_ID}&response_type=code&redirect_uri=${redirectUri}&scope=openid+User.Read&state=${callbackKey}&prompt=login`;
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
status: 200,
|
||||||
|
message: "Successfully fetch Auth URI",
|
||||||
|
data: {
|
||||||
|
uri: msUri,
|
||||||
|
callbackKey: callbackKey,
|
||||||
|
},
|
||||||
|
successful: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../../modules/api-utils/createRoute";
|
||||||
|
import { companies } from "../../../managers/companies";
|
||||||
|
import { apiResponse } from "../../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../../middleware/authorization";
|
||||||
|
|
||||||
|
/* /v1/company/companies/[id]/configurations */
|
||||||
|
export default createRoute(
|
||||||
|
"get",
|
||||||
|
["/companies/:identifier/configurations"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
const company = await companies.fetch(c.req.param("identifier"));
|
||||||
|
const configurations = await company.fetchConfigurations();
|
||||||
|
|
||||||
|
const response = apiResponse.successful(
|
||||||
|
"Company Configurations Fetched Successfully!",
|
||||||
|
configurations,
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({
|
||||||
|
permissions: ["company.fetch", "company.fetch.configurations"],
|
||||||
|
}),
|
||||||
|
);
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../../modules/api-utils/createRoute";
|
||||||
|
import { companies } from "../../../managers/companies";
|
||||||
|
import { apiResponse } from "../../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../../middleware/authorization";
|
||||||
|
import GenericError from "../../../Errors/GenericError";
|
||||||
|
import { processObjectValuePerms } from "../../../modules/permission-utils/processObjectPermissions";
|
||||||
|
|
||||||
|
/* /v1/company/companies/[id] */
|
||||||
|
export default createRoute(
|
||||||
|
"get",
|
||||||
|
["/companies/:identifier"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
const company = await companies.fetch(c.req.param("identifier"));
|
||||||
|
const includeAddress = c.req.query("includeAddress") === "true";
|
||||||
|
const includePrimaryContact =
|
||||||
|
c.req.query("includePrimaryContact") === "true";
|
||||||
|
const includeAllContacts = c.req.query("includeAllContacts") === "true";
|
||||||
|
|
||||||
|
// Check for address-specific permission if includeAddress is requested
|
||||||
|
if (includeAddress) {
|
||||||
|
const user = c.get("user");
|
||||||
|
if (!user || !(await user.hasPermission("company.fetch.address"))) {
|
||||||
|
throw new GenericError({
|
||||||
|
name: "InsufficientPermission",
|
||||||
|
message: "You do not have permission to view company addresses.",
|
||||||
|
status: 403,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for contacts permission if includeAllContacts is requested
|
||||||
|
if (includeAllContacts) {
|
||||||
|
const user = c.get("user");
|
||||||
|
if (!user || !(await user.hasPermission("company.fetch.contacts"))) {
|
||||||
|
throw new GenericError({
|
||||||
|
name: "InsufficientPermission",
|
||||||
|
message: "You do not have permission to view company contacts.",
|
||||||
|
status: 403,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const companyData = company.toJson({
|
||||||
|
includeAddress,
|
||||||
|
includePrimaryContact,
|
||||||
|
includeAllContacts,
|
||||||
|
});
|
||||||
|
const gatedData = await processObjectValuePerms(
|
||||||
|
companyData,
|
||||||
|
"obj.company",
|
||||||
|
c.get("user"),
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = apiResponse.successful(
|
||||||
|
"Company Fetched Successfully!",
|
||||||
|
gatedData,
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({ permissions: ["company.fetch"] }),
|
||||||
|
);
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { createRoute } from "../../../modules/api-utils/createRoute";
|
||||||
|
import { companies } from "../../../managers/companies";
|
||||||
|
import { apiResponse } from "../../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../../middleware/authorization";
|
||||||
|
|
||||||
|
/* /v1/company/companies/[id]/sites */
|
||||||
|
export default createRoute(
|
||||||
|
"get",
|
||||||
|
["/companies/:identifier/sites"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
const company = await companies.fetch(c.req.param("identifier"));
|
||||||
|
const sites = await company.fetchSites();
|
||||||
|
|
||||||
|
const response = apiResponse.successful(
|
||||||
|
"Company Sites Fetched Successfully!",
|
||||||
|
sites,
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({
|
||||||
|
permissions: ["company.fetch", "company.fetch.sites"],
|
||||||
|
}),
|
||||||
|
);
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { createRoute } from "../../../modules/api-utils/createRoute";
|
||||||
|
import { unifiSites } from "../../../managers/unifiSites";
|
||||||
|
import { companies } from "../../../managers/companies";
|
||||||
|
import { apiResponse } from "../../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../../middleware/authorization";
|
||||||
|
import { processObjectValuePerms } from "../../../modules/permission-utils/processObjectPermissions";
|
||||||
|
|
||||||
|
/* GET /v1/company/companies/:identifier/unifi/sites */
|
||||||
|
export default createRoute(
|
||||||
|
"get",
|
||||||
|
["/companies/:identifier/unifi/sites"],
|
||||||
|
async (c) => {
|
||||||
|
const company = await companies.fetch(c.req.param("identifier"));
|
||||||
|
const sites = await unifiSites.fetchByCompany(company.id);
|
||||||
|
|
||||||
|
const gatedData = await Promise.all(
|
||||||
|
sites.map((site) =>
|
||||||
|
processObjectValuePerms(site, "obj.unifiSite", c.get("user")),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = apiResponse.successful(
|
||||||
|
"Company UniFi Sites Fetched Successfully!",
|
||||||
|
gatedData,
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({
|
||||||
|
permissions: ["unifi.access", "company.fetch"],
|
||||||
|
}),
|
||||||
|
);
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { companies } from "../../managers/companies";
|
||||||
|
import { apiResponse } from "../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../middleware/authorization";
|
||||||
|
|
||||||
|
/* /v1/company/count */
|
||||||
|
export default createRoute(
|
||||||
|
"get",
|
||||||
|
["/count"],
|
||||||
|
async (c) => {
|
||||||
|
const count = await companies.count();
|
||||||
|
|
||||||
|
const response = apiResponse.successful(
|
||||||
|
"Company count fetched successfully!",
|
||||||
|
{
|
||||||
|
count,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({ permissions: ["company.fetch.many"] }),
|
||||||
|
);
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { companies } from "../../managers/companies";
|
||||||
|
import { apiResponse } from "../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../middleware/authorization";
|
||||||
|
import { processObjectValuePerms } from "../../modules/permission-utils/processObjectPermissions";
|
||||||
|
|
||||||
|
/* /v1/company/companies */
|
||||||
|
export default createRoute(
|
||||||
|
"get",
|
||||||
|
["/companies"],
|
||||||
|
async (c) => {
|
||||||
|
const page = new Number(c.req.query("page") ?? 1) as number;
|
||||||
|
const rpp = new Number(c.req.query("rpp") ?? 30) as number; // Records Per Page
|
||||||
|
const search = c.req.query("search") as string;
|
||||||
|
|
||||||
|
const data = search
|
||||||
|
? await companies.search(search, page, rpp)
|
||||||
|
: await companies.fetchPages(page, rpp);
|
||||||
|
|
||||||
|
const companyQty = search
|
||||||
|
? (await companies.search(search, 1, 999999)).length
|
||||||
|
: await companies.count();
|
||||||
|
|
||||||
|
const gatedData = await Promise.all(
|
||||||
|
data.map((item) =>
|
||||||
|
processObjectValuePerms(item, "obj.company", c.get("user")),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
let response = apiResponse.successful(
|
||||||
|
"Companies Fetched Successfully!",
|
||||||
|
gatedData,
|
||||||
|
{
|
||||||
|
pagination: {
|
||||||
|
previousPage: page == 1 ? null : page - 1, // Previous Page
|
||||||
|
currentPage: page, // Current Page
|
||||||
|
nextPage: page >= companyQty / rpp ? null : page + 1, // Next Page
|
||||||
|
totalPages: Math.ceil(companyQty / rpp), // Total Number of Pages
|
||||||
|
totalRecords: companyQty, // Total Number of Records
|
||||||
|
listedRecords: rpp, // Total Number of Records being recieved at time of request.
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({ permissions: ["company.fetch.many"] }),
|
||||||
|
);
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { default as fetchAll } from "./fetchAll";
|
||||||
|
import { default as fetch } from "./[id]/fetch";
|
||||||
|
import { default as configurations } from "./[id]/configurations";
|
||||||
|
import { default as sites } from "./[id]/sites";
|
||||||
|
import { default as unifiSites } from "./[id]/unifiSites";
|
||||||
|
import { default as count } from "./count";
|
||||||
|
|
||||||
|
export { configurations, count, fetch, fetchAll, sites, unifiSites };
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { credentialTypes } from "../../managers/credentialTypes";
|
||||||
|
import { apiResponse } from "../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../middleware/authorization";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { ValueType } from "../../modules/credentials/credentialTypeDefs";
|
||||||
|
|
||||||
|
/* /v1/credential-type */
|
||||||
|
export default createRoute(
|
||||||
|
"post",
|
||||||
|
["/"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
const body = await c.req.json();
|
||||||
|
|
||||||
|
const fieldSchema: z.ZodType<any> = z.lazy(() =>
|
||||||
|
z.object({
|
||||||
|
id: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
required: z.boolean(),
|
||||||
|
secure: z.boolean(),
|
||||||
|
valueType: z.enum(Object.values(ValueType)),
|
||||||
|
subFields: z.array(fieldSchema).optional(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const schema = z.object({
|
||||||
|
name: z.string().min(1, "Name is required"),
|
||||||
|
permissionScope: z.string().min(1, "Permission scope is required"),
|
||||||
|
icon: z.string().optional(),
|
||||||
|
fields: z.array(fieldSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = schema.parse(body);
|
||||||
|
|
||||||
|
console.log("Creating Credential Type with data:", data);
|
||||||
|
|
||||||
|
const credentialType = await credentialTypes.create(data as any);
|
||||||
|
|
||||||
|
const response = apiResponse.created(
|
||||||
|
"Credential Type Created Successfully!",
|
||||||
|
credentialType.toJson(),
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({ permissions: ["credential_type.create"] }),
|
||||||
|
);
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { credentialTypes } from "../../managers/credentialTypes";
|
||||||
|
import { apiResponse } from "../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../middleware/authorization";
|
||||||
|
|
||||||
|
/* /v1/credential-type/:id */
|
||||||
|
export default createRoute(
|
||||||
|
"delete",
|
||||||
|
["/:id"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
await credentialTypes.delete(c.req.param("id"));
|
||||||
|
|
||||||
|
const response = apiResponse.successful(
|
||||||
|
"Credential Type Deleted Successfully!",
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({ permissions: ["credential_type.delete"] }),
|
||||||
|
);
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { credentialTypes } from "../../managers/credentialTypes";
|
||||||
|
import { apiResponse } from "../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../middleware/authorization";
|
||||||
|
import { processObjectValuePerms } from "../../modules/permission-utils/processObjectPermissions";
|
||||||
|
|
||||||
|
/* /v1/credential-type/:identifier */
|
||||||
|
export default createRoute(
|
||||||
|
"get",
|
||||||
|
["/:identifier"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
const credentialType = await credentialTypes.fetch(
|
||||||
|
c.req.param("identifier"),
|
||||||
|
);
|
||||||
|
|
||||||
|
const gatedData = await processObjectValuePerms(
|
||||||
|
credentialType.toJson({ includeCredentialCount: true }),
|
||||||
|
"obj.credentialType",
|
||||||
|
c.get("user"),
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = apiResponse.successful(
|
||||||
|
"Credential Type Fetched Successfully!",
|
||||||
|
gatedData,
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({ permissions: ["credential_type.fetch"] }),
|
||||||
|
);
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { credentialTypes } from "../../managers/credentialTypes";
|
||||||
|
import { apiResponse } from "../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../middleware/authorization";
|
||||||
|
import { processObjectValuePerms } from "../../modules/permission-utils/processObjectPermissions";
|
||||||
|
|
||||||
|
/* /v1/credential-type */
|
||||||
|
export default createRoute(
|
||||||
|
"get",
|
||||||
|
["/"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
const allCredentialTypes = await credentialTypes.fetchAll();
|
||||||
|
|
||||||
|
const gatedData = await Promise.all(
|
||||||
|
allCredentialTypes.map((ct) =>
|
||||||
|
processObjectValuePerms(
|
||||||
|
ct.toJson({ includeCredentialCount: true }),
|
||||||
|
"obj.credentialType",
|
||||||
|
c.get("user"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = apiResponse.successful(
|
||||||
|
"Credential Types Fetched Successfully!",
|
||||||
|
gatedData,
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({ permissions: ["credential_type.fetch.many"] }),
|
||||||
|
);
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { credentialTypes } from "../../managers/credentialTypes";
|
||||||
|
import { apiResponse } from "../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../middleware/authorization";
|
||||||
|
import { processObjectValuePerms } from "../../modules/permission-utils/processObjectPermissions";
|
||||||
|
|
||||||
|
/* /v1/credential-type/:id/credentials */
|
||||||
|
export default createRoute(
|
||||||
|
"get",
|
||||||
|
["/:id/credentials"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
const credentialType = await credentialTypes.fetch(c.req.param("id"));
|
||||||
|
const credentials = await credentialType.fetchCredentials();
|
||||||
|
|
||||||
|
const gatedData = await Promise.all(
|
||||||
|
credentials.map((cred) =>
|
||||||
|
processObjectValuePerms(cred.toJson(), "obj.credential", c.get("user")),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = apiResponse.successful(
|
||||||
|
"Credentials Fetched Successfully!",
|
||||||
|
gatedData,
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({
|
||||||
|
permissions: ["credential_type.fetch", "credential.fetch.many"],
|
||||||
|
}),
|
||||||
|
);
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { default as fetch } from "./fetch";
|
||||||
|
import { default as fetchAll } from "./fetchAll";
|
||||||
|
import { default as create } from "./create";
|
||||||
|
import { default as update } from "./update";
|
||||||
|
import { default as deleteCredentialType } from "./delete";
|
||||||
|
import { default as fetchCredentials } from "./fetchCredentials";
|
||||||
|
|
||||||
|
export {
|
||||||
|
fetch,
|
||||||
|
fetchAll,
|
||||||
|
create,
|
||||||
|
update,
|
||||||
|
deleteCredentialType as delete,
|
||||||
|
fetchCredentials,
|
||||||
|
};
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { credentialTypes } from "../../managers/credentialTypes";
|
||||||
|
import { apiResponse } from "../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../middleware/authorization";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { ValueType } from "../../modules/credentials/credentialTypeDefs";
|
||||||
|
|
||||||
|
/* /v1/credential-type/:id */
|
||||||
|
export default createRoute(
|
||||||
|
"patch",
|
||||||
|
["/:id"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
const body = await c.req.json();
|
||||||
|
const credentialType = await credentialTypes.fetch(c.req.param("id"));
|
||||||
|
|
||||||
|
const fieldSchema: z.ZodType<any> = z.lazy(() =>
|
||||||
|
z.object({
|
||||||
|
id: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
required: z.boolean(),
|
||||||
|
secure: z.boolean(),
|
||||||
|
valueType: z.enum(Object.values(ValueType)),
|
||||||
|
subFields: z.array(fieldSchema).optional(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const schema = z.object({
|
||||||
|
name: z.string().optional(),
|
||||||
|
permissionScope: z.string().optional(),
|
||||||
|
icon: z.string().optional(),
|
||||||
|
fields: z.array(fieldSchema).optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = schema.parse(body);
|
||||||
|
|
||||||
|
await credentialType.update(data as any);
|
||||||
|
|
||||||
|
const response = apiResponse.successful(
|
||||||
|
"Credential Type Updated Successfully!",
|
||||||
|
credentialType.toJson(),
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({ permissions: ["credential_type.update"] }),
|
||||||
|
);
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { credentials } from "../../managers/credentials";
|
||||||
|
import { apiResponse } from "../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../middleware/authorization";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
/* POST /v1/credential/credentials/:id/sub-credentials */
|
||||||
|
export default createRoute(
|
||||||
|
"post",
|
||||||
|
["/credentials/:id/sub-credentials"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
const parentId = c.req.param("id");
|
||||||
|
const body = await c.req.json();
|
||||||
|
|
||||||
|
const schema = z.object({
|
||||||
|
fieldId: z.string().min(1, "Field ID is required"),
|
||||||
|
name: z.string().min(1, "Name is required"),
|
||||||
|
fields: z.array(
|
||||||
|
z.object({
|
||||||
|
fieldId: z.string(),
|
||||||
|
value: z.string(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = schema.parse(body);
|
||||||
|
|
||||||
|
const subCredential = await credentials.addSubCredential(
|
||||||
|
parentId,
|
||||||
|
data.fieldId,
|
||||||
|
{
|
||||||
|
name: data.name,
|
||||||
|
fields: data.fields,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = apiResponse.created(
|
||||||
|
"Sub-Credential Created Successfully!",
|
||||||
|
subCredential.toJson(),
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({
|
||||||
|
permissions: ["credential.fetch", "credential.sub_credentials.create"],
|
||||||
|
}),
|
||||||
|
);
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { Hono } from "hono/tiny";
|
||||||
|
import { createRoute } from "../../modules/api-utils/createRoute";
|
||||||
|
import { credentials } from "../../managers/credentials";
|
||||||
|
import { apiResponse } from "../../modules/api-utils/apiResponse";
|
||||||
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
||||||
|
import { authMiddleware } from "../middleware/authorization";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
/* /v1/credential */
|
||||||
|
export default createRoute(
|
||||||
|
"post",
|
||||||
|
["/credentials"],
|
||||||
|
|
||||||
|
async (c) => {
|
||||||
|
const body = await c.req.json();
|
||||||
|
|
||||||
|
const schema = z.object({
|
||||||
|
name: z.string().min(1, "Name is required"),
|
||||||
|
notes: z.string().optional(),
|
||||||
|
typeId: z.string().min(1, "Type ID is required"),
|
||||||
|
companyId: z.string().min(1, "Company ID is required"),
|
||||||
|
fields: z.array(
|
||||||
|
z.object({
|
||||||
|
fieldId: z.string(),
|
||||||
|
value: z.string(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
subCredentials: z
|
||||||
|
.record(
|
||||||
|
z.string(),
|
||||||
|
z.array(
|
||||||
|
z.object({
|
||||||
|
name: z.string().min(1, "Sub-credential name is required"),
|
||||||
|
fields: z.array(
|
||||||
|
z.object({
|
||||||
|
fieldId: z.string(),
|
||||||
|
value: z.string(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = schema.parse(body);
|
||||||
|
|
||||||
|
const credential = await credentials.create(data);
|
||||||
|
|
||||||
|
const response = apiResponse.created(
|
||||||
|
"Credential Created Successfully!",
|
||||||
|
credential.toJson(),
|
||||||
|
);
|
||||||
|
return c.json(response, response.status as ContentfulStatusCode);
|
||||||
|
},
|
||||||
|
authMiddleware({ permissions: ["credential.create"] }),
|
||||||
|
);
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user