@code0-tech/triangulum 0.37.1 → 0.37.2
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/dist/index.cjs +3 -3
- package/dist/index.js +149 -127
- package/dist/schema/getSignatureSchema.d.ts +9 -3
- package/dist/server.cjs +1 -1
- package/dist/server.js +1 -1
- package/dist/util/nodes.util.d.ts +9 -2
- package/dist/util/schema.util.d.ts +94 -1
- package/dist/{utils-CAOAm6k-.js → utils-DSmUMJiO.js} +214 -162
- package/dist/utils-euztPiZI.cjs +45 -0
- package/package.json +1 -1
- package/dist/utils-oMAOCPrM.cjs +0 -45
|
@@ -189,8 +189,42 @@ export interface DataInput extends Input {
|
|
|
189
189
|
*/
|
|
190
190
|
export interface ListInput extends Input {
|
|
191
191
|
input?: "list";
|
|
192
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* Schema or array of schemas for list items.
|
|
194
|
+
*
|
|
195
|
+
* In a parameter schema this is *value-driven*: once an array value is
|
|
196
|
+
* entered it holds exactly one entry per entered element, so it says what the
|
|
197
|
+
* list currently contains — not what an element may be. Use
|
|
198
|
+
* {@link ListInput.declaredItems} for the latter.
|
|
199
|
+
*
|
|
200
|
+
* An entered entry only ever *refines* one of the `declaredItems`: it is that
|
|
201
|
+
* option's input kind, properties and suggestions, with the concrete value's
|
|
202
|
+
* `type` and per-element cardinality filled in. A union element type is
|
|
203
|
+
* resolved to the member the entered element picked, so the COLOR entries of a
|
|
204
|
+
* `LIST<COLOR | OBJECT<…>>` stay color inputs and its object entries keep the
|
|
205
|
+
* declared object's property schemas.
|
|
206
|
+
*/
|
|
193
207
|
items?: Schema[];
|
|
208
|
+
/**
|
|
209
|
+
* The item schemas the *declared* element type produces — what `items` holds
|
|
210
|
+
* while no value is entered, and therefore the answer to "what may an element
|
|
211
|
+
* of this list be": its input kind, and the suggestions an element slot offers.
|
|
212
|
+
* A union element contributes one entry per member (e.g. all six methods of a
|
|
213
|
+
* `LIST<HTTP_METHOD>`), so the entries enumerate the element's options rather
|
|
214
|
+
* than the list's contents.
|
|
215
|
+
*
|
|
216
|
+
* Always present alongside `items` on an input slot's schema — an entered
|
|
217
|
+
* value can empty `items` (`[]`) or reduce it to the elements that happen to be
|
|
218
|
+
* there, and neither tells the UI what to render for a new element or which
|
|
219
|
+
* candidates the element slot accepts. An unconstrained element slot (a generic
|
|
220
|
+
* `LIST<T>`, or a list in a slot the declared type does not describe) yields a
|
|
221
|
+
* single generic entry carrying the "accepts anything" suggestion set.
|
|
222
|
+
*
|
|
223
|
+
* Omitted on schemas that describe a *produced* value rather than an input slot
|
|
224
|
+
* (a signature's return type, {@link getTypeSchema}); there `items` is already
|
|
225
|
+
* the declared expansion.
|
|
226
|
+
*/
|
|
227
|
+
declaredItems?: Schema[];
|
|
194
228
|
}
|
|
195
229
|
/**
|
|
196
230
|
* Represents a type input.
|
|
@@ -248,6 +282,36 @@ export declare const getSchema: (checker: ts.TypeChecker, node: ts.VariableDecla
|
|
|
248
282
|
* {@link mergeSchemas}.
|
|
249
283
|
*/
|
|
250
284
|
export declare const normalizeNodeSchema: (schema: Schema) => Schema;
|
|
285
|
+
/**
|
|
286
|
+
* Strips `undefined` and `null` from a union type so the *declared* shape can be
|
|
287
|
+
* inspected. An optional parameter (or property) resolves to
|
|
288
|
+
* `<declared> | undefined`, and a union carries none of its members' type flags —
|
|
289
|
+
* so a test like "is this an object" or `checker.isArrayType` answers `false` for
|
|
290
|
+
* every optional slot unless the nullish part is removed first. A union that has
|
|
291
|
+
* more than one real member left is returned unchanged: there is no single
|
|
292
|
+
* declared shape to speak of then.
|
|
293
|
+
*/
|
|
294
|
+
export declare const nonNullishType: (type: ts.Type) => ts.Type;
|
|
295
|
+
/**
|
|
296
|
+
* Sets a schema's `suggestions` to the given set, dropping the key entirely when
|
|
297
|
+
* the set is empty or missing. Suggestion-carrying schemas are built with the
|
|
298
|
+
* key always present (an empty array when nothing matched), whereas the rest of
|
|
299
|
+
* the pipeline omits it — so every schema that is spread into a result passes
|
|
300
|
+
* through here instead of relying on the spread.
|
|
301
|
+
*/
|
|
302
|
+
export declare const withSuggestions: <T extends Schema>(schema: T, suggestions: Input["suggestions"] | undefined) => T;
|
|
303
|
+
/**
|
|
304
|
+
* A declared (function-side) schema kept as the answer for its position, because
|
|
305
|
+
* the node side has no counterpart to merge into it — e.g. a property the entered
|
|
306
|
+
* value does not carry, or a union-typed position whose members no longer line up.
|
|
307
|
+
*
|
|
308
|
+
* The declared schema already carries the suggestions of every level it
|
|
309
|
+
* describes; only a fully generic slot inside it is rewritten to the constant
|
|
310
|
+
* `any` set, which is what the merge itself would have produced for such a slot
|
|
311
|
+
* (see {@link genericNodeSchema}). Empty suggestion arrays are dropped so the
|
|
312
|
+
* result follows the same convention as every other schema.
|
|
313
|
+
*/
|
|
314
|
+
export declare const declaredSchema: (schema: Schema, anySuggestions?: Input["suggestions"]) => Schema;
|
|
251
315
|
/**
|
|
252
316
|
* Treats a node-side schema as sitting in a fully generic ("accepts anything")
|
|
253
317
|
* slot: the declared type constrains nothing here, so the value keeps its shape
|
|
@@ -264,8 +328,37 @@ export declare const normalizeNodeSchema: (schema: Schema) => Schema;
|
|
|
264
328
|
* type-parameter constraint — e.g. `keyof T` — so they are kept). Descendants are
|
|
265
329
|
* always overridden regardless.
|
|
266
330
|
*/
|
|
331
|
+
/**
|
|
332
|
+
* The declared element expansion of a list slot: the function-side `items`, each
|
|
333
|
+
* kept as the declared answer for its position (see {@link declaredSchema}). An
|
|
334
|
+
* element the declared type leaves unconstrained — a generic `LIST<T>`, or a list
|
|
335
|
+
* in a slot with no declared type at all — yields a single generic entry carrying
|
|
336
|
+
* the "accepts anything" set, which is what such an element slot accepts.
|
|
337
|
+
*
|
|
338
|
+
* This is what {@link ListInput.declaredItems} carries, and it never depends on the
|
|
339
|
+
* entered value.
|
|
340
|
+
*/
|
|
341
|
+
export declare const declaredItemsOf: (functionItems: Schema[] | undefined, anySuggestions?: Input["suggestions"]) => Schema[];
|
|
267
342
|
export declare const genericNodeSchema: (schema: Schema, anySuggestions?: Input["suggestions"], overrideRoot?: boolean) => Schema;
|
|
268
343
|
export declare const mergeSchemas: (functionSchema: Schema | undefined, nodeSchema: Schema, valueProvided?: boolean, anySuggestions?: Input["suggestions"], topLevel?: boolean) => Schema;
|
|
344
|
+
/**
|
|
345
|
+
* Checks whether a union's members are the *options of one input* rather than
|
|
346
|
+
* alternative inputs: a string/number literal union (`'GET' | 'POST' | …`, which
|
|
347
|
+
* renders as a single select offering all of them) or `boolean` (internally the
|
|
348
|
+
* union `true | false`, which renders as a single boolean input).
|
|
349
|
+
*
|
|
350
|
+
* The distinction decides whether an entered value may narrow a union-typed slot
|
|
351
|
+
* to the single member it picked. For an options union it must not: narrowing
|
|
352
|
+
* `HTTP_METHOD` to the entered "GET" would hide the five other options of the
|
|
353
|
+
* very select the user is filling. For a union of alternative inputs
|
|
354
|
+
* (`COLOR | OBJECT<…>`, `TEXT | NUMBER`) it must: the member the value picked is
|
|
355
|
+
* the one input of the set that describes it, and it is also the entry the slot's
|
|
356
|
+
* {@link ListInput.declaredItems} already offers for it.
|
|
357
|
+
*
|
|
358
|
+
* @param type - The type to check
|
|
359
|
+
* @returns True if the type is a union whose members are options of one input
|
|
360
|
+
*/
|
|
361
|
+
export declare function isOptionsUnion(type: ts.Type): boolean;
|
|
269
362
|
/**
|
|
270
363
|
* Checks if a type is a callable type (has call signatures).
|
|
271
364
|
*
|