forked from appwrite/sdk-for-react-native
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: Add TypeScript definitions for client-side SDK
TypeScript definitions have been added to enhance the development experience when using the Appwrite client-side SDK. These definitions include interfaces, types, and enums that correspond to various Appwrite services such as account management, storage, databases, and more. This allows developers to leverage TypeScript's static type checking for better code quality and easier maintenance.
- Loading branch information
Showing
27 changed files
with
3,375 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
dist/ | ||
node_modules/ | ||
types/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
import { Models } from './models'; | ||
|
||
declare type Payload = { | ||
[key: string]: any; | ||
}; | ||
declare type Headers = { | ||
[key: string]: string; | ||
}; | ||
export declare type RealtimeResponseEvent<T extends unknown> = { | ||
events: string[]; | ||
channels: string[]; | ||
timestamp: number; | ||
payload: T; | ||
}; | ||
export declare type UploadProgress = { | ||
$id: string; | ||
progress: number; | ||
sizeUploaded: number; | ||
chunksTotal: number; | ||
chunksUploaded: number; | ||
}; | ||
declare class AppwriteException extends Error { | ||
code: number; | ||
response: string; | ||
type: string; | ||
constructor(message: string, code?: number, type?: string, response?: string); | ||
} | ||
declare class Client { | ||
config: { | ||
endpoint: string; | ||
endpointRealtime: string; | ||
project: string; | ||
jwt: string; | ||
locale: string; | ||
session: string; | ||
platform: string; | ||
}; | ||
headers: Headers; | ||
/** | ||
* Set Endpoint | ||
* | ||
* Your project endpoint | ||
* | ||
* @param {string} endpoint | ||
* | ||
* @returns {this} | ||
*/ | ||
setEndpoint(endpoint: string): this; | ||
/** | ||
* Set Realtime Endpoint | ||
* | ||
* @param {string} endpointRealtime | ||
* | ||
* @returns {this} | ||
*/ | ||
setEndpointRealtime(endpointRealtime: string): this; | ||
/** | ||
* Set platform | ||
* | ||
* Set platform. Will be used as origin for all requests. | ||
* | ||
* @param {string} platform | ||
* @returns {this} | ||
*/ | ||
setPlatform(platform: string): this; | ||
/** | ||
* Set Project | ||
* | ||
* Your project ID | ||
* | ||
* @param value string | ||
* | ||
* @return {this} | ||
*/ | ||
setProject(value: string): this; | ||
/** | ||
* Set JWT | ||
* | ||
* Your secret JSON Web Token | ||
* | ||
* @param value string | ||
* | ||
* @return {this} | ||
*/ | ||
setJWT(value: string): this; | ||
/** | ||
* Set Locale | ||
* | ||
* @param value string | ||
* | ||
* @return {this} | ||
*/ | ||
setLocale(value: string): this; | ||
/** | ||
* Set Session | ||
* | ||
* The user session to authenticate with | ||
* | ||
* @param value string | ||
* | ||
* @return {this} | ||
*/ | ||
setSession(value: string): this; | ||
private realtime; | ||
/** | ||
* Subscribes to Appwrite events and passes you the payload in realtime. | ||
* | ||
* @param {string|string[]} channels | ||
* Channel to subscribe - pass a single channel as a string or multiple with an array of strings. | ||
* | ||
* Possible channels are: | ||
* - account | ||
* - collections | ||
* - collections.[ID] | ||
* - collections.[ID].documents | ||
* - documents | ||
* - documents.[ID] | ||
* - files | ||
* - files.[ID] | ||
* - executions | ||
* - executions.[ID] | ||
* - functions.[ID] | ||
* - teams | ||
* - teams.[ID] | ||
* - memberships | ||
* - memberships.[ID] | ||
* @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update. | ||
* @returns {() => void} Unsubscribes from events. | ||
*/ | ||
subscribe<T extends unknown>( | ||
channels: string | string[], | ||
callback: (payload: RealtimeResponseEvent<T>) => void, | ||
): () => void; | ||
call(method: string, url: URL, headers?: Headers, params?: Payload): Promise<any>; | ||
} | ||
export { Client, AppwriteException }; | ||
export type { Models, Payload }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export declare enum AuthenticationFactor { | ||
Email = 'email', | ||
Phone = 'phone', | ||
Totp = 'totp', | ||
Recoverycode = 'recoverycode', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export declare enum AuthenticatorType { | ||
Totp = 'totp', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export declare enum Browser { | ||
AvantBrowser = 'aa', | ||
AndroidWebViewBeta = 'an', | ||
GoogleChrome = 'ch', | ||
GoogleChromeIOS = 'ci', | ||
GoogleChromeMobile = 'cm', | ||
Chromium = 'cr', | ||
MozillaFirefox = 'ff', | ||
Safari = 'sf', | ||
MobileSafari = 'mf', | ||
MicrosoftEdge = 'ps', | ||
MicrosoftEdgeIOS = 'oi', | ||
OperaMini = 'om', | ||
Opera = 'op', | ||
OperaNext = 'on', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export declare enum CreditCard { | ||
AmericanExpress = 'amex', | ||
Argencard = 'argencard', | ||
Cabal = 'cabal', | ||
Consosud = 'censosud', | ||
DinersClub = 'diners', | ||
Discover = 'discover', | ||
Elo = 'elo', | ||
Hipercard = 'hipercard', | ||
JCB = 'jcb', | ||
Mastercard = 'mastercard', | ||
Naranja = 'naranja', | ||
TarjetaShopping = 'targeta-shopping', | ||
UnionChinaPay = 'union-china-pay', | ||
Visa = 'visa', | ||
MIR = 'mir', | ||
Maestro = 'maestro', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export declare enum ExecutionMethod { | ||
GET = 'GET', | ||
POST = 'POST', | ||
PUT = 'PUT', | ||
PATCH = 'PATCH', | ||
DELETE = 'DELETE', | ||
OPTIONS = 'OPTIONS', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
export declare enum Flag { | ||
Afghanistan = 'af', | ||
Angola = 'ao', | ||
Albania = 'al', | ||
Andorra = 'ad', | ||
UnitedArabEmirates = 'ae', | ||
Argentina = 'ar', | ||
Armenia = 'am', | ||
AntiguaAndBarbuda = 'ag', | ||
Australia = 'au', | ||
Austria = 'at', | ||
Azerbaijan = 'az', | ||
Burundi = 'bi', | ||
Belgium = 'be', | ||
Benin = 'bj', | ||
BurkinaFaso = 'bf', | ||
Bangladesh = 'bd', | ||
Bulgaria = 'bg', | ||
Bahrain = 'bh', | ||
Bahamas = 'bs', | ||
BosniaAndHerzegovina = 'ba', | ||
Belarus = 'by', | ||
Belize = 'bz', | ||
Bolivia = 'bo', | ||
Brazil = 'br', | ||
Barbados = 'bb', | ||
BruneiDarussalam = 'bn', | ||
Bhutan = 'bt', | ||
Botswana = 'bw', | ||
CentralAfricanRepublic = 'cf', | ||
Canada = 'ca', | ||
Switzerland = 'ch', | ||
Chile = 'cl', | ||
China = 'cn', | ||
CoteDIvoire = 'ci', | ||
Cameroon = 'cm', | ||
DemocraticRepublicOfTheCongo = 'cd', | ||
RepublicOfTheCongo = 'cg', | ||
Colombia = 'co', | ||
Comoros = 'km', | ||
CapeVerde = 'cv', | ||
CostaRica = 'cr', | ||
Cuba = 'cu', | ||
Cyprus = 'cy', | ||
CzechRepublic = 'cz', | ||
Germany = 'de', | ||
Djibouti = 'dj', | ||
Dominica = 'dm', | ||
Denmark = 'dk', | ||
DominicanRepublic = 'do', | ||
Algeria = 'dz', | ||
Ecuador = 'ec', | ||
Egypt = 'eg', | ||
Eritrea = 'er', | ||
Spain = 'es', | ||
Estonia = 'ee', | ||
Ethiopia = 'et', | ||
Finland = 'fi', | ||
Fiji = 'fj', | ||
France = 'fr', | ||
MicronesiaFederatedStatesOf = 'fm', | ||
Gabon = 'ga', | ||
UnitedKingdom = 'gb', | ||
Georgia = 'ge', | ||
Ghana = 'gh', | ||
Guinea = 'gn', | ||
Gambia = 'gm', | ||
GuineaBissau = 'gw', | ||
EquatorialGuinea = 'gq', | ||
Greece = 'gr', | ||
Grenada = 'gd', | ||
Guatemala = 'gt', | ||
Guyana = 'gy', | ||
Honduras = 'hn', | ||
Croatia = 'hr', | ||
Haiti = 'ht', | ||
Hungary = 'hu', | ||
Indonesia = 'id', | ||
India = 'in', | ||
Ireland = 'ie', | ||
IranIslamicRepublicOf = 'ir', | ||
Iraq = 'iq', | ||
Iceland = 'is', | ||
Israel = 'il', | ||
Italy = 'it', | ||
Jamaica = 'jm', | ||
Jordan = 'jo', | ||
Japan = 'jp', | ||
Kazakhstan = 'kz', | ||
Kenya = 'ke', | ||
Kyrgyzstan = 'kg', | ||
Cambodia = 'kh', | ||
Kiribati = 'ki', | ||
SaintKittsAndNevis = 'kn', | ||
SouthKorea = 'kr', | ||
Kuwait = 'kw', | ||
LaoPeopleSDemocraticRepublic = 'la', | ||
Lebanon = 'lb', | ||
Liberia = 'lr', | ||
Libya = 'ly', | ||
SaintLucia = 'lc', | ||
Liechtenstein = 'li', | ||
SriLanka = 'lk', | ||
Lesotho = 'ls', | ||
Lithuania = 'lt', | ||
Luxembourg = 'lu', | ||
Latvia = 'lv', | ||
Morocco = 'ma', | ||
Monaco = 'mc', | ||
Moldova = 'md', | ||
Madagascar = 'mg', | ||
Maldives = 'mv', | ||
Mexico = 'mx', | ||
MarshallIslands = 'mh', | ||
NorthMacedonia = 'mk', | ||
Mali = 'ml', | ||
Malta = 'mt', | ||
Myanmar = 'mm', | ||
Montenegro = 'me', | ||
Mongolia = 'mn', | ||
Mozambique = 'mz', | ||
Mauritania = 'mr', | ||
Mauritius = 'mu', | ||
Malawi = 'mw', | ||
Malaysia = 'my', | ||
Namibia = 'na', | ||
Niger = 'ne', | ||
Nigeria = 'ng', | ||
Nicaragua = 'ni', | ||
Netherlands = 'nl', | ||
Norway = 'no', | ||
Nepal = 'np', | ||
Nauru = 'nr', | ||
NewZealand = 'nz', | ||
Oman = 'om', | ||
Pakistan = 'pk', | ||
Panama = 'pa', | ||
Peru = 'pe', | ||
Philippines = 'ph', | ||
Palau = 'pw', | ||
PapuaNewGuinea = 'pg', | ||
Poland = 'pl', | ||
FrenchPolynesia = 'pf', | ||
NorthKorea = 'kp', | ||
Portugal = 'pt', | ||
Paraguay = 'py', | ||
Qatar = 'qa', | ||
Romania = 'ro', | ||
Russia = 'ru', | ||
Rwanda = 'rw', | ||
SaudiArabia = 'sa', | ||
Sudan = 'sd', | ||
Senegal = 'sn', | ||
Singapore = 'sg', | ||
SolomonIslands = 'sb', | ||
SierraLeone = 'sl', | ||
ElSalvador = 'sv', | ||
SanMarino = 'sm', | ||
Somalia = 'so', | ||
Serbia = 'rs', | ||
SouthSudan = 'ss', | ||
SaoTomeAndPrincipe = 'st', | ||
Suriname = 'sr', | ||
Slovakia = 'sk', | ||
Slovenia = 'si', | ||
Sweden = 'se', | ||
Eswatini = 'sz', | ||
Seychelles = 'sc', | ||
Syria = 'sy', | ||
Chad = 'td', | ||
Togo = 'tg', | ||
Thailand = 'th', | ||
Tajikistan = 'tj', | ||
Turkmenistan = 'tm', | ||
TimorLeste = 'tl', | ||
Tonga = 'to', | ||
TrinidadAndTobago = 'tt', | ||
Tunisia = 'tn', | ||
Turkey = 'tr', | ||
Tuvalu = 'tv', | ||
Tanzania = 'tz', | ||
Uganda = 'ug', | ||
Ukraine = 'ua', | ||
Uruguay = 'uy', | ||
UnitedStates = 'us', | ||
Uzbekistan = 'uz', | ||
VaticanCity = 'va', | ||
SaintVincentAndTheGrenadines = 'vc', | ||
Venezuela = 've', | ||
Vietnam = 'vn', | ||
Vanuatu = 'vu', | ||
Samoa = 'ws', | ||
Yemen = 'ye', | ||
SouthAfrica = 'za', | ||
Zambia = 'zm', | ||
Zimbabwe = 'zw', | ||
} |
Oops, something went wrong.