Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript definitions for Meteor-Files #226

Closed
Lavan opened this issue Sep 8, 2016 · 14 comments
Closed

Typescript definitions for Meteor-Files #226

Lavan opened this issue Sep 8, 2016 · 14 comments

Comments

@Lavan
Copy link

Lavan commented Sep 8, 2016

I'm interested in using Meteor-Files together with ng2-files-upload which being an Angular 2 component is written in Typescript.

Here's my initial try if anyone is interested.

declare module 'meteor/ostrio:files' {

    import {Mongo} from 'meteor/mongo';
    import {ReactiveVar} from 'meteor/reactive-var';

    export interface FilesCollectionOptions {
        storagePath?: string;
        collection?: Mongo.Collection<any>;
        collectionName?: string;
        continueUploadTTL?: string;
        cacheControl?: string;
        responseHeaders?: {[x: string]: string} | ((responseCode?, fileRef?, versionRef?, version?) => {[x: string]: string});
        throttle?: string;
        schema?: Object;
        chunkSize?: number;
        namingFunction?: Function;
        permissions?: number;
        parentDirPermissions?: number;
        integrityCheck?: boolean;
        strict?: boolean;
        downloadCallback?: Function;
        protected?: boolean | Function;
        public?: boolean;
        onBeforeUpload?: (fileData) => boolean | string;
        onInitiateUpload?: (fileData) => void;
        onBeforeRemove?: (cursor: Mongo.Cursor<any>) => boolean;
        onAfterUpload?: (Object) => any;
        onAfterRemove?: (Object) => any;
        onbeforeunloadMessage?: string | (() => string);
        allowClientCode?: boolean;
        debug?: boolean;
        interceptDownload?: (http, fileRef, version) => any;
    }

    export interface SearchOptions {
        sort?: Mongo.SortSpecifier;
        skip?: number;
        limit?: number;
        fields?: Mongo.FieldSpecifier;
        reactive?: boolean;
        transform?: Function;
    }

    export interface InsertOptions {
        file: File | Object | string;
        isBase64?: boolean;
        meta?: {[x: string]: any};
        transport?: 'ddp' | 'http'
        onStart?: (error: Object, fileData: Object) => any;
        onUploaded?: (error: Object, fileData: Object) => any;
        onAbort?: (fileData: Object) => any;
        onError?: (error: Object, fileData: Object) => any;
        onProgress?: (progress: number, fileData: Object) => any;
        onBeforeUpload?: (fileData: Object) => any;
        chunkSize?: number | 'dynamic';
        allowWebWorkers?: boolean;
    }

    export interface LoadOptions {
        fileName: string;
        meta?: Object;
        type?: string;
        size?: number;
    }

    export class FileUpload {
        file: File;
        onPause: ReactiveVar<boolean>;
        progress: ReactiveVar<number>;
        estimateTime: ReactiveVar<number>;
        estimateSpeed: ReactiveVar<number>;
        state: ReactiveVar<'active' | 'paused' | 'aborted' | 'completed'>;

        pause();

        continue();

        toggle();

        pipe();
    }

    export class FileCursor {
        remove(callback: (err) => void);

        link(): string;

        get(property: string): any;

        fetch(): Object[];

        with(): FileCursor;
    }

    export class FilesCursor extends Mongo.Cursor<any> {

        cursor: Mongo.Cursor<any>;

        get(): Object[];

        hasNext(): boolean;

        next(): Object;

        hasPrevious(): boolean;

        previous(): Object;

        fetch(): Object[]

        first(): Object;

        last(): Object;

        count(): number;

        remove(callback: (err) => void);

        forEach(callback: (doc)=>void, context: Object);

        each(): FileCursor[];

        map(callback: (doc)=>Object, context: Object): Object[];

        current(): Object | undefined;

        observe(callbacks: Mongo.ObserveCallbacks): Meteor.LiveQueryHandle;

        observeChanges(callbacks: Mongo.ObserveChangesCallbacks): Meteor.LiveQueryHandle;
    }

    export class FilesCollection {
        collection: Mongo.Collection<any>;
        schema: any;

        constructor(config: FilesCollectionOptions)

        find(selector?: Mongo.Selector, options?: SearchOptions): FilesCursor;

        findOne(selector?: Mongo.Selector, options?: SearchOptions): FileCursor;

        insert(settings: InsertOptions, autoStart: boolean): FileUpload;

        remove(select: Mongo.Selector, callback: (error)=>any): FilesCollection;

        link(fileRef: Object): string;

        allow(options: Mongo.AllowDenyOptions): void;

        deny(options: Mongo.AllowDenyOptions): void;

        denyClient(): void;

        on(event: string, callback: (fileRef) => void);

        unlink(fileRef: Object, version: string): FilesCollection;

        addFile(path: string, opts: LoadOptions, callback: (err: any, fileRef: Object) => any, proceedAfterUpload: boolean);

        load(url: string, opts: LoadOptions, callback: (err: any, fileRef: Object) => any, proceedAfterUpload: boolean);

        write(buffer: Buffer, opts: LoadOptions, callback: (err: any, fileRef: Object) => any, proceedAfterUpload: boolean);
    }
}

Edit: allowWebWorkers should be optional
Edit 2: I've made a few more changes. This will be my last update as while this package does have some good features it doesn't really fit into my app.

@dr-dimitru
Copy link
Member

Hi @Lavan ,

Is there any chance make a docs, like "TS definition" from your snippet?

@Lavan
Copy link
Author

Lavan commented Oct 4, 2016

@dr-dimitru what do you mean by docs like?

As I mentioned in my edit, I'm not using this package any more and I really don't have time to work on it anymore.

@Lavan Lavan closed this as completed Oct 4, 2016
@dr-dimitru
Copy link
Member

@Lavan sad to hear that.
I saw some developers already young your definitions within theirs TS apps.

Okay, hope someone who uses TS will make docs from it.

@Avijobo
Copy link

Avijobo commented Dec 16, 2016

Hi dr.dimitru,

Thanks for pointing me here. I am trying to update and further complete the definitions file

, however I still have a few questions:

  • In your docs you refer to FileObj, FileRef and FileData, which are all different objects. I think I have distinguished them all correctly, however I am confused about FileCursor. Is it correct to say that FileCursor extends FileObj with extra methods?

  • FilesCursor seems to extend Mongo.Cursor. Why is there still a 'cursor' member in there and what does it refer to : to the base Mongo.Cursor? What's the reason behind that?

Attached is a first attempt of my updated version. Would you or anyone else be able to roughly verify if this is more or less correct, and I don't make any wrong assumptions?

Thanks!

Avijobo

declare module "meteor/ostrio:files" {

	import { Mongo } from 'meteor/mongo';
	import { ReactiveVar } from 'meteor/reactive-var';

	class FileObj {
		size: number;
		name: string;
		type: string;
		path: string;
		isVideo: boolean;
		isAudio: boolean;
		isImage: boolean;
		isText: boolean;
		isJSON: boolean;
		isPDF: boolean;
		extension?: string;
		_storagePath: string;
		_downloadRoute: string;
		_collectionName: string;
		public?: boolean;
		meta?: Object;
		userid?: string;
		updatedAt?: Date;
		versions: Object;
	}

	type FileRef = any; // File record from Mongo DB... don't know the details yet

	interface FileData {
		size: number;
		type: string;
		mime: string;
		"mime-type": string;
		ext: string;
		extension: string;
		name: string;
	}

	interface FilesCollectionConfig {
		storagePath?: string;
		collection?: Mongo.Collection<any>;
		collectionName?: string;
		continueUploadTTL?: string;
		ddp?: Object;
		cacheControl?: string;
		responseHeaders?: { [x: string]: string } | ((responseCode?, fileRef?, versionRef?, version?) => { [x: string]: string });
		throttle?: number | boolean;
		downloadRoute?: string;
		schema?: Object;
		chunkSize?: number;
		namingFunction?: () => string;
		permissions?: number;
		parentDirPermissions?: number;
		integrityCheck?: boolean;
		strict?: boolean;
		downloadCallback?: (fileObj: FileObj) => boolean;
		protected?: boolean | ((fileObj: FileObj) => boolean | number);
		public?: boolean;
		onBeforeUpload?: (fileData: FileData) => boolean | string;
		onBeforeRemove?: (cursor: Mongo.Cursor<any>) => boolean;
		onInitiateUpload?: (fileData: FileData) => void;
		onAfterUpload?: (fileRef: FileRef) => any;
		onAfterRemove?: (files: Object[]) => any;
		onbeforeunloadMessage?: string | (() => string);
		allowClientCode?: boolean;
		debug?: boolean;
		interceptDownload?: (http: any, fileRef: any, version: string) => boolean;
	}

	export interface SearchOptions {
		sort?: Mongo.SortSpecifier;
		skip?: number;
		limit?: number;
		fields?: Mongo.FieldSpecifier;
		reactive?: boolean;
		transform?: Function;
	}

	export interface InsertOptions {
		file: File | Object | string;
		isBase64?: boolean;
		meta?: { [x: string]: any };
		transport?: 'ddp' | 'http'
		onStart?: (error: Object, fileData: Object) => any;
		onUploaded?: (error: Object, fileData: Object) => any;
		onAbort?: (fileData: Object) => any;
		onError?: (error: Object, fileData: Object) => any;
		onProgress?: (progress: number, fileData: Object) => any;
		onBeforeUpload?: (fileData: Object) => any;
		streams?: number | 'dynamic';
		chunkSize?: number | 'dynamic';
		allowWebWorkers?: boolean;
	}

	export interface LoadOptions {
		fileName: string;
		meta?: Object;
		type?: string;
		size?: number;
	}

	export class FileUpload {
		file: File;
		onPause: ReactiveVar<boolean>;
		progress: ReactiveVar<number>;
		estimateTime: ReactiveVar<number>;
		estimateSpeed: ReactiveVar<number>;
		state: ReactiveVar<'active' | 'paused' | 'aborted' | 'completed'>;

		pause();
		continue();
		toggle();
		pipe();
		start();
		on(event: string, callback: Function): void;
	}

	export class FileCursor extends FileObj { // Is it correct to say that it extends FileObj?
		remove(callback: (err) => void): void;
		link(): string;
		get(property: string): Object | any;
		fetch(): Object[];
		with(): ReactiveVar<FileCursor>;
	}

	export class FilesCursor extends Mongo.Cursor<FileObj> {
		cursor: Mongo.Cursor<FileObj>; // Refers to base cursor? Why is this existing?

		get(): Object[];
		hasNext(): boolean;
		next(): Object;
		hasPrevious(): boolean;
		previous(): Object;
		first(): Object;
		last(): Object;
		remove(callback: (err) => void): void;
		each(): FileCursor[];
		current(): Object | undefined;
	}

	export class FilesCollection {
		collection: Mongo.Collection<FileObj>;
		schema: any;

		constructor(config: FilesCollectionConfig)

		find(selector?: Mongo.Selector, options?: SearchOptions): FilesCursor;
		findOne(selector?: Mongo.Selector, options?: SearchOptions): FileCursor;
		insert(settings: InsertOptions, autoStart?: boolean): FileUpload;
		remove(select: Mongo.Selector, callback: (error) => any): FilesCollection;
		link(fileRef: FileRef, version?: string): string;
		allow(options: Mongo.AllowDenyOptions): void;
		deny(options: Mongo.AllowDenyOptions): void;
		denyClient(): void;
		on(event: string, callback: (fileRef: FileRef) => void): void;
		unlink(fileRef: FileRef, version?: string): FilesCollection;
		addFile(path: string, opts: LoadOptions, callback: (err: any, fileRef: FileRef) => any, proceedAfterUpload: boolean);
		load(url: string, opts: LoadOptions, callback: (err: any, fileRef: FileRef) => any, proceedAfterUpload: boolean);
		write(buffer: Buffer, opts: LoadOptions, callback: (err: any, fileRef: FileRef) => any, proceedAfterUpload: boolean);
	}
}

@vjau
Copy link

vjau commented Mar 25, 2020

I have updated @Avijobo version, there was a typo on fileObj userId

declare module "meteor/ostrio:files" {

	import { Mongo } from 'meteor/mongo';
	import { ReactiveVar } from 'meteor/reactive-var';

	class FileObj {
		size: number;
		name: string;
		type: string;
		path: string;
		isVideo: boolean;
		isAudio: boolean;
		isImage: boolean;
		isText: boolean;
		isJSON: boolean;
		isPDF: boolean;
		extension?: string;
		_storagePath: string;
		_downloadRoute: string;
		_collectionName: string;
		public?: boolean;
		meta?: Object;
		userId?: string;
		updatedAt?: Date;
		versions: Object;
	}

	type FileRef = any; // File record from Mongo DB... don't know the details yet

	interface FileData {
		size: number;
		type: string;
		mime: string;
		"mime-type": string;
		ext: string;
		extension: string;
		name: string;
	}

	interface FilesCollectionConfig {
		storagePath?: string;
		collection?: Mongo.Collection<any>;
		collectionName?: string;
		continueUploadTTL?: string;
		ddp?: Object;
		cacheControl?: string;
		responseHeaders?: { [x: string]: string } | ((responseCode?, fileRef?, versionRef?, version?) => { [x: string]: string });
		throttle?: number | boolean;
		downloadRoute?: string;
		schema?: Object;
		chunkSize?: number;
		namingFunction?: () => string;
		permissions?: number;
		parentDirPermissions?: number;
		integrityCheck?: boolean;
		strict?: boolean;
		downloadCallback?: (fileObj: FileObj) => boolean;
		protected?: boolean | ((fileObj: FileObj) => boolean | number);
		public?: boolean;
		onBeforeUpload?: (fileData: FileData) => boolean | string;
		onBeforeRemove?: (cursor: Mongo.Cursor<any>) => boolean;
		onInitiateUpload?: (fileData: FileData) => void;
		onAfterUpload?: (fileRef: FileRef) => any;
		onAfterRemove?: (files: Object[]) => any;
		onbeforeunloadMessage?: string | (() => string);
		allowClientCode?: boolean;
		debug?: boolean;
		interceptDownload?: (http: any, fileRef: any, version: string) => boolean;
	}

	export interface SearchOptions {
		sort?: Mongo.SortSpecifier;
		skip?: number;
		limit?: number;
		fields?: Mongo.FieldSpecifier;
		reactive?: boolean;
		transform?: Function;
	}

	export interface InsertOptions {
		file: File | Object | string;
		isBase64?: boolean;
		meta?: { [x: string]: any };
		transport?: 'ddp' | 'http'
		onStart?: (error: Object, fileData: Object) => any;
		onUploaded?: (error: Object, fileData: Object) => any;
		onAbort?: (fileData: Object) => any;
		onError?: (error: Object, fileData: Object) => any;
		onProgress?: (progress: number, fileData: Object) => any;
		onBeforeUpload?: (fileData: Object) => any;
		streams?: number | 'dynamic';
		chunkSize?: number | 'dynamic';
		allowWebWorkers?: boolean;
	}

	export interface LoadOptions {
		fileName: string;
		meta?: Object;
		type?: string;
		size?: number;
	}

	export class FileUpload {
		file: File;
		onPause: ReactiveVar<boolean>;
		progress: ReactiveVar<number>;
		estimateTime: ReactiveVar<number>;
		estimateSpeed: ReactiveVar<number>;
		state: ReactiveVar<'active' | 'paused' | 'aborted' | 'completed'>;

		pause();
		continue();
		toggle();
		pipe();
		start();
		on(event: string, callback: Function): void;
	}

	export class FileCursor extends FileObj { // Is it correct to say that it extends FileObj?
		remove(callback: (err) => void): void;
		link(): string;
		get(property: string): Object | any;
		fetch(): Object[];
		with(): ReactiveVar<FileCursor>;
	}

	export class FilesCursor extends Mongo.Cursor<FileObj> {
		cursor: Mongo.Cursor<FileObj>; // Refers to base cursor? Why is this existing?

		get(): Object[];
		hasNext(): boolean;
		next(): Object;
		hasPrevious(): boolean;
		previous(): Object;
		first(): Object;
		last(): Object;
		remove(callback: (err) => void): void;
		each(): FileCursor[];
		current(): Object | undefined;
	}

	export class FilesCollection {
		collection: Mongo.Collection<FileObj>;
		schema: any;

		constructor(config: FilesCollectionConfig)

		find(selector?: Mongo.Selector, options?: SearchOptions): FilesCursor;
		findOne(selector?: Mongo.Selector, options?: SearchOptions): FileCursor;
		insert(settings: InsertOptions, autoStart?: boolean): FileUpload;
		remove(select: Mongo.Selector, callback: (error) => any): FilesCollection;
		link(fileRef: FileRef, version?: string): string;
		allow(options: Mongo.AllowDenyOptions): void;
		deny(options: Mongo.AllowDenyOptions): void;
		denyClient(): void;
		on(event: string, callback: (fileRef: FileRef) => void): void;
		unlink(fileRef: FileRef, version?: string): FilesCollection;
		addFile(path: string, opts: LoadOptions, callback: (err: any, fileRef: FileRef) => any, proceedAfterUpload: boolean);
		load(url: string, opts: LoadOptions, callback: (err: any, fileRef: FileRef) => any, proceedAfterUpload: boolean);
		write(buffer: Buffer, opts: LoadOptions, callback: (err: any, fileRef: FileRef) => any, proceedAfterUpload: boolean);
	}
}

@OliverColeman
Copy link
Contributor

OliverColeman commented Apr 30, 2020

Here's yet more changes:

  • fixes a couple of bugs (eg FilesCollectionConfig.storagePath should also accept a function); and
  • adds a generic parameter, M, to set the type of the meta field.
// defs for meteor/ostrio:files, adapted from https://github.com/VeliovGroup/Meteor-Files/issues/226#issuecomment-603940729

declare module "meteor/ostrio:files" {

	import { Mongo } from 'meteor/mongo';
	import { ReactiveVar } from 'meteor/reactive-var';

	class FileObj<M> {
		size: number;
		name: string;
		type: string;
		path: string;
		isVideo: boolean;
		isAudio: boolean;
		isImage: boolean;
		isText: boolean;
		isJSON: boolean;
		isPDF: boolean;
		extension?: string;
		_storagePath: string;
		_downloadRoute: string;
		_collectionName: string;
		public?: boolean;
		meta?: M;
		userId?: string;
		updatedAt?: Date;
		versions: Object;
	}

	type FileRef = any; // File record from Mongo DB... don't know the details yet

	interface FileData<M> {
		size: number;
		type: string;
		mime: string;
		"mime-type": string;
		ext: string;
		extension: string;
    name: string;
    meta: M;
	}

	interface FilesCollectionConfig<M> {
		storagePath?: string | ((fileObj: FileObj<M>) => string);
		collection?: Mongo.Collection<any>;
		collectionName?: string;
		continueUploadTTL?: string;
		ddp?: Object;
		cacheControl?: string;
		responseHeaders?: { [x: string]: string } | ((responseCode?, fileRef?, versionRef?, version?) => { [x: string]: string });
		throttle?: number | boolean;
		downloadRoute?: string;
		schema?: Object;
		chunkSize?: number;
		namingFunction?: (fileObj: FileObj<M>) => string;
		permissions?: number;
		parentDirPermissions?: number;
		integrityCheck?: boolean;
		strict?: boolean;
		downloadCallback?: (fileObj: FileObj<M>) => boolean;
		protected?: boolean | ((fileObj: FileObj<M>) => boolean | number);
		public?: boolean;
		onBeforeUpload?: (fileData: FileData<M>) => boolean | string;
		onBeforeRemove?: (cursor: Mongo.Cursor<any>) => boolean;
		onInitiateUpload?: (fileData: FileData<M>) => void;
		onAfterUpload?: (fileRef: FileRef) => any;
		onAfterRemove?: (files: Object[]) => any;
		onbeforeunloadMessage?: string | (() => string);
		allowClientCode?: boolean;
		debug?: boolean;
		interceptDownload?: (http: any, fileRef: any, version: string) => boolean;
	}

	export interface SearchOptions {
		sort?: Mongo.SortSpecifier;
		skip?: number;
		limit?: number;
		fields?: Mongo.FieldSpecifier;
		reactive?: boolean;
		transform?: Function;
	}

	export interface InsertOptions {
		file: File | Object | string;
		isBase64?: boolean;
		meta?: { [x: string]: any };
		transport?: 'ddp' | 'http'
		onStart?: (error: Object, fileData: Object) => any;
		onUploaded?: (error: Object, fileData: Object) => any;
		onAbort?: (fileData: Object) => any;
		onError?: (error: Object, fileData: Object) => any;
		onProgress?: (progress: number, fileData: Object) => any;
		onBeforeUpload?: (fileData: Object) => any;
		streams?: number | 'dynamic';
		chunkSize?: number | 'dynamic';
		allowWebWorkers?: boolean;
	}

	export interface LoadOptions<M> {
		fileName: string;
		meta?: M;
		type?: string;
		size?: number;
	}

	export class FileUpload {
		file: File;
		onPause: ReactiveVar<boolean>;
		progress: ReactiveVar<number>;
		estimateTime: ReactiveVar<number>;
		estimateSpeed: ReactiveVar<number>;
		state: ReactiveVar<'active' | 'paused' | 'aborted' | 'completed'>;

		pause();
		continue();
		toggle();
		pipe();
		start();
		on(event: string, callback: Function): void;
	}

	export class FileCursor<M> extends FileObj<M> { // Is it correct to say that it extends FileObj?
		remove(callback: (err) => void): void;
		link(): string;
		get(property: string): Object | any;
		fetch(): Object[];
		with(): ReactiveVar<FileCursor<M>>;
	}

	export class FilesCursor<M> extends Mongo.Cursor<FileObj<M>> {
		cursor: Mongo.Cursor<FileObj<M>>; // Refers to base cursor? Why is this existing?

		get(): Object[];
		hasNext(): boolean;
		next(): Object;
		hasPrevious(): boolean;
		previous(): Object;
		first(): Object;
		last(): Object;
		remove(callback: (err) => void): void;
		each(): FileCursor<M>[];
		current(): Object | undefined;
	}

	export class FilesCollection<M> {
		collection: Mongo.Collection<FileObj<M>>;
		schema: any;

		constructor(config: FilesCollectionConfig<M>)

		find(selector?: Mongo.Selector<FileObj<M>>, options?: SearchOptions): FilesCursor<M>;
		findOne(selector?: Mongo.Selector<FileObj<M>>, options?: SearchOptions): FileCursor<M>;
		insert(settings: InsertOptions, autoStart?: boolean): FileUpload;
		remove(select: Mongo.Selector<FileObj<M>>, callback: (error) => any): FilesCollection<M>;
		link(fileRef: FileRef, version?: string): string;
		allow(options: Mongo.AllowDenyOptions): void;
		deny(options: Mongo.AllowDenyOptions): void;
		denyClient(): void;
		on(event: string, callback: (fileRef: FileRef) => void): void;
		unlink(fileRef: FileRef, version?: string): FilesCollection<M>;
		addFile(path: string, opts: LoadOptions<M>, callback: (err: any, fileRef: FileRef) => any, proceedAfterUpload: boolean);
		load(url: string, opts: LoadOptions<M>, callback: (err: any, fileRef: FileRef) => any, proceedAfterUpload: boolean);
		write(buffer: Buffer, opts: LoadOptions<M>, callback: (err: any, fileRef: FileRef) => any, proceedAfterUpload: boolean);
	}
}

@dr-dimitru
Copy link
Member

@OliverColeman thank you for contribution!

Feel free to send a PR to the docs, here's original file — https://github.com/VeliovGroup/Meteor-Files/blob/dev/docs/typescript-definitions.md

Please, make sure you're pushing to dev branch;

@dr-dimitru
Copy link
Member

Reopening as updates submitted by @OliverColeman are pending for PR

@dr-dimitru dr-dimitru reopened this May 2, 2020
@dr-dimitru
Copy link
Member

Closed with #743, thanks to @OliverColeman

dr-dimitru added a commit that referenced this issue May 4, 2020
- 🐞 Fix #742, thanks to @menelike and @jankapunkt
- 🤓 Update *TypeScript* definitions, thanks to @OliverColeman PR #743,
see #226 thread for details
- 🤝 Compatibility with `meteor@1.10.2`
- 📋 Documentation update to address issue described in #737, thanks to
@menelike, @Lickshotz, @s-ol, and @jankapunkt
@dr-dimitru dr-dimitru mentioned this issue May 4, 2020
dr-dimitru added a commit that referenced this issue May 4, 2020
v1.14.2
- 🐞 Fix #742, thanks to @menelike and @jankapunkt 
- 🤓 Update *TypeScript* definitions, thanks to @OliverColeman PR #743, see #226 thread for details
- 🤝 Compatibility with `meteor@1.10.2`
- 📋 Documentation update to address issue described in #737, thanks to @menelike, @Lickshotz, @s-ol, and @jankapunkt
@Delph
Copy link

Delph commented Apr 19, 2022

Shouldn't the type for FileUpload's on member be on(event: string, callback(error: unknown, obj: FileObj<MetadataType>) => void): void? With perhaps a proper type for error rather than unknown, I'm not sure what that should be right now.

@dr-dimitru
Copy link
Member

dr-dimitru commented Jun 13, 2022

@Delph thank you for the addition
@Lavan can you check on the suggestion over your PR, please?

@Delph
Copy link

Delph commented Jun 14, 2022

I now have;

  type FileUploadCallback<MetadataType> = ((error: unknown, obj: FileObj<MetadataType>) => void) |
    ((progress: number, obj: FileObj<MetadataType>) => void)

  class FileUpload<MetadataType> {
      file: File;
      onPause: ReactiveVar<boolean>;
      progress: ReactiveVar<number>;
      estimateTime: ReactiveVar<number>;
      estimateSpeed: ReactiveVar<number>;
      state: ReactiveVar<'active' | 'paused' | 'aborted' | 'completed'>;
      pause(): void;
      continue(): void;
      toggle(): void;
      pipe(): void;
      start(): void;
      on(event: string, callback: FileUploadCallback<MetadataType>): void;
  }

@dr-dimitru
Copy link
Member

@Delph do you wish to PR into typescript-definitions.md ?

@Lavan
Copy link
Author

Lavan commented Jun 15, 2022

I have no comment at all regarding this. I haven't used meteor at all these last 4-5 years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants