Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for npm i firecrawl #344

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/archive/publish-js-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm run build-and-publish
bash ./build_and_publish.sh
working-directory: ./apps/js-sdk/firecrawl
10 changes: 2 additions & 8 deletions .github/archive/publish-python-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@ jobs:
VERSION_INCREMENTED=$(python .github/scripts/check_version_has_incremented.py python ./apps/python-sdk/firecrawl firecrawl-py)
echo "VERSION_INCREMENTED=$VERSION_INCREMENTED" >> $GITHUB_ENV

- name: Build the package
if: ${{ env.VERSION_INCREMENTED == 'true' }}
run: |
python -m build
working-directory: ./apps/python-sdk

- name: Publish to PyPI
- name: Build and Publish to PyPI
if: ${{ env.VERSION_INCREMENTED == 'true' }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
bash ./build_and_publish.sh
working-directory: ./apps/python-sdk

12 changes: 3 additions & 9 deletions .github/workflows/fly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,13 @@ jobs:
PYTHON_SDK_VERSION_INCREMENTED=$(python .github/scripts/check_version_has_incremented.py python ./apps/python-sdk/firecrawl firecrawl-py)
echo "PYTHON_SDK_VERSION_INCREMENTED=$PYTHON_SDK_VERSION_INCREMENTED" >> $GITHUB_ENV

- name: Build the package
if: ${{ env.PYTHON_SDK_VERSION_INCREMENTED == 'true' }}
run: |
python -m build
working-directory: ./apps/python-sdk

- name: Publish to PyPI
- name: Build and Publish to PyPI
if: ${{ env.PYTHON_SDK_VERSION_INCREMENTED == 'true' }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
bash ./build_and_publish.sh
working-directory: ./apps/python-sdk

build-and-publish-js-sdk:
Expand Down Expand Up @@ -260,6 +254,6 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm run build-and-publish
bash ./build_and_publish.sh
working-directory: ./apps/js-sdk/firecrawl

20 changes: 11 additions & 9 deletions apps/js-sdk/firecrawl/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export default class FirecrawlApp {
* @param {Params | null} params - Additional parameters for the scrape request.
* @returns {Promise<ScrapeResponse>} The response from the scrape operation.
*/
scrapeUrl(url_1) {
return __awaiter(this, arguments, void 0, function* (url, params = null) {
var _a;
scrapeUrl(url, params = null) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${this.apiKey}`,
Expand Down Expand Up @@ -74,8 +74,8 @@ export default class FirecrawlApp {
* @param {Params | null} params - Additional parameters for the search request.
* @returns {Promise<SearchResponse>} The response from the search operation.
*/
search(query_1) {
return __awaiter(this, arguments, void 0, function* (query, params = null) {
search(query, params = null) {
return __awaiter(this, void 0, void 0, function* () {
const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${this.apiKey}`,
Expand Down Expand Up @@ -114,8 +114,8 @@ export default class FirecrawlApp {
* @param {string} idempotencyKey - Optional idempotency key for the request.
* @returns {Promise<CrawlResponse | any>} The response from the crawl operation.
*/
crawlUrl(url_1) {
return __awaiter(this, arguments, void 0, function* (url, params = null, waitUntilDone = true, pollInterval = 2, idempotencyKey) {
crawlUrl(url, params = null, waitUntilDone = true, pollInterval = 2, idempotencyKey) {
return __awaiter(this, void 0, void 0, function* () {
const headers = this.prepareHeaders(idempotencyKey);
let jsonData = { url };
if (params) {
Expand Down Expand Up @@ -158,7 +158,9 @@ export default class FirecrawlApp {
success: true,
status: response.data.status,
data: response.data.data,
partial_data: !response.data.data ? response.data.partial_data : undefined,
partial_data: !response.data.data
? response.data.partial_data
: undefined,
};
}
else {
Expand All @@ -180,7 +182,7 @@ export default class FirecrawlApp {
* @returns {AxiosRequestHeaders} The prepared headers.
*/
prepareHeaders(idempotencyKey) {
return Object.assign({ 'Content-Type': 'application/json', 'Authorization': `Bearer ${this.apiKey}` }, (idempotencyKey ? { 'x-idempotency-key': idempotencyKey } : {}));
return Object.assign({ "Content-Type": "application/json", Authorization: `Bearer ${this.apiKey}` }, (idempotencyKey ? { "x-idempotency-key": idempotencyKey } : {}));
}
/**
* Sends a POST request to the specified URL.
Expand Down
37 changes: 37 additions & 0 deletions apps/js-sdk/firecrawl/build_and_publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

function build_and_publish {
PACKAGE_NAME=$1

# Replace placeholder with the package name in package.json
jq --arg name "$PACKAGE_NAME" '.name = $name' package.json > temp.json && mv temp.json package.json

# Debug: show modified state
echo "Modified package.json for $PACKAGE_NAME:"
cat package.json

# Publish the package using npm
npm publish

# Check if publish was successful
if [ $? -ne 0 ]; then
echo "Publish failed for $PACKAGE_NAME"
exit 1
fi

# Wait for a moment to ensure npm publish has processed
sleep 10

# Revert the changes to the original placeholder in package.json
jq '.name = "PLACEHOLDER_NAME"' package.json > temp.json && mv temp.json package.json

# Debug: show reverted state
echo "Reverted package.json to placeholder:"
cat package.json
}

# Build and publish the first package to npm
build_and_publish "@mendable/firecrawl-js"

# Build and publish the second package to npm
build_and_publish "firecrawl"
4 changes: 2 additions & 2 deletions apps/js-sdk/firecrawl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mendable/firecrawl-js",
"version": "0.0.28",
"name": "PLACEHOLDER_NAME",
"version": "0.0.30",
"description": "JavaScript SDK for Firecrawl API",
"main": "build/index.js",
"types": "types/index.d.ts",
Expand Down
16 changes: 8 additions & 8 deletions apps/js-sdk/firecrawl/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,25 @@ export interface ScrapeResponse {
error?: string;
}
/**
* Response interface for searching operations.
*/
* Response interface for searching operations.
*/
export interface SearchResponse {
success: boolean;
data?: FirecrawlDocument[];
error?: string;
}
/**
* Response interface for crawling operations.
*/
* Response interface for crawling operations.
*/
export interface CrawlResponse {
success: boolean;
jobId?: string;
data?: FirecrawlDocument[];
error?: string;
}
/**
* Response interface for job status checks.
*/
* Response interface for job status checks.
*/
export interface JobStatusResponse {
success: boolean;
status: string;
Expand All @@ -101,8 +101,8 @@ export interface JobStatusResponse {
error?: string;
}
/**
* Generic parameter interface.
*/
* Generic parameter interface.
*/
export interface Params {
[key: string]: any;
extractorOptions?: {
Expand Down
1 change: 0 additions & 1 deletion apps/python-sdk/build/lib/firecrawl/__init__.py

This file was deleted.

Loading
Loading