@8base/file-server-sdk
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -5,4 +5,4 @@ export default class FileServer { | ||
upload(file: any, metadata: any): XMLHttpRequest; | ||
static uploadLink(file: any, metadata: any, mutate: any): XMLHttpRequest; | ||
static uploadLink(file: any, metadata: any, isPublic: boolean, mutate: any): XMLHttpRequest; | ||
private static uploadFile(request, data, file); | ||
} |
@@ -59,3 +59,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
FileServer.uploadLink = function (file, metadata, mutate) { | ||
FileServer.uploadLink = function (file, metadata, isPublic, mutate) { | ||
if (typeof metadata == 'object') | ||
@@ -67,3 +67,10 @@ metadata = JSON.stringify(metadata); | ||
file.upload = request.upload; | ||
mutate(gql("\n mutation Mutation {\n uploadFile(filename:\"" + file.name + "\",meta:\"" + metadata + "\") {\n id\n url\n fields\n }\n }")).subscribe({ | ||
mutate({ | ||
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 }"), | ||
variables: { | ||
"filename": file.name, | ||
"meta": metadata, | ||
"public": isPublic | ||
} | ||
}).subscribe({ | ||
error: function (error) { | ||
@@ -70,0 +77,0 @@ request.onerror(error); |
@@ -6,5 +6,4 @@ import { ApolloLink, Observable, Operation, NextLink } from 'apollo-link-core'; | ||
export default class FileUploadLink extends ApolloLink { | ||
private url; | ||
constructor(url: string); | ||
constructor(); | ||
request(operation: Operation, forward: NextLink): Observable<{}>; | ||
} |
@@ -11,3 +11,3 @@ var __extends = (this && this.__extends) || (function () { | ||
})(); | ||
import { ApolloLink, Observable, } from 'apollo-link-core'; | ||
import { ApolloLink, Observable } from 'apollo-link-core'; | ||
import FileServer from './FileServer'; | ||
@@ -34,6 +34,4 @@ var isObject = function (value) { return value !== null && typeof value === 'object'; }; | ||
__extends(FileUploadLink, _super); | ||
function FileUploadLink(url) { | ||
var _this = _super.call(this) || this; | ||
_this.url = url; | ||
return _this; | ||
function FileUploadLink() { | ||
return _super.call(this) || this; | ||
} | ||
@@ -44,3 +42,3 @@ FileUploadLink.prototype.request = function (operation, forward) { | ||
var file = variables[fieldName]; | ||
FileServer.uploadLink(file, file.meta || file.metadata, function (op) { return forward({ query: op }); }); | ||
FileServer.uploadLink(file, file.meta || file.metadata, !!file.public, function (op) { return forward(op); }); | ||
file.upload.onstart = function (data) { | ||
@@ -47,0 +45,0 @@ if (variables) { |
{ | ||
"name": "@8base/file-server-sdk", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "JavaScript SDK for working with files at 8base", | ||
@@ -20,3 +20,2 @@ "main": "./lib/index.js", | ||
"apollo-link-core": "0.5.4", | ||
"fast-memoize": "^2.2.8", | ||
"graphql": "^0.10.5", | ||
@@ -39,5 +38,2 @@ "typed-graphql": "^1.0.2" | ||
}, | ||
"peerDependencies": { | ||
"apollo-link-core": "0.5.4" | ||
}, | ||
"repository": { | ||
@@ -44,0 +40,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
110274
4
2651
- Removedfast-memoize@^2.2.8
- Removedfast-memoize@2.5.2(transitive)