Files
Stirling-PDF/frontend/editor/src/proprietary/services/workflowService.ts
T
0a50e765b7 Restructure/frontend editor (#6404)
## Move editor under `frontend/editor/`

Pure restructure: `frontend/` becomes the workspace, `frontend/editor/`
holds
  the PDF editor. 1775 file renames + 40 wiring edits. No logic changes.

  ### Why

`frontend/` is currently the editor — its `src/`, `public/`,
`src-tauri/`,
  config files all sit at the root. Promoting `frontend/` to a
workspace and putting the editor in a sibling folder leaves room for
future
apps to drop in alongside it, sharing one `package.json` /
`node_modules` /
  lint config / Storybook.

  ### What moves

  frontend/
  ├── editor/                ← NEW: everything editor-specific
  │   ├── src/               ← was frontend/src/
  │   ├── public/            ← was frontend/public/
  │   ├── src-tauri/         ← was frontend/src-tauri/
│ ├── index.html, vite.config.ts, vitest.config.ts, playwright.config.ts
  │   ├── tsconfig*.json, tailwind.config.js, postcss.config.js
  │   ├── scripts/
  │   ├── .env, .env.desktop, .env.saas
  │   └── DeveloperGuide.md
├── package.json, package-lock.json, node_modules/ ← workspace install
  ├── eslint.config.mjs, .prettierrc, .prettierignore ← shared tooling
  ├── .gitignore
  └── README.md

  ### Wiring edits (40 files)

  - `.taskfiles/frontend.yml`, `desktop.yml`, `e2e.yml`
  - `build.gradle`, `app/core/build.gradle`
- `eslint.config.mjs`, `frontend/package.json`, `.gitignore`,
`.prettierignore`
  - `docker/frontend/Dockerfile`
  - 8 `.github/workflows/*.yml`, plus `.github/dependabot.yml`,
    `.github/config/.files.yaml`, `.github/labeler-config-srvaroa.yml`
  - `scripts/translations/**`
- Docs: `AGENTS.md`, `CLAUDE.md`, `ADDING_TOOLS.md`,
`DeveloperGuide.md`,
`WINDOWS_SIGNING.md`, `devGuide/HowToAddNewLanguage.md`,
`frontend/README.md`,
    `frontend/editor/DeveloperGuide.md`

Plus 3 renamed + edited: `editor/vite.config.ts` (env path +
node_modules
  walk-up), `editor/scripts/setup-env.mts` (renamed from `.ts` for
`import.meta.url`), `editor/scripts/build-provisioner.mjs` (resolve
src-tauri
  relative to script).

  ### Verification

  | Check | Result |
  |---|---|
  | `task frontend:typecheck:all` (6 variants) | exit 0 |
  | `task frontend:lint` (eslint + dpdm) | exit 0 |
  | `task frontend:format:check` | exit 0 |
  | `task frontend:test` | 657 tests pass, 50 files |
| `task frontend:build:{core,proprietary,saas,desktop,prototypes}` | all
green |
| `task desktop:build` | full Tauri pipeline →
`Stirling-PDF_2.11.0_x64_en-US.msi` |
  | `playwright test --list --project=stubbed` | 172 tests discovered |

`task desktop:build` exercises the heaviest path — Rust + WiX + MSI
bundle
against the moved `editor/src-tauri/`. If anything in the restructure
was
  wrong it wouldn't have built.

  ### Test plan

  - [ ] `frontend-validation.yml` green
  - [ ] `e2e-stubbed.yml` green
  - [ ] `tauri-build.yml` green on at least one platform
  - [ ] `check_toml.yml` runs on a translation-touching PR

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
2026-05-22 13:40:34 +01:00

138 lines
3.9 KiB
TypeScript

import api from "@app/services/apiClient";
export interface ParticipantResponse {
id: number;
userId?: number;
email: string;
name: string;
status: "PENDING" | "NOTIFIED" | "VIEWED" | "SIGNED" | "DECLINED";
// Null for participant-facing endpoints (`/api/v1/workflow/participant/...`); the owner-facing
// `/api/v1/security/cert-sign/sessions/...` endpoints still populate it for share-link
// distribution. Never used to look up other participants — see GHSA-qgg6-mxw4-xg62.
shareToken: string | null;
accessRole: "EDITOR" | "COMMENTER" | "VIEWER";
expiresAt?: string;
lastUpdated: string;
hasCompleted: boolean;
isExpired: boolean;
}
export interface WorkflowSessionResponse {
sessionId: string;
ownerId: number;
ownerUsername: string;
workflowType: "SIGNING" | "REVIEW" | "APPROVAL";
documentName: string;
ownerEmail?: string;
message?: string;
dueDate?: string;
status: "IN_PROGRESS" | "COMPLETED" | "CANCELLED";
finalized: boolean;
createdAt: string;
updatedAt: string;
participants: ParticipantResponse[];
hasProcessedFile: boolean;
originalFileId?: number;
processedFileId?: number;
}
export interface SignatureSubmissionRequest {
participantToken: string;
certType?: string;
password?: string;
p12File?: File;
jksFile?: File;
showSignature?: boolean;
pageNumber?: number;
location?: string;
reason?: string;
showLogo?: boolean;
wetSignatureData?: string;
}
/**
* Service for managing workflow sessions
*/
class WorkflowService {
/**
* Get session details by participant token (no authentication required)
*/
async getSessionByToken(token: string): Promise<WorkflowSessionResponse> {
const response = await api.get("/api/v1/workflow/participant/session", {
params: { token },
});
return response.data;
}
/**
* Get participant details by token
*/
async getParticipantDetails(token: string): Promise<ParticipantResponse> {
const response = await api.get("/api/v1/workflow/participant/details", {
params: { token },
});
return response.data;
}
/**
* Submit signature as a participant
*/
async submitSignature(
request: SignatureSubmissionRequest,
): Promise<ParticipantResponse> {
const formData = new FormData();
formData.append("participantToken", request.participantToken);
if (request.certType) formData.append("certType", request.certType);
if (request.password) formData.append("password", request.password);
if (request.p12File) formData.append("p12File", request.p12File);
if (request.jksFile) formData.append("jksFile", request.jksFile);
if (request.showSignature !== undefined)
formData.append("showSignature", request.showSignature.toString());
if (request.pageNumber)
formData.append("pageNumber", request.pageNumber.toString());
if (request.location) formData.append("location", request.location);
if (request.reason) formData.append("reason", request.reason);
if (request.showLogo !== undefined)
formData.append("showLogo", request.showLogo.toString());
if (request.wetSignatureData)
formData.append("wetSignatureData", request.wetSignatureData);
const response = await api.post(
"/api/v1/workflow/participant/submit-signature",
formData,
);
return response.data;
}
/**
* Decline participation
*/
async declineParticipation(
token: string,
reason?: string,
): Promise<ParticipantResponse> {
const response = await api.post(
"/api/v1/workflow/participant/decline",
null,
{
params: { token, reason },
},
);
return response.data;
}
/**
* Download document as participant
*/
async getParticipantDocument(token: string): Promise<Blob> {
const response = await api.get("/api/v1/workflow/participant/document", {
params: { token },
responseType: "blob",
});
return response.data;
}
}
export default new WorkflowService();