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

@uniformdev/files

Package Overview
Dependencies
Maintainers
11
Versions
387
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniformdev/files - npm Package Compare versions

Comparing version 19.51.1-alpha.10 to 19.51.1-alpha.22

60

./dist/index.js

@@ -26,3 +26,5 @@ "use strict";

FILE_READY_STATE: () => FILE_READY_STATE,
FILE_TYPES_IMAGE: () => FILE_TYPES_IMAGE,
FileClient: () => FileClient,
UncachedFileClient: () => UncachedFileClient,
getFileNameFromUrl: () => getFileNameFromUrl

@@ -34,3 +36,3 @@ });

var import_api = require("@uniformdev/context/api");
var FILE_BASE_PATH = "/api/v1/file";
var FILE_BASE_PATH = "/api/v1/files";
var FileClient = class extends import_api.ApiClient {

@@ -40,28 +42,31 @@ constructor(options) {

}
async createNewProjectFile(options) {
if (!this.options.projectId)
throw new Error("A project ID must exist to upload a file to a project");
const fetchUrl = this.createUrl(FILE_BASE_PATH);
return await this.apiClient(fetchUrl, {
async get(options) {
const { projectId } = this.options;
const fetchUri = this.createUrl(FILE_BASE_PATH, {
...options,
projectId
});
return this.apiClient(fetchUri);
}
async insert(options) {
const { projectId } = this.options;
const fetchUri = this.createUrl(FILE_BASE_PATH);
return this.apiClient(fetchUri, {
method: "POST",
body: JSON.stringify({
projectId: this.options.projectId,
...options
})
body: JSON.stringify({ ...options, projectId })
});
}
async getFile(options) {
const fetchUrl = this.createUrl(FILE_BASE_PATH, options);
return await this.apiClient(fetchUrl);
}
async deleteFileByUrl(url) {
const fetchUrl = this.createUrl(FILE_BASE_PATH);
return await this.apiClient(fetchUrl, {
async delete(options) {
const fetchUri = this.createUrl(FILE_BASE_PATH);
return this.apiClient(fetchUri, {
method: "DELETE",
body: JSON.stringify({
url
})
body: JSON.stringify(options)
});
}
};
var UncachedFileClient = class extends FileClient {
constructor(options) {
super({ ...options, bypassCache: true });
}
};

@@ -79,2 +84,15 @@ // src/fileUrl.ts

var FILE_MAX_SIZE = 1024 * 1024 * 10;
var FILE_TYPES_IMAGE = [
".jpg",
".jpeg",
".jfif",
".pjpeg",
".pjp",
".png",
".gif",
".svg",
".webp",
".apng",
".avif"
];
// Annotate the CommonJS export names for ESM import in node:

@@ -85,4 +103,6 @@ 0 && (module.exports = {

FILE_READY_STATE,
FILE_TYPES_IMAGE,
FileClient,
UncachedFileClient,
getFileNameFromUrl
});
import { ApiClient, ClientOptions } from '@uniformdev/context/api';
type GetFileOptions = {
id: string;
} | {
url: string;
projectId?: string;
} | {
sourceId: string;
projectId: string;
};
interface NewFileOptions {
name: string;
size: number;
mediaType: string;
width?: number;
height?: number;
sourceId?: string;
projectId?: string;
/**
* This file was auto-generated by openapi-typescript.
* Do not make direct changes to the file.
*/
interface paths {
"/api/v1/files": {
/** Gets a single file */
get: {
parameters: {
query: {
id?: string;
url?: string;
sourceId?: string;
projectId?: string;
};
};
responses: {
/** 200 response */
200: {
content: {
"application/json": {
/** Format: uuid */
id: string;
state: number;
url?: string;
name: string;
mediaType: string;
metadata?: unknown;
size: number;
};
};
};
400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
/** 404 response */
404: unknown;
429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
};
};
/** Creates a new file */
post: {
responses: {
/** 202 response */
202: {
content: {
"application/json": {
/** Format: uuid */
id: string;
uploadUrl: string;
/** @enum {string} */
method: "POST" | "PUT";
};
};
};
400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
/** 404 response */
404: unknown;
429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
};
requestBody: {
content: {
"application/json": {
/** Format: uuid */
projectId?: string;
sourceId?: string;
/** Format: uuid */
teamId?: string;
name: string;
size: number;
mediaType: string;
width?: number;
height?: number;
};
};
};
};
/** Deletes a file */
delete: {
responses: {
/** 200 response */
200: {
content: {
"application/json": {
/** Format: uuid */
id: string;
};
};
};
400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
/** 404 response */
404: unknown;
429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
};
requestBody: {
content: {
"application/json": {
url: string;
};
};
};
};
};
}
interface NewFileResponse {
id: string;
uploadUrl: string;
method: string;
interface external {
"swagger.yml": {
paths: {};
components: {
schemas: {
Error: {
/** @description Error message(s) that occurred while processing the request */
errorMessage?: string[] | string;
};
};
responses: {
/** Request input validation failed */
BadRequestError: {
content: {
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
};
};
/** API key or token was not valid */
UnauthorizedError: {
content: {
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
};
};
/** Permission was denied */
ForbiddenError: {
content: {
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
};
};
/** Resource not found */
NotFoundError: {
content: {
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
};
};
/** Too many requests in allowed time period */
RateLimitError: unknown;
/** Execution error occurred */
InternalServerError: unknown;
};
};
operations: {};
};
}
interface FileStateResponse {
id: string;
state: number;
url: string;
mediaType: string;
name: string;
size: number;
metadata: unknown;
}
type FileInsertRequest = paths['/api/v1/files']['post']['requestBody']['content']['application/json'];
type FileInsertResponse = paths['/api/v1/files']['post']['responses']['202']['content']['application/json'];
type FileDeleteRequest = paths['/api/v1/files']['delete']['requestBody']['content']['application/json'];
type FileDeleteResponse = paths['/api/v1/files']['delete']['responses']['200']['content']['application/json'];
type FileGetRequest = paths['/api/v1/files']['get']['parameters']['query'];
type FileGetByIDRequest = Pick<FileGetRequest, 'id'>;
type FileGetByURLRequest = Pick<FileGetRequest, 'url' | 'projectId'>;
type FileGetBySourceIDRequest = Pick<FileGetRequest, 'sourceId' | 'projectId'>;
type FileGetResponse = paths['/api/v1/files']['get']['responses']['200']['content']['application/json'];
type WithoutProjectId<T extends {
projectId?: string;
}> = Omit<T, 'projectId'>;
declare class FileClient extends ApiClient {
constructor(options: ClientOptions);
createNewProjectFile(options: NewFileOptions): Promise<NewFileResponse>;
getFile(options: GetFileOptions): Promise<FileStateResponse>;
deleteFileByUrl(url: string): Promise<FileStateResponse>;
constructor(options: ClientOptions & {
projectId: NonNullable<ClientOptions['projectId']>;
});
get(options: FileGetByIDRequest | WithoutProjectId<FileGetBySourceIDRequest> | WithoutProjectId<FileGetByURLRequest>): Promise<FileGetResponse>;
insert(options: WithoutProjectId<FileInsertRequest>): Promise<{
id: string;
uploadUrl: string;
method: "POST" | "PUT";
}>;
delete(options: FileDeleteRequest): Promise<{
id: string;
}>;
}
declare class UncachedFileClient extends FileClient {
constructor(options: Omit<ClientOptions & {
projectId: NonNullable<ClientOptions['projectId']>;
}, 'bypassCache'>);
}

@@ -50,3 +200,4 @@ declare const getFileNameFromUrl: (fileUrl: string) => string;

declare const FILE_MAX_SIZE: number;
declare const FILE_TYPES_IMAGE: string[];
export { FILE_IN_PROGRESS_STATE, FILE_MAX_SIZE, FILE_READY_STATE, FileClient, FileStateResponse, NewFileOptions, NewFileResponse, getFileNameFromUrl };
export { FILE_IN_PROGRESS_STATE, FILE_MAX_SIZE, FILE_READY_STATE, FILE_TYPES_IMAGE, FileClient, FileDeleteRequest, FileDeleteResponse, FileGetByIDRequest, FileGetBySourceIDRequest, FileGetByURLRequest, FileGetRequest, FileGetResponse, FileInsertRequest, FileInsertResponse, UncachedFileClient, getFileNameFromUrl };
// src/FileClient.ts
import { ApiClient } from "@uniformdev/context/api";
var FILE_BASE_PATH = "/api/v1/file";
var FILE_BASE_PATH = "/api/v1/files";
var FileClient = class extends ApiClient {

@@ -8,28 +8,31 @@ constructor(options) {

}
async createNewProjectFile(options) {
if (!this.options.projectId)
throw new Error("A project ID must exist to upload a file to a project");
const fetchUrl = this.createUrl(FILE_BASE_PATH);
return await this.apiClient(fetchUrl, {
async get(options) {
const { projectId } = this.options;
const fetchUri = this.createUrl(FILE_BASE_PATH, {
...options,
projectId
});
return this.apiClient(fetchUri);
}
async insert(options) {
const { projectId } = this.options;
const fetchUri = this.createUrl(FILE_BASE_PATH);
return this.apiClient(fetchUri, {
method: "POST",
body: JSON.stringify({
projectId: this.options.projectId,
...options
})
body: JSON.stringify({ ...options, projectId })
});
}
async getFile(options) {
const fetchUrl = this.createUrl(FILE_BASE_PATH, options);
return await this.apiClient(fetchUrl);
}
async deleteFileByUrl(url) {
const fetchUrl = this.createUrl(FILE_BASE_PATH);
return await this.apiClient(fetchUrl, {
async delete(options) {
const fetchUri = this.createUrl(FILE_BASE_PATH);
return this.apiClient(fetchUri, {
method: "DELETE",
body: JSON.stringify({
url
})
body: JSON.stringify(options)
});
}
};
var UncachedFileClient = class extends FileClient {
constructor(options) {
super({ ...options, bypassCache: true });
}
};

@@ -47,2 +50,15 @@ // src/fileUrl.ts

var FILE_MAX_SIZE = 1024 * 1024 * 10;
var FILE_TYPES_IMAGE = [
".jpg",
".jpeg",
".jfif",
".pjpeg",
".pjp",
".png",
".gif",
".svg",
".webp",
".apng",
".avif"
];
export {

@@ -52,4 +68,6 @@ FILE_IN_PROGRESS_STATE,

FILE_READY_STATE,
FILE_TYPES_IMAGE,
FileClient,
UncachedFileClient,
getFileNameFromUrl
};

@@ -26,3 +26,5 @@ "use strict";

FILE_READY_STATE: () => FILE_READY_STATE,
FILE_TYPES_IMAGE: () => FILE_TYPES_IMAGE,
FileClient: () => FileClient,
UncachedFileClient: () => UncachedFileClient,
getFileNameFromUrl: () => getFileNameFromUrl

@@ -34,3 +36,3 @@ });

var import_api = require("@uniformdev/context/api");
var FILE_BASE_PATH = "/api/v1/file";
var FILE_BASE_PATH = "/api/v1/files";
var FileClient = class extends import_api.ApiClient {

@@ -40,28 +42,31 @@ constructor(options) {

}
async createNewProjectFile(options) {
if (!this.options.projectId)
throw new Error("A project ID must exist to upload a file to a project");
const fetchUrl = this.createUrl(FILE_BASE_PATH);
return await this.apiClient(fetchUrl, {
async get(options) {
const { projectId } = this.options;
const fetchUri = this.createUrl(FILE_BASE_PATH, {
...options,
projectId
});
return this.apiClient(fetchUri);
}
async insert(options) {
const { projectId } = this.options;
const fetchUri = this.createUrl(FILE_BASE_PATH);
return this.apiClient(fetchUri, {
method: "POST",
body: JSON.stringify({
projectId: this.options.projectId,
...options
})
body: JSON.stringify({ ...options, projectId })
});
}
async getFile(options) {
const fetchUrl = this.createUrl(FILE_BASE_PATH, options);
return await this.apiClient(fetchUrl);
}
async deleteFileByUrl(url) {
const fetchUrl = this.createUrl(FILE_BASE_PATH);
return await this.apiClient(fetchUrl, {
async delete(options) {
const fetchUri = this.createUrl(FILE_BASE_PATH);
return this.apiClient(fetchUri, {
method: "DELETE",
body: JSON.stringify({
url
})
body: JSON.stringify(options)
});
}
};
var UncachedFileClient = class extends FileClient {
constructor(options) {
super({ ...options, bypassCache: true });
}
};

@@ -79,2 +84,15 @@ // src/fileUrl.ts

var FILE_MAX_SIZE = 1024 * 1024 * 10;
var FILE_TYPES_IMAGE = [
".jpg",
".jpeg",
".jfif",
".pjpeg",
".pjp",
".png",
".gif",
".svg",
".webp",
".apng",
".avif"
];
// Annotate the CommonJS export names for ESM import in node:

@@ -85,4 +103,6 @@ 0 && (module.exports = {

FILE_READY_STATE,
FILE_TYPES_IMAGE,
FileClient,
UncachedFileClient,
getFileNameFromUrl
});
{
"name": "@uniformdev/files",
"version": "19.51.1-alpha.10+ee32ab8b6",
"version": "19.51.1-alpha.22+ee274f045",
"description": "Uniform Files helpers",

@@ -22,8 +22,11 @@ "license": "SEE LICENSE IN LICENSE.txt",

"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"build": "run-s update-openapi build:ts",
"build:ts": "tsup",
"dev": "run-s update-openapi dev:ts",
"dev:ts": "tsup --watch",
"clean": "rimraf dist",
"test": "jest --maxWorkers=1 --passWithNoTests",
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
"format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
"update-openapi": "tsx ./scripts/update-openapi.cts"
},

@@ -37,5 +40,5 @@ "files": [

"dependencies": {
"@uniformdev/context": "19.51.1-alpha.10+ee32ab8b6"
"@uniformdev/context": "19.51.1-alpha.22+ee274f045"
},
"gitHead": "ee32ab8b66da53e39f0714b708d5cd2ec49592bd"
"gitHead": "ee274f04521c4024826b21fee01d50fcc1e414a1"
}

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