@digo-labs/common 0.1.10 → 0.1.12
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 +11 -0
- package/dist/icons.d.ts +224 -0
- package/dist/index.css +16 -3
- package/dist/index.js +2435 -2036
- package/dist/index.js.map +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/schemas/ai.d.ts +105 -40
- package/package.json +4 -8
- package/vite-plugin-raw-mdx.ts +0 -63
- package/vite.apps.ts +0 -54
package/dist/routes.d.ts
CHANGED
package/dist/schemas/ai.d.ts
CHANGED
|
@@ -6,46 +6,89 @@ export interface ModelMetadata {
|
|
|
6
6
|
version: string;
|
|
7
7
|
description: string;
|
|
8
8
|
}
|
|
9
|
-
export declare const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
9
|
+
export declare const imageGenerateBodySchema: z.ZodObject<{
|
|
10
|
+
prompt: z.ZodString;
|
|
11
|
+
aspectRatio: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`${number}:${number}`, string>>>;
|
|
12
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type ImageGenerateBody = z.infer<typeof imageGenerateBodySchema>;
|
|
15
|
+
export declare const imageEditBodySchema: z.ZodObject<{
|
|
16
|
+
prompt: z.ZodString;
|
|
17
|
+
image: z.ZodString;
|
|
18
|
+
strength: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export type ImageEditBody = z.infer<typeof imageEditBodySchema>;
|
|
21
|
+
export declare const imageUpscaleBodySchema: z.ZodObject<{
|
|
22
|
+
image: z.ZodString;
|
|
23
|
+
factor: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type ImageUpscaleBody = z.infer<typeof imageUpscaleBodySchema>;
|
|
26
|
+
export declare const imageRemoveBackgroundBodySchema: z.ZodObject<{
|
|
27
|
+
image: z.ZodString;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type ImageRemoveBackgroundBody = z.infer<typeof imageRemoveBackgroundBodySchema>;
|
|
30
|
+
export declare const generatedImageSchema: z.ZodObject<{
|
|
31
|
+
url: z.ZodString;
|
|
32
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
33
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
model: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type GeneratedImage = z.infer<typeof generatedImageSchema>;
|
|
39
|
+
export declare const videoGenerateBodySchema: z.ZodObject<{
|
|
40
|
+
prompt: z.ZodString;
|
|
41
|
+
aspectRatio: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`${number}:${number}`, string>>>;
|
|
42
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type VideoGenerateBody = z.infer<typeof videoGenerateBodySchema>;
|
|
45
|
+
export declare const generatedVideoSchema: z.ZodObject<{
|
|
46
|
+
url: z.ZodString;
|
|
47
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
48
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
model: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export type GeneratedVideo = z.infer<typeof generatedVideoSchema>;
|
|
52
|
+
export declare const audioSpeechBodySchema: z.ZodObject<{
|
|
53
|
+
text: z.ZodString;
|
|
54
|
+
voice: z.ZodOptional<z.ZodString>;
|
|
55
|
+
speed: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
export type AudioSpeechBody = z.infer<typeof audioSpeechBodySchema>;
|
|
58
|
+
export declare const audioMusicBodySchema: z.ZodObject<{
|
|
59
|
+
prompt: z.ZodString;
|
|
60
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type AudioMusicBody = z.infer<typeof audioMusicBodySchema>;
|
|
63
|
+
export declare const audioTranscribeBodySchema: z.ZodObject<{
|
|
64
|
+
audio: z.ZodString;
|
|
65
|
+
language: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type AudioTranscribeBody = z.infer<typeof audioTranscribeBodySchema>;
|
|
68
|
+
export declare const generatedAudioSchema: z.ZodObject<{
|
|
69
|
+
url: z.ZodString;
|
|
70
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
71
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
model: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
export type GeneratedAudio = z.infer<typeof generatedAudioSchema>;
|
|
75
|
+
export declare const transcriptionSegmentSchema: z.ZodObject<{
|
|
76
|
+
text: z.ZodString;
|
|
77
|
+
startSecond: z.ZodNumber;
|
|
78
|
+
endSecond: z.ZodNumber;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
export type TranscriptionSegment = z.infer<typeof transcriptionSegmentSchema>;
|
|
81
|
+
export declare const transcriptionSchema: z.ZodObject<{
|
|
82
|
+
text: z.ZodString;
|
|
83
|
+
segments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
84
|
+
text: z.ZodString;
|
|
85
|
+
startSecond: z.ZodNumber;
|
|
86
|
+
endSecond: z.ZodNumber;
|
|
87
|
+
}, z.core.$strip>>>;
|
|
88
|
+
language: z.ZodOptional<z.ZodString>;
|
|
89
|
+
model: z.ZodOptional<z.ZodString>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
export type Transcription = z.infer<typeof transcriptionSchema>;
|
|
49
92
|
export declare const textMessageSchema: z.ZodObject<{
|
|
50
93
|
role: z.ZodEnum<{
|
|
51
94
|
user: "user";
|
|
@@ -88,6 +131,28 @@ export declare const textBodySchema: z.ZodObject<{
|
|
|
88
131
|
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
89
132
|
}, z.core.$strip>;
|
|
90
133
|
export type TextBody = z.infer<typeof textBodySchema>;
|
|
134
|
+
export declare const textGenerateBodySchema: z.ZodObject<{
|
|
135
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
136
|
+
role: z.ZodEnum<{
|
|
137
|
+
user: "user";
|
|
138
|
+
assistant: "assistant";
|
|
139
|
+
}>;
|
|
140
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
141
|
+
type: z.ZodLiteral<"text">;
|
|
142
|
+
text: z.ZodString;
|
|
143
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
144
|
+
type: z.ZodLiteral<"image">;
|
|
145
|
+
source: z.ZodObject<{
|
|
146
|
+
base64: z.ZodString;
|
|
147
|
+
mediaType: z.ZodString;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
}, z.core.$strip>]>>]>;
|
|
150
|
+
}, z.core.$strip>>;
|
|
151
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
152
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
153
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
export type TextGenerateBody = z.infer<typeof textGenerateBodySchema>;
|
|
91
156
|
export type TextStreamChunk = {
|
|
92
157
|
text: string;
|
|
93
158
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digo-labs/common",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -17,21 +17,17 @@
|
|
|
17
17
|
"development": "./src/index.css",
|
|
18
18
|
"default": "./dist/index.css"
|
|
19
19
|
},
|
|
20
|
-
"./vite.apps": "./vite.apps.ts",
|
|
21
|
-
"./vite-plugin-raw-mdx": "./vite-plugin-raw-mdx.ts",
|
|
22
20
|
"./package.json": "./package.json"
|
|
23
21
|
},
|
|
24
22
|
"files": [
|
|
25
|
-
"dist"
|
|
26
|
-
"vite.apps.ts",
|
|
27
|
-
"vite-plugin-raw-mdx.ts"
|
|
23
|
+
"dist"
|
|
28
24
|
],
|
|
29
25
|
"publishConfig": {
|
|
30
26
|
"access": "public",
|
|
31
27
|
"registry": "https://registry.npmjs.org/"
|
|
32
28
|
},
|
|
33
29
|
"scripts": {
|
|
34
|
-
"build": "vite build
|
|
30
|
+
"build": "vite build",
|
|
35
31
|
"lint": "eslint ./src",
|
|
36
32
|
"lint:fix": "eslint ./src --fix"
|
|
37
33
|
},
|
|
@@ -59,6 +55,6 @@
|
|
|
59
55
|
},
|
|
60
56
|
"devDependencies": {
|
|
61
57
|
"@digo-labs/dev-dependencies": "*",
|
|
62
|
-
"vite-
|
|
58
|
+
"@digo-labs/vite-config": "*"
|
|
63
59
|
}
|
|
64
60
|
}
|
package/vite-plugin-raw-mdx.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import type { Plugin } from 'vite';
|
|
4
|
-
|
|
5
|
-
type RawMdxConfig = { docsDir: string; };
|
|
6
|
-
|
|
7
|
-
function extractSection(content: string): string {
|
|
8
|
-
const match = content.match(/^section:\s*(.+)$/m);
|
|
9
|
-
return match?.[1].trim().replace(/['"]/g, '') ?? 'Uncategorized';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function toSlug(name: string): string {
|
|
13
|
-
return name.toLowerCase().replace(/\s+/g, '-');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function rawMdxPlugin(config: RawMdxConfig): Plugin {
|
|
17
|
-
const { docsDir } = config;
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
name: 'vite-plugin-raw-mdx',
|
|
21
|
-
|
|
22
|
-
configureServer(server) {
|
|
23
|
-
server.middlewares.use((req, res, next) => {
|
|
24
|
-
const match = req.url?.match(/^\/docs\/([^/]+)\/([^/]+)\.mdx(\?.*)?$/);
|
|
25
|
-
if (!match) return next();
|
|
26
|
-
|
|
27
|
-
const [, sectionSlug, slug] = match;
|
|
28
|
-
const filePath = join(docsDir, `${slug}.mdx`);
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
const content = readFileSync(filePath, 'utf8');
|
|
32
|
-
const expectedSlug = toSlug(extractSection(content));
|
|
33
|
-
|
|
34
|
-
if (expectedSlug !== sectionSlug) {
|
|
35
|
-
res.statusCode = 404;
|
|
36
|
-
res.end('Not found');
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
|
41
|
-
res.end(content);
|
|
42
|
-
} catch {
|
|
43
|
-
next();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
generateBundle() {
|
|
49
|
-
const files = readdirSync(docsDir).filter(f => f.endsWith('.mdx'));
|
|
50
|
-
|
|
51
|
-
for (const file of files) {
|
|
52
|
-
const content = readFileSync(join(docsDir, file), 'utf8');
|
|
53
|
-
const sectionSlug = toSlug(extractSection(content));
|
|
54
|
-
|
|
55
|
-
this.emitFile({
|
|
56
|
-
type: 'asset',
|
|
57
|
-
fileName: `docs/${sectionSlug}/${file}`,
|
|
58
|
-
source: content,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
package/vite.apps.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import react from '@vitejs/plugin-react';
|
|
3
|
-
import tailwindcss from '@tailwindcss/vite';
|
|
4
|
-
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
5
|
-
import { DynamicPublicDirectory } from 'vite-multiple-assets';
|
|
6
|
-
import svgr from 'vite-plugin-svgr';
|
|
7
|
-
import mdx from '@mdx-js/rollup';
|
|
8
|
-
import remarkGfm from 'remark-gfm';
|
|
9
|
-
import remarkFrontmatter from 'remark-frontmatter';
|
|
10
|
-
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
|
|
11
|
-
import rehypeSlug from 'rehype-slug';
|
|
12
|
-
import { resolve } from 'node:path';
|
|
13
|
-
import { rawMdxPlugin } from './vite-plugin-raw-mdx';
|
|
14
|
-
|
|
15
|
-
export type DigoViteConfigProperties = {
|
|
16
|
-
includeAssetsFrom: string[];
|
|
17
|
-
port: number;
|
|
18
|
-
allowedHosts?: string[];
|
|
19
|
-
docsDir?: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function digoViteConfig(properties: DigoViteConfigProperties) {
|
|
23
|
-
const { includeAssetsFrom, port, allowedHosts, docsDir } = properties;
|
|
24
|
-
return defineConfig({
|
|
25
|
-
plugins: [
|
|
26
|
-
react({
|
|
27
|
-
babel: {
|
|
28
|
-
plugins: ['module:@preact/signals-react-transform'],
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
tailwindcss(),
|
|
32
|
-
tsconfigPaths(),
|
|
33
|
-
DynamicPublicDirectory(
|
|
34
|
-
includeAssetsFrom.map(mod => `../../${mod}/public/**`),
|
|
35
|
-
),
|
|
36
|
-
svgr(),
|
|
37
|
-
mdx({
|
|
38
|
-
providerImportSource: '@mdx-js/react',
|
|
39
|
-
remarkPlugins: [remarkGfm, remarkFrontmatter, remarkMdxFrontmatter],
|
|
40
|
-
rehypePlugins: [rehypeSlug],
|
|
41
|
-
|
|
42
|
-
}),
|
|
43
|
-
...docsDir ? [rawMdxPlugin({ docsDir: resolve(process.cwd(), docsDir) })] : [],
|
|
44
|
-
],
|
|
45
|
-
server: {
|
|
46
|
-
port: port,
|
|
47
|
-
allowedHosts: allowedHosts,
|
|
48
|
-
},
|
|
49
|
-
build: {
|
|
50
|
-
chunkSizeWarningLimit: 10000,
|
|
51
|
-
},
|
|
52
|
-
assetsInclude: ['**/*.tsx?raw', '**/*.html?raw', '**/*.ts?raw', '**/*.css?raw', '**/*.json?raw'],
|
|
53
|
-
});
|
|
54
|
-
}
|