Skip to content

Commit

Permalink
Release 0.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed May 7, 2024
1 parent 1f2cd8e commit 3f7cb42
Show file tree
Hide file tree
Showing 94 changed files with 5,318 additions and 131 deletions.
1 change: 1 addition & 0 deletions .fernignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Specify files that shouldn't be modified by Fern
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: ci

on: [push]

jobs:
compile:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3

- name: Compile
run: yarn && yarn build

test:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3

- name: Compile
run: yarn && yarn test

publish:
needs: [ compile, test ]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3

- name: Install dependencies
run: yarn install

- name: Build
run: yarn build

- name: Publish to npm
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
133 changes: 3 additions & 130 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,130 +1,3 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# 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/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# 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
.cache

# 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.*
node_modules
.DS_Store
/dist
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
src
tests
.gitignore
.github
.fernignore
.prettierrc.yml
tsconfig.json
yarn.lock
2 changes: 2 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tabWidth: 4
printWidth: 120
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Fileforge.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 0 additions & 1 deletion README.md

This file was deleted.

5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('jest').Config} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "fileforge",
"version": "0.0.0",
"private": false,
"repository": "https://github.com/OnedocLabs/fileforge-node-sdk",
"license": "MIT",
"main": "./index.js",
"types": "./index.d.ts",
"scripts": {
"format": "prettier . --write --ignore-unknown",
"build": "tsc",
"prepack": "cp -rv dist/. .",
"test": "jest"
},
"dependencies": {
"form-data": "4.0.0",
"url-join": "4.0.1",
"node-fetch": "2.7.0",
"qs": "6.11.2",
"js-base64": "3.7.2"
},
"devDependencies": {
"@types/url-join": "4.0.1",
"@types/qs": "6.9.8",
"@types/node-fetch": "2.6.9",
"jest": "29.7.0",
"@types/jest": "29.5.5",
"ts-jest": "29.1.1",
"jest-environment-jsdom": "29.7.0",
"@types/node": "17.0.33",
"prettier": "2.7.1",
"typescript": "4.6.4"
}
}
103 changes: 103 additions & 0 deletions src/Client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as environments from "./environments";
import * as core from "./core";
import * as fs from "fs";
import * as FileForge from "./api/index";
import { default as FormData } from "form-data";
import urlJoin from "url-join";
import * as errors from "./errors/index";

export declare namespace FileForgeClient {
interface Options {
environment?: core.Supplier<environments.FileForgeEnvironment | string>;
username: core.Supplier<string>;
password: core.Supplier<string>;
apiKey: core.Supplier<string>;
}

interface RequestOptions {
timeoutInSeconds?: number;
maxRetries?: number;
}
}

export class FileForgeClient {
constructor(protected readonly _options: FileForgeClient.Options) {}

/**
* @param {File[] | fs.ReadStream[]} files
* @param {FileForge.GenerateRequest} request
* @param {FileForgeClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @example
* await fileForge.generate([fs.createReadStream("/path/to/your/file")], {
* options: {}
* })
*/
public async generate(
files: File[] | fs.ReadStream[],
request: FileForge.GenerateRequest,
requestOptions?: FileForgeClient.RequestOptions
): Promise<void> {
const _request = new FormData();
_request.append("options", JSON.stringify(request.options));
for (const _file of files) {
_request.append("files", _file);
}

const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.FileForgeEnvironment.Default,
"pdf/generate/"
),
method: "POST",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-API-Key": await core.Supplier.get(this._options.apiKey),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "fileforge",
"X-Fern-SDK-Version": "0.0.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "multipart/form-data; boundary=" + _request.getBoundary(),
body: _request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
});
if (_response.ok) {
return;
}

if (_response.error.reason === "status-code") {
throw new errors.FileForgeError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}

switch (_response.error.reason) {
case "non-json":
throw new errors.FileForgeError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.FileForgeTimeoutError();
case "unknown":
throw new errors.FileForgeError({
message: _response.error.errorMessage,
});
}
}

protected async _getAuthorizationHeader(): Promise<string | undefined> {
return core.BasicAuth.toAuthorizationHeader({
username: await core.Supplier.get(this._options.username),
password: await core.Supplier.get(this._options.password),
});
}
}
1 change: 1 addition & 0 deletions src/api/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./requests";
15 changes: 15 additions & 0 deletions src/api/client/requests/GenerateRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as FileForge from "../../index";

/**
* @example
* {
* options: {}
* }
*/
export interface GenerateRequest {
options: FileForge.GenerateRequestOptions;
}
1 change: 1 addition & 0 deletions src/api/client/requests/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { type GenerateRequest } from "./GenerateRequest";
Loading

0 comments on commit 3f7cb42

Please sign in to comment.