feat: expand novel IP and production workflows

This commit is contained in:
www
2026-09-18 08:14:05 +02:00
parent b2ae4600b4
commit d9c81a3ac0
235 changed files with 117971 additions and 2721 deletions
+4147 -64
View File
File diff suppressed because it is too large Load Diff
+67 -20
View File
@@ -1,4 +1,10 @@
import { ApiCryptoClient, base64ToBytes } from './crypto';
import {
beginAiRequestInspection,
completeAiRequestInspection,
failAiRequestInspection,
isInspectableAiRequest
} from '../../../shared/frontend/ai-request-inspector/ai-request-inspector';
export interface ApiEnvelope<T> {
code: number;
@@ -89,6 +95,23 @@ export class ApiClient {
});
}
async delete<T>(path: string) {
return this.request<T>(path, {
method: 'DELETE'
});
}
async getAssetPreviewUrl(assetId: string) {
const result = await this.request<{ asset: unknown; url: string; expires_in_seconds: number }>(
`/assets/${assetId}/preview-url`
);
return {
...result,
url: this.localizePreviewUrl(result.url)
};
}
async downloadAssetBlob(assetId: string) {
const response = await fetch(`${API_BASE_URL}/assets/${assetId}/download`, {
headers: {
@@ -136,6 +159,17 @@ export class ApiClient {
return { blob, filename };
}
private localizePreviewUrl(url: string) {
if (!API_BASE_URL.startsWith('/')) return url;
try {
const parsed = new URL(url);
return `${parsed.pathname}${parsed.search}${parsed.hash}`;
} catch {
return url;
}
}
private async request<T>(path: string, init: RequestInit = {}) {
const method = (init.method ?? 'GET').toUpperCase();
const shouldSendEmptyJsonBody =
@@ -146,29 +180,42 @@ export class ApiClient {
: shouldSendEmptyJsonBody
? {}
: undefined;
const encryptedBody =
bodyPayload !== undefined ? await apiCrypto.encryptBody(bodyPayload) : null;
const encryptedHeaders = encryptedBody?.headers ?? (await apiCrypto.encryptionHeaders());
const response = await fetch(`${API_BASE_URL}${path}`, {
...init,
body: encryptedBody ? JSON.stringify(encryptedBody.body) : init.body,
headers: {
...encryptedHeaders,
'content-type': 'application/json',
...(this.token ? { authorization: `Bearer ${this.token}` } : {}),
...(init.headers ?? {})
}
});
const rawPayload = (await response.json().catch(() => null)) as unknown;
const payload = rawPayload
? await apiCrypto.decryptResponse<ApiEnvelope<T>>(rawPayload)
const inspectionId = isInspectableAiRequest(path, method)
? beginAiRequestInspection({ path, method, body: bodyPayload })
: null;
if (!response.ok || !payload || payload.code !== 0) {
throw new Error(payload?.message || `Request failed: ${response.status}`);
}
try {
const encryptedBody =
bodyPayload !== undefined ? await apiCrypto.encryptBody(bodyPayload) : null;
const encryptedHeaders = encryptedBody?.headers ?? (await apiCrypto.encryptionHeaders());
const response = await fetch(`${API_BASE_URL}${path}`, {
...init,
body: encryptedBody ? JSON.stringify(encryptedBody.body) : init.body,
headers: {
...encryptedHeaders,
'content-type': 'application/json',
...(this.token ? { authorization: `Bearer ${this.token}` } : {}),
...(init.headers ?? {})
}
});
const rawPayload = (await response.json().catch(() => null)) as unknown;
const payload = rawPayload
? await apiCrypto.decryptResponse<ApiEnvelope<T>>(rawPayload)
: null;
return payload.data;
if (!response.ok || !payload || payload.code !== 0) {
throw new Error(payload?.message || `Request failed: ${response.status}`);
}
completeAiRequestInspection(inspectionId, {
requestId: payload.request_id,
responseData: payload.data
});
return payload.data;
} catch (error) {
failAiRequestInspection(inspectionId, error);
throw error;
}
}
}
+536
View File
@@ -351,6 +351,23 @@ nav button:hover {
justify-content: space-between;
}
.pagination-bar {
align-items: center;
border-top: 1px solid #e7edf5;
color: #607086;
display: flex;
flex-wrap: wrap;
gap: 10px;
justify-content: space-between;
margin-top: 12px;
padding-top: 12px;
}
.pagination-bar strong {
color: #243044;
font-size: 13px;
}
.guide-card {
align-content: start;
min-height: 112px;
@@ -438,6 +455,16 @@ nav button:hover {
min-width: 0;
}
.form-hint {
color: #718096;
font-size: 12px;
line-height: 1.45;
}
.warning-text {
color: #b7791f;
}
.quota-grant-form input,
.quota-grant-form select {
min-width: 0;
@@ -536,6 +563,353 @@ nav button:hover {
grid-template-columns: minmax(360px, 1.1fr) minmax(360px, 0.9fr);
}
.novel-command-bar {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: 12px;
justify-content: space-between;
position: sticky;
top: 0;
z-index: 12;
}
.novel-command-bar > div:first-child {
display: grid;
gap: 3px;
}
.novel-command-bar strong {
color: #243044;
font-size: 15px;
}
.novel-command-bar span {
color: #64748b;
font-size: 12px;
}
.novel-export-mini-form {
align-items: end;
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: flex-end;
}
.novel-export-mini-form label {
display: grid;
gap: 4px;
}
.novel-export-mini-form input {
min-width: 112px;
width: 128px;
}
.novel-action-drawer {
width: min(900px, calc(100vw - 36px));
}
.novel-action-drawer .provider-form {
grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.novel-action-drawer .wide-field {
grid-column: 1 / -1;
}
.drawer-proposal-grid {
grid-template-columns: 1fr;
}
.novel-generation-panel {
display: grid;
gap: 14px;
}
.novel-generation-form {
border-bottom: 1px solid #e7edf5;
padding-bottom: 14px;
}
.novel-generation-runner {
display: grid;
gap: 10px;
}
.novel-generation-runner h3,
.novel-generation-summary h3 {
color: #243044;
font-size: 14px;
margin-bottom: 8px;
}
.novel-generation-summary {
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.novel-wizard-panel {
border-color: #bfd1ee;
display: grid;
gap: 14px;
}
.novel-wizard-form {
border-bottom: 1px solid #e7edf5;
padding-bottom: 14px;
}
.wizard-targets {
align-content: start;
display: flex;
flex-wrap: wrap;
gap: 10px 14px;
}
.wizard-targets > span {
flex-basis: 100%;
}
.wizard-progress {
background: #f7fafc;
border: 1px solid #d7e2ef;
border-radius: 8px;
display: grid;
gap: 8px;
grid-column: 1 / -1;
padding: 12px;
}
.wizard-progress-head {
align-items: center;
display: flex;
gap: 10px;
justify-content: space-between;
}
.wizard-progress-head strong {
color: #1f2a3a;
font-size: 14px;
}
.wizard-progress-head span,
.wizard-progress p,
.wizard-progress dd,
.wizard-progress dt {
color: #5c6d82;
font-size: 12px;
}
.wizard-progress p {
margin: 0;
}
.wizard-progress-track {
background: #e6edf5;
border-radius: 999px;
height: 8px;
overflow: hidden;
}
.wizard-progress-track span {
background: #2f6fdd;
border-radius: inherit;
display: block;
height: 100%;
transition: width 0.3s ease;
}
.wizard-progress dl {
display: grid;
gap: 4px 10px;
grid-template-columns: 64px minmax(0, 1fr);
margin: 0;
}
.wizard-progress dt {
font-weight: 700;
}
.wizard-progress dd {
margin: 0;
overflow-wrap: anywhere;
}
.wizard-progress.status-success {
background: #f2fbf6;
border-color: #bfe8cf;
}
.wizard-progress.status-success .wizard-progress-track span {
background: #2f9e61;
}
.wizard-progress.status-fallback {
background: #fffaf0;
border-color: #f2d39a;
}
.wizard-progress.status-fallback .wizard-progress-track span {
background: #d69e2e;
}
.wizard-progress.status-failed {
background: #fff5f5;
border-color: #f0b8b8;
}
.wizard-progress.status-failed .wizard-progress-track span {
background: #d64545;
}
.wizard-progress.status-paused {
background: #fffaf0;
border-color: #e8c46c;
}
.wizard-progress.status-paused .wizard-progress-track span {
background: #b7791f;
}
.wizard-proposal-grid {
display: grid;
gap: 12px;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.wizard-proposal-card {
background: #f8fbff;
border: 1px solid #d4e0ef;
border-radius: 8px;
display: grid;
gap: 10px;
min-width: 0;
padding: 13px;
}
.wizard-proposal-card.selected {
background: #f1f6ff;
border-color: #6d96d8;
}
.proposal-card-head {
align-items: start;
display: flex;
gap: 10px;
justify-content: space-between;
}
.proposal-card-head strong {
color: #18202c;
display: block;
font-size: 15px;
overflow-wrap: anywhere;
}
.proposal-card-head span,
.wizard-proposal-card p,
.proposal-detail-list dd {
color: #526379;
font-size: 12px;
line-height: 1.55;
}
.proposal-detail-list {
display: grid;
gap: 6px 10px;
grid-template-columns: 64px minmax(0, 1fr);
margin: 0;
}
.proposal-detail-list dt {
color: #243044;
font-size: 12px;
font-weight: 700;
}
.proposal-detail-list dd {
margin: 0;
overflow-wrap: anywhere;
}
.wizard-debug {
display: grid;
gap: 8px;
}
.wizard-debug summary {
color: #526379;
cursor: pointer;
font-size: 13px;
}
.wizard-idea-log-panel {
border-top: 1px solid #e7edf5;
display: grid;
gap: 10px;
padding-top: 12px;
}
.compact-heading {
margin-bottom: 0;
}
.compact-heading h3 {
color: #243044;
font-size: 14px;
margin: 0;
}
.wizard-idea-log-list {
display: grid;
gap: 10px;
}
.wizard-idea-log-card {
background: #ffffff;
border: 1px solid #dbe5f0;
border-radius: 8px;
display: grid;
gap: 8px;
padding: 12px;
}
.wizard-idea-log-head {
align-items: start;
display: flex;
gap: 10px;
justify-content: space-between;
}
.wizard-idea-log-head strong {
color: #1f2a3a;
font-size: 13px;
line-height: 1.45;
overflow-wrap: anywhere;
}
.wizard-idea-log-card dl {
display: grid;
gap: 5px 10px;
grid-template-columns: 52px minmax(0, 1fr);
margin: 0;
}
.wizard-idea-log-card dt {
color: #243044;
font-size: 12px;
font-weight: 700;
}
.wizard-idea-log-card dd {
color: #526379;
font-size: 12px;
line-height: 1.5;
margin: 0;
overflow-wrap: anywhere;
}
.selected {
background: #f1f6ff;
}
@@ -714,6 +1088,35 @@ nav button:hover {
width: min(820px, calc(100vw - 36px));
}
.ip-bible-drawer {
background: #f8fafc;
border-color: #b9c9dc;
color: #243044;
gap: 16px;
padding: 18px;
width: min(920px, calc(100vw - 36px));
}
.ip-bible-drawer .preview-header,
.ip-bible-drawer .drawer-section {
background: #ffffff;
border: 1px solid #dbe5f0;
border-radius: 8px;
padding: 14px;
}
.ip-bible-drawer .preview-header h2 {
color: #17243a;
font-size: 20px;
line-height: 1.25;
}
.ip-bible-drawer .preview-header p {
color: #5f7086;
line-height: 1.55;
margin: 3px 0 0;
}
.preview-header {
align-items: start;
display: flex;
@@ -740,6 +1143,139 @@ nav button:hover {
overflow-wrap: anywhere;
}
.inline-actions {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.ip-bible-hero {
background: #eef6ff;
border: 1px solid #c9ddf2;
border-radius: 8px;
border-left: 4px solid #3272c7;
display: grid;
gap: 6px;
padding: 15px 16px;
}
.ip-bible-hero span,
.ip-bible-summary-grid span {
color: #5b6d84;
font-size: 12px;
font-weight: 700;
}
.ip-bible-hero strong {
color: #16243a;
font-size: 16px;
line-height: 1.6;
overflow-wrap: anywhere;
}
.ip-bible-summary-grid {
display: grid;
gap: 10px;
grid-template-columns: repeat(4, minmax(0, 1fr));
}
.ip-bible-rule-grid {
display: grid;
gap: 10px;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.ip-bible-summary-grid article,
.ip-bible-rule-grid article,
.ip-bible-list article {
align-content: start;
align-items: start;
background: #ffffff;
border: 1px solid #dbe3ed;
border-radius: 8px;
display: grid;
gap: 6px;
grid-auto-rows: max-content;
min-width: 0;
padding: 12px;
}
.ip-bible-summary-grid article {
min-height: 174px;
}
.ip-bible-summary-grid p,
.ip-bible-rule-grid p {
color: #28364d;
font-size: 13px;
line-height: 1.6;
margin: 0;
overflow-wrap: anywhere;
white-space: pre-wrap;
}
.ip-bible-list {
display: grid;
gap: 8px;
}
.ip-bible-list pre,
.ip-bible-readable {
color: #28364d;
font-family: inherit;
font-size: 13px;
line-height: 1.6;
margin: 0;
overflow-wrap: anywhere;
white-space: pre-wrap;
word-break: break-word;
}
.ip-bible-rule-grid strong {
color: #17243a;
font-size: 13px;
}
.ip-bible-rule-grid ul {
display: grid;
gap: 6px;
margin: 0;
padding-left: 18px;
}
.ip-bible-rule-grid li {
overflow-wrap: anywhere;
}
.ip-bible-editor-section textarea {
background: #fbfdff;
border-color: #cbd7e6;
color: #20304a;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
font-size: 12px;
line-height: 1.55;
min-height: 320px;
resize: vertical;
width: 100%;
}
@media (max-width: 860px) {
.ip-bible-summary-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 560px) {
.ip-bible-summary-grid {
grid-template-columns: 1fr;
}
.ip-bible-summary-grid article {
min-height: 0;
}
}
.media-preview {
display: grid;
gap: 10px;