| $ TIMING=1 eslint "**/*.ts*" --fix | ||
| (node:76467) [ESLINT_LEGACY_ECMAFEATURES] DeprecationWarning: The 'ecmaFeatures' config file property is deprecated and has no effect. (found in "../../.eslintrc.js » eslint-config-custom") | ||
| (Use `node --trace-deprecation ...` to show where the warning was created) | ||
| /home/samy/Programming/dev/writer.js/packages/writerjs/Writer.ts | ||
| 1:25 warning 'object' is defined but never used @typescript-eslint/no-unused-vars | ||
| 1:33 warning 'string' is defined but never used @typescript-eslint/no-unused-vars | ||
| 41:106 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| /home/samy/Programming/dev/writer.js/packages/writerjs/dist/Writer.d.ts | ||
| 12:124 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| 18:24 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| /home/samy/Programming/dev/writer.js/packages/writerjs/dist/openai.d.ts | ||
| 12:149 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| ✖ 6 problems (0 errors, 6 warnings) | ||
| Rule | Time (ms) | Relative | ||
| :-----------------------------------------------|----------:|--------: | ||
| @typescript-eslint/no-unused-vars | 10.322 | 45.1% | ||
| react/display-name | 2.565 | 11.2% | ||
| object-curly-spacing | 1.040 | 4.5% | ||
| react/no-direct-mutation-state | 0.899 | 3.9% | ||
| react/require-render-return | 0.808 | 3.5% | ||
| @typescript-eslint/object-curly-spacing | 0.762 | 3.3% | ||
| @typescript-eslint/no-explicit-any | 0.651 | 2.8% | ||
| @typescript-eslint/adjacent-overload-signatures | 0.588 | 2.6% | ||
| @typescript-eslint/no-loss-of-precision | 0.508 | 2.2% | ||
| prefer-const | 0.466 | 2.0% |
| import * as axios from 'axios'; | ||
| import * as openai from 'openai'; | ||
| import { Struct } from 'superstruct'; | ||
| declare class Writer { | ||
| private static types; | ||
| private static openai; | ||
| static initialize({ apiKey, types }: { | ||
| apiKey: string; | ||
| types?: any[]; | ||
| }): void; | ||
| static write(type: WriterType | string, params: unknown): Promise<axios.AxiosResponse<openai.CreateCompletionResponse, any>>; | ||
| } | ||
| type WriterType = { | ||
| makeQuery: (params: unknown) => string; | ||
| config: { | ||
| type: string; | ||
| params: Struct<any, object>; | ||
| }; | ||
| }; | ||
| export { Writer, WriterType }; |
+102
| "use strict"; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var __async = (__this, __arguments, generator) => { | ||
| return new Promise((resolve, reject) => { | ||
| var fulfilled = (value) => { | ||
| try { | ||
| step(generator.next(value)); | ||
| } catch (e) { | ||
| reject(e); | ||
| } | ||
| }; | ||
| var rejected = (value) => { | ||
| try { | ||
| step(generator.throw(value)); | ||
| } catch (e) { | ||
| reject(e); | ||
| } | ||
| }; | ||
| var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); | ||
| step((generator = generator.apply(__this, __arguments)).next()); | ||
| }); | ||
| }; | ||
| // Writer.ts | ||
| var Writer_exports = {}; | ||
| __export(Writer_exports, { | ||
| Writer: () => Writer | ||
| }); | ||
| module.exports = __toCommonJS(Writer_exports); | ||
| var import_superstruct = require("superstruct"); | ||
| // openai.ts | ||
| var import_openai = require("openai"); | ||
| var OpenAI = class { | ||
| constructor(apiKey) { | ||
| this.createDavinciCompletion = (_0) => __async(this, [_0], function* ({ prompt, maxToken = 144, temperature = 0.7 }) { | ||
| return yield this.openai.createCompletion({ | ||
| model: "text-davinci-003", | ||
| prompt, | ||
| temperature, | ||
| max_tokens: maxToken | ||
| }); | ||
| }); | ||
| const configuration = new import_openai.Configuration({ | ||
| apiKey | ||
| }); | ||
| this.openai = new import_openai.OpenAIApi(configuration); | ||
| } | ||
| }; | ||
| // Writer.ts | ||
| var Writer = class { | ||
| static initialize({ apiKey, types }) { | ||
| this.openai = new OpenAI(apiKey); | ||
| this.types = types ? types : null; | ||
| } | ||
| static write(type, params) { | ||
| return __async(this, null, function* () { | ||
| var _a; | ||
| let writerType; | ||
| if (typeof type === "string") { | ||
| writerType = (_a = Writer.types) == null ? void 0 : _a.find((value) => value.config.type === type); | ||
| if (writerType === void 0) { | ||
| throw new Error(`Type ${type} not found.`); | ||
| } | ||
| } else { | ||
| writerType = type; | ||
| } | ||
| try { | ||
| const writerParams = writerType.config.params; | ||
| (0, import_superstruct.assert)(params, writerParams); | ||
| } catch (e) { | ||
| if (e instanceof import_superstruct.StructError) { | ||
| const { message } = e; | ||
| throw new Error(`Typing verification for type ${writerType.config.type} failed. ${message}.`); | ||
| } | ||
| } | ||
| const prompt = writerType.makeQuery(params); | ||
| return this.openai.createDavinciCompletion({ prompt }); | ||
| }); | ||
| } | ||
| }; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| Writer | ||
| }); |
| Arguments: | ||
| /home/samy/.nvm/versions/node/v18.12.1/bin/node /usr/local/bin/yarn add tsup | ||
| PATH: | ||
| /home/samy/.nvm/versions/node/v18.12.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/samy/.local/share/JetBrains/Toolbox/scripts:/home/samy/Programming/dev/writer.js/node_modules/.bin | ||
| Yarn version: | ||
| 1.22.19 | ||
| Node version: | ||
| 18.12.1 | ||
| Platform: | ||
| linux x64 | ||
| Trace: | ||
| SyntaxError: /home/samy/Programming/dev/writer.js/packages/writerjs/package.json: Unexpected token } in JSON at position 237 | ||
| at JSON.parse (<anonymous>) | ||
| at /usr/local/lib/node_modules/yarn/lib/cli.js:1629:59 | ||
| at Generator.next (<anonymous>) | ||
| at step (/usr/local/lib/node_modules/yarn/lib/cli.js:310:30) | ||
| at /usr/local/lib/node_modules/yarn/lib/cli.js:321:13 | ||
| npm manifest: | ||
| { | ||
| "name": "writerjs", | ||
| "version": "0.0.0", | ||
| "main": "./index.ts", | ||
| "types": "./index.ts", | ||
| "license": "MIT", | ||
| "scripts": { | ||
| "lint": "TIMING=1 eslint \"**/*.ts*\"", | ||
| "lint:fix": "TIMING=1 eslint \"**/*.ts*\" --fix", | ||
| "" | ||
| }, | ||
| "devDependencies": { | ||
| "eslint": "^7.32.0", | ||
| "eslint-config-custom": "*", | ||
| "tsconfig": "*", | ||
| "typescript": "^4.5.2" | ||
| }, | ||
| "dependencies": { | ||
| "openai": "^3.1.0", | ||
| "superstruct": "^1.0.3" | ||
| } | ||
| } | ||
| yarn manifest: | ||
| No manifest | ||
| Lockfile: | ||
| No lockfile |
+14
-14
| $ tsup *.ts --format cjs --dts | ||
| [34mCLI[39m Building entry: Writebot.ts, index.ts, openai.ts | ||
| [34mCLI[39m Using tsconfig: tsconfig.json | ||
| [34mCLI[39m tsup v6.5.0 | ||
| [34mCLI[39m Target: es6 | ||
| [34mCJS[39m Build start | ||
| [32mCJS[39m [1mdist/Writebot.js [22m[32m3.18 KB[39m | ||
| [32mCJS[39m [1mdist/index.js [22m[32m3.22 KB[39m | ||
| [32mCJS[39m [1mdist/openai.js [22m[32m2.06 KB[39m | ||
| [32mCJS[39m ⚡️ Build success in 104ms | ||
| [34mDTS[39m Build start | ||
| [32mDTS[39m ⚡️ Build success in 6679ms | ||
| [32mDTS[39m [1mdist/Writebot.d.ts [22m[32m600.00 B[39m | ||
| [32mDTS[39m [1mdist/index.d.ts [22m[32m130.00 B[39m | ||
| [32mDTS[39m [1mdist/openai.d.ts [22m[32m447.00 B[39m | ||
| CLI Building entry: Writebot.ts, index.ts, openai.ts | ||
| CLI Using tsconfig: tsconfig.json | ||
| CLI tsup v6.5.0 | ||
| CLI Target: es6 | ||
| CJS Build start | ||
| CJS dist/Writebot.js 3.18 KB | ||
| CJS dist/index.js 878.00 B | ||
| CJS dist/openai.js 2.06 KB | ||
| CJS ⚡️ Build success in 14ms | ||
| DTS Build start | ||
| DTS ⚡️ Build success in 708ms | ||
| DTS dist/Writebot.d.ts 622.00 B | ||
| DTS dist/index.d.ts 99.00 B | ||
| DTS dist/openai.d.ts 447.00 B |
+23
-17
| $ TIMING=1 eslint "**/*.ts*" | ||
| (node:1971) [ESLINT_LEGACY_ECMAFEATURES] DeprecationWarning: The 'ecmaFeatures' config file property is deprecated and has no effect. (found in "../../.eslintrc.js » eslint-config-custom") | ||
| (node:29830) [ESLINT_LEGACY_ECMAFEATURES] DeprecationWarning: The 'ecmaFeatures' config file property is deprecated and has no effect. (found in "../../.eslintrc.js » eslint-config-custom") | ||
| (Use `node --trace-deprecation ...` to show where the warning was created) | ||
| /home/runner/work/writerbot/writerbot/packages/writebot/Writebot.ts | ||
| 8:66 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| 41:106 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| /home/samy/Programming/dev/writer.js/packages/writebot/Writebot.ts | ||
| 4:1 warning Unexpected default export of anonymous class import/no-anonymous-default-export | ||
| 8:66 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| 41:106 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| /home/runner/work/writerbot/writerbot/packages/writebot/dist/Writebot.d.ts | ||
| /home/samy/Programming/dev/writer.js/packages/writebot/dist/Writebot.d.ts | ||
| 10:17 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
@@ -14,18 +15,23 @@ 12:124 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| /home/runner/work/writerbot/writerbot/packages/writebot/dist/openai.d.ts | ||
| /home/samy/Programming/dev/writer.js/packages/writebot/dist/Writer.d.ts | ||
| 10:17 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| 12:124 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| 18:24 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| /home/samy/Programming/dev/writer.js/packages/writebot/dist/openai.d.ts | ||
| 12:149 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| ✖ 6 problems (0 errors, 6 warnings) | ||
| ✖ 10 problems (0 errors, 10 warnings) | ||
| Rule | Time (ms) | Relative | ||
| :-----------------------------------------------|----------:|--------: | ||
| @typescript-eslint/no-unused-vars | 14.654 | 45.1% | ||
| react/display-name | 3.538 | 10.9% | ||
| react/no-direct-mutation-state | 1.529 | 4.7% | ||
| object-curly-spacing | 1.393 | 4.3% | ||
| @typescript-eslint/object-curly-spacing | 1.089 | 3.4% | ||
| react/require-render-return | 1.050 | 3.2% | ||
| @typescript-eslint/no-explicit-any | 0.998 | 3.1% | ||
| @typescript-eslint/adjacent-overload-signatures | 0.750 | 2.3% | ||
| @typescript-eslint/no-loss-of-precision | 0.701 | 2.2% | ||
| @typescript-eslint/no-empty-function | 0.610 | 1.9% | ||
| @typescript-eslint/no-unused-vars | 8.684 | 40.5% | ||
| react/display-name | 2.540 | 11.8% | ||
| object-curly-spacing | 1.046 | 4.9% | ||
| react/no-direct-mutation-state | 0.996 | 4.6% | ||
| @typescript-eslint/object-curly-spacing | 0.889 | 4.1% | ||
| react/require-render-return | 0.693 | 3.2% | ||
| @typescript-eslint/no-explicit-any | 0.523 | 2.4% | ||
| @typescript-eslint/adjacent-overload-signatures | 0.518 | 2.4% | ||
| @typescript-eslint/no-loss-of-precision | 0.501 | 2.3% | ||
| prefer-const | 0.426 | 2.0% |
+6
-0
| # writerjs | ||
| ## 0.3.1 | ||
| ### Patch Changes | ||
| - Fixed issue were it didn't export default | ||
| ## 0.3.0 | ||
@@ -4,0 +10,0 @@ |
+1
-1
@@ -1,4 +0,4 @@ | ||
| export { Writebot, WriterType, Writebot as default } from './Writebot.js'; | ||
| export { WriterType } from './Writebot.js'; | ||
| import 'axios'; | ||
| import 'openai'; | ||
| import 'superstruct'; |
+0
-81
@@ -6,6 +6,2 @@ "use strict"; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
@@ -20,29 +16,5 @@ if (from && typeof from === "object" || typeof from === "function") { | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var __async = (__this, __arguments, generator) => { | ||
| return new Promise((resolve, reject) => { | ||
| var fulfilled = (value) => { | ||
| try { | ||
| step(generator.next(value)); | ||
| } catch (e) { | ||
| reject(e); | ||
| } | ||
| }; | ||
| var rejected = (value) => { | ||
| try { | ||
| step(generator.throw(value)); | ||
| } catch (e) { | ||
| reject(e); | ||
| } | ||
| }; | ||
| var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); | ||
| step((generator = generator.apply(__this, __arguments)).next()); | ||
| }); | ||
| }; | ||
| // index.ts | ||
| var writebot_exports = {}; | ||
| __export(writebot_exports, { | ||
| Writebot: () => Writebot, | ||
| default: () => Writebot | ||
| }); | ||
| module.exports = __toCommonJS(writebot_exports); | ||
@@ -55,54 +27,1 @@ | ||
| var import_openai = require("openai"); | ||
| var OpenAI = class { | ||
| constructor(apiKey) { | ||
| this.createDavinciCompletion = (_0) => __async(this, [_0], function* ({ prompt, maxToken = 144, temperature = 0.7 }) { | ||
| return yield this.openai.createCompletion({ | ||
| model: "text-davinci-003", | ||
| prompt, | ||
| temperature, | ||
| max_tokens: maxToken | ||
| }); | ||
| }); | ||
| const configuration = new import_openai.Configuration({ | ||
| apiKey | ||
| }); | ||
| this.openai = new import_openai.OpenAIApi(configuration); | ||
| } | ||
| }; | ||
| // Writebot.ts | ||
| var Writebot = class { | ||
| static initialize({ apiKey, types }) { | ||
| this.openai = new OpenAI(apiKey); | ||
| this.types = types ? types : null; | ||
| } | ||
| static write(type, params) { | ||
| return __async(this, null, function* () { | ||
| var _a; | ||
| let writerType; | ||
| if (typeof type === "string") { | ||
| writerType = (_a = Writebot.types) == null ? void 0 : _a.find((value) => value.config.type === type); | ||
| if (writerType === void 0) { | ||
| throw new Error(`Type ${type} not found.`); | ||
| } | ||
| } else { | ||
| writerType = type; | ||
| } | ||
| try { | ||
| const writerParams = writerType.config.params; | ||
| (0, import_superstruct.assert)(params, writerParams); | ||
| } catch (e) { | ||
| if (e instanceof import_superstruct.StructError) { | ||
| const { message } = e; | ||
| throw new Error(`Typing verification for type ${writerType.config.type} failed. ${message}.`); | ||
| } | ||
| } | ||
| const prompt = writerType.makeQuery(params); | ||
| return this.openai.createDavinciCompletion({ prompt }); | ||
| }); | ||
| } | ||
| }; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| Writebot | ||
| }); |
@@ -5,3 +5,3 @@ import * as axios from 'axios'; | ||
| declare class Writebot { | ||
| declare class export_default{ | ||
| private static types; | ||
@@ -23,2 +23,2 @@ private static openai; | ||
| export { Writebot, WriterType }; | ||
| export { WriterType, export_default as default }; |
+4
-6
@@ -43,3 +43,3 @@ "use strict"; | ||
| __export(Writebot_exports, { | ||
| Writebot: () => Writebot | ||
| default: () => Writebot_default | ||
| }); | ||
@@ -69,3 +69,3 @@ module.exports = __toCommonJS(Writebot_exports); | ||
| // Writebot.ts | ||
| var Writebot = class { | ||
| var Writebot_default = class { | ||
| static initialize({ apiKey, types }) { | ||
@@ -80,3 +80,3 @@ this.openai = new OpenAI(apiKey); | ||
| if (typeof type === "string") { | ||
| writerType = (_a = Writebot.types) == null ? void 0 : _a.find((value) => value.config.type === type); | ||
| writerType = (_a = this.types) == null ? void 0 : _a.find((value) => value.config.type === type); | ||
| if (writerType === void 0) { | ||
@@ -103,4 +103,2 @@ throw new Error(`Type ${type} not found.`); | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| Writebot | ||
| }); | ||
| 0 && (module.exports = {}); |
+0
-1
| export * from './Writebot'; | ||
| export { Writebot as default } from './Writebot'; |
+1
-1
| { | ||
| "name": "writebot", | ||
| "version": "0.3.0", | ||
| "version": "0.3.1", | ||
| "main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
+2
-2
| import { assert, Infer, Struct, StructError } from 'superstruct'; | ||
| import { OpenAI } from './openai'; | ||
| export class Writebot { | ||
| export default class { | ||
| private static types: WriterType[] | null; | ||
@@ -17,3 +17,3 @@ private static openai: OpenAI; | ||
| if (typeof type === 'string') { | ||
| writerType = Writebot.types?.find(value => value.config.type === type); | ||
| writerType = this.types?.find(value => value.config.type === type); | ||
@@ -20,0 +20,0 @@ if (writerType === undefined) { |
20352
32.69%18
28.57%401
9.86%