Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"i18next": "^25.3.2",
"jcode-ui": "file:../../jcode/packages/jcode-ui",
"jcode-ui-core": "file:../../jcode/packages/jcode-ui-core",
"jtype-board-react": "github:cnjack/jtype#eff1d85fbff89d05d950b02135ef0a3d534a6c4b&path:/packages/board-react",
"jtype-board-react": "github:cnjack/jtype#a83f55b8112cc534f42c66e9f8f1b6274ce3706d&path:/packages/board-react",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-i18next": "^15.6.1",
Expand Down
12 changes: 6 additions & 6 deletions console/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions console/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { NewProjectPage } from './pages/NewProjectPage';
import { ProjectDetailPage } from './pages/ProjectDetailPage';
import { ProjectPluginDetailPage } from './pages/ProjectPluginDetailPage';
import { AutomationEditorPage } from './pages/AutomationEditorPage';
import { AutomationDetailPage } from './pages/AutomationDetailPage';
import { RunDetailPage } from './pages/RunDetailPage';
import { DevicesPage } from './pages/DevicesPage';
import { DeviceWelcomePage } from './pages/DeviceWelcomePage';
Expand Down Expand Up @@ -70,6 +71,7 @@ export function App() {
<Route path="/projects/:projectId" element={<ProjectDetailPage />} />
<Route path="/projects/:projectId/plugins/:provider" element={<ProjectPluginDetailPage />} />
<Route path="/projects/:projectId/automations/new" element={<AutomationEditorPage />} />
<Route path="/projects/:projectId/automations/:automationId" element={<AutomationDetailPage />} />
<Route path="/projects/:projectId/automations/:automationId/edit" element={<AutomationEditorPage />} />
<Route path="/runs/:runId" element={<RunDetailPage />} />
<Route path="/devices" element={<DevicesPage />} />
Expand Down
16 changes: 16 additions & 0 deletions console/src/api/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ describe('httpClient — request shaping', () => {
expect(JSON.parse(calls[0]!.init!.body as string)).toEqual({ prompt: 'do it' });
});

it('encodes Card execution scope and opaque pagination cursor', async () => {
const { calls } = mockFetch(() => ({
body: { claim: null, items: [], next_cursor: null },
}));
const client = createHttpClient('t');
await client.listServiceKanbanCardExecutions(
'service/1', 'workspace 1', 'cards/payment fix.md', 'opaque+/cursor', 12,
);
const url = new URL(calls[0]!.url, 'https://console.test');
expect(url.pathname).toBe('/api/v1/services/service%2F1/kanban/card-executions');
expect(url.searchParams.get('workspace_id')).toBe('workspace 1');
expect(url.searchParams.get('document_path')).toBe('cards/payment fix.md');
expect(url.searchParams.get('before')).toBe('opaque+/cursor');
expect(url.searchParams.get('limit')).toBe('12');
});

it('stages an attachment as JSON and uploads its raw body through Cloud', async () => {
const { calls } = mockFetch(({ url }) => {
if (url.endsWith('/attachments/intents')) {
Expand Down
80 changes: 80 additions & 0 deletions console/src/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ import type {
PrInfo,
Project,
ProjectAutomationSpec,
AutomationExecution,
AutomationExecutionsPage,
ProjectPlugin,
PluginAuditEvent,
PluginConsentInput,
PluginInstallStart,
GitHubAppInstallation,
GitHubInstallationConsentPreview,
JTypePluginConnectStatus,
KanbanCardExecutionsPage,
ProviderKind,
PluginRepositoryResource,
PluginWorkspaceResource,
Expand Down Expand Up @@ -77,13 +80,18 @@ import type {
UpdateProjectAutomationInput,
PutServiceKanbanInput,
ServiceKanbanBinding,
ServiceKanbanPolicy,
UpdateModelInput,
UpdateModelProviderInput,
UpdateProjectInput,
UpdateProviderModelInput,
UpdateServiceInput,
UserSearchResult,
UsersEnvelope,
UsageSummary,
UsageSummaryEnvelope,
ModelPricingRevision,
CreateModelPricingRevisionInput,
} from './types';

// ApiError / apiErrorCode / TokenSource live in @jcloud/device-ui (M6 shared
Expand Down Expand Up @@ -335,7 +343,18 @@ export interface ApiClient {
createProjectAutomation(projectId: string, input: CreateProjectAutomationInput): Promise<ProjectAutomationSpec>;
updateProjectAutomation(projectId: string, automationId: string, input: UpdateProjectAutomationInput): Promise<ProjectAutomationSpec>;
deleteProjectAutomation(projectId: string, automationId: string): Promise<void>;
listAutomationExecutions(automationId: string, before?: string, state?: string, limit?: number): Promise<AutomationExecutionsPage>;
getAutomationExecution(automationId: string, executionId: string): Promise<AutomationExecution>;
runAutomationNow(automationId: string, idempotencyKey: string): Promise<AutomationExecution>;
getAutomationUsage(automationId: string, from?: string, to?: string): Promise<UsageSummary>;
getProjectUsage(projectId: string, groupBy: 'service' | 'automation' | 'model', from?: string, to?: string): Promise<UsageSummaryEnvelope>;
getAccountUsage(groupBy: 'device' | 'model' | 'grant', from?: string, to?: string): Promise<UsageSummaryEnvelope>;
getServiceUsage(serviceId: string, from?: string, to?: string): Promise<UsageSummary>;
listModelPricingRevisions(modelId: string): Promise<ModelPricingRevision[]>;
createModelPricingRevision(modelId: string, input: CreateModelPricingRevisionInput): Promise<ModelPricingRevision>;
getServiceKanban(serviceId: string): Promise<ServiceKanbanBinding>;
getServiceKanbanPolicy(serviceId: string): Promise<ServiceKanbanPolicy>;
listServiceKanbanCardExecutions(serviceId: string, workspaceId: string, documentPath: string, before?: string, limit?: number): Promise<KanbanCardExecutionsPage>;
putServiceKanban(serviceId: string, input: PutServiceKanbanInput): Promise<ServiceKanbanBinding>;
deleteServiceKanban(serviceId: string): Promise<void>;
/** Lists branches through the Service's bound Plugin; never exposes a Git credential. */
Expand Down Expand Up @@ -406,6 +425,14 @@ export interface HttpClientOptions {
onUnauthorized?: () => void;
}

function usageParams(from?: string, to?: string): string {
const params = new URLSearchParams();
if (from) params.set('from', from);
if (to) params.set('to', to);
const value = params.toString();
return value ? `?${value}` : '';
}

export function createHttpClient(
token: TokenSource,
opts: HttpClientOptions = {},
Expand Down Expand Up @@ -823,7 +850,60 @@ export function createHttpClient(
}),
deleteProjectAutomation: (_projectId, automationId) =>
req<void>(`/automations/${encodeURIComponent(automationId)}`, { method: 'DELETE' }),
listAutomationExecutions: (automationId, before, state, limit = 20) => {
const params = new URLSearchParams({ limit: String(limit) });
if (before) params.set('before', before);
if (state) params.set('state', state);
return req<AutomationExecutionsPage>(`/automations/${encodeURIComponent(automationId)}/executions?${params.toString()}`);
},
getAutomationExecution: (automationId, executionId) =>
req<AutomationExecution>(`/automations/${encodeURIComponent(automationId)}/executions/${encodeURIComponent(executionId)}`),
runAutomationNow: (automationId, idempotencyKey) =>
req<AutomationExecution>(`/automations/${encodeURIComponent(automationId)}/executions`, {
method: 'POST', body: JSON.stringify({ idempotency_key: idempotencyKey }),
}),
getAutomationUsage: (automationId, from, to) => {
const params = usageParams(from, to);
return req<UsageSummary>(`/automations/${encodeURIComponent(automationId)}/usage${params}`);
},
getProjectUsage: (projectId, groupBy, from, to) => {
const params = new URLSearchParams({ group_by: groupBy });
if (from) params.set('from', from);
if (to) params.set('to', to);
return req<UsageSummaryEnvelope>(`/projects/${encodeURIComponent(projectId)}/usage?${params.toString()}`);
},
getAccountUsage: (groupBy, from, to) => {
const params = new URLSearchParams({ group_by: groupBy });
if (from) params.set('from', from);
if (to) params.set('to', to);
return req<UsageSummaryEnvelope>(`/account/usage?${params.toString()}`);
},
getServiceUsage: (serviceId, from, to) => {
const params = usageParams(from, to);
return req<UsageSummary>(`/services/${encodeURIComponent(serviceId)}/usage${params}`);
},
listModelPricingRevisions: async (modelId) =>
(await req<{ pricing_revisions: ModelPricingRevision[] }>(
`/system/models/${encodeURIComponent(modelId)}/pricing-revisions`,
)).pricing_revisions ?? [],
createModelPricingRevision: (modelId, input) =>
req<ModelPricingRevision>(`/system/models/${encodeURIComponent(modelId)}/pricing-revisions`, {
method: 'POST',
body: JSON.stringify(input),
}),
getServiceKanban: (serviceId) => req<ServiceKanbanBinding>(`/services/${encodeURIComponent(serviceId)}/kanban`),
getServiceKanbanPolicy: (serviceId) => req<ServiceKanbanPolicy>(`/services/${encodeURIComponent(serviceId)}/kanban/policy`),
listServiceKanbanCardExecutions: (serviceId, workspaceId, documentPath, before, limit = 20) => {
const params = new URLSearchParams({
workspace_id: workspaceId,
document_path: documentPath,
limit: String(limit),
});
if (before) params.set('before', before);
return req<KanbanCardExecutionsPage>(
`/services/${encodeURIComponent(serviceId)}/kanban/card-executions?${params.toString()}`,
);
},
putServiceKanban: (serviceId, input) => req<ServiceKanbanBinding>(`/services/${encodeURIComponent(serviceId)}/kanban`, {
method: 'PUT', body: JSON.stringify(input),
}),
Expand Down
Loading
Loading