@zhin.js/console-contract 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/page.d.ts +441 -0
- package/lib/page.js +866 -1
- package/package.json +1 -1
- package/src/page.ts +1532 -1
package/lib/page.d.ts
CHANGED
|
@@ -21,8 +21,10 @@ export interface ClientModuleArtifact {
|
|
|
21
21
|
readonly module: string;
|
|
22
22
|
readonly hash: string;
|
|
23
23
|
readonly metadata?: unknown;
|
|
24
|
+
readonly blueprint?: ConsolePageBlueprint | ConsoleAdapterPageBlueprint;
|
|
24
25
|
}
|
|
25
26
|
export declare function normalizeClientModuleArtifact(value: unknown, label: string): Readonly<ClientModuleArtifact>;
|
|
27
|
+
export declare function isConsoleBlueprint(value: unknown): value is ConsolePageBlueprint | ConsoleAdapterPageBlueprint;
|
|
26
28
|
export interface PageManifest extends NormalizedPageMetadata {
|
|
27
29
|
readonly id: string;
|
|
28
30
|
readonly owner: string;
|
|
@@ -31,8 +33,447 @@ export interface PageManifest extends NormalizedPageMetadata {
|
|
|
31
33
|
readonly module: string;
|
|
32
34
|
readonly hash: string;
|
|
33
35
|
readonly route: string;
|
|
36
|
+
readonly blueprint?: ConsolePageBlueprint | ConsoleAdapterPageBlueprint;
|
|
34
37
|
}
|
|
35
38
|
export declare function definePage(metadata?: PageMetadata): Readonly<PageMetadata>;
|
|
36
39
|
export declare function normalizePageMetadata(localName: string, metadata: unknown): Readonly<NormalizedPageMetadata>;
|
|
37
40
|
export declare function pageRoute(owner: string, root: string, localName: string): string;
|
|
38
41
|
export declare function assertPageLocalName(value: string): void;
|
|
42
|
+
export type DeclarativeI18nText = string | {
|
|
43
|
+
readonly zh: string;
|
|
44
|
+
readonly en?: string;
|
|
45
|
+
readonly 'zh-CN'?: string;
|
|
46
|
+
};
|
|
47
|
+
export type DeclarativeBadgeTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';
|
|
48
|
+
export type DeclarativeButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
49
|
+
export type DeclarativeUiLocale = 'zh-CN' | 'en';
|
|
50
|
+
/** Framework-agnostic renderable value (string, number, boolean, null, undefined, or JSX/ReactNode in browser). */
|
|
51
|
+
export type DeclarativeRenderable = unknown;
|
|
52
|
+
/**
|
|
53
|
+
* Pure JSON-serializable expression descriptor for zero-closure Server-Driven Blueprints.
|
|
54
|
+
* Can be evaluated identically in Web Console, IM Card projection, and CLI TUI panels.
|
|
55
|
+
*/
|
|
56
|
+
export type DeclarativeValueExpr = {
|
|
57
|
+
readonly $path: string;
|
|
58
|
+
readonly fallback?: string | number | boolean;
|
|
59
|
+
} | {
|
|
60
|
+
readonly $count: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly $sum: {
|
|
63
|
+
readonly path: string;
|
|
64
|
+
readonly field: string;
|
|
65
|
+
};
|
|
66
|
+
} | {
|
|
67
|
+
readonly $format: DeclarativeI18nText;
|
|
68
|
+
readonly args: readonly string[];
|
|
69
|
+
} | {
|
|
70
|
+
readonly $map: {
|
|
71
|
+
readonly path: string;
|
|
72
|
+
readonly cases: Readonly<Record<string, DeclarativeI18nText>>;
|
|
73
|
+
readonly default?: DeclarativeI18nText;
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
readonly $join: {
|
|
77
|
+
readonly path: string;
|
|
78
|
+
readonly sep?: string;
|
|
79
|
+
readonly empty?: DeclarativeI18nText;
|
|
80
|
+
};
|
|
81
|
+
} | {
|
|
82
|
+
readonly $coalesce: readonly string[];
|
|
83
|
+
readonly fallback?: string | number | boolean;
|
|
84
|
+
};
|
|
85
|
+
export declare function isDeclarativeValueExpr(value: unknown): value is DeclarativeValueExpr;
|
|
86
|
+
export declare function resolveDataPath(data: unknown, path: string): unknown;
|
|
87
|
+
export declare function evaluateDeclarativeValue(exprOrKey: unknown, data: unknown, locale?: DeclarativeUiLocale): unknown;
|
|
88
|
+
export interface DeclarativePageContext<TData = Record<string, unknown>> {
|
|
89
|
+
readonly pluginId: string;
|
|
90
|
+
readonly locale: DeclarativeUiLocale;
|
|
91
|
+
readonly t: (key: string, ...values: readonly (string | number)[]) => string;
|
|
92
|
+
readonly resource: {
|
|
93
|
+
readonly state: 'loading' | 'ready' | 'empty' | 'error' | 'stale';
|
|
94
|
+
readonly data: TData | undefined;
|
|
95
|
+
readonly error: Error | undefined;
|
|
96
|
+
readonly lastSuccessAt: number | undefined;
|
|
97
|
+
readonly refreshing: boolean;
|
|
98
|
+
readonly refresh: () => Promise<boolean>;
|
|
99
|
+
readonly mutate: (updater: TData | ((previous: TData | undefined) => TData | undefined)) => void;
|
|
100
|
+
};
|
|
101
|
+
readonly call: <TResult = unknown>(method: string, params?: Readonly<Record<string, unknown>>) => Promise<TResult>;
|
|
102
|
+
readonly refresh: () => Promise<boolean>;
|
|
103
|
+
readonly notify: (tone: 'info' | 'success' | 'warning' | 'danger', message: string) => void;
|
|
104
|
+
}
|
|
105
|
+
export interface DeclarativeBadgeSpec<TData = Record<string, unknown>> {
|
|
106
|
+
readonly key?: string;
|
|
107
|
+
readonly label: DeclarativeI18nText | DeclarativeValueExpr | ((data: TData, ctx: DeclarativePageContext<TData>) => DeclarativeRenderable);
|
|
108
|
+
readonly tone?: DeclarativeBadgeTone | DeclarativeValueExpr | ((data: TData) => DeclarativeBadgeTone);
|
|
109
|
+
}
|
|
110
|
+
export interface DeclarativeStatSpec<TData = Record<string, unknown>> {
|
|
111
|
+
readonly key?: string;
|
|
112
|
+
readonly label: DeclarativeI18nText;
|
|
113
|
+
readonly value: (keyof TData & string) | string | DeclarativeValueExpr | ((data: TData, ctx: DeclarativePageContext<TData>) => DeclarativeRenderable);
|
|
114
|
+
readonly unit?: DeclarativeI18nText;
|
|
115
|
+
readonly icon?: DeclarativeRenderable;
|
|
116
|
+
readonly image?: string;
|
|
117
|
+
readonly watermark?: DeclarativeRenderable | string;
|
|
118
|
+
readonly tone?: DeclarativeBadgeTone | 'primary';
|
|
119
|
+
readonly progress?: number | string | DeclarativeValueExpr;
|
|
120
|
+
readonly sparkline?: string;
|
|
121
|
+
readonly trend?: {
|
|
122
|
+
readonly value: DeclarativeI18nText | DeclarativeValueExpr;
|
|
123
|
+
readonly direction?: 'up' | 'down' | 'flat';
|
|
124
|
+
};
|
|
125
|
+
readonly hint?: DeclarativeI18nText | DeclarativeValueExpr | ((data: TData) => DeclarativeRenderable);
|
|
126
|
+
readonly badge?: {
|
|
127
|
+
readonly label: DeclarativeI18nText | DeclarativeValueExpr | ((data: TData) => DeclarativeRenderable);
|
|
128
|
+
readonly tone?: DeclarativeBadgeTone | DeclarativeValueExpr | ((data: TData) => DeclarativeBadgeTone);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export interface DeclarativeActionFieldSpec {
|
|
132
|
+
readonly key: string;
|
|
133
|
+
readonly label: DeclarativeI18nText;
|
|
134
|
+
readonly type?: 'text' | 'password' | 'number' | 'textarea' | 'select' | 'switch' | 'radio' | 'checkbox-group' | 'segmented';
|
|
135
|
+
readonly options?: readonly {
|
|
136
|
+
readonly value: string;
|
|
137
|
+
readonly label: DeclarativeI18nText;
|
|
138
|
+
readonly description?: DeclarativeI18nText;
|
|
139
|
+
readonly icon?: DeclarativeRenderable;
|
|
140
|
+
readonly badge?: DeclarativeRenderable;
|
|
141
|
+
readonly disabled?: boolean;
|
|
142
|
+
}[];
|
|
143
|
+
readonly variant?: 'default' | 'card' | 'button';
|
|
144
|
+
readonly direction?: 'column' | 'row' | 'grid';
|
|
145
|
+
readonly hint?: DeclarativeI18nText;
|
|
146
|
+
readonly rows?: number;
|
|
147
|
+
readonly placeholder?: string;
|
|
148
|
+
readonly required?: boolean;
|
|
149
|
+
readonly defaultValue?: string;
|
|
150
|
+
readonly secret?: boolean;
|
|
151
|
+
}
|
|
152
|
+
export interface DeclarativeActionSpec<TData = Record<string, unknown>> {
|
|
153
|
+
/** RPC action method name (`plugin.<pluginId>.<name>`). */
|
|
154
|
+
readonly name: string;
|
|
155
|
+
readonly label: DeclarativeI18nText;
|
|
156
|
+
readonly description?: DeclarativeI18nText;
|
|
157
|
+
readonly icon?: DeclarativeRenderable;
|
|
158
|
+
readonly variant?: DeclarativeButtonVariant;
|
|
159
|
+
readonly confirm?: DeclarativeI18nText;
|
|
160
|
+
readonly confirmLabel?: DeclarativeI18nText;
|
|
161
|
+
readonly fields?: readonly DeclarativeActionFieldSpec[];
|
|
162
|
+
readonly params?: Readonly<Record<string, unknown>> | ((data: TData | undefined, values: Readonly<Record<string, string>>) => Readonly<Record<string, unknown>>);
|
|
163
|
+
readonly disabled?: boolean | ((data: TData | undefined) => boolean);
|
|
164
|
+
readonly successMessage?: DeclarativeI18nText;
|
|
165
|
+
}
|
|
166
|
+
export type DeclarativeColumnType = 'auto' | 'text' | 'code' | 'badge' | 'boolean' | 'link' | 'datetime' | 'number' | 'progress' | 'tags' | 'json';
|
|
167
|
+
export interface DeclarativeColumnSpec<TRow = Record<string, unknown>, TData = Record<string, unknown>> {
|
|
168
|
+
readonly key: keyof TRow & string;
|
|
169
|
+
readonly label: DeclarativeI18nText;
|
|
170
|
+
readonly icon?: DeclarativeRenderable;
|
|
171
|
+
readonly type?: DeclarativeColumnType;
|
|
172
|
+
readonly align?: 'left' | 'center' | 'right';
|
|
173
|
+
readonly fixed?: 'left' | 'right';
|
|
174
|
+
readonly sortable?: boolean;
|
|
175
|
+
readonly copyable?: boolean;
|
|
176
|
+
readonly width?: string | number;
|
|
177
|
+
readonly toneMap?: Readonly<Record<string, DeclarativeBadgeTone>>;
|
|
178
|
+
readonly render?: (value: unknown, row: TRow, ctx: DeclarativePageContext<TData>) => DeclarativeRenderable;
|
|
179
|
+
}
|
|
180
|
+
export interface DeclarativeBatchActionSpec<TRow = Record<string, unknown>, TData = Record<string, unknown>> {
|
|
181
|
+
readonly name: string;
|
|
182
|
+
readonly label: DeclarativeI18nText;
|
|
183
|
+
readonly icon?: DeclarativeRenderable;
|
|
184
|
+
readonly variant?: DeclarativeButtonVariant;
|
|
185
|
+
readonly confirm?: DeclarativeI18nText;
|
|
186
|
+
readonly confirmLabel?: DeclarativeI18nText;
|
|
187
|
+
readonly idsParamKey?: string;
|
|
188
|
+
readonly params?: (selectedRows: readonly TRow[], selectedKeys: readonly string[], data: TData | undefined) => Readonly<Record<string, unknown>>;
|
|
189
|
+
readonly onExecute?: (selectedRows: readonly TRow[], selectedKeys: readonly string[], ctx: DeclarativePageContext<TData>) => unknown;
|
|
190
|
+
readonly successMessage?: DeclarativeI18nText;
|
|
191
|
+
}
|
|
192
|
+
export interface DeclarativeRowActionSpec<TRow = Record<string, unknown>, TData = Record<string, unknown>> {
|
|
193
|
+
readonly name: string;
|
|
194
|
+
readonly label: DeclarativeI18nText;
|
|
195
|
+
readonly icon?: DeclarativeRenderable;
|
|
196
|
+
readonly variant?: DeclarativeButtonVariant;
|
|
197
|
+
readonly confirm?: DeclarativeI18nText;
|
|
198
|
+
readonly confirmLabel?: DeclarativeI18nText;
|
|
199
|
+
readonly idParamKey?: string;
|
|
200
|
+
readonly params?: (row: TRow, rowKey: string, data: TData | undefined) => Readonly<Record<string, unknown>>;
|
|
201
|
+
readonly onExecute?: (row: TRow, rowKey: string, ctx: DeclarativePageContext<TData>) => unknown;
|
|
202
|
+
readonly disabled?: boolean | ((row: TRow) => boolean);
|
|
203
|
+
readonly successMessage?: DeclarativeI18nText;
|
|
204
|
+
}
|
|
205
|
+
export interface DeclarativeSectionSpec<TData = Record<string, unknown>, TRow = Record<string, unknown>> {
|
|
206
|
+
readonly id?: string;
|
|
207
|
+
readonly title?: DeclarativeI18nText;
|
|
208
|
+
readonly description?: DeclarativeI18nText;
|
|
209
|
+
readonly tab?: DeclarativeI18nText;
|
|
210
|
+
readonly layout?: 'table' | 'cards' | 'kv' | 'timeline' | 'json';
|
|
211
|
+
readonly columnsCount?: 1 | 2 | 3;
|
|
212
|
+
readonly collapsible?: boolean;
|
|
213
|
+
readonly defaultCollapsed?: boolean;
|
|
214
|
+
readonly emptyText?: DeclarativeI18nText;
|
|
215
|
+
readonly rowKey?: keyof TRow & string;
|
|
216
|
+
readonly selectable?: boolean;
|
|
217
|
+
readonly batchActions?: readonly DeclarativeBatchActionSpec<TRow, TData>[];
|
|
218
|
+
readonly rowActions?: readonly DeclarativeRowActionSpec<TRow, TData>[];
|
|
219
|
+
readonly renderExpandedRow?: (row: TRow, index: number, ctx: DeclarativePageContext<TData>) => DeclarativeRenderable;
|
|
220
|
+
readonly responsiveStack?: boolean;
|
|
221
|
+
/** Extract rows for a declarative table or list. */
|
|
222
|
+
readonly items?: (keyof TData & string) | ((data: TData) => readonly TRow[]);
|
|
223
|
+
/** Columns for a declarative table/card list when `items` is provided. */
|
|
224
|
+
readonly columns?: readonly DeclarativeColumnSpec<TRow, TData>[];
|
|
225
|
+
/** Custom row renderer when `items` is provided. */
|
|
226
|
+
readonly renderItem?: (item: TRow, index: number, ctx: DeclarativePageContext<TData>) => DeclarativeRenderable;
|
|
227
|
+
/** Key-value description list extractor (`<dl className="zk-dl">`). */
|
|
228
|
+
readonly entries?: readonly {
|
|
229
|
+
readonly label: DeclarativeI18nText;
|
|
230
|
+
readonly value?: DeclarativeRenderable | DeclarativeValueExpr;
|
|
231
|
+
readonly dataKey?: string;
|
|
232
|
+
}[] | ((data: TData, ctx: DeclarativePageContext<TData>) => Readonly<Record<string, DeclarativeRenderable>> | readonly {
|
|
233
|
+
readonly label: DeclarativeRenderable;
|
|
234
|
+
readonly value: DeclarativeRenderable;
|
|
235
|
+
}[]);
|
|
236
|
+
/** Custom section body renderer. */
|
|
237
|
+
readonly render?: (data: TData, ctx: DeclarativePageContext<TData>) => DeclarativeRenderable;
|
|
238
|
+
}
|
|
239
|
+
export interface DeclarativePageSpec<TData = Record<string, unknown>> {
|
|
240
|
+
/** Explicit plugin ID (`root/<name>`); auto-resolved from page props or route when omitted. */
|
|
241
|
+
readonly pluginId?: string;
|
|
242
|
+
readonly title: DeclarativeI18nText;
|
|
243
|
+
readonly description?: DeclarativeI18nText;
|
|
244
|
+
readonly mark?: DeclarativeRenderable;
|
|
245
|
+
/** Status RPC method name; defaults to `'status'`. */
|
|
246
|
+
readonly statusMethod?: string;
|
|
247
|
+
/** Optional polling interval in ms; defaults to 10_000. Pass `0` to disable polling. */
|
|
248
|
+
readonly pollMs?: number;
|
|
249
|
+
readonly dictionary?: Readonly<Record<string, string>>;
|
|
250
|
+
readonly isEmpty?: (data: TData) => boolean;
|
|
251
|
+
readonly emptyTitle?: DeclarativeI18nText;
|
|
252
|
+
readonly emptyDescription?: DeclarativeI18nText;
|
|
253
|
+
readonly badges?: readonly DeclarativeBadgeSpec<TData>[] | ((data: TData, ctx: DeclarativePageContext<TData>) => readonly DeclarativeBadgeSpec<TData>[]);
|
|
254
|
+
readonly stats?: readonly DeclarativeStatSpec<TData>[] | ((data: TData, ctx: DeclarativePageContext<TData>) => readonly DeclarativeStatSpec<TData>[]);
|
|
255
|
+
readonly actions?: readonly DeclarativeActionSpec<TData>[];
|
|
256
|
+
readonly sections?: readonly DeclarativeSectionSpec<TData, any>[];
|
|
257
|
+
readonly render?: (data: TData, ctx: DeclarativePageContext<TData>) => DeclarativeRenderable;
|
|
258
|
+
readonly footnote?: DeclarativeI18nText;
|
|
259
|
+
}
|
|
260
|
+
export interface DeclarativePageComponentProps {
|
|
261
|
+
readonly pluginId?: string;
|
|
262
|
+
readonly owner?: string;
|
|
263
|
+
readonly localName?: string;
|
|
264
|
+
readonly route?: string;
|
|
265
|
+
readonly title?: string;
|
|
266
|
+
readonly [key: string]: unknown;
|
|
267
|
+
}
|
|
268
|
+
export type ConsolePageBlueprintSection = {
|
|
269
|
+
readonly type: 'stats';
|
|
270
|
+
readonly id: string;
|
|
271
|
+
readonly title: string;
|
|
272
|
+
readonly items: readonly {
|
|
273
|
+
readonly key: string;
|
|
274
|
+
readonly label: string;
|
|
275
|
+
readonly value?: unknown;
|
|
276
|
+
readonly suffix?: string;
|
|
277
|
+
readonly dataKey?: string;
|
|
278
|
+
readonly expr?: DeclarativeValueExpr;
|
|
279
|
+
}[];
|
|
280
|
+
} | {
|
|
281
|
+
readonly type: 'table';
|
|
282
|
+
readonly id: string;
|
|
283
|
+
readonly title: string;
|
|
284
|
+
readonly dataKey?: string;
|
|
285
|
+
readonly rowKey: string;
|
|
286
|
+
readonly columns: readonly {
|
|
287
|
+
readonly key: string;
|
|
288
|
+
readonly label: string;
|
|
289
|
+
}[];
|
|
290
|
+
} | {
|
|
291
|
+
readonly type: 'entries';
|
|
292
|
+
readonly id: string;
|
|
293
|
+
readonly title: string;
|
|
294
|
+
readonly entries?: readonly {
|
|
295
|
+
readonly label: string;
|
|
296
|
+
readonly value: string;
|
|
297
|
+
readonly dataKey?: string;
|
|
298
|
+
readonly expr?: DeclarativeValueExpr;
|
|
299
|
+
}[];
|
|
300
|
+
} | {
|
|
301
|
+
readonly type: 'actions';
|
|
302
|
+
readonly id: string;
|
|
303
|
+
readonly title: string;
|
|
304
|
+
readonly items: readonly {
|
|
305
|
+
readonly label: string;
|
|
306
|
+
readonly action: string;
|
|
307
|
+
readonly name?: string;
|
|
308
|
+
readonly description?: string;
|
|
309
|
+
readonly variant?: DeclarativeButtonVariant;
|
|
310
|
+
readonly confirm?: DeclarativeI18nText;
|
|
311
|
+
readonly confirmLabel?: DeclarativeI18nText;
|
|
312
|
+
readonly fields?: readonly DeclarativeActionFieldSpec[];
|
|
313
|
+
readonly params?: DeclarativeActionSpec<any>['params'];
|
|
314
|
+
readonly disabled?: DeclarativeActionSpec<any>['disabled'];
|
|
315
|
+
readonly successMessage?: DeclarativeI18nText;
|
|
316
|
+
}[];
|
|
317
|
+
} | {
|
|
318
|
+
readonly type: 'markdown';
|
|
319
|
+
readonly id: string;
|
|
320
|
+
readonly title?: string;
|
|
321
|
+
readonly content: string;
|
|
322
|
+
} | {
|
|
323
|
+
readonly type: 'custom';
|
|
324
|
+
readonly id: string;
|
|
325
|
+
readonly title?: string;
|
|
326
|
+
};
|
|
327
|
+
export interface ConsolePageBlueprint<TData = Record<string, unknown>> {
|
|
328
|
+
readonly kind: 'zhin.console.page-blueprint';
|
|
329
|
+
readonly version: 1;
|
|
330
|
+
readonly title: string;
|
|
331
|
+
readonly titleI18n?: Readonly<Partial<Record<'zh-CN' | 'en', string>>>;
|
|
332
|
+
readonly description?: string;
|
|
333
|
+
readonly dataSource: {
|
|
334
|
+
readonly action: string;
|
|
335
|
+
};
|
|
336
|
+
readonly sections: readonly ConsolePageBlueprintSection[];
|
|
337
|
+
readonly spec?: DeclarativePageSpec<TData>;
|
|
338
|
+
readonly reviewSpec?: CommentReviewBlueprintSpec<any, any>;
|
|
339
|
+
}
|
|
340
|
+
export interface CommentReviewDraftBase {
|
|
341
|
+
readonly id: string;
|
|
342
|
+
readonly url: string;
|
|
343
|
+
readonly message: string;
|
|
344
|
+
readonly status: 'pending' | 'sending';
|
|
345
|
+
readonly interrupted: boolean;
|
|
346
|
+
readonly createdAt: number;
|
|
347
|
+
readonly updatedAt?: number;
|
|
348
|
+
readonly author?: string;
|
|
349
|
+
readonly original?: string;
|
|
350
|
+
}
|
|
351
|
+
export interface CommentReviewEndpointBase<D extends CommentReviewDraftBase = CommentReviewDraftBase> {
|
|
352
|
+
readonly id: string;
|
|
353
|
+
readonly sendMode: 'review' | 'off';
|
|
354
|
+
readonly persistent: boolean;
|
|
355
|
+
readonly circuit: {
|
|
356
|
+
readonly code: number;
|
|
357
|
+
} | null;
|
|
358
|
+
readonly login: {
|
|
359
|
+
readonly state: 'none' | 'ok' | 'expired';
|
|
360
|
+
};
|
|
361
|
+
readonly pendingCount: number;
|
|
362
|
+
readonly drafts: readonly D[];
|
|
363
|
+
}
|
|
364
|
+
export interface CommentReviewBlueprintSpec<E extends CommentReviewEndpointBase<any> = CommentReviewEndpointBase<CommentReviewDraftBase>, D extends CommentReviewDraftBase = CommentReviewDraftBase> {
|
|
365
|
+
readonly adapter: string;
|
|
366
|
+
readonly platform: {
|
|
367
|
+
readonly zh: string;
|
|
368
|
+
readonly en: string;
|
|
369
|
+
};
|
|
370
|
+
readonly mark: string;
|
|
371
|
+
readonly resource: {
|
|
372
|
+
readonly zh: string;
|
|
373
|
+
readonly en: string;
|
|
374
|
+
};
|
|
375
|
+
readonly dictionary?: Readonly<Record<string, string>>;
|
|
376
|
+
readonly openLabel?: string;
|
|
377
|
+
readonly account?: (endpoint: E) => {
|
|
378
|
+
readonly id?: string;
|
|
379
|
+
readonly name?: string;
|
|
380
|
+
};
|
|
381
|
+
readonly draftResource?: (draft: D, t: (key: string, ...values: readonly (string | number)[]) => string) => string;
|
|
382
|
+
readonly loginHint?: (endpoint: E, t: (key: string, ...values: readonly (string | number)[]) => string) => string | undefined;
|
|
383
|
+
readonly isLoginPending?: (endpoint: E) => boolean;
|
|
384
|
+
readonly loginMode?: 'qr' | 'cookie-check';
|
|
385
|
+
readonly resourcesKey?: string;
|
|
386
|
+
readonly pollMs?: number;
|
|
387
|
+
readonly pendingPollMs?: number;
|
|
388
|
+
}
|
|
389
|
+
export interface ConsoleAdapterPageBlueprint {
|
|
390
|
+
readonly kind: 'zhin.console.adapter-page';
|
|
391
|
+
readonly version: 1;
|
|
392
|
+
readonly adapterKey: string;
|
|
393
|
+
readonly dataSource: {
|
|
394
|
+
readonly action: 'status';
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
export type BlueprintPageComponent<TData = Record<string, unknown>> = ((props?: DeclarativePageComponentProps) => ConsolePageBlueprint<TData>) & Readonly<ConsolePageBlueprint<TData>>;
|
|
398
|
+
export type AdapterPageComponent = ((props?: DeclarativePageComponentProps) => ConsoleAdapterPageBlueprint) & Readonly<ConsoleAdapterPageBlueprint>;
|
|
399
|
+
export declare function resolveDeclarativeText(text: DeclarativeI18nText | undefined, preferredLocale?: 'en' | 'zh-CN'): string;
|
|
400
|
+
export declare function buildBlueprintFromSpec<TData = Record<string, unknown>>(input: DeclarativePageSpec<TData> | ConsolePageBlueprint<TData>): Readonly<ConsolePageBlueprint<TData>>;
|
|
401
|
+
export declare function definePageBlueprint<TData = Record<string, unknown>>(spec: DeclarativePageSpec<TData> | ConsolePageBlueprint<TData>): BlueprintPageComponent<TData>;
|
|
402
|
+
export declare const createDeclarativePage: typeof definePageBlueprint;
|
|
403
|
+
export declare function defineAdapterPage(adapterKey: string): AdapterPageComponent;
|
|
404
|
+
export declare const createAdapterConsolePage: typeof defineAdapterPage;
|
|
405
|
+
export declare function defineCommentReviewPage<E extends CommentReviewEndpointBase<any> = CommentReviewEndpointBase<CommentReviewDraftBase>, D extends CommentReviewDraftBase = CommentReviewDraftBase>(reviewSpec: CommentReviewBlueprintSpec<E, D>): BlueprintPageComponent<{
|
|
406
|
+
readonly endpoints?: readonly E[];
|
|
407
|
+
readonly updatedAt?: number;
|
|
408
|
+
}>;
|
|
409
|
+
export declare const createCommentReviewPage: typeof defineCommentReviewPage;
|
|
410
|
+
export interface BlueprintProjectionOptions {
|
|
411
|
+
readonly locale?: DeclarativeUiLocale;
|
|
412
|
+
readonly pluginId?: string;
|
|
413
|
+
readonly maxRows?: number;
|
|
414
|
+
}
|
|
415
|
+
export interface BlueprintImStatItem {
|
|
416
|
+
readonly key: string;
|
|
417
|
+
readonly label: string;
|
|
418
|
+
readonly value: string;
|
|
419
|
+
readonly hint?: string;
|
|
420
|
+
readonly badge?: string;
|
|
421
|
+
}
|
|
422
|
+
export interface BlueprintImTableSection {
|
|
423
|
+
readonly id: string;
|
|
424
|
+
readonly title: string;
|
|
425
|
+
readonly columns: readonly {
|
|
426
|
+
readonly key: string;
|
|
427
|
+
readonly label: string;
|
|
428
|
+
}[];
|
|
429
|
+
readonly rows: readonly (readonly string[])[];
|
|
430
|
+
readonly totalRows: number;
|
|
431
|
+
readonly emptyText?: string;
|
|
432
|
+
}
|
|
433
|
+
export interface BlueprintImEntriesSection {
|
|
434
|
+
readonly id: string;
|
|
435
|
+
readonly title: string;
|
|
436
|
+
readonly items: readonly {
|
|
437
|
+
readonly label: string;
|
|
438
|
+
readonly value: string;
|
|
439
|
+
}[];
|
|
440
|
+
}
|
|
441
|
+
export interface BlueprintImActionItem {
|
|
442
|
+
readonly name: string;
|
|
443
|
+
readonly label: string;
|
|
444
|
+
readonly rpcMethod: string;
|
|
445
|
+
readonly description?: string;
|
|
446
|
+
readonly variant: DeclarativeButtonVariant;
|
|
447
|
+
readonly disabled: boolean;
|
|
448
|
+
}
|
|
449
|
+
export interface BlueprintImSegment {
|
|
450
|
+
readonly type: 'card' | 'markdown' | 'button' | 'text';
|
|
451
|
+
readonly data: Readonly<Record<string, unknown>>;
|
|
452
|
+
}
|
|
453
|
+
export interface BlueprintImCardProjection {
|
|
454
|
+
readonly kind: 'zhin.im.blueprint-card';
|
|
455
|
+
readonly pluginId: string;
|
|
456
|
+
readonly title: string;
|
|
457
|
+
readonly description?: string;
|
|
458
|
+
readonly stats: readonly BlueprintImStatItem[];
|
|
459
|
+
readonly tables: readonly BlueprintImTableSection[];
|
|
460
|
+
readonly entries: readonly BlueprintImEntriesSection[];
|
|
461
|
+
readonly actions: readonly BlueprintImActionItem[];
|
|
462
|
+
readonly markdown: string;
|
|
463
|
+
readonly segments: readonly BlueprintImSegment[];
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Projects any Server-Driven Console Blueprint (`definePageBlueprint`, `defineAdapterPage`,
|
|
467
|
+
* `defineCommentReviewPage`, or `DeclarativePageSpec`) + runtime status payload into a
|
|
468
|
+
* structured IM Card / Markdown / Segment payload ready for `Message.$reply` or `Adapter.sendMessage`.
|
|
469
|
+
*/
|
|
470
|
+
export declare function projectBlueprintToImCard<TData = Record<string, unknown>>(input: ConsolePageBlueprint<TData> | ConsoleAdapterPageBlueprint | DeclarativePageSpec<TData>, data?: TData, options?: BlueprintProjectionOptions): Readonly<BlueprintImCardProjection>;
|
|
471
|
+
export interface BlueprintCliPanelOptions extends BlueprintProjectionOptions {
|
|
472
|
+
readonly width?: number;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Projects any Server-Driven Console Blueprint (`definePageBlueprint`, `defineAdapterPage`,
|
|
476
|
+
* `defineCommentReviewPage`, or `DeclarativePageSpec`) + runtime status payload into a
|
|
477
|
+
* formatted CLI TUI panel string.
|
|
478
|
+
*/
|
|
479
|
+
export declare function projectBlueprintToCliPanel<TData = Record<string, unknown>>(input: ConsolePageBlueprint<TData> | ConsoleAdapterPageBlueprint | DeclarativePageSpec<TData>, data?: TData, options?: BlueprintCliPanelOptions): string;
|