Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@planet-a/affinity-node

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@planet-a/affinity-node - npm Package Compare versions

Comparing version 0.0.1-test.16 to 0.0.1-test.17

26

esm/v1/entity_files.js
import * as dntShim from "../_dnt.shims.js";
import { assert } from '../deps/jsr.io/@std/assert/0.226.0/mod.js';
import fs from 'node:fs';
import path from 'node:path';
import { fileFrom } from 'fetch-blob/from.js';
import { defaultTransformers } from './axios_default_transformers.js';

@@ -107,5 +106,4 @@ import { createSearchIteratorFn } from './create_search_iterator_fn.js';

* ```typescript
* const file = fs.createReadStream('example.pdf');
* const entityFile = await affinity.entityFiles.upload({
* files: [file],
* files: ['/path/to/example.pdf'],
* person_id: 123,

@@ -119,3 +117,2 @@ * });

assert(files.length, 'At least one file must be provided');
await Promise.all(files.map((file) => appendToFormData(formData, file)));
if (params.person_id) {

@@ -133,2 +130,3 @@ formData.append('person_id', params.person_id.toString());

}
await Promise.all(files.map((file) => appendToFormData(formData, file)));
const response = await this.axios.post(entityFilesUrl(), formData, {

@@ -147,6 +145,8 @@ headers: {

if (typeof file === 'string') {
formData.append('files[]', await openAsBlob(file), path.basename(file));
const f = await fileFrom(file);
formData.append('files[]', f);
}
else if (isFile(file)) {
formData.append('files[]', file);
return null;
}

@@ -157,15 +157,1 @@ else {

}
// TODO(@joscha): replace with `import { openAsBlob } from "node:fs";` ASAP
function openAsBlob(filePath) {
return new Promise((resolve, reject) => {
const fileStream = fs.createReadStream(filePath);
const chunks = [];
fileStream.on('data', (chunk) => {
chunks.push(typeof chunk === 'string' ? chunk : chunk.buffer);
});
fileStream.on('end', () => {
resolve(new Blob(chunks));
});
fileStream.on('error', reject);
});
}
{
"name": "@planet-a/affinity-node",
"version": "0.0.1-test.16",
"version": "0.0.1-test.17",
"description": "API wrapper for the affinity.co API",

@@ -46,2 +46,3 @@ "keywords": [

"axios": "^1.7.2",
"fetch-blob": "^4.0.0",
"undici": "^6.0.0"

@@ -48,0 +49,0 @@ },

@@ -112,5 +112,4 @@ /// <reference types="node" />

* ```typescript
* const file = fs.createReadStream('example.pdf');
* const entityFile = await affinity.entityFiles.upload({
* files: [file],
* files: ['/path/to/example.pdf'],
* person_id: 123,

@@ -117,0 +116,0 @@ * });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc