feat: init

This commit is contained in:
2026-02-13 22:02:30 +01:00
commit 8f9ff830fb
16711 changed files with 3307340 additions and 0 deletions

50
node_modules/untyped/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,50 @@
MIT License
Copyright (c) Pooya Parsa <pooya@pi0.io>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Third party library "@babel/types" bundled.
"""
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

187
node_modules/untyped/README.md generated vendored Normal file
View File

@@ -0,0 +1,187 @@
# untyped
<!-- automd:badges bundlejs -->
[![npm version](https://img.shields.io/npm/v/untyped)](https://npmjs.com/package/untyped)
[![npm downloads](https://img.shields.io/npm/dm/untyped)](https://npm.chart.dev/untyped)
[![bundle size](https://img.shields.io/bundlejs/size/untyped)](https://bundlejs.com/?q=untyped)
<!-- /automd -->
**▶️ Check [online playground](https://untyped.unjs.io)**
## Install
<!-- automd:pm-i -->
```sh
# ✨ Auto-detect
npx nypm install untyped
# npm
npm install untyped
# yarn
yarn add untyped
# pnpm
pnpm install untyped
# bun
bun install untyped
# deno
deno install untyped
```
<!-- /automd -->
## Usage
First we have to define a reference object that describes types, defaults, and a `$resolve` method (normalizer).
```js
const defaultPlanet = {
name: "earth",
specs: {
gravity: {
$resolve: (val) => Number.parseFloat(val),
$default: "9.8",
},
moons: {
$resolve: (val = ["moon"]) => [val].flat(),
$schema: {
title: "planet moons",
},
},
},
};
```
## API
### `resolveSchema`
```js
import { resolveSchema } from "untyped";
const schema = await resolveSchema(defaultPlanet);
```
Output:
```json
{
"properties": {
"name": {
"type": "string",
"default": "earth"
},
"specs": {
"properties": {
"gravity": {
"default": 9.8,
"type": "number"
},
"moons": {
"title": "planet moons",
"default": ["moon"],
"type": "array",
"items": [
{
"type": "string"
}
]
}
},
"type": "object"
}
},
"type": "object"
}
```
### `generateTypes`
```js
import { resolveSchema, generateTypes } from "untyped";
const types = generateTypes(await resolveSchema(defaultPlanet));
```
Output:
```ts
interface Untyped {
/** @default "earth" */
name: string;
specs: {
/** @default 9.8 */
gravity: number;
/**
* planet moons
* @default ["moon"]
*/
moons: string[];
};
}
```
### `generateMarkdown`
```js
import { resolveSchema, generateMarkdown } from "untyped";
const markdown = generateMarkdown(await resolveSchema(defaultPlanet));
```
Output:
```markdown
# `name`
- **Type**: `string`
- **Default**: `"earth"`
# `specs`
## `gravity`
- **Type**: `number`
- **Default**: `9.8`
## `moons`
- **Type**: `array`
- **Default**: `["moon"]`
```
## 💻 Development
- Clone this repository
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)
- Install dependencies using `pnpm install`
- Run interactive tests using `pnpm dev`
- Use `pnpm web` to start playground website
- Use `pnpm test` before push to ensure all tests and lint checks passing
## License
[MIT](./LICENSE)
Thanks to [@dominikschreiber](https://github.com/dominikschreiber) for donating package name.
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/untyped?style=flat-square
[npm-version-href]: https://npmjs.com/package/untyped
[npm-downloads-src]: https://img.shields.io/npm/dm/untyped?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/untyped
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/unjs/untyped/ci.yml?branch-main&style=flat-square
[github-actions-href]: https://github.com/unjs/untyped/actions?query=workflow%3Aci
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/untyped/main?style=flat-square
[codecov-href]: https://codecov.io/gh/unjs/untyped
[bundle-src]: https://img.shields.io/bundlephobia/minzip/untyped?style=flat-square
[bundle-href]: https://bundlephobia.com/result?p=untyped

58
node_modules/untyped/dist/cli.mjs generated vendored Executable file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env node
import { writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { defineCommand, runMain } from 'citty';
const load = defineCommand({
meta: {
name: "load",
description: "Load a schema from the specified entry path"
},
args: {
entryPath: {
type: "positional",
required: true,
description: "Path to the entry file"
},
write: {
type: "string",
required: false,
description: "Write the output to a file"
},
ignoreDefaults: {
type: "boolean",
required: false,
description: "Ignore default values"
}
},
async run({ args }) {
const { loadSchema } = await import('./loader/loader.mjs');
const cwd = process.cwd();
const schema = await loadSchema(resolve(cwd, args.entryPath), {
ignoreDefaults: args.ignoreDefaults
});
if (args.write) {
const json = JSON.stringify(schema, null, 2);
const outfile = resolve(
cwd,
args.write === "true" ? "schema.json" : args.write
);
await writeFile(outfile, json);
} else {
console.log(schema);
}
}
});
const cli = defineCommand({
meta: {
name: "untyped",
description: "CLI tool for untyped operations"
},
subCommands: {
load
}
});
runMain(cli).catch((error) => {
console.error(error);
process.exit(1);
});

27
node_modules/untyped/dist/index.d.mts generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import { I as InputObject, S as Schema, a as SchemaDefinition } from './shared/untyped.kR35CG5k.mjs';
export { F as FunctionArg, c as InputValue, b as JSType, J as JSValue, R as ResolveFn, T as TypeDescriptor } from './shared/untyped.kR35CG5k.mjs';
interface NormalizeSchemaOptions {
ignoreDefaults?: boolean;
}
interface ResolveSchemaOptions extends NormalizeSchemaOptions {
}
declare function resolveSchema(obj: InputObject, defaults?: InputObject, options?: ResolveSchemaOptions): Promise<Schema>;
declare function applyDefaults(ref: InputObject, input: InputObject): Promise<InputObject>;
interface GenerateTypesOptions {
interfaceName?: string;
addExport?: boolean;
addDefaults?: boolean;
defaultDescription?: string;
indentation?: number;
allowExtraKeys?: boolean;
partial?: boolean;
}
declare function generateTypes(schema: Schema, opts?: GenerateTypesOptions): string;
declare function generateMarkdown(schema: Schema): string;
declare function defineUntypedSchema(options: SchemaDefinition): SchemaDefinition;
export { InputObject, Schema, SchemaDefinition, applyDefaults, defineUntypedSchema, generateMarkdown, generateTypes, resolveSchema };

256
node_modules/untyped/dist/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,256 @@
export { a as applyDefaults, r as resolveSchema } from './shared/untyped.BTwOq8Jl.mjs';
import { genObjectKey } from 'knitwork';
import { n as normalizeTypes } from './shared/untyped.Br_uXjZG.mjs';
export { d as defineUntypedSchema } from './shared/untyped.Br_uXjZG.mjs';
import 'scule';
const GenerateTypesDefaults = {
interfaceName: "Untyped",
addExport: true,
addDefaults: true,
allowExtraKeys: void 0,
partial: false,
indentation: 0
};
const TYPE_MAP = {
array: "any[]",
bigint: "bigint",
boolean: "boolean",
number: "number",
object: "",
// Will be precisely defined
any: "any",
string: "string",
symbol: "Symbol",
function: "Function"
};
const SCHEMA_KEYS = /* @__PURE__ */ new Set([
"items",
"default",
"resolve",
"properties",
"title",
"description",
"$schema",
"type",
"tsType",
"markdownType",
"tags",
"args",
"id",
"returns"
]);
const DECLARATION_RE = /typeof import\(["'](?<source>[^)]+)["']\)(\.(?<type>\w+)|\[["'](?<type1>\w+)["']])/g;
function extractTypeImports(declarations) {
const typeImports = {};
const aliases = /* @__PURE__ */ new Set();
const imports = [];
for (const match of declarations.matchAll(DECLARATION_RE)) {
const { source, type1, type = type1 } = match.groups || {};
typeImports[source] = typeImports[source] || /* @__PURE__ */ new Set();
typeImports[source].add(type);
}
for (const source in typeImports) {
const sourceImports = [];
for (const type of typeImports[source]) {
let count = 0;
let alias = type;
while (aliases.has(alias)) {
alias = `${type}${count++}`;
}
aliases.add(alias);
sourceImports.push(alias === type ? type : `${type} as ${alias}`);
declarations = declarations.replace(
new RegExp(
`typeof import\\(['"]${source}['"]\\)(\\.${type}|\\[['"]${type}['"]\\])`,
"g"
),
alias
);
}
imports.push(
`import type { ${sourceImports.join(", ")} } from '${source}'`
);
}
return [...imports, declarations].join("\n");
}
function generateTypes(schema, opts = {}) {
opts = { ...GenerateTypesDefaults, ...opts };
const baseIden = " ".repeat(opts.indentation || 0);
const interfaceCode = `interface ${opts.interfaceName} {
` + _genTypes(schema, baseIden + " ", opts).map((l) => l.trim().length > 0 ? l : "").join("\n") + `
${baseIden}}`;
if (!opts.addExport) {
return baseIden + interfaceCode;
}
return extractTypeImports(baseIden + `export ${interfaceCode}`);
}
function _genTypes(schema, spaces, opts) {
const buff = [];
if (!schema) {
return buff;
}
for (const key in schema.properties) {
const val = schema.properties[key];
buff.push(...generateJSDoc(val, opts));
if (val.tsType) {
buff.push(
`${genObjectKey(key)}${isRequired(schema, key, opts) ? "" : "?"}: ${val.tsType},
`
);
} else if (val.type === "object") {
buff.push(
`${genObjectKey(key)}${isRequired(schema, key, opts) ? "" : "?"}: {`,
..._genTypes(val, spaces, opts),
"},\n"
);
} else {
let type;
if (val.type === "array") {
type = `Array<${getTsType(val.items || [], opts)}>`;
} else if (val.type === "function") {
type = genFunctionType(val, opts);
} else {
type = getTsType(val, opts);
}
buff.push(
`${genObjectKey(key)}${isRequired(schema, key, opts) ? "" : "?"}: ${type},
`
);
}
}
if (buff.length > 0) {
const last = buff.pop() || "";
buff.push(last.slice(0, Math.max(0, last.length - 1)));
}
if (opts.allowExtraKeys === true || buff.length === 0 && opts.allowExtraKeys !== false) {
buff.push("[key: string]: any");
}
return buff.flatMap((l) => l.split("\n")).map((l) => spaces + l);
}
function getTsType(type, opts) {
if (Array.isArray(type)) {
return [normalizeTypes(type.map((t) => getTsType(t, opts)))].flat().join("|") || "any";
}
if (!type) {
return "any";
}
if (type.tsType) {
return type.tsType;
}
if (!type.type) {
return "any";
}
if (Array.isArray(type.type)) {
return type.type.map((t) => {
if (t === "object" && type.type.length > 1) {
return `{
` + _genTypes(type, " ", opts).join("\n") + `
}`;
}
return TYPE_MAP[t];
}).join("|");
}
if (type.type === "array") {
return `Array<${getTsType(type.items || [], opts)}>`;
}
if (type.type === "object") {
return `{
` + _genTypes(type, " ", opts).join("\n") + `
}`;
}
return TYPE_MAP[type.type] || type.type;
}
function genFunctionType(schema, opts) {
return `(${genFunctionArgs(schema.args, opts)}) => ${getTsType(
schema.returns || [],
opts
)}`;
}
function genFunctionArgs(args, opts) {
return args?.map((arg) => {
let argStr = arg.name;
if (arg.optional || arg.default) {
argStr += "?";
}
if (arg.type || arg.tsType) {
argStr += `: ${getTsType(arg, opts)}`;
}
return argStr;
}).join(", ") || "";
}
function generateJSDoc(schema, opts) {
opts.defaultDescription = opts.defaultDescription || opts.defaultDescrption;
let buff = [];
if (schema.title) {
buff.push(schema.title, "");
}
if (schema.description) {
buff.push(schema.description, "");
} else if (opts.defaultDescription && schema.type !== "object") {
buff.push(opts.defaultDescription, "");
}
if (opts.addDefaults && schema.type !== "object" && schema.type !== "any" && !(Array.isArray(schema.default) && schema.default.length === 0)) {
const stringified = JSON.stringify(schema.default);
if (stringified) {
buff.push(`@default ${stringified.replace(/\*\//g, String.raw`*\/`)}`);
}
}
for (const key in schema) {
if (!SCHEMA_KEYS.has(key)) {
buff.push("", `@${key} ${schema[key]}`);
}
}
if (Array.isArray(schema.tags)) {
for (const tag of schema.tags) {
if (tag !== "@untyped") {
buff.push("", tag);
}
}
}
buff = buff.flatMap((i) => i.split("\n"));
if (buff.length > 0) {
return buff.length === 1 ? ["/** " + buff[0] + " */"] : ["/**", ...buff.map((i) => ` * ${i}`), "*/"];
}
return [];
}
function isRequired(schema, key, opts) {
if (Array.isArray(schema.required) && schema.required.includes(key)) {
return true;
}
return !opts.partial;
}
function generateMarkdown(schema) {
return _generateMarkdown(schema, "", "").join("\n");
}
function _generateMarkdown(schema, title, level) {
const lines = [];
lines.push(`${level} ${title}`);
if (schema.type === "object") {
for (const key in schema.properties) {
const val = schema.properties[key];
lines.push("", ..._generateMarkdown(val, `\`${key}\``, level + "#"));
}
return lines;
}
lines.push(
`- **Type**: \`${schema.markdownType || schema.tsType || schema.type}\``
);
if ("default" in schema) {
lines.push(`- **Default**: \`${JSON.stringify(schema.default)}\``);
}
lines.push("");
if (schema.title) {
lines.push("> " + schema.title, "");
}
if (schema.type === "function") {
lines.push("```ts", genFunctionType(schema, {}), "```", "");
}
if (schema.description) {
lines.push("", schema.description, "");
}
return lines;
}
export { generateMarkdown, generateTypes };

5
node_modules/untyped/dist/loader/babel.d.mts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import { PluginItem } from '@babel/core';
declare const babelPluginUntyped: PluginItem;
export { babelPluginUntyped as default };

679
node_modules/untyped/dist/loader/babel.mjs generated vendored Normal file

File diff suppressed because one or more lines are too long

12
node_modules/untyped/dist/loader/loader.d.mts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import { JitiOptions } from 'jiti';
import { S as Schema } from '../shared/untyped.kR35CG5k.mjs';
interface LoaderOptions {
jiti?: JitiOptions;
defaults?: Record<string, any>;
ignoreDefaults?: boolean;
cwd?: string;
}
declare function loadSchema(entryPath: string, options?: LoaderOptions): Promise<Schema>;
export { type LoaderOptions, loadSchema };

31
node_modules/untyped/dist/loader/loader.mjs generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import { defu } from 'defu';
import { createJiti } from 'jiti';
import { r as resolveSchema } from '../shared/untyped.BTwOq8Jl.mjs';
import babelPluginUntyped from './babel.mjs';
import '../shared/untyped.Br_uXjZG.mjs';
import 'scule';
async function loadSchema(entryPath, options = {}) {
const jiti = createJiti(
options.cwd || process.cwd(),
defu(options.jiti, {
interopDefault: true,
transformOptions: {
babel: {
plugins: [[babelPluginUntyped, { experimentalFunctions: true }]]
}
}
})
);
let rawSchema = await jiti.import(entryPath);
const rawSchemaKeys = Object.keys(rawSchema);
if (rawSchemaKeys.length === 1 && rawSchemaKeys[0] === "default") {
rawSchema = rawSchema.default;
}
const schema = await resolveSchema(rawSchema, options.defaults, {
ignoreDefaults: options.ignoreDefaults
});
return schema;
}
export { loadSchema };

103
node_modules/untyped/dist/shared/untyped.BTwOq8Jl.mjs generated vendored Normal file
View File

@@ -0,0 +1,103 @@
import { i as isObject, g as getType, a as getValue, s as setValue, j as joinPath, b as nonEmpty, u as unique } from './untyped.Br_uXjZG.mjs';
async function resolveSchema(obj, defaults, options = {}) {
const schema = await _resolveSchema(obj, "", {
root: obj,
defaults,
resolveCache: {},
ignoreDefaults: !!options.ignoreDefaults
});
return schema;
}
async function _resolveSchema(input, id, ctx) {
if (id in ctx.resolveCache) {
return ctx.resolveCache[id];
}
const schemaId = "#" + id.replace(/\./g, "/");
if (!isObject(input)) {
const safeInput = Array.isArray(input) ? [...input] : input;
const schema2 = {
type: getType(input),
id: schemaId,
default: ctx.ignoreDefaults ? void 0 : safeInput
};
normalizeSchema(schema2, { ignoreDefaults: ctx.ignoreDefaults });
ctx.resolveCache[id] = schema2;
if (ctx.defaults && getValue(ctx.defaults, id) === void 0) {
setValue(ctx.defaults, id, schema2.default);
}
return schema2;
}
const node = { ...input };
const schema = ctx.resolveCache[id] = {
...node.$schema,
id: schemaId
};
for (const key in node) {
if (key === "$resolve" || key === "$schema" || key === "$default") {
continue;
}
schema.properties = schema.properties || {};
if (!schema.properties[key]) {
const child = schema.properties[key] = await _resolveSchema(
node[key],
joinPath(id, key),
ctx
);
if (Array.isArray(child.tags) && child.tags.includes("@required")) {
schema.required = schema.required || [];
if (!schema.required.includes(key)) {
schema.required.push(key);
}
}
}
}
if (!ctx.ignoreDefaults) {
if (ctx.defaults) {
schema.default = getValue(ctx.defaults, id);
}
if (schema.default === void 0 && "$default" in node) {
schema.default = node.$default;
}
if (typeof node.$resolve === "function") {
schema.default = await node.$resolve(schema.default, async (key) => {
return (await _resolveSchema(getValue(ctx.root, key), key, ctx)).default;
});
}
}
if (ctx.defaults) {
setValue(ctx.defaults, id, schema.default);
}
if (!schema.type) {
schema.type = getType(schema.default) || (schema.properties ? "object" : "any");
}
normalizeSchema(schema, { ignoreDefaults: ctx.ignoreDefaults });
if (ctx.defaults && getValue(ctx.defaults, id) === void 0) {
setValue(ctx.defaults, id, schema.default);
}
return schema;
}
async function applyDefaults(ref, input) {
await resolveSchema(ref, input);
return input;
}
function normalizeSchema(schema, options) {
if (schema.type === "array" && !("items" in schema)) {
schema.items = {
type: nonEmpty(unique(schema.default.map((i) => getType(i))))
};
if (schema.items.type) {
if (schema.items.type.length === 0) {
schema.items.type = "any";
} else if (schema.items.type.length === 1) {
schema.items.type = schema.items.type[0];
}
}
}
if (!options.ignoreDefaults && schema.default === void 0 && ("properties" in schema || schema.type === "object" || schema.type === "any")) {
const propsWithDefaults = Object.entries(schema.properties || {}).filter(([, prop]) => "default" in prop).map(([key, value]) => [key, value.default]);
schema.default = Object.fromEntries(propsWithDefaults);
}
}
export { applyDefaults as a, resolveSchema as r };

132
node_modules/untyped/dist/shared/untyped.Br_uXjZG.mjs generated vendored Normal file
View File

@@ -0,0 +1,132 @@
import { pascalCase } from 'scule';
function defineUntypedSchema(options) {
return options;
}
function getType(val) {
const type = typeof val;
if (type === "undefined" || val === null) {
return void 0;
}
if (Array.isArray(val)) {
return "array";
}
return type;
}
function isObject(val) {
return val !== null && !Array.isArray(val) && typeof val === "object";
}
function nonEmpty(arr) {
return arr.filter(Boolean);
}
function unique(arr) {
return [...new Set(arr)];
}
function joinPath(a, b = "", sep = ".") {
return a ? a + sep + b : b;
}
function setValue(obj, path, val) {
const keys = path.split(".");
const _key = keys.pop();
for (const key of keys) {
if (!obj || typeof obj !== "object") {
return;
}
if (!(key in obj)) {
obj[key] = {};
}
obj = obj[key];
}
if (_key) {
if (!obj || typeof obj !== "object") {
return;
}
obj[_key] = val;
}
}
function getValue(obj, path) {
for (const key of path.split(".")) {
if (!obj || typeof obj !== "object" || !(key in obj)) {
return;
}
obj = obj[key];
}
return obj;
}
function mergedTypes(...types) {
types = types.filter(Boolean);
if (types.length === 0) {
return {};
}
if (types.length === 1) {
return types[0];
}
const tsTypes = normalizeTypes(
types.flatMap((t) => t.tsType).filter(Boolean)
);
return {
type: normalizeTypes(
types.flatMap((t) => t.type).filter(Boolean)
),
tsType: Array.isArray(tsTypes) ? tsTypes.join(" | ") : tsTypes,
items: mergedTypes(
...types.flatMap((t) => t.items).filter(Boolean)
)
};
}
function normalizeTypes(val) {
const arr = unique(val.filter(Boolean));
if (arr.length === 0 || arr.includes("any")) {
return;
}
return arr.length > 1 ? arr : arr[0];
}
function cachedFn(fn) {
let val;
let resolved = false;
const cachedFn2 = () => {
if (!resolved) {
val = fn();
resolved = true;
}
return val;
};
return cachedFn2;
}
const jsTypes = /* @__PURE__ */ new Set([
"string",
"number",
"bigint",
"boolean",
"symbol",
"function",
"object",
"any",
"array"
]);
function isJSType(val) {
return jsTypes.has(val);
}
const FRIENDLY_TYPE_RE = /(typeof )?import\(["'](?<importName>[^"']+)["']\)(\[["']|\.)(?<firstType>[^\s"']+)(["']])?/g;
function getTypeDescriptor(type) {
if (!type) {
return {};
}
let markdownType = type;
for (const match of type.matchAll(FRIENDLY_TYPE_RE) || []) {
const { importName, firstType } = match.groups || {};
if (importName && firstType) {
markdownType = markdownType.replace(
match[0],
pascalCase(importName) + pascalCase(firstType)
);
}
}
return {
...isJSType(type) ? { type } : {},
tsType: type,
...markdownType === type ? {} : { markdownType }
};
}
export { getValue as a, nonEmpty as b, getTypeDescriptor as c, defineUntypedSchema as d, cachedFn as e, getType as g, isObject as i, joinPath as j, mergedTypes as m, normalizeTypes as n, setValue as s, unique as u };

View File

@@ -0,0 +1,44 @@
type JSValue = string | number | bigint | boolean | symbol | Function | Array<any> | undefined | object | null;
type JSType = "string" | "number" | "bigint" | "boolean" | "symbol" | "function" | "object" | "any" | "array";
type ResolveFn = (value: unknown, get: (key: string) => Promise<unknown>) => JSValue | Promise<JSValue>;
interface TypeDescriptor {
/** Used internally to handle schema types */
type?: JSType | JSType[];
/** Fully resolved correct TypeScript type for generated TS declarations */
tsType?: string;
/** Human-readable type description for use in generated documentation */
markdownType?: string;
items?: TypeDescriptor | TypeDescriptor[];
}
interface FunctionArg extends TypeDescriptor {
name?: string;
default?: JSValue;
optional?: boolean;
}
interface Schema extends TypeDescriptor {
id?: string;
default?: JSValue;
resolve?: ResolveFn;
properties?: {
[key: string]: Schema;
};
required?: string[];
title?: string;
description?: string;
$schema?: string;
tags?: string[];
args?: FunctionArg[];
returns?: TypeDescriptor;
}
interface InputObject {
$schema?: Schema;
$resolve?: ResolveFn;
$default?: any;
[key: string]: JSValue | InputObject;
}
type InputValue = InputObject | JSValue;
type SchemaDefinition = {
[x: string]: JSValue | InputObject;
};
export type { FunctionArg as F, InputObject as I, JSValue as J, ResolveFn as R, Schema as S, TypeDescriptor as T, SchemaDefinition as a, JSType as b, InputValue as c };

76
node_modules/untyped/package.json generated vendored Normal file
View File

@@ -0,0 +1,76 @@
{
"name": "untyped",
"version": "2.0.0",
"description": "",
"repository": "unjs/untyped",
"license": "MIT",
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"./babel-plugin": {
"types": "./dist/loader/babel.d.mts",
"default": "./dist/loader/babel.mjs"
},
"./loader": {
"types": "./dist/loader/loader.d.mts",
"default": "./dist/loader/loader.mjs"
}
},
"types": "./dist/index.d.mts",
"bin": {
"untyped": "./dist/cli.mjs"
},
"files": [
"dist"
],
"scripts": {
"build": "unbuild",
"dev": "vitest",
"lint": "eslint . && prettier -c src test web",
"lint:fix": "automd && eslint --fix . && prettier -w src test web",
"prepack": "pnpm build",
"release": "pnpm test && changelogen --release --push && npm publish",
"test": "pnpm lint && vitest run --coverage",
"untyped": "jiti ./src/cli.ts",
"web": "nuxi dev web",
"web:build": "nuxi generate web"
},
"dependencies": {
"citty": "^0.1.6",
"defu": "^6.1.4",
"jiti": "^2.4.2",
"knitwork": "^1.2.0",
"scule": "^1.3.0"
},
"devDependencies": {
"@babel/core": "^7.26.9",
"@babel/standalone": "^7.26.9",
"@babel/template": "^7.26.9",
"@babel/types": "^7.26.9",
"@types/babel__standalone": "^7.1.9",
"@types/babel__traverse": "^7.20.6",
"@types/node": "^22.13.5",
"@vitest/coverage-v8": "^3.0.7",
"@vue/compiler-sfc": "^3.5.13",
"automd": "^0.3.12",
"changelogen": "^0.6.0",
"esbuild": "^0.25.0",
"eslint": "^9.21.0",
"eslint-config-unjs": "^0.4.2",
"hljs": "^6.2.3",
"json-schema": "^0.4.0",
"marked": "^15.0.7",
"monaco-editor": "^0.52.2",
"nuxt": "^3.15.4",
"nuxt-windicss": "^3.0.1",
"prettier": "^3.5.2",
"prismjs": "^1.29.0",
"typescript": "^5.7.3",
"unbuild": "^3.4.1",
"vitest": "^3.0.7"
},
"packageManager": "pnpm@10.5.1"
}