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

@contember/client

Package Overview
Dependencies
Maintainers
5
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contember/client - npm Package Compare versions

Comparing version 1.1.0-rc.5 to 1.1.0-rc.12

19

dist/development/content/upload/GenerateUploadUrlMutationBuilder.js

@@ -0,1 +1,3 @@

import { ObjectBuilder } from "../../graphQlBuilder/ObjectBuilder.js";
import { QueryBuilder } from "../../graphQlBuilder/QueryBuilder.js";
var __defProp = Object.defineProperty;

@@ -7,4 +9,2 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;

};
import { ObjectBuilder } from "../../graphQlBuilder/ObjectBuilder.js";
import { QueryBuilder } from "../../graphQlBuilder/QueryBuilder.js";
const _GenerateUploadUrlMutationBuilder = class {

@@ -15,6 +15,13 @@ static buildQuery(parameters) {

const fileParameters = parameters[alias];
builder = builder.object(
alias,
_GenerateUploadUrlMutationBuilder.generateUploadUrlFields.argument("contentType", fileParameters.contentType).argument("expiration", fileParameters.expiration).argument("prefix", fileParameters.prefix).argument("acl", fileParameters.acl)
);
if (fileParameters.suffix || fileParameters.fileName || fileParameters.extension) {
builder = builder.object(
alias,
_GenerateUploadUrlMutationBuilder.generateUploadUrlFields.argument("input", fileParameters)
);
} else {
builder = builder.object(
alias,
_GenerateUploadUrlMutationBuilder.generateUploadUrlFields.argument("contentType", fileParameters.contentType).argument("expiration", fileParameters.expiration).argument("prefix", fileParameters.prefix).argument("acl", fileParameters.acl)
);
}
}

@@ -21,0 +28,0 @@ return builder;

@@ -0,1 +1,5 @@

import pLimit from "p-limit";
import { FileUploadError } from "./FileUploadError.js";
import { GenerateUploadUrlMutationBuilder } from "./GenerateUploadUrlMutationBuilder.js";
import { readFileAsArrayBuffer } from "../../utils/readFileAsArrayBuffer.js";
var __defProp = Object.defineProperty;

@@ -7,8 +11,5 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;

};
import { GenerateUploadUrlMutationBuilder } from "./GenerateUploadUrlMutationBuilder.js";
import { FileUploadError } from "./FileUploadError.js";
import pLimit from "p-limit";
import { readFileAsArrayBuffer } from "../../utils/readFileAsArrayBuffer.js";
class S3FileUploader {
constructor(options = {}) {
this.options = options;
__publicField(this, "uploadState");

@@ -19,3 +20,2 @@ __publicField(this, "generateNewAlias", (() => {

})());
this.options = options;
this.uploadState = /* @__PURE__ */ new WeakMap();

@@ -41,2 +41,6 @@ }

prefix: uploadOptions?.filePrefix,
suffix: uploadOptions?.fileSuffix,
size: uploadOptions?.fileSize,
extension: uploadOptions?.fileExtension,
fileName: uploadOptions?.fileName,
expiration: uploadOptions?.fileExpiration,

@@ -43,0 +47,0 @@ acl: uploadOptions?.fileAcl

@@ -0,1 +1,6 @@

import { CrudQueryBuilderError } from "./CrudQueryBuilderError.js";
import { WriteManyRelationBuilder } from "./WriteManyRelationBuilder.js";
import { WriteOneRelationBuilder } from "./WriteOneRelationBuilder.js";
import { GraphQlLiteral } from "../graphQlBuilder/GraphQlLiteral.js";
import { isEmptyObject } from "../utils/isEmptyObject.js";
var __defProp = Object.defineProperty;

@@ -7,7 +12,2 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;

};
import { CrudQueryBuilderError } from "./CrudQueryBuilderError.js";
import { WriteManyRelationBuilder } from "./WriteManyRelationBuilder.js";
import { WriteOneRelationBuilder } from "./WriteOneRelationBuilder.js";
import { GraphQlLiteral } from "../graphQlBuilder/GraphQlLiteral.js";
import { isEmptyObject } from "../utils/isEmptyObject.js";
class WriteDataBuilder {

@@ -14,0 +14,0 @@ constructor(data) {

@@ -0,1 +1,3 @@

import { ObjectBuilder } from "../../graphQlBuilder/ObjectBuilder.js";
import { QueryBuilder } from "../../graphQlBuilder/QueryBuilder.js";
var __defProp = Object.defineProperty;

@@ -7,4 +9,2 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;

};
import { ObjectBuilder } from "../../graphQlBuilder/ObjectBuilder.js";
import { QueryBuilder } from "../../graphQlBuilder/QueryBuilder.js";
const _GenerateUploadUrlMutationBuilder = class {

@@ -15,6 +15,13 @@ static buildQuery(parameters) {

const fileParameters = parameters[alias];
builder = builder.object(
alias,
_GenerateUploadUrlMutationBuilder.generateUploadUrlFields.argument("contentType", fileParameters.contentType).argument("expiration", fileParameters.expiration).argument("prefix", fileParameters.prefix).argument("acl", fileParameters.acl)
);
if (fileParameters.suffix || fileParameters.fileName || fileParameters.extension) {
builder = builder.object(
alias,
_GenerateUploadUrlMutationBuilder.generateUploadUrlFields.argument("input", fileParameters)
);
} else {
builder = builder.object(
alias,
_GenerateUploadUrlMutationBuilder.generateUploadUrlFields.argument("contentType", fileParameters.contentType).argument("expiration", fileParameters.expiration).argument("prefix", fileParameters.prefix).argument("acl", fileParameters.acl)
);
}
}

@@ -21,0 +28,0 @@ return builder;

@@ -0,1 +1,5 @@

import pLimit from "p-limit";
import { FileUploadError } from "./FileUploadError.js";
import { GenerateUploadUrlMutationBuilder } from "./GenerateUploadUrlMutationBuilder.js";
import { readFileAsArrayBuffer } from "../../utils/readFileAsArrayBuffer.js";
var __defProp = Object.defineProperty;

@@ -7,8 +11,5 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;

};
import { GenerateUploadUrlMutationBuilder } from "./GenerateUploadUrlMutationBuilder.js";
import { FileUploadError } from "./FileUploadError.js";
import pLimit from "p-limit";
import { readFileAsArrayBuffer } from "../../utils/readFileAsArrayBuffer.js";
class S3FileUploader {
constructor(options = {}) {
this.options = options;
__publicField(this, "uploadState");

@@ -19,3 +20,2 @@ __publicField(this, "generateNewAlias", (() => {

})());
this.options = options;
this.uploadState = /* @__PURE__ */ new WeakMap();

@@ -41,2 +41,6 @@ }

prefix: uploadOptions?.filePrefix,
suffix: uploadOptions?.fileSuffix,
size: uploadOptions?.fileSize,
extension: uploadOptions?.fileExtension,
fileName: uploadOptions?.fileName,
expiration: uploadOptions?.fileExpiration,

@@ -43,0 +47,0 @@ acl: uploadOptions?.fileAcl

@@ -0,1 +1,6 @@

import { CrudQueryBuilderError } from "./CrudQueryBuilderError.js";
import { WriteManyRelationBuilder } from "./WriteManyRelationBuilder.js";
import { WriteOneRelationBuilder } from "./WriteOneRelationBuilder.js";
import { GraphQlLiteral } from "../graphQlBuilder/GraphQlLiteral.js";
import { isEmptyObject } from "../utils/isEmptyObject.js";
var __defProp = Object.defineProperty;

@@ -7,7 +12,2 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;

};
import { CrudQueryBuilderError } from "./CrudQueryBuilderError.js";
import { WriteManyRelationBuilder } from "./WriteManyRelationBuilder.js";
import { WriteOneRelationBuilder } from "./WriteOneRelationBuilder.js";
import { GraphQlLiteral } from "../graphQlBuilder/GraphQlLiteral.js";
import { isEmptyObject } from "../utils/isEmptyObject.js";
class WriteDataBuilder {

@@ -14,0 +14,0 @@ constructor(data) {

@@ -7,7 +7,12 @@ import { GraphQlLiteral } from '../../graphQlBuilder';

declare namespace GenerateUploadUrlMutationBuilder {
type Acl = GraphQlLiteral<'PUBLIC_READ' | 'PRIVATE' | 'NONE'>;
interface FileParameters {
contentType: string;
expiration?: number;
size?: number;
prefix?: string;
acl?: GraphQlLiteral<'PUBLIC_READ' | 'PRIVATE' | 'NONE'>;
extension?: string;
suffix?: string;
fileName?: string;
acl?: Acl;
}

@@ -14,0 +19,0 @@ interface MutationParameters {

@@ -23,5 +23,9 @@ import type { FileUploader, FileUploaderInitializeOptions } from './FileUploader';

fileType?: GenerateUploadUrlMutationBuilder.FileParameters['contentType'];
fileExpiration?: GenerateUploadUrlMutationBuilder.FileParameters['expiration'];
filePrefix?: GenerateUploadUrlMutationBuilder.FileParameters['prefix'];
fileAcl?: GenerateUploadUrlMutationBuilder.FileParameters['acl'];
fileExpiration?: number;
fileSize?: number;
filePrefix?: string;
fileSuffix?: string;
fileName?: string;
fileExtension?: string;
fileAcl?: GenerateUploadUrlMutationBuilder.Acl;
}

@@ -28,0 +32,0 @@ }

@@ -17,4 +17,4 @@ export interface GraphQlClientRequestOptions {

constructor(apiUrl: string, apiToken?: string | undefined);
sendRequest<T = any>(query: string, { apiTokenOverride, signal, variables, headers }?: GraphQlClientRequestOptions): Promise<T>;
sendRequest<T = unknown>(query: string, { apiTokenOverride, signal, variables, headers }?: GraphQlClientRequestOptions): Promise<T>;
}
//# sourceMappingURL=GraphQlClient.d.ts.map
{
"name": "@contember/client",
"license": "Apache-2.0",
"version": "1.1.0-rc.5",
"version": "1.1.0-rc.12",
"main": "./dist/production/index.js",

@@ -22,8 +22,4 @@ "exports": {

"sideEffects": false,
"dependencies": {
"@contember/schema": "^1.2.0",
"p-limit": "^4.0.0"
},
"scripts": {
"build": "pnpm run build:js:dev && pnpm run build:js:prod",
"build": "yarn build:js:dev && yarn build:js:prod",
"build:js:dev": "vite build --mode development",

@@ -34,3 +30,8 @@ "build:js:prod": "vite build --mode production",

"test": "vitest"
}
},
"dependencies": {
"@contember/schema": "^1.2.0",
"p-limit": "^4.0.0"
},
"stableVersion": "0.0.0"
}

@@ -15,11 +15,19 @@ import { GraphQlLiteral, ObjectBuilder, QueryBuilder } from '../../graphQlBuilder'

const fileParameters = parameters[alias]
builder = builder.object(
alias,
GenerateUploadUrlMutationBuilder.generateUploadUrlFields
.argument('contentType', fileParameters.contentType)
.argument('expiration', fileParameters.expiration)
.argument('prefix', fileParameters.prefix)
.argument('acl', fileParameters.acl),
)
if (fileParameters.suffix || fileParameters.fileName || fileParameters.extension) {
builder = builder.object(
alias,
GenerateUploadUrlMutationBuilder.generateUploadUrlFields
.argument('input', fileParameters),
)
} else {
// BC
builder = builder.object(
alias,
GenerateUploadUrlMutationBuilder.generateUploadUrlFields
.argument('contentType', fileParameters.contentType)
.argument('expiration', fileParameters.expiration)
.argument('prefix', fileParameters.prefix)
.argument('acl', fileParameters.acl),
)
}
}

@@ -33,7 +41,13 @@

namespace GenerateUploadUrlMutationBuilder {
export type Acl = GraphQlLiteral<'PUBLIC_READ' | 'PRIVATE' | 'NONE'>;
export interface FileParameters {
contentType: string
expiration?: number
size?: number
prefix?: string
acl?: GraphQlLiteral<'PUBLIC_READ' | 'PRIVATE' | 'NONE'>
extension?: string
suffix?: string
fileName?: string
acl?: Acl
}

@@ -40,0 +54,0 @@

@@ -0,7 +1,7 @@

import pLimit from 'p-limit'
import { readFileAsArrayBuffer } from '../../utils'
import { FileUploadError } from './FileUploadError'
import type { FileUploader, FileUploaderInitializeOptions } from './FileUploader'
import { GenerateUploadUrlMutationBuilder } from './GenerateUploadUrlMutationBuilder'
import type { UploadedFileMetadata } from './UploadedFileMetadata'
import { FileUploadError } from './FileUploadError'
import pLimit from 'p-limit'

@@ -51,2 +51,6 @@ interface S3UploadState {

prefix: uploadOptions?.filePrefix,
suffix: uploadOptions?.fileSuffix,
size: uploadOptions?.fileSize,
extension: uploadOptions?.fileExtension,
fileName: uploadOptions?.fileName,
expiration: uploadOptions?.fileExpiration,

@@ -63,4 +67,4 @@ acl: uploadOptions?.fileAcl,

try {
const response = await options.contentApiClient.sendRequest(mutation)
const responseData: GenerateUploadUrlMutationBuilder.MutationResponse = response.data
const response = await options.contentApiClient.sendRequest<{ data: GenerateUploadUrlMutationBuilder.MutationResponse }>(mutation)
const responseData = response.data
const limit = pLimit(this.options.concurrency ?? 5)

@@ -112,3 +116,3 @@ const promises: Promise<void>[] = []

})
xhr.upload?.addEventListener('progress', e => {
xhr.upload?.addEventListener('progress', e => {
onProgress([

@@ -140,5 +144,9 @@ [

fileType?: GenerateUploadUrlMutationBuilder.FileParameters['contentType']
fileExpiration?: GenerateUploadUrlMutationBuilder.FileParameters['expiration']
filePrefix?: GenerateUploadUrlMutationBuilder.FileParameters['prefix']
fileAcl?: GenerateUploadUrlMutationBuilder.FileParameters['acl']
fileExpiration?: number
fileSize?: number
filePrefix?: string
fileSuffix?: string
fileName?: string
fileExtension?: string
fileAcl?: GenerateUploadUrlMutationBuilder.Acl
}

@@ -145,0 +153,0 @@ }

@@ -17,5 +17,5 @@ export interface GraphQlClientRequestOptions {

export class GraphQlClient {
constructor(public readonly apiUrl: string, private readonly apiToken?: string) {}
constructor(public readonly apiUrl: string, private readonly apiToken?: string) { }
async sendRequest<T = any>(
async sendRequest<T = unknown>(
query: string,

@@ -22,0 +22,0 @@ { apiTokenOverride, signal, variables, headers }: GraphQlClientRequestOptions = {},

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 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 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 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 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 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