New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@8base/file-server-sdk

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@8base/file-server-sdk - npm Package Compare versions

Comparing version 0.0.24 to 0.0.27

test/FileUploadLink.test.ts

3

lib/FileServer.d.ts
export default class FileServer {
private apolloClient;
constructor(apolloClient: any);
upload(file: any, metadata: any): XMLHttpRequest;
static uploadLink(file: any, metadata: any, isPublic: boolean, mutate: any): XMLHttpRequest;
static uploadLink(file: any, metadata: any, isPublic: boolean, mutate: any, onGraphqlError: any): XMLHttpRequest;
private static uploadFile(request, data, file);
}

@@ -1,36 +0,1 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import gql from 'graphql-tag';

@@ -41,4 +6,4 @@ var FileServer = (function () {

}
FileServer.prototype.upload = function (file, metadata) {
if (typeof metadata == 'object')
FileServer.uploadLink = function (file, metadata, isPublic, mutate, onGraphqlError) {
if (typeof metadata === 'object')
metadata = JSON.stringify(metadata);

@@ -49,20 +14,2 @@ metadata = metadata || '';

file.upload = request.upload;
this.apolloClient.mutate({
mutation: gql("\n mutation Mutation {\n uploadFile(filename:\"" + file.name + "\",meta:\"" + metadata + "\") {\n id\n url\n fields\n }\n }")
}).then(function (result) {
if (result.errors && result.errors.length) {
request.onerror(result.errors[0]);
throw new Error(result.errors[0]);
}
FileServer.uploadFile(request, result.data.uploadFile, file);
});
return request;
};
FileServer.uploadLink = function (file, metadata, isPublic, mutate) {
if (typeof metadata == 'object')
metadata = JSON.stringify(metadata);
metadata = metadata || '';
var request = new XMLHttpRequest();
file.request = request;
file.upload = request.upload;
mutate({

@@ -78,8 +25,6 @@ query: gql("\n mutation Mutation ($filename: String, $public: Boolean, $meta: String) {\n uploadFile(filename:$filename, meta:$meta, public: $public) {\n id\n url\n fields\n }\n }"),

request.onerror(error);
throw error;
},
next: function (data) {
if (data.errors && data.errors.length) {
request.onerror(data.errors[0]);
throw new Error(data.errors[0]);
return onGraphqlError(data);
}

@@ -107,17 +52,2 @@ FileServer.uploadFile(request, data.data.uploadFile, file);

export default FileServer;
function findFile(SelectionSet) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, Promise.all(SelectionSet.selections.map(function (selection) {
selection.arguments.map(function (arg) {
});
}))];
case 1:
_a.sent();
return [2];
}
});
});
}
//# sourceMappingURL=FileServer.js.map

@@ -37,23 +37,26 @@ var __extends = (this && this.__extends) || (function () {

FileUploadLink.prototype.request = function (operation, forward) {
var promises = [];
var handleFile = function (variables, fieldName) {
var file = variables[fieldName];
FileServer.uploadLink(file, file.meta || file.metadata, !!file.public, function (op) { return forward(op); });
file.upload.onstart = function (data) {
if (variables) {
variables[fieldName] = data.id;
}
return new Observable(function (observer) {
var promises = [];
var handleFile = function (variables, fieldName) {
var file = variables[fieldName];
FileServer.uploadLink(file, file.meta || file.metadata, !!file.public, function (op) { return forward(op); }, function (error) {
observer.next(error);
observer.complete();
return;
});
file.upload.onstart = function (data) {
if (variables) {
variables[fieldName] = data.id;
}
};
promises.push(new Promise(function (resolve, reject) {
file.request.ontimeout = function (err) { return reject(err); };
file.request.onabort = function (err) { return reject(err); };
file.request.onerror = function (err) { return reject(err); };
file.request.onload = function () { return resolve(); };
return;
}));
};
promises.push(new Promise(function (resolve, reject) {
file.request.ontimeout = function (err) { return reject(err); };
file.request.onabort = function (err) { return reject(err); };
file.request.onerror = function (err) { return reject(err); };
file.request.onload = function () { return resolve(); };
return;
}));
};
mutateOperationVariables(operation.variables || {}, handleFile);
return new Observable(function (observer) {
Promise.all(promises)
.then(function () {
mutateOperationVariables(operation.variables || {}, handleFile);
Promise.all(promises).then(function () {
forward(operation).subscribe({

@@ -66,4 +69,3 @@ error: function (error) {

});
})
.catch(function (err) {
}).catch(function (err) {
observer.error(err);

@@ -70,0 +72,0 @@ });

{
"name": "@8base/file-server-sdk",
"version": "0.0.24",
"version": "0.0.27",
"description": "JavaScript SDK for working with files at 8base",

@@ -8,3 +8,3 @@ "main": "./lib/index.js",

"scripts": {
"test": "jest",
"test": "jest --no-cache --coverage",
"build": "tsc",

@@ -16,2 +16,21 @@ "start": "npm run build -- --watch",

},
"jest": {
"globals": {
"ts-jest": {
"tsConfigFile": "tsconfig.json"
}
},
"moduleFileExtensions": [
"ts",
"js",
"json"
],
"transform": {
"^.+\\.(ts|tsx)$": "./node_modules/ts-jest/preprocessor.js"
},
"testMatch": [
"**/test/**/*.test.(ts|js)"
],
"clearMocks": true
},
"author": "8base",

@@ -36,2 +55,3 @@ "license": "MIT",

"ts-jest": "^21.2.2",
"tslib": "^1.8.0",
"tslint": "^5.7.0",

@@ -47,16 +67,3 @@ "typescript": "^2.5.1"

},
"homepage": "https://gitlab.com/8base-shared/file-server-sdk#README",
"jest": {
"transform": {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
]
}
"homepage": "https://gitlab.com/8base-shared/file-server-sdk#README"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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