appwrite/sdk-for-node

๐Ÿ› Bug Report: Some Classes not present in Typescript Module

Y4shin opened this issue ยท 2 comments

๐Ÿ‘Ÿ Reproduction steps

Installing the Node SDK, importing the Permission and/or Role class and compiling with tsc.

Import Statement

import sdk, {Permission, Role} from 'node-appwrite';

package.json

{
	"name": "appwrite-function",
	"version": "1.0.0",
	"description": "",
	"main": "src/index.js",
	"scripts": {
		"test": "echo \"Error: no test specified\" && exit 1",
		"build": "npx tsc"
	},
	"keywords": [],
	"author": "",
	"license": "ISC",
	"dependencies": {
		"node-appwrite": "^8.0.0",
		"typescript": "^4.8.3"
	}
}

๐Ÿ‘ Expected behavior

Import the classes.

๐Ÿ‘Ž Actual Behavior

Raises an error for each of the two classes during Typescript Compilation:

user@host someFolder % npm run build

> appwrite-function@1.0.0 build
> npx tsc

src/index.ts:1:14 - error TS2305: Module '"node-appwrite"' has no exported member 'Permission'.

1 import sdk, {Permission, Role} from 'node-appwrite';
               ~~~~~~~~~~

src/index.ts:1:26 - error TS2305: Module '"node-appwrite"' has no exported member 'Role'.

1 import sdk, {Permission, Role} from 'node-appwrite';
                           ~~~~


Found 2 errors in the same file, starting at: src/index.ts:1

The error does not appear, when manually adding these Lines into the index.d.ts file after line 1719 (into the root namespace of the node-appwritemodule):

export class Permission {
    static read(role: string): string;
    static write(role: string): string;
    static create(role: string): string;
    static update(role: string): string;
    static delete(role: string): string;
  }
  export class Role {
    static any(): string;
    static user(id: string, status?: string): string;
    static users(status?: string): string;
    static guests(): string;
    static team(id, role?: string): string;
    static member(id): string;
    static status(status: string): string;
  }

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

Appwrite Version: 1.0.1
node-appwrite Version: ^8.0.0
tsc Version: 4.8.3

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

@Y4shin, thanks for raising this issue! ๐Ÿ™

@Meldiron, would you be able to handle this?

Closing as this should be resolved now. Feel free to comment if it is not and I can re-open it.

sdk-for-node/index.d.ts

Lines 1845 to 1860 in 0fac3f6

export class Permission {
static read(role: string): string;
static write(role: string): string;
static create(role: string): string;
static update(role: string): string;
static delete(role: string): string;
}
export class Role {
static any(): string;
static user(id: string, status?: string): string;
static users(status?: string): string;
static guests(): string;
static team(id: string, role?: string): string;
static member(id: string): string;
}