abp.d.ts 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. declare namespace abp {
  2. let appPath: string;
  3. let pageLoadTime: Date;
  4. function toAbsAppPath(path: string): string;
  5. namespace multiTenancy {
  6. enum sides {
  7. TENANT = 1,
  8. HOST = 2
  9. }
  10. let isEnabled: boolean;
  11. let tenantIdCookieName: string;
  12. function setTenantIdCookie(tenantId?: number): void;
  13. function getTenantIdCookie(): number;
  14. }
  15. interface IAbpSession {
  16. readonly userId?: number;
  17. readonly tenantId?: number;
  18. readonly impersonatorUserId?: number;
  19. readonly impersonatorTenantId?: number;
  20. readonly multiTenancySide: multiTenancy.sides;
  21. }
  22. let session: IAbpSession;
  23. namespace localization {
  24. interface ILanguageInfo {
  25. name: string;
  26. displayName: string;
  27. icon: string;
  28. isDefault: boolean;
  29. isDisabled: boolean;
  30. }
  31. interface ILocalizationSource {
  32. name: string;
  33. type: string;
  34. }
  35. let languages: ILanguageInfo[];
  36. let currentLanguage: ILanguageInfo;
  37. let sources: ILocalizationSource[];
  38. let defaultSourceName: string;
  39. let values: { [key: string]: string };
  40. let abpWeb: (key: string) => string;
  41. function localize(key: string, sourceName: string): string;
  42. function getSource(sourceName: string): (key: string) => string;
  43. function isCurrentCulture(name: string): boolean;
  44. }
  45. namespace auth {
  46. let allPermissions: { [name: string]: boolean };
  47. let grantedPermissions: { [name: string]: boolean };
  48. function isGranted(permissionName: string): boolean;
  49. function isAnyGranted(...args: string[]): boolean;
  50. function areAllGranted(...args: string[]): boolean;
  51. let tokenCookieName: string;
  52. /**
  53. * Saves auth token.
  54. * @param authToken The token to be saved.
  55. * @param expireDate Optional expire date. If not specified, token will be deleted at end of the session.
  56. */
  57. function setToken(authToken: string, expireDate?: Date): void;
  58. function getToken(): string;
  59. function clearToken(): void;
  60. }
  61. namespace features {
  62. interface IFeature {
  63. value: string;
  64. }
  65. let allFeatures: { [name: string]: IFeature };
  66. function get(name: string): IFeature;
  67. function getValue(name: string): string;
  68. function isEnabled(name: string): boolean;
  69. }
  70. namespace setting {
  71. let values: { [name: string]: string };
  72. function get(name: string): string;
  73. function getBoolean(name: string): boolean;
  74. function getInt(name: string): number;
  75. enum settingScopes {
  76. Application = 1,
  77. Tenant = 2,
  78. User = 4
  79. }
  80. }
  81. namespace nav {
  82. interface IMenu {
  83. name: string;
  84. displayName?: string;
  85. customData?: any;
  86. items: IMenuItem[];
  87. }
  88. interface IMenuItem {
  89. name: string;
  90. order: number;
  91. displayName?: string;
  92. icon?: string;
  93. url?: string;
  94. customData?: any;
  95. items: IMenuItem[];
  96. }
  97. let menus: { [name: string]: IMenu };
  98. }
  99. namespace notifications {
  100. enum severity {
  101. INFO,
  102. SUCCESS,
  103. WARN,
  104. ERROR,
  105. FATAL
  106. }
  107. enum userNotificationState {
  108. UNREAD,
  109. READ
  110. }
  111. //TODO: We can extend this interface to define built-in notification types, like ILocalizableMessageNotificationData
  112. interface INotificationData {
  113. type: string;
  114. properties: any;
  115. }
  116. interface INotification {
  117. id: string;
  118. notificationName: string;
  119. severity: severity;
  120. entityType?: any;
  121. entityTypeName?: string;
  122. entityId?: any;
  123. data: INotificationData;
  124. creationTime: Date;
  125. }
  126. interface IUserNotification {
  127. id: string;
  128. userId: number;
  129. state: userNotificationState;
  130. notification: INotification;
  131. }
  132. let messageFormatters: any;
  133. function getUserNotificationStateAsString(userNotificationState: userNotificationState): string;
  134. function getUiNotifyFuncBySeverity(severity: severity): (message: string, title?: string, options?: any) => void;
  135. function getFormattedMessageFromUserNotification(userNotification: IUserNotification): string;
  136. function showUiNotifyForUserNotification(userNotification: IUserNotification, options?: any): void;
  137. }
  138. namespace log {
  139. enum levels {
  140. DEBUG,
  141. INFO,
  142. WARN,
  143. ERROR,
  144. FATAL
  145. }
  146. let level: levels;
  147. function log(logObject?: any, logLevel?: levels): void;
  148. function debug(logObject?: any): void;
  149. function info(logObject?: any): void;
  150. function warn(logObject?: any): void;
  151. function error(logObject?: any): void;
  152. function fatal(logObject?: any): void;
  153. }
  154. namespace notify {
  155. function info(message: string, title?: string, options?: any): void;
  156. function success(message: string, title?: string, options?: any): void;
  157. function warn(message: string, title?: string, options?: any): void;
  158. function error(message: string, title?: string, options?: any): void;
  159. }
  160. namespace message {
  161. //TODO: these methods return jQuery.Promise instead of any. fix it.
  162. function info(message: string, title?: string, isHtml?: boolean): any;
  163. function success(message: string, title?: string, isHtml?: boolean): any;
  164. function warn(message: string, title?: string, isHtml?: boolean): any;
  165. function error(message: string, title?: string, isHtml?: boolean): any;
  166. function confirm(message: string, callback?: (result: boolean) => void): any;
  167. function confirm(message: string, title?: string, callback?: (result: boolean) => void, isHtml?: boolean): any;
  168. }
  169. namespace ui {
  170. function block(elm?: any): void;
  171. function unblock(elm?: any): void;
  172. function setBusy(elm?: any, optionsOrPromise?: any): void;
  173. function clearBusy(elm?: any): void;
  174. }
  175. namespace event {
  176. function on(eventName: string, callback: (...args: any[]) => void): void;
  177. function off(eventName: string, callback: (...args: any[]) => void): void;
  178. function trigger(eventName: string, ...args: any[]): void;
  179. }
  180. interface INameValue {
  181. name: string;
  182. value?: any;
  183. }
  184. namespace utils {
  185. function createNamespace(root: any, ns: string): any;
  186. function replaceAll(str: string, search: string, replacement: any): string;
  187. function formatString(str: string, ...args: any[]): string;
  188. function toPascalCase(str: string): string;
  189. function toCamelCase(str: string): string;
  190. function truncateString(str: string, maxLength: number): string;
  191. function truncateStringWithPostfix(str: string, maxLength: number, postfix?: string): string;
  192. function isFunction(obj: any): boolean;
  193. function buildQueryString(parameterInfos: INameValue[], includeQuestionMark?: boolean): string;
  194. /**
  195. * Sets a cookie value for given key.
  196. * This is a simple implementation created to be used by ABP.
  197. * Please use a complete cookie library if you need.
  198. * @param {string} key
  199. * @param {string} value
  200. * @param {Date} expireDate (optional). If not specified the cookie will expire at the end of session.
  201. * @param {string} path (optional)
  202. */
  203. function setCookieValue(key: string, value: string, expireDate?: Date, path?: string): void;
  204. /**
  205. * Gets a cookie with given key.
  206. * This is a simple implementation created to be used by ABP.
  207. * Please use a complete cookie library if you need.
  208. * @param {string} key
  209. * @returns {string} Cookie value or null
  210. */
  211. function getCookieValue(key: string): string;
  212. /**
  213. * Deletes cookie for given key.
  214. * This is a simple implementation created to be used by ABP.
  215. * Please use a complete cookie library if you need.
  216. * @param {string} key
  217. * @param {string} path (optional)
  218. */
  219. function deleteCookie(key: string, path?: string): void;
  220. }
  221. namespace timing {
  222. interface IClockProvider {
  223. supportsMultipleTimezone: boolean;
  224. now(): Date;
  225. normalize(date: Date): Date;
  226. }
  227. interface ITimeZoneInfo {
  228. windows: {
  229. timeZoneId: string;
  230. baseUtcOffsetInMilliseconds: number;
  231. currentUtcOffsetInMilliseconds: number;
  232. isDaylightSavingTimeNow: boolean;
  233. },
  234. iana: {
  235. timeZoneId: string;
  236. }
  237. }
  238. const utcClockProvider: IClockProvider;
  239. const localClockProvider: IClockProvider;
  240. const unspecifiedClockProvider: IClockProvider;
  241. function convertToUserTimezone(date: Date): Date;
  242. let timeZoneInfo: ITimeZoneInfo;
  243. }
  244. namespace clock {
  245. let provider: timing.IClockProvider;
  246. function now(): Date;
  247. function normalize(date: Date): Date;
  248. }
  249. namespace security {
  250. namespace antiForgery {
  251. let tokenCookieName: string;
  252. let tokenHeaderName: string;
  253. function getToken(): string;
  254. }
  255. }
  256. }