@devup-api/utils
Advanced tools
+1
-1
| { | ||
| "name": "@devup-api/utils", | ||
| "version": "0.1.2", | ||
| "version": "0.1.3", | ||
| "license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+45
-5
| # @devup-api/utils | ||
| Common utility package for devup API | ||
| Utility functions for OpenAPI processing and file operations. | ||
| Provides file creation and common utility functions. | ||
| ## Installation | ||
@@ -13,6 +11,48 @@ | ||
| ## Exports | ||
| ### Case Conversion Functions | ||
| - `toCamel(str: string): string` - Convert string to camelCase | ||
| - `toSnake(str: string): string` - Convert string to snake_case | ||
| - `toPascal(str: string): string` - Convert string to PascalCase | ||
| ### File Operations | ||
| - `readOpenapi(filePath?: string): OpenAPIV3_1.Document` - Read and parse OpenAPI JSON file (synchronous) | ||
| - `readOpenapiAsync(filePath?: string): Promise<OpenAPIV3_1.Document>` - Read and parse OpenAPI JSON file (asynchronous) | ||
| - `writeInterface(filePath: string, content: string): void` - Write TypeScript interface file (synchronous) | ||
| - `writeInterfaceAsync(filePath: string, content: string): Promise<void>` - Write TypeScript interface file (asynchronous) | ||
| - `createTmpDir(tempDir?: string): string` - Create temporary directory (synchronous) | ||
| - `createTmpDirAsync(tempDir?: string): Promise<string>` - Create temporary directory (asynchronous) | ||
| ## Usage | ||
| ```typescript | ||
| import { createFile, formatPath } from '@devup-api/utils'; | ||
| ### Case Conversion | ||
| ```ts | ||
| import { toCamel, toSnake, toPascal } from '@devup-api/utils' | ||
| toCamel('hello_world') // 'helloWorld' | ||
| toSnake('helloWorld') // 'hello_world' | ||
| toPascal('hello_world') // 'HelloWorld' | ||
| ``` | ||
| ### File Operations | ||
| ```ts | ||
| import { readOpenapiAsync, writeInterfaceAsync, createTmpDirAsync } from '@devup-api/utils' | ||
| // Read OpenAPI schema | ||
| const schema = await readOpenapiAsync('openapi.json') | ||
| // Create temp directory | ||
| const tempDir = await createTmpDirAsync('my-temp-dir') | ||
| // Write interface file | ||
| await writeInterfaceAsync('api.d.ts', interfaceContent) | ||
| ``` | ||
| ## License | ||
| Apache 2.0 |
10056
16.13%58
222.22%