Skip to content

Commit

Permalink
Merge pull request #607 from ClarityCafe/v4
Browse files Browse the repository at this point in the history
V4.x Rewrite
  • Loading branch information
sr229 authored Aug 26, 2024
2 parents 683a96e + 7600be8 commit e4c7103
Show file tree
Hide file tree
Showing 28 changed files with 355 additions and 1,964 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/node.js.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: BunJS CI

on:
push:
branches: ["**"]
pull_request:
branches: ["**"]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
bun-version: [latest, 1.1]

steps:
- uses: actions/checkout@v4.1.7
- name: Use Bun.js ${{ matrix.bun-version }}
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ matrix.bun-version }}

- name: Get Dependencies
run: bun install
# - name: Get CodeClimate Coverage
# run: |
# curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# chmod +x ./cc-test-reporter
# ./cc-test-reporter before-build

- name: Run Coverage and Lint
run: |
echo 'SAUCENAO_TOKEN=${{ secrets.SAUCENAO_TOKEN }}' > ./.env.test.local
bun run coverage
# ./cc-test-reporter after-build --exit-code $(echo $?)
# env:
# CC_TEST_REPORTER_ID: bda3746e9ecd039cee2dcfb3c1e4efc59c712a40fa3b9316e281eb00d61c613e
1 change: 1 addition & 0 deletions .idx/dev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
pkgs.vim
pkgs.git
pkgs.bun
pkgs.deno
];
}
37 changes: 37 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "bun",
"internalConsoleOptions": "neverOpen",
"request": "launch",
"name": "Debug File",
"program": "${file}",
"cwd": "${workspaceFolder}",
"envFile": ".env.test.local",
"stopOnEntry": false,
"watchMode": false
},
{
"type": "bun",
"internalConsoleOptions": "neverOpen",
"request": "launch",
"name": "Run File",
"program": "${file}",
"cwd": "${workspaceFolder}",
"noDebug": true,
"watchMode": false
},
{
"type": "bun",
"internalConsoleOptions": "neverOpen",
"request": "attach",
"name": "Attach Bun",
"url": "ws://localhost:6499/",
"stopOnEntry": false
}
]
}
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- **BREAKING** - Interfaces have been renamed to use the hungarian notation style (e.g. `SagiriResult` is now `ISagiriResult`). Please adapt your code accordingly.
- **BREAKING** - ESM support has been added to allow the module to be used on Node.js 16+ code that uses ESM code.
- **NEW** - Package is now published in the [JSR](https://jsr.io) registry. To install the package, run `npm install jsr:@clarity/sagiri`.
- **BREAKING** - Bun and Deno support has been added. Library contributors are encouraged to try the library on these platforms and avoid any Node.js specific code.
- **NEW** - Package is now published in the [JSR](https://jsr.io) registry. To install the package, run `deno install jsr:@clarity/sagiri`.
- **NEW** - Library now uses the native [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). A [node-fetch](https://npmjs.com/package/node-fetch) fallback is provided for LTS versions below 21.x - however this will be removed once 18 and 20.x versions become deprecated.

## [3.6.0] - 2024-04-10

Expand Down
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default [
{
ignores: [
"*.config.*",
"tests/**"
"tests/**",
"dist/**"
]
}
];
4 changes: 0 additions & 4 deletions jest.config.cjs

This file was deleted.

4 changes: 2 additions & 2 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@clarity/sagiri",
"version": "4.0.1",
"exports": "./lib/index.ts"
"version": "4.0.2",
"exports": "./lib/sagiri.ts"
}
10 changes: 10 additions & 0 deletions lib/errors.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
/**
* Represents an error specific to the Sagiri library.
*/
export class SagiriError extends Error {
constructor(code: number, message: string) {
super(`${message} (${code})`);
this.name = "SagiriError";
}
}

/**
* Represents an error specific to the Sagiri client.
*/
export class SagiriClientError extends SagiriError {
constructor(code: number, message: string) {
super(code, message);
this.name = "SagiriClientError";
}
}

/**
* Represents a error specific to the SauceNAO API.
* @extends SagiriError
*/
export class SagiriServerError extends SagiriError {
constructor(code: number, message: string) {
super(code, message);
Expand Down
162 changes: 0 additions & 162 deletions lib/index.ts

This file was deleted.

27 changes: 27 additions & 0 deletions lib/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { IResult } from "./response";

/**
* Represents the valid options to pass on to SauceNAO.
*/
export interface IOptions {
results?: number;
mask?: number[];
excludeMask?: number[];
getRatings?: boolean;
testMode?: boolean;
db?: number;
}

/**
* Represents the result of a Sagiri search.
*/
export interface ISagiriResult {
url: string;
site: string;
index: number;
similarity: number;
thumbnail: string;
authorName: string | null;
authorUrl: string | null;
raw: IResult;
}
5 changes: 5 additions & 0 deletions lib/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export interface IResponse {
results: IResult[];
}

export interface IHeaderStatus {
status: number;
message: string;
}

export interface IHeader {
account_type: string;
index: { [id: string]: IHeaderIndex | undefined }; // do i wanna generic this to be id value?
Expand Down
Loading

0 comments on commit e4c7103

Please sign in to comment.