@sparkelf/dsh-artifact-app 0.0.0-stage → 0.1.0
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/README.md +56 -2
- package/cordis.patch.yml +3 -0
- package/lib/client.js +824 -0
- package/lib/client.js.map +1 -0
- package/lib/index.d.ts +638 -0
- package/lib/index.js +2154 -0
- package/package.json +82 -3
- package/skills/artifact-app-authoring/SKILL.md +157 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cosmokit@1.8.5/node_modules/@deepseek-ai/cosmokit/lib/types/types.d.ts
|
|
4
|
+
declare function isArrayBufferLike(value: any): value is ArrayBufferLike;
|
|
5
|
+
declare function isArrayBufferSource(value: any): value is Binary.Source;
|
|
6
|
+
/** Binary source detection and base64/hex conversion helpers. */
|
|
7
|
+
declare namespace Binary {
|
|
8
|
+
type Source<T extends ArrayBufferLike = ArrayBufferLike> = T | ArrayBufferView<T>;
|
|
9
|
+
const is: typeof isArrayBufferLike;
|
|
10
|
+
const isSource: typeof isArrayBufferSource;
|
|
11
|
+
function fromSource<T extends ArrayBufferLike>(source: Source<T>): T;
|
|
12
|
+
function toBase64(source: Source): string;
|
|
13
|
+
function fromBase64(source: string): ArrayBuffer | Uint8Array<ArrayBuffer>;
|
|
14
|
+
function toHex(source: Source): string;
|
|
15
|
+
function fromHex(source: string): ArrayBuffer;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cosmokit@1.8.5/node_modules/@deepseek-ai/cosmokit/lib/types/misc.d.ts
|
|
19
|
+
/** String/symbol keyed dictionary type. */
|
|
20
|
+
type Dict<T = any, K extends string | symbol = string> = { [key in K]: T; };
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cosmokit@1.8.5/node_modules/@deepseek-ai/cosmokit/lib/types/volatile.d.ts
|
|
23
|
+
/** Shared config references used by schema validators and plugin runtimes. */
|
|
24
|
+
/** Recursively readonly data returned by a volatile config reference. */
|
|
25
|
+
type VolatileSnapshot<T> = T extends object ? { readonly [K in keyof T]: VolatileSnapshot<T[K]>; } : T;
|
|
26
|
+
/** A stable reference; keep the reference, or capture its value for one operation only. */
|
|
27
|
+
interface Volatile<T> {
|
|
28
|
+
/** @returns the current immutable snapshot, including undefined for an absent value. */
|
|
29
|
+
get(): VolatileSnapshot<T>;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
33
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
34
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
35
|
+
/** The Standard properties. */
|
|
36
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
37
|
+
}
|
|
38
|
+
declare namespace StandardTypedV1 {
|
|
39
|
+
/** The Standard Typed properties interface. */
|
|
40
|
+
interface Props<Input = unknown, Output = Input> {
|
|
41
|
+
/** The version number of the standard. */
|
|
42
|
+
readonly version: 1;
|
|
43
|
+
/** The vendor name of the schema library. */
|
|
44
|
+
readonly vendor: string;
|
|
45
|
+
/** Inferred types associated with the schema. */
|
|
46
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
47
|
+
}
|
|
48
|
+
/** The Standard Typed types interface. */
|
|
49
|
+
interface Types<Input = unknown, Output = Input> {
|
|
50
|
+
/** The input type of the schema. */
|
|
51
|
+
readonly input: Input;
|
|
52
|
+
/** The output type of the schema. */
|
|
53
|
+
readonly output: Output;
|
|
54
|
+
}
|
|
55
|
+
/** Infers the input type of a Standard Typed. */
|
|
56
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
57
|
+
/** Infers the output type of a Standard Typed. */
|
|
58
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
59
|
+
}
|
|
60
|
+
/** The Standard Schema interface. */
|
|
61
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
62
|
+
/** The Standard Schema properties. */
|
|
63
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
64
|
+
}
|
|
65
|
+
declare namespace StandardSchemaV1 {
|
|
66
|
+
/** The Standard Schema properties interface. */
|
|
67
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
68
|
+
/** Validates unknown input values. */
|
|
69
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
70
|
+
}
|
|
71
|
+
/** The result interface of the validate function. */
|
|
72
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
73
|
+
/** The result interface if validation succeeds. */
|
|
74
|
+
interface SuccessResult<Output> {
|
|
75
|
+
/** The typed output value. */
|
|
76
|
+
readonly value: Output;
|
|
77
|
+
/** A falsy value for `issues` indicates success. */
|
|
78
|
+
readonly issues?: undefined;
|
|
79
|
+
}
|
|
80
|
+
interface Options {
|
|
81
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
82
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
83
|
+
}
|
|
84
|
+
/** The result interface if validation fails. */
|
|
85
|
+
interface FailureResult {
|
|
86
|
+
/** The issues of failed validation. */
|
|
87
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
88
|
+
}
|
|
89
|
+
/** The issue interface of the failure output. */
|
|
90
|
+
interface Issue {
|
|
91
|
+
/** The error message of the issue. */
|
|
92
|
+
readonly message: string;
|
|
93
|
+
/** The path of the issue, if any. */
|
|
94
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
95
|
+
}
|
|
96
|
+
/** The path segment interface of the issue. */
|
|
97
|
+
interface PathSegment {
|
|
98
|
+
/** The key representing a path segment. */
|
|
99
|
+
readonly key: PropertyKey;
|
|
100
|
+
}
|
|
101
|
+
/** The Standard types interface. */
|
|
102
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
103
|
+
/** Infers the input type of a Standard. */
|
|
104
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
105
|
+
/** Infers the output type of a Standard. */
|
|
106
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+schemastery@3.18.4/node_modules/@deepseek-ai/schemastery/lib/types/index.d.ts
|
|
110
|
+
declare const kSchema: unique symbol;
|
|
111
|
+
declare global {
|
|
112
|
+
namespace Schemastery {
|
|
113
|
+
/** Convert primitive constructors, constants, and existing schemas into a schema type. */
|
|
114
|
+
type From<X> = X extends string | number | boolean ? Schema<X> : X extends Schema<any, any, SchemaMode> ? X : X extends typeof String ? Schema<string> : X extends typeof Number ? Schema<number> : X extends typeof Boolean ? Schema<boolean> : X extends typeof Function ? Schema<Function, (...args: any[]) => any> : X extends Constructor<infer S> ? Schema<S> : never;
|
|
115
|
+
type TypeS1<X> = X extends Schema<infer S, infer _T, infer _M> ? S : never;
|
|
116
|
+
type Inverse<X> = X extends Schema<infer _S, infer T, infer M> ? (arg: SchemaOutput<T, M>) => void : never;
|
|
117
|
+
/** Input type accepted by a schema-like value. */
|
|
118
|
+
type TypeS<X> = TypeS1<From<X>>;
|
|
119
|
+
/** Output type returned by a schema-like value after validation. */
|
|
120
|
+
type TypeT<X> = ReturnType<From<X>>;
|
|
121
|
+
/** Resolver callback used by custom schema types registered with `Schema.extend()`. */
|
|
122
|
+
type Resolve = (data: any, schema: Schema, options: Options, strict?: boolean) => [any, any?];
|
|
123
|
+
/** Input type accepted by one schema in an intersection. */
|
|
124
|
+
type IntersectS<X> = From<X> extends Schema<infer S, infer _T, infer _M> ? S : never;
|
|
125
|
+
/** Output type returned by one schema in an intersection. */
|
|
126
|
+
type IntersectT<X> = Inverse<From<X>> extends ((arg: infer T) => void) ? T : never;
|
|
127
|
+
type TupleS<X extends readonly any[]> = X extends readonly [infer L, ...infer R] ? [TypeS<L>?, ...TupleS<R>] : any[];
|
|
128
|
+
type TupleT<X extends readonly any[]> = X extends readonly [infer L, ...infer R] ? [TypeT<L>?, ...TupleT<R>] : any[];
|
|
129
|
+
type ObjectS<X extends Dict> = { [K in keyof X]?: TypeS<X[K]> | null; } & Dict;
|
|
130
|
+
type ObjectT<X extends Dict> = { [K in keyof X]: TypeT<X[K]>; } & Dict;
|
|
131
|
+
type Constructor<T = any> = new (...args: any[]) => T;
|
|
132
|
+
/** Static constructor and factory methods exposed by the default `Schema` export. */
|
|
133
|
+
interface Static {
|
|
134
|
+
<T = any>(options: Partial<Schema<T>>): Schema<T>;
|
|
135
|
+
new <T = any>(options: Partial<Schema<T>>): Schema<T>;
|
|
136
|
+
prototype: Schema;
|
|
137
|
+
/** Validate a value against a schema node and return `[output, adaptedInput?]`. */
|
|
138
|
+
resolve: Resolve;
|
|
139
|
+
/** Infer a schema from a primitive value, constructor, or existing schema. */
|
|
140
|
+
from<X = any>(source?: X): From<X>;
|
|
141
|
+
/** Register a resolver for a custom schema `type`. */
|
|
142
|
+
extend(type: string, resolve: Resolve): void;
|
|
143
|
+
/** Accept any value without validation. */
|
|
144
|
+
any<T = any>(): Schema<T>;
|
|
145
|
+
/** Accept only nullable input. */
|
|
146
|
+
never(): Schema<never>;
|
|
147
|
+
/** Accept exactly one constant value. */
|
|
148
|
+
const<const T>(value: T): Schema<T>;
|
|
149
|
+
/** Accept strings, with optional metadata constraints added by instance methods. */
|
|
150
|
+
string(): Schema<string>;
|
|
151
|
+
/** Accept numbers, with optional range and step constraints. */
|
|
152
|
+
number(): Schema<number>;
|
|
153
|
+
/** Accept non-negative integer numbers. */
|
|
154
|
+
natural(): Schema<number>;
|
|
155
|
+
/** Accept a number between 0 and 1 and mark it as a slider. */
|
|
156
|
+
percent(): Schema<number>;
|
|
157
|
+
/** Accept booleans. */
|
|
158
|
+
boolean(): Schema<boolean>;
|
|
159
|
+
/** Accept `Date` instances or parse datetime strings into `Date` objects. */
|
|
160
|
+
date(): Schema<string | Date, Date>;
|
|
161
|
+
/** Accept `RegExp` instances or parse strings into regular expressions. */
|
|
162
|
+
regExp(flag?: string): Schema<string | RegExp, RegExp>;
|
|
163
|
+
/** Accept binary sources and normalize them to `ArrayBufferLike`. */
|
|
164
|
+
arrayBuffer(): Schema<Binary.Source, ArrayBufferLike>;
|
|
165
|
+
arrayBuffer(encoding: 'hex' | 'base64'): Schema<Binary.Source | string, ArrayBufferLike>;
|
|
166
|
+
/** Accept a numeric bitset or string keys and normalize to a number. */
|
|
167
|
+
bitset<K extends string>(bits: Partial<Record<K, number>>): Schema<number | readonly K[], number>;
|
|
168
|
+
/** Accept functions. */
|
|
169
|
+
function(): Schema<Function, (...args: any[]) => any>;
|
|
170
|
+
/** Accept instances of a constructor or objects whose constructor name matches. */
|
|
171
|
+
is(constructor: string): Schema;
|
|
172
|
+
is<T>(constructor: Constructor<T>): Schema<T>;
|
|
173
|
+
/** Accept arrays whose elements match `inner`. */
|
|
174
|
+
array<X>(inner: X): Schema<TypeS<X>[], TypeT<X>[]>;
|
|
175
|
+
/** Accept plain objects with values matching `inner` and optional key schema. */
|
|
176
|
+
dict<X, Y extends Schema<any, string> = Schema<string>>(inner: X, sKey?: Y): Schema<Dict<TypeS<X>, TypeS<Y>>, Dict<TypeT<X>, TypeT<Y>>>;
|
|
177
|
+
/** Accept tuple arrays where each index matches the corresponding schema. */
|
|
178
|
+
tuple<const X extends readonly any[]>(list: X): Schema<TupleS<X>, TupleT<X>>;
|
|
179
|
+
/** Accept plain objects; infer fields from the dictionary, not the enclosing schema's output type. */
|
|
180
|
+
object<X extends Dict>(dict: X): Schema<ObjectS<NoInfer<X>>, ObjectT<NoInfer<X>>>;
|
|
181
|
+
/** Accept values matching at least one schema in `list`. */
|
|
182
|
+
union<const X>(list: readonly X[]): Schema<TypeS<X>, TypeT<X>>;
|
|
183
|
+
/** Accept values matching every schema in `list`, merging object outputs. */
|
|
184
|
+
intersect<const X>(list: readonly X[]): Schema<IntersectS<X>, IntersectT<X>>;
|
|
185
|
+
/** Validate with `inner`, then convert the result with `callback`. */
|
|
186
|
+
transform<X, T>(inner: X, callback: (value: TypeS<X>, options: Schemastery.Options) => T, preserve?: boolean): Schema<TypeS<X>, T>;
|
|
187
|
+
/** Defer construction of a recursive schema until validation or serialization. */
|
|
188
|
+
lazy<X extends Schema<any, any, SchemaMode>>(callback: () => X): X;
|
|
189
|
+
ValidationError: typeof ValidationError;
|
|
190
|
+
}
|
|
191
|
+
/** Runtime validation options shared by all schema calls. */
|
|
192
|
+
interface Options {
|
|
193
|
+
/** Remove invalid object properties instead of throwing when possible. */
|
|
194
|
+
autofix?: boolean;
|
|
195
|
+
/** Skip validation for selected values and schema nodes. */
|
|
196
|
+
ignore?(data: any, schema: Schema): boolean;
|
|
197
|
+
/** Path used to format nested validation errors. */
|
|
198
|
+
path?: (keyof any)[];
|
|
199
|
+
}
|
|
200
|
+
/** UI and validation metadata attached by schema builder methods. */
|
|
201
|
+
interface Meta<T = any> {
|
|
202
|
+
default?: T extends {} ? Partial<T> : T;
|
|
203
|
+
required?: boolean;
|
|
204
|
+
/** Parse this node as a stable config reference; its type and UI metadata remain unchanged. */
|
|
205
|
+
volatile?: boolean;
|
|
206
|
+
disabled?: boolean;
|
|
207
|
+
collapse?: boolean;
|
|
208
|
+
badges?: {
|
|
209
|
+
text: string;
|
|
210
|
+
type: string;
|
|
211
|
+
}[];
|
|
212
|
+
hidden?: boolean;
|
|
213
|
+
loose?: boolean;
|
|
214
|
+
role?: string;
|
|
215
|
+
extra?: any;
|
|
216
|
+
link?: string;
|
|
217
|
+
description?: string | Dict<string>;
|
|
218
|
+
comment?: string;
|
|
219
|
+
pattern?: {
|
|
220
|
+
source: string;
|
|
221
|
+
flags?: string;
|
|
222
|
+
};
|
|
223
|
+
max?: number;
|
|
224
|
+
min?: number;
|
|
225
|
+
step?: number;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/** Callable schema instance that validates input and returns normalized output. */
|
|
229
|
+
interface Schemastery<S = any, T = S, Mode extends SchemaMode = 'plain'> {
|
|
230
|
+
(data?: S | null, options?: Schemastery.Options): SchemaOutput<T, Mode>;
|
|
231
|
+
new (data?: S | null, options?: Schemastery.Options): SchemaOutput<T, Mode>;
|
|
232
|
+
[kSchema]: true;
|
|
233
|
+
uid: number;
|
|
234
|
+
meta: Schemastery.Meta<T>;
|
|
235
|
+
type: string;
|
|
236
|
+
sKey?: Schema;
|
|
237
|
+
inner?: Schema;
|
|
238
|
+
list?: Schema[];
|
|
239
|
+
dict?: Dict<Schema>;
|
|
240
|
+
bits?: Dict<number>;
|
|
241
|
+
callback?: Function;
|
|
242
|
+
constructor?: string | Function;
|
|
243
|
+
builder?: Function;
|
|
244
|
+
value?: T;
|
|
245
|
+
refs?: Dict<Schema>;
|
|
246
|
+
preserve?: boolean;
|
|
247
|
+
'~standard': StandardSchemaV1.Props;
|
|
248
|
+
/** Format this schema as a compact TypeScript-like type string. */
|
|
249
|
+
toString(inline?: boolean): string;
|
|
250
|
+
/** Serialize this schema, preserving shared and recursive references. */
|
|
251
|
+
toJSON(): Schema<S, T, Mode>;
|
|
252
|
+
/** Mark nullable input as invalid unless a default supplies a fallback. */
|
|
253
|
+
required<R extends boolean = true>(value?: R): Schema<S, T, SetRequired<Mode, R>>;
|
|
254
|
+
/**
|
|
255
|
+
* Parse this config field as a stable reference containing immutable data.
|
|
256
|
+
* @returns a schema whose output supports get(), including when the field is absent.
|
|
257
|
+
*/
|
|
258
|
+
volatile(): Schema<NoInfer<S>, NoInfer<T>, Mode extends 'defined' | 'volatile-defined' ? 'volatile-defined' : 'volatile'>;
|
|
259
|
+
/** Hide this schema node from UI renderers. */
|
|
260
|
+
hidden(value?: boolean): Schema<S, T, Mode>;
|
|
261
|
+
/** Return the default value instead of throwing when validation fails. */
|
|
262
|
+
loose(value?: boolean): Schema<S, T, Mode>;
|
|
263
|
+
/** Attach a renderer role and optional role-specific metadata. */
|
|
264
|
+
role(text: string, extra?: any): Schema<S, T, Mode>;
|
|
265
|
+
/** Attach an external documentation link. */
|
|
266
|
+
link(link: string): Schema<S, T, Mode>;
|
|
267
|
+
/** Set the fallback value used for nullable input. */
|
|
268
|
+
default(value: T | NoInfer<Partial<S>>): Schema<S, T, SetRequired<Mode, true>>;
|
|
269
|
+
/** Attach an auxiliary comment for documentation or form UIs. */
|
|
270
|
+
comment(text: string): Schema<S, T, Mode>;
|
|
271
|
+
/** Attach a localized or plain description for documentation or form UIs. */
|
|
272
|
+
description(text: string): Schema<S, T, Mode>;
|
|
273
|
+
/** Mark this schema node as disabled for form UIs. */
|
|
274
|
+
disabled(value?: boolean): Schema<S, T, Mode>;
|
|
275
|
+
/** Request collapsed rendering for nested form UIs. */
|
|
276
|
+
collapse(value?: boolean): Schema<S, T, Mode>;
|
|
277
|
+
/** Add a deprecated badge to this schema node. */
|
|
278
|
+
deprecated(): Schema<S, T, Mode>;
|
|
279
|
+
/** Add an experimental badge to this schema node. */
|
|
280
|
+
experimental(): Schema<S, T, Mode>;
|
|
281
|
+
/** Require strings to match a regular expression. */
|
|
282
|
+
pattern(regexp: RegExp): Schema<S, T, Mode>;
|
|
283
|
+
/** Set an inclusive maximum for numbers or collection lengths. */
|
|
284
|
+
max(value: number): Schema<S, T, Mode>;
|
|
285
|
+
/** Set an inclusive minimum for numbers or collection lengths. */
|
|
286
|
+
min(value: number): Schema<S, T, Mode>;
|
|
287
|
+
/** Set the numeric increment constraint. */
|
|
288
|
+
step(value: number): Schema<S, T, Mode>;
|
|
289
|
+
/** Add or replace an object property schema. */
|
|
290
|
+
set(key: string, value: Schema): Schema<S, T, Mode>;
|
|
291
|
+
/** Append a tuple, union, or intersection member schema. */
|
|
292
|
+
push(value: Schema): Schema<S, T, Mode>;
|
|
293
|
+
/** Remove values equal to schema defaults from normalized output. */
|
|
294
|
+
simplify(value?: any): any;
|
|
295
|
+
/** Return a schema clone with descriptions merged from locale messages. */
|
|
296
|
+
i18n(messages: Dict): Schema<S, T, Mode>;
|
|
297
|
+
/** Attach arbitrary metadata consumed by form renderers and downstream tools. */
|
|
298
|
+
extra<K extends keyof Schemastery.Meta>(key: K, value: Schemastery.Meta[K]): Schema<S, T, Mode>;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
declare class ValidationError extends TypeError {
|
|
302
|
+
options: Schemastery.Options;
|
|
303
|
+
name: string;
|
|
304
|
+
constructor(message: string, options: Schemastery.Options);
|
|
305
|
+
static is(error: any): error is ValidationError;
|
|
306
|
+
}
|
|
307
|
+
type SchemaMode = 'plain' | 'defined' | 'volatile' | 'volatile-defined';
|
|
308
|
+
type SchemaOutput<T, M extends SchemaMode> = M extends 'volatile' ? Volatile<T | undefined> : M extends 'volatile-defined' ? Volatile<T> : T;
|
|
309
|
+
type SetRequired<M extends SchemaMode, R extends boolean> = M extends 'volatile' | 'volatile-defined' ? R extends true ? 'volatile-defined' : 'volatile' : R extends true ? 'defined' : 'plain';
|
|
310
|
+
type Schema<S = any, T = S, Mode extends SchemaMode = 'plain'> = Schemastery<S, T, Mode>;
|
|
311
|
+
declare const Schema: Schemastery.Static;
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/config.d.ts
|
|
314
|
+
/** Host-side artifact-app settings. */
|
|
315
|
+
interface Config$1 {
|
|
316
|
+
/** DataOps API origin, e.g. `http://host.docker.internal:3101`. */
|
|
317
|
+
baseUrl: string;
|
|
318
|
+
/** Browser-reachable DataOps frontend origin; empty derives it from the request. */
|
|
319
|
+
webBaseUrl: string;
|
|
320
|
+
/** Credential reference holding the workspace's DataOps JWT. */
|
|
321
|
+
credentialRef: string;
|
|
322
|
+
/** Maximum accepted cockpit HTML size. */
|
|
323
|
+
htmlMaxBytes: number;
|
|
324
|
+
/** Inject ECharts with the runtime; false only for tests. */
|
|
325
|
+
injectRuntime: boolean;
|
|
326
|
+
/** Root the `html_path` tool arguments resolve against. */
|
|
327
|
+
workspaceRoot: string;
|
|
328
|
+
/** Upstream timeout for one DataOps call. */
|
|
329
|
+
requestTimeoutMs: number;
|
|
330
|
+
}
|
|
331
|
+
/** Schemastery parser for the artifact-app config. */
|
|
332
|
+
declare const Config$1: Schema<Config$1>;
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/api.d.ts
|
|
335
|
+
/**
|
|
336
|
+
* DataOps artifact API client.
|
|
337
|
+
*
|
|
338
|
+
* Every call carries the workspace credential; the browser never sees it. Errors
|
|
339
|
+
* keep the server's own `message` so a tool result explains what DataOps said
|
|
340
|
+
* instead of a generic "request failed".
|
|
341
|
+
*
|
|
342
|
+
* @module api
|
|
343
|
+
*/
|
|
344
|
+
/** Minimal credential surface this client needs. */
|
|
345
|
+
interface TokenSource {
|
|
346
|
+
resolve(): Promise<string | undefined>;
|
|
347
|
+
}
|
|
348
|
+
/** One artifact row as the list endpoint returns it. */
|
|
349
|
+
interface ArtifactAppRow {
|
|
350
|
+
id: string;
|
|
351
|
+
name: string;
|
|
352
|
+
description?: string | null;
|
|
353
|
+
catalog?: string | null;
|
|
354
|
+
status: string;
|
|
355
|
+
currentVersion: number;
|
|
356
|
+
publishedVersion: number;
|
|
357
|
+
refreshIntervalSeconds?: number;
|
|
358
|
+
keepConnection?: boolean;
|
|
359
|
+
updatedAt: string;
|
|
360
|
+
canManage?: boolean;
|
|
361
|
+
}
|
|
362
|
+
/** One template row from `/api/artifact-templates`. */
|
|
363
|
+
interface ArtifactTemplateRow {
|
|
364
|
+
id: string;
|
|
365
|
+
name: string;
|
|
366
|
+
description?: string | null;
|
|
367
|
+
catalog?: string | null;
|
|
368
|
+
appType?: string;
|
|
369
|
+
status?: string;
|
|
370
|
+
currentVersion?: number;
|
|
371
|
+
contract?: {
|
|
372
|
+
slots?: string[];
|
|
373
|
+
question?: string;
|
|
374
|
+
} | null;
|
|
375
|
+
updatedAt?: string;
|
|
376
|
+
}
|
|
377
|
+
/** Publish request body. */
|
|
378
|
+
interface PublishInput {
|
|
379
|
+
artifactId?: string;
|
|
380
|
+
name?: string;
|
|
381
|
+
description?: string;
|
|
382
|
+
catalog?: string;
|
|
383
|
+
html?: string;
|
|
384
|
+
templateId?: string;
|
|
385
|
+
templateVersion?: string;
|
|
386
|
+
}
|
|
387
|
+
/** Preview request body. */
|
|
388
|
+
interface PreviewInput extends PublishInput {
|
|
389
|
+
html: string;
|
|
390
|
+
baseVersion?: number;
|
|
391
|
+
}
|
|
392
|
+
/** Grants payload. */
|
|
393
|
+
interface GrantInput {
|
|
394
|
+
principalType: 'USER' | 'ROLE' | 'DEPARTMENT';
|
|
395
|
+
principalId: string;
|
|
396
|
+
action: 'READ' | 'MANAGE';
|
|
397
|
+
}
|
|
398
|
+
/** Server error carrying the DataOps status. */
|
|
399
|
+
declare class DataOpsError extends Error {
|
|
400
|
+
readonly status: number;
|
|
401
|
+
constructor(message: string, status: number);
|
|
402
|
+
}
|
|
403
|
+
/** Client for the DataOps artifact endpoints. */
|
|
404
|
+
declare class ArtifactApi {
|
|
405
|
+
private readonly baseUrl;
|
|
406
|
+
private readonly tokens;
|
|
407
|
+
private readonly timeoutMs;
|
|
408
|
+
constructor(baseUrl: string, tokens: TokenSource, timeoutMs: number);
|
|
409
|
+
/** Read the workspace token or explain why the call cannot run. */
|
|
410
|
+
token(): Promise<string>;
|
|
411
|
+
private request;
|
|
412
|
+
/** Read the current DataOps principal and roles. */
|
|
413
|
+
me(): Promise<{
|
|
414
|
+
user?: {
|
|
415
|
+
roles?: Array<{
|
|
416
|
+
code?: string;
|
|
417
|
+
name?: string;
|
|
418
|
+
}>;
|
|
419
|
+
};
|
|
420
|
+
}>;
|
|
421
|
+
/** List published cockpit templates. */
|
|
422
|
+
listTemplates(): Promise<ArtifactTemplateRow[]>;
|
|
423
|
+
/** Read one template's metadata and contract. */
|
|
424
|
+
getTemplate(id: string): Promise<ArtifactTemplateRow>;
|
|
425
|
+
/** Read one template's HTML. */
|
|
426
|
+
getTemplateHtml(id: string): Promise<{
|
|
427
|
+
id: string;
|
|
428
|
+
version: number;
|
|
429
|
+
html: string;
|
|
430
|
+
}>;
|
|
431
|
+
/** List visible cockpit apps. */
|
|
432
|
+
listApps(query?: {
|
|
433
|
+
q?: string;
|
|
434
|
+
catalog?: string;
|
|
435
|
+
status?: string;
|
|
436
|
+
page?: number;
|
|
437
|
+
pageSize?: number;
|
|
438
|
+
}): Promise<{
|
|
439
|
+
items: ArtifactAppRow[];
|
|
440
|
+
total: number;
|
|
441
|
+
page: number;
|
|
442
|
+
pageSize: number;
|
|
443
|
+
}>;
|
|
444
|
+
/** Catalog counts for the tab's folder filter. */
|
|
445
|
+
catalogs(): Promise<Array<{
|
|
446
|
+
catalog: string | null;
|
|
447
|
+
count: number;
|
|
448
|
+
}>>;
|
|
449
|
+
/** Read one app's metadata. */
|
|
450
|
+
getApp(id: string): Promise<ArtifactAppRow>;
|
|
451
|
+
/** Read one app's HTML (current for managers, published for viewers). */
|
|
452
|
+
getAppHtml(id: string, version?: number): Promise<{
|
|
453
|
+
id: string;
|
|
454
|
+
version: number;
|
|
455
|
+
html: string;
|
|
456
|
+
}>;
|
|
457
|
+
/** Patch metadata only. */
|
|
458
|
+
patchApp(id: string, patch: {
|
|
459
|
+
name?: string;
|
|
460
|
+
description?: string;
|
|
461
|
+
catalog?: string;
|
|
462
|
+
refreshIntervalSeconds?: number;
|
|
463
|
+
keepConnection?: boolean;
|
|
464
|
+
}): Promise<unknown>;
|
|
465
|
+
/** Soft-delete one app. */
|
|
466
|
+
deleteApp(id: string): Promise<{
|
|
467
|
+
success: boolean;
|
|
468
|
+
}>;
|
|
469
|
+
/** Read one app's grants. */
|
|
470
|
+
getGrants(id: string): Promise<{
|
|
471
|
+
ownerId: string;
|
|
472
|
+
grants: GrantInput[];
|
|
473
|
+
}>;
|
|
474
|
+
/** Replace one app's grants. */
|
|
475
|
+
putGrants(id: string, grants: GrantInput[]): Promise<{
|
|
476
|
+
ownerId: string;
|
|
477
|
+
grants: GrantInput[];
|
|
478
|
+
}>;
|
|
479
|
+
/** Create or update a draft without publishing. */
|
|
480
|
+
preview(input: PreviewInput): Promise<{
|
|
481
|
+
id: string;
|
|
482
|
+
version: number;
|
|
483
|
+
created: boolean;
|
|
484
|
+
}>;
|
|
485
|
+
/** Publish a new app or a new version of an existing one. */
|
|
486
|
+
publish(input: PublishInput): Promise<{
|
|
487
|
+
id: string;
|
|
488
|
+
version: number;
|
|
489
|
+
publishedVersion: number;
|
|
490
|
+
created: boolean;
|
|
491
|
+
}>;
|
|
492
|
+
/** Public runtime script served by DataOps. */
|
|
493
|
+
runtimeScript(): Promise<string>;
|
|
494
|
+
/** Public ECharts bundle served by DataOps. */
|
|
495
|
+
echartsScript(): Promise<string>;
|
|
496
|
+
/** Proxy one gateway call with the caller's own Authorization header. */
|
|
497
|
+
/**
|
|
498
|
+
* 批量解析素材逻辑名 → 可用 URL。
|
|
499
|
+
*
|
|
500
|
+
* 渲染时把 HTML 里的 `asset://<逻辑名>` 换成这里的地址;解析不到的名字保持原样,
|
|
501
|
+
* 由页面自己降级(不阻断渲染)。
|
|
502
|
+
* @param names - 逻辑名列表。
|
|
503
|
+
* @param scope - shared 或 template(默认 template,ownerId 为模板 id)。
|
|
504
|
+
* @param ownerId - 模板 id。
|
|
505
|
+
*/
|
|
506
|
+
/**
|
|
507
|
+
* 发布模板包:把打包好的 zip 交给后端解压、校验、落素材并建模板版本。
|
|
508
|
+
* @param zipBase64 - zip 的 base64。
|
|
509
|
+
* @returns 模板 id 与版本。
|
|
510
|
+
*/
|
|
511
|
+
publishTemplatePackage(zipBase64: string): Promise<{
|
|
512
|
+
templateId: string;
|
|
513
|
+
version: number;
|
|
514
|
+
assets: number;
|
|
515
|
+
}>;
|
|
516
|
+
resolveAssets(names: string[], scope: 'shared' | 'template', ownerId?: string): Promise<Record<string, string>>;
|
|
517
|
+
gateway(path: string, init: RequestInit, authorization: string | undefined): Promise<{
|
|
518
|
+
status: number;
|
|
519
|
+
body: string;
|
|
520
|
+
contentType: string;
|
|
521
|
+
}>;
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/open-hub.d.ts
|
|
525
|
+
/** SSE route the client subscribes to. */
|
|
526
|
+
declare const OPEN_EVENTS_PATH = "/dsh-artifact-app/open/events";
|
|
527
|
+
/** Same-origin route the client uses to read render and gateway addresses. */
|
|
528
|
+
declare const CONFIG_PATH = "/dsh-artifact-app/config";
|
|
529
|
+
/** Same-origin route the client uses to read the workspace token for postMessage. */
|
|
530
|
+
declare const TOKEN_PATH = "/dsh-artifact-app/token";
|
|
531
|
+
/** Same-origin app-list proxy used by the sidebar tab. */
|
|
532
|
+
declare const APPS_PATH = "/dsh-artifact-app/apps";
|
|
533
|
+
/** Same-origin preview creation used by the HTML file viewer. */
|
|
534
|
+
declare const PREVIEW_PATH = "/dsh-artifact-app/preview";
|
|
535
|
+
/** Render route prefix; `:id` follows it. */
|
|
536
|
+
declare const RENDER_PATH = "/dsh-artifact-app/render";
|
|
537
|
+
/** Gateway prefix the sandboxed cockpit HTML may call. */
|
|
538
|
+
declare const GATEWAY_PATH = "/dsh-artifact-app/gateway";
|
|
539
|
+
/** Tab type registered by the client half. */
|
|
540
|
+
declare const ARTIFACT_TAB_TYPE = "dataops-artifact-apps";
|
|
541
|
+
/** One navigation request delivered to every connected client. */
|
|
542
|
+
interface OpenCockpitEvent {
|
|
543
|
+
type: 'open_cockpit';
|
|
544
|
+
requestId: string;
|
|
545
|
+
cockpitId: string;
|
|
546
|
+
cockpitName: string | null;
|
|
547
|
+
mode: 'focus' | 'detail';
|
|
548
|
+
nonce: string;
|
|
549
|
+
}
|
|
550
|
+
/** One refresh request for an already-open viewer. */
|
|
551
|
+
interface CockpitUpdatedEvent {
|
|
552
|
+
type: 'cockpit_updated';
|
|
553
|
+
cockpitId: string;
|
|
554
|
+
nonce: string;
|
|
555
|
+
}
|
|
556
|
+
/** Minimal logger surface used by the hub. */
|
|
557
|
+
interface HubLogger {
|
|
558
|
+
warn(message: string): void;
|
|
559
|
+
}
|
|
560
|
+
/** Fan-out registry for the workspace's live SSE subscribers. */
|
|
561
|
+
declare class OpenCockpitHub {
|
|
562
|
+
private readonly logger;
|
|
563
|
+
private readonly clients;
|
|
564
|
+
private heartbeat;
|
|
565
|
+
constructor(logger: HubLogger);
|
|
566
|
+
/** Accept one SSE subscription and own its response until the client disconnects. */
|
|
567
|
+
subscribe(request: IncomingMessage, response: ServerResponse): void;
|
|
568
|
+
/** Send one navigation event to every connected client. */
|
|
569
|
+
broadcastOpen(event: Omit<OpenCockpitEvent, 'type' | 'requestId'> & {
|
|
570
|
+
requestId?: string;
|
|
571
|
+
}): OpenCockpitEvent;
|
|
572
|
+
/** Ask open viewers of one cockpit to reload it. */
|
|
573
|
+
broadcastUpdated(event: Omit<CockpitUpdatedEvent, 'type'>): CockpitUpdatedEvent;
|
|
574
|
+
/** Number of live subscribers, used by a tool result to explain a missing browser. */
|
|
575
|
+
size(): number;
|
|
576
|
+
/** Close every subscriber; called by the plugin disposer. */
|
|
577
|
+
dispose(): void;
|
|
578
|
+
private write;
|
|
579
|
+
private ensureHeartbeat;
|
|
580
|
+
}
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region src/templates.d.ts
|
|
583
|
+
/**
|
|
584
|
+
* Cockpit HTML contract, validation and runtime injection.
|
|
585
|
+
*
|
|
586
|
+
* The HTML is untrusted content rendered in an opaque-origin iframe. The plugin
|
|
587
|
+
* never "sanitizes" it; instead it refuses files that cannot be rendered safely
|
|
588
|
+
* (missing SDK markers or external resources) and injects the SDK, ECharts and a
|
|
589
|
+
* small theme reset before the bytes leave the host.
|
|
590
|
+
*
|
|
591
|
+
* @module templates
|
|
592
|
+
*/
|
|
593
|
+
/** One failed contract check. */
|
|
594
|
+
declare class TemplateContractError extends Error {
|
|
595
|
+
readonly missing: string[];
|
|
596
|
+
readonly code = "TEMPLATE_CONTRACT_MISSING";
|
|
597
|
+
constructor(missing: string[]);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Validate one cockpit HTML document against the template contract.
|
|
601
|
+
* @param html - document bytes as text.
|
|
602
|
+
* @param maxBytes - configured size ceiling.
|
|
603
|
+
* @throws TemplateContractError when a required marker is missing or an external resource is present.
|
|
604
|
+
* @throws Error when the document is too large.
|
|
605
|
+
*/
|
|
606
|
+
declare function assertCockpitHtml(html: string, maxBytes: number): void;
|
|
607
|
+
/**
|
|
608
|
+
* Inject the theme reset, ECharts and the artifact runtime into a cockpit document.
|
|
609
|
+
* @param html - validated document.
|
|
610
|
+
* @param options - runtime sources; `echartsJs` is omitted when ECharts injection is off.
|
|
611
|
+
* @returns the document the render route serves.
|
|
612
|
+
*/
|
|
613
|
+
declare function injectCockpitRuntime(html: string, options: {
|
|
614
|
+
runtimeJs: string;
|
|
615
|
+
echartsJs?: string;
|
|
616
|
+
}): string;
|
|
617
|
+
/**
|
|
618
|
+
* Build the CSP header for a rendered cockpit.
|
|
619
|
+
* @param origin - the DSH origin the sandboxed page may call for gateway traffic.
|
|
620
|
+
* @returns the header value.
|
|
621
|
+
*/
|
|
622
|
+
declare function cockpitCsp(origin: string): string;
|
|
623
|
+
//#endregion
|
|
624
|
+
//#region src/index.d.ts
|
|
625
|
+
declare const Config: Schema<Config$1>;
|
|
626
|
+
type Config = Config$1;
|
|
627
|
+
/** Cordis plugin name. */
|
|
628
|
+
declare const name = "artifact-app";
|
|
629
|
+
/** Host services this plugin needs. */
|
|
630
|
+
declare const inject: string[];
|
|
631
|
+
/**
|
|
632
|
+
* Register the host routes, the model tools and the authoring skill.
|
|
633
|
+
* @param ctx - DSH host context with web routes, tools, approval and credentials.
|
|
634
|
+
* @param config - DataOps origin, credential ref and HTML limits.
|
|
635
|
+
*/
|
|
636
|
+
declare function apply(ctx: Context, config: Config$1): void;
|
|
637
|
+
//#endregion
|
|
638
|
+
export { APPS_PATH, ARTIFACT_TAB_TYPE, ArtifactApi, ArtifactAppRow, ArtifactTemplateRow, CONFIG_PATH, CockpitUpdatedEvent, Config, DataOpsError, GATEWAY_PATH, GrantInput, OPEN_EVENTS_PATH, OpenCockpitEvent, OpenCockpitHub, PREVIEW_PATH, PreviewInput, PublishInput, RENDER_PATH, TOKEN_PATH, TemplateContractError, TokenSource, apply, assertCockpitHtml, cockpitCsp, inject, injectCockpitRuntime, name };
|