@adgytec/adgytec-web-utils 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ export * from './types';
2
+ export * from './mediaInfo';
3
+ export * from './toUploadPayload';
4
+ export * from './uploadDetails';
5
+ export * from './upload';
@@ -0,0 +1,12 @@
1
+ import { U as e, n as o, a as d, b as l, c as t, t as p, d as n, u as U, e as i } from "../chunks/upload";
2
+ export {
3
+ e as UploadDetailsAPIResSchema,
4
+ o as newMediaInfo,
5
+ d as newMediaInfos,
6
+ l as newUploadDetails,
7
+ t as newUploadsDetails,
8
+ p as toUploadPayload,
9
+ n as toUploadPayloads,
10
+ U as uploadItem,
11
+ i as uploadItems
12
+ };
@@ -0,0 +1,3 @@
1
+ import { NewMediaInfos, NewMediaInfo } from './types';
2
+ export declare const newMediaInfo: NewMediaInfo;
3
+ export declare const newMediaInfos: NewMediaInfos;
@@ -0,0 +1,18 @@
1
+ import { MultipartUploadedPartDetails } from './types';
2
+ export declare class MultipartUtil {
3
+ #private;
4
+ constructor(id: string, blob: Blob, completeURL: string, totalParts: number);
5
+ get failed(): boolean;
6
+ fail(): void;
7
+ get id(): string;
8
+ get completeURL(): string;
9
+ get blob(): Blob;
10
+ add(itemRes: MultipartUploadedPartDetails): void;
11
+ contains(partNumber: number): boolean;
12
+ get list(): MultipartUploadedPartDetails[];
13
+ get canComplete(): boolean;
14
+ tryStartComplete(): boolean;
15
+ resetComplete(): void;
16
+ get totalPartsCount(): number;
17
+ get uploadedPartsCount(): number;
18
+ }
@@ -0,0 +1,10 @@
1
+ export declare class SinglepartUtil {
2
+ #private;
3
+ constructor(id: string, blob: Blob, uploadURL: string, completeURL: string);
4
+ get canComplete(): boolean;
5
+ allowComplete(): void;
6
+ get id(): string;
7
+ get blob(): Blob;
8
+ get completeURL(): string;
9
+ get uploadURL(): string;
10
+ }
@@ -0,0 +1,3 @@
1
+ import { ToUploadPayload, ToUploadPayloads } from './types';
2
+ export declare const toUploadPayload: ToUploadPayload;
3
+ export declare const toUploadPayloads: ToUploadPayloads;
@@ -0,0 +1,17 @@
1
+ import { default as z } from 'zod';
2
+ export declare const UploadDetailsAPIResSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ mediaID: z.ZodUUID;
4
+ uploadType: z.ZodLiteral<"multipart">;
5
+ multipartPresignPart: z.ZodArray<z.ZodObject<{
6
+ presignPut: z.ZodURL;
7
+ partNumber: z.ZodInt;
8
+ partSize: z.ZodInt;
9
+ }, z.core.$strip>>;
10
+ multipartSuccessCallback: z.ZodURL;
11
+ }, z.core.$strip>, z.ZodObject<{
12
+ mediaID: z.ZodUUID;
13
+ uploadType: z.ZodLiteral<"singlepart">;
14
+ presignPut: z.ZodURL;
15
+ singlepartSuccessCallback: z.ZodURL;
16
+ }, z.core.$strip>], "uploadType">;
17
+ export type UploadDetailsAPIRes = z.infer<typeof UploadDetailsAPIResSchema>;
@@ -0,0 +1,6 @@
1
+ export * from './mediaInfo';
2
+ export * from './toUploadPayload';
3
+ export * from './uploadDetails';
4
+ export * from './apiResponse';
5
+ export * from './lifecycle';
6
+ export * from './upload';
@@ -0,0 +1,11 @@
1
+ import { APPError } from '../../errors';
2
+ import { UploadDetails } from './uploadDetails';
3
+ export type LifecycleHandler = {
4
+ init: (details: UploadDetails[]) => void;
5
+ completed: () => void;
6
+ failed: (id: string, reason: APPError) => void;
7
+ itemUploaded: (id: string) => void;
8
+ multipartPartUploaded: (id: string, uploadedPartsCount: number, totalPartsCount: number) => void;
9
+ uploadRetrying: (id: string) => void;
10
+ multipartPartUploadRetrying: (id: string, partNumber: number) => void;
11
+ };
@@ -0,0 +1,8 @@
1
+ export type MediaInfo = {
2
+ id: string;
3
+ name: string;
4
+ size: number;
5
+ file: File;
6
+ };
7
+ export type NewMediaInfo = (item: File) => MediaInfo;
8
+ export type NewMediaInfos = (items: File[]) => MediaInfo[];
@@ -0,0 +1,4 @@
1
+ import { MediaInfo } from './mediaInfo';
2
+ export type MediaUploadPayload = Omit<MediaInfo, "file">;
3
+ export type ToUploadPayload = (item: MediaInfo) => MediaUploadPayload;
4
+ export type ToUploadPayloads = (items: MediaInfo[]) => MediaUploadPayload[];
@@ -0,0 +1,42 @@
1
+ import { MultipartUtil } from '../multipartUtil';
2
+ import { SinglepartUtil } from '../singlepartUtil';
3
+ import { LifecycleHandler } from './lifecycle';
4
+ import { UploadDetails } from './uploadDetails';
5
+ export type UploadLimits = {
6
+ concurrentUploads: number;
7
+ retryLimit: number;
8
+ };
9
+ export type UploadItem = (item: UploadDetails, lifecycleHandler: LifecycleHandler, uploadLimits?: UploadLimits, languageTag?: string) => Promise<void>;
10
+ export type UploadItems = (items: UploadDetails[], lifecycleHandler: LifecycleHandler, uploadLimits?: UploadLimits, languageTag?: string) => Promise<void>;
11
+ export type MultipartUploadedPartDetails = {
12
+ etag: string;
13
+ partNumber: number;
14
+ };
15
+ type SinglepartUploadRetry = {
16
+ type: "singlepart-upload";
17
+ singlepartObj: SinglepartUtil;
18
+ };
19
+ type SinglepartCompleteRetry = {
20
+ type: "singlepart-complete";
21
+ singlepartObj: SinglepartUtil;
22
+ };
23
+ export type MultipartPartInfo = {
24
+ uploadURL: string;
25
+ partNumber: number;
26
+ startByte: number;
27
+ endByte: number;
28
+ };
29
+ type MultipartPartUploadRetry = {
30
+ type: "multipart-part-upload";
31
+ multipartObj: MultipartUtil;
32
+ partInfo: MultipartPartInfo;
33
+ };
34
+ type MultipartCompleteRetry = {
35
+ type: "multipart-complete";
36
+ multipartObj: MultipartUtil;
37
+ };
38
+ type RetryAction = SinglepartUploadRetry | SinglepartCompleteRetry | MultipartPartUploadRetry | MultipartCompleteRetry;
39
+ export type Retry = RetryAction & {
40
+ retryCount: number;
41
+ };
42
+ export {};
@@ -0,0 +1,8 @@
1
+ import { UploadDetailsAPIRes } from './apiResponse';
2
+ import { MediaInfo } from './mediaInfo';
3
+ export type UploadDetails = UploadDetailsAPIRes & {
4
+ file: File;
5
+ size: number;
6
+ };
7
+ export type NewUploadDetails = (mediaInfo: MediaInfo, apiResponse: UploadDetailsAPIRes) => UploadDetails;
8
+ export type NewUploadsDetails = (mediaInfos: MediaInfo[], apiResponse: UploadDetailsAPIRes[]) => UploadDetails[];
@@ -0,0 +1,3 @@
1
+ import { UploadItems, UploadItem } from './types';
2
+ export declare const uploadItem: UploadItem;
3
+ export declare const uploadItems: UploadItems;
@@ -0,0 +1,3 @@
1
+ import { NewUploadDetails, NewUploadsDetails } from './types';
2
+ export declare const newUploadDetails: NewUploadDetails;
3
+ export declare const newUploadsDetails: NewUploadsDetails;
@@ -0,0 +1,6 @@
1
+ import { LifecycleHandler, UploadDetails, UploadLimits } from './types';
2
+ export declare class Upload {
3
+ #private;
4
+ constructor(uploadItems: UploadDetails[], handler: LifecycleHandler, limits?: UploadLimits, languageTag?: string);
5
+ init(): Promise<void>;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { d } from "../chunks/decode";
2
+ export {
3
+ d as decodeAPIResponse
4
+ };
package/package.json CHANGED
@@ -1,47 +1,54 @@
1
1
  {
2
- "name": "@adgytec/adgytec-web-utils",
3
- "private": false,
4
- "version": "0.0.1",
5
- "type": "module",
6
- "sideEffects": false,
7
- "files": [
8
- "dist"
9
- ],
10
- "exports": {
11
- ".": {
12
- "import": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
14
- }
15
- },
16
- "main": "./dist/index.js",
17
- "types": "./dist/index.d.ts",
18
- "publishConfig": {
19
- "access": "public"
20
- },
21
- "scripts": {
22
- "dev": "vite",
23
- "build": "tsc && vite build",
24
- "preview": "vite preview",
25
- "release": "npm run build && npm publish --public"
26
- },
27
- "devDependencies": {
28
- "@types/node": "^25.0.9",
29
- "typescript": "~5.9.3",
30
- "vite": "^7.2.4",
31
- "vite-plugin-dts": "^4.5.4"
32
- },
33
- "author": {
34
- "name": "Adgytec",
35
- "email": "rohan@adgytec.in",
36
- "url": "https://adgytec.in"
37
- },
38
- "license": "MIT",
39
- "repository": {
40
- "type": "git",
41
- "url": "git+https://github.com/Adgytec/adgytec-web-utils.git"
42
- },
43
- "homepage": "https://github.com/Adgytec/adgytec-web-utils/#/README.md",
44
- "dependencies": {
45
- "zod": "^4.3.5"
46
- }
2
+ "name": "@adgytec/adgytec-web-utils",
3
+ "private": false,
4
+ "version": "0.0.2",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "generate:index": "node src/scripts/generate-root-index.mjs",
23
+ "dev": "vite",
24
+ "build": "npm run generate:index && tsc && vite build",
25
+ "preview": "vite preview",
26
+ "release": "npm run build && npm publish --public"
27
+ },
28
+ "peerDependencies": {
29
+ "@datastructures-js/queue": ">=4.3.0",
30
+ "uuid": ">=13.0.0",
31
+ "zod": ">=4.3.6"
32
+ },
33
+ "devDependencies": {
34
+ "@datastructures-js/queue": "^4.3.0",
35
+ "@types/node": "^25.3.3",
36
+ "glob": "^13.0.6",
37
+ "typescript": "~5.9.3",
38
+ "uuid": "^13.0.0",
39
+ "vite": "^7.3.1",
40
+ "vite-plugin-dts": "^4.5.4",
41
+ "zod": "^4.3.6"
42
+ },
43
+ "author": {
44
+ "name": "Adgytec",
45
+ "email": "rohan@adgytec.in",
46
+ "url": "https://adgytec.in"
47
+ },
48
+ "license": "MIT",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/Adgytec/adgytec-web-utils.git"
52
+ },
53
+ "homepage": "https://github.com/Adgytec/adgytec-web-utils/#/README.md"
47
54
  }