diff --git a/README.md b/README.md index b843d14..dc5dce5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- logo + logo

@@ -11,6 +11,15 @@

+

+ + License: MIT + + + NPM + +

+ DriaJS client is a library & CLI that integrates [Dria](https://dria.co/) to your application, providing a convenient interface to harness the capabilities of Dria's vector search and retrieval services. - [x] Create & manage your knowledge bases on Dria. diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..468f82a --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,175 @@ +# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore + +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Caches + +.cache + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) + +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..2564f1f --- /dev/null +++ b/example/README.md @@ -0,0 +1,13 @@ +# DriaJS Example + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` diff --git a/example/bun.lockb b/example/bun.lockb new file mode 100755 index 0000000..61133d6 Binary files /dev/null and b/example/bun.lockb differ diff --git a/example/index.ts b/example/index.ts new file mode 100644 index 0000000..6bd0127 --- /dev/null +++ b/example/index.ts @@ -0,0 +1,3 @@ +import Dria from "dria"; + +// TODO: will do example diff --git a/example/package.json b/example/package.json new file mode 100644 index 0000000..2816502 --- /dev/null +++ b/example/package.json @@ -0,0 +1,14 @@ +{ + "private": true, + "module": "index.ts", + "type": "module", + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "dria": "^0.0.1" + } +} diff --git a/example/tsconfig.json b/example/tsconfig.json new file mode 100644 index 0000000..dcd8fc5 --- /dev/null +++ b/example/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "lib": ["ESNext"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + /* Linting */ + "skipLibCheck": true, + "strict": true, + "noFallthroughCasesInSwitch": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/package.json b/package.json index c12b809..d89fb55 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "dria", - "version": "0.0.1", - "author": "FirstBatch Team ", + "version": "0.0.2", "license": "Apache-2.0", + "author": "FirstBatch Team ", "contributors": [ "Erhan Tezcan (https://github.com/erhant)" ], @@ -11,6 +11,10 @@ "LICENSE", "README.md" ], + "type": "module", + "module": "index.ts", + "main": "build/index.js", + "types": "build/index.d.ts", "scripts": { "build": "bun run ./build.ts", "b": "bun run build", @@ -23,8 +27,6 @@ "proto:type": "npx pbts ./proto/insert.js -o ./proto/insert.d.ts", "proto": "bun proto:code && bun proto:type" }, - "type": "module", - "module": "index.ts", "dependencies": { "axios": "^1.6.5", "zod": "^3.22.4" diff --git a/src/dria.ts b/src/dria.ts index 48e2177..db9189f 100644 --- a/src/dria.ts +++ b/src/dria.ts @@ -40,7 +40,7 @@ import constants from "./constants"; * dria.contractId = contractId; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -export default class Dria { +export class Dria { protected client: AxiosInstance; contractId: string | undefined; /** Cached contract models. */ diff --git a/src/index.ts b/src/index.ts index 49588c3..2babd69 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,2 @@ -import Dria from "./dria"; -export default Dria; - +export { Dria } from "./dria"; export type { DriaParams } from "./types"; diff --git a/tests/api.test.ts b/tests/api.test.ts index 32ce522..922c569 100644 --- a/tests/api.test.ts +++ b/tests/api.test.ts @@ -1,7 +1,7 @@ import { expect, describe, it } from "bun:test"; import { randomVector } from "./utils"; import { BatchTexts, BatchVectors } from "../src/schemas"; -import Dria from "../src"; +import { Dria } from "../src"; describe("API", () => { // contract of a TypeScript Book uploaded to Dria diff --git a/tests/create.test.ts b/tests/create.test.ts index 42992c0..3606465 100644 --- a/tests/create.test.ts +++ b/tests/create.test.ts @@ -1,7 +1,7 @@ import { expect, describe, it } from "bun:test"; import { randomVector } from "./utils"; -import Dria from "../src"; import { BatchVectors } from "../src/schemas"; +import { Dria } from "../src"; describe.todo("create knowledge", () => { type MetadataType = { id: number }; diff --git a/tsconfig.json b/tsconfig.json index 7556e1d..89bdaf2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,8 @@ "forceConsistentCasingInFileNames": true, "allowJs": true, "types": [ - "bun-types" // add Bun global - ] - } + "bun-types", // add Bun global + ], + }, + "exclude": ["example", "./build", "./node_modules", "./proto"], }