@bcrumbs.net/bc-api 0.0.3 → 0.0.4

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.
@@ -1,33 +1,33 @@
1
- export interface Model {
2
- Id: number;
3
- Name: string;
4
- ViewFields: ModelField[];
5
- }
6
- export interface ModelField {
7
- Id: number;
8
- Name: string;
9
- Type: ModelFieldsTypes;
10
- EnumId: number;
11
- }
12
- export interface ModelQueryResult {
13
- viewTypes: Model[];
14
- }
15
- export declare class ModelUtilities {
16
- static ConvertModelsListToFieldsMap(models: Model[]): Map<number, ModelField>;
17
- }
18
- export declare enum ModelFieldsTypes {
19
- String = "String",
20
- StringML = "String - Multiple Lines",
21
- RichTextBox = "Rich Text Box",
22
- Date = "Date",
23
- PredefinedList = "Predefined List",
24
- PredefinedListCheckboxes = "Predefined List - Checkboxes",
25
- PredefinedListRadioButtons = "Predefined List - Radio Buttons",
26
- PredefinedListFilterSelect = "Predefined List - Filter/Select",
27
- AutoIncrementNumber = "Auto Increment Number",
28
- ContentUrl = "Content Url",
29
- Boolean = "Boolean",
30
- Number = "Number",
31
- Image = "Image",
32
- MultipleImages = "Multiple Images"
33
- }
1
+ export interface Model {
2
+ Id: number;
3
+ Name: string;
4
+ ViewFields: ModelField[];
5
+ }
6
+ export interface ModelField {
7
+ Id: number;
8
+ Name: string;
9
+ Type: ModelFieldsTypes;
10
+ EnumId: number;
11
+ }
12
+ export interface ModelQueryResult {
13
+ viewTypes: Model[];
14
+ }
15
+ export declare class ModelUtilities {
16
+ static ConvertModelsListToFieldsMap(models: Model[]): Map<number, ModelField>;
17
+ }
18
+ export declare enum ModelFieldsTypes {
19
+ String = "String",
20
+ StringML = "String - Multiple Lines",
21
+ RichTextBox = "Rich Text Box",
22
+ Date = "Date",
23
+ PredefinedList = "Predefined List",
24
+ PredefinedListCheckboxes = "Predefined List - Checkboxes",
25
+ PredefinedListRadioButtons = "Predefined List - Radio Buttons",
26
+ PredefinedListFilterSelect = "Predefined List - Filter/Select",
27
+ AutoIncrementNumber = "Auto Increment Number",
28
+ ContentUrl = "Content Url",
29
+ Boolean = "Boolean",
30
+ Number = "Number",
31
+ Image = "Image",
32
+ MultipleImages = "Multiple Images"
33
+ }
@@ -0,0 +1,16 @@
1
+ export interface UsageRecord {
2
+ id: string;
3
+ object: string;
4
+ livemode: boolean;
5
+ total_usage: number;
6
+ subscription_item: string;
7
+ timestamp: number;
8
+ }
9
+ export interface UsageRecordQueryResult {
10
+ queryUsage: {
11
+ object: string;
12
+ data: UsageRecord[];
13
+ has_more: boolean;
14
+ url: string;
15
+ };
16
+ }
@@ -1,120 +1,123 @@
1
- declare type STORES_TYPES = 'localStorage' | 'sessionStorage';
2
- declare type Storage = STORES_TYPES;
3
- declare type TokenKey = string;
4
- declare type ContextKey = string;
5
- declare type UserInfoKey = string;
6
- declare type User = {
7
- name: string;
8
- surname: string;
9
- };
10
- export declare const auth: {
11
- /**
12
- * get token from localstorage
13
- *
14
- * @param {'localStorage' | 'sessionStorage'} [fromStorage='localStorage'] specify storage
15
- * @param {any} [tokenKey=TOKEN_KEY] optionnal parameter to specify a token key
16
- * @returns {string} token value
17
- */
18
- getToken(fromStorage?: Storage, tokenKey?: TokenKey): string | null;
19
- /**
20
- * set the token value into localstorage (managed by localforage)
21
- *
22
- * @param {string} [value=''] token value
23
- * @param {'localStorage' | 'sessionStorage'} [toStorage='localStorage'] specify storage
24
- * @param {any} [tokenKey='token'] token key
25
- * @returns {boolean} success/failure flag
26
- */
27
- setToken(value?: string, toStorage?: Storage, tokenKey?: TokenKey): void;
28
- /**
29
- * check
30
- * - if token key contains a valid token value (defined and not an empty value)
31
- * - if the token expiration date is passed
32
- *
33
- *
34
- * Note: 'isAuthenticated' just checks 'tokenKey' on store (localStorage by default or sessionStorage)
35
- *
36
- * You may think: 'ok I just put an empty token key and I have access to protected routes?''
37
- * -> answer is: YES^^
38
- * BUT
39
- * -> : your backend will not recognize a wrong token so private data or safe and you protected view could be a bit ugly without any data.
40
- *
41
- * => ON CONCLUSION: this aim of 'isAuthenticated'
42
- * -> is to help for a better "user experience" (= better than displaying a view with no data since server did not accept the user).
43
- * -> it is not a security purpose (security comes from backend, since frontend is easily hackable => user has access to all your frontend)
44
- *
45
- * @param {'localStorage' | 'sessionStorage'} [fromStorage='localStorage'] specify storage
46
- * @param {any} [tokenKey=TOKEN_KEY] token key
47
- * @returns {bool} is authenticed response
48
- */
49
- isAuthenticated(fromStorage?: Storage, tokenKey?: TokenKey): boolean;
50
- /**
51
- * delete token
52
- *
53
- * @param {any} [tokenKey='token'] token key
54
- * @returns {bool} success/failure flag
55
- */
56
- clearToken(storage?: Storage, tokenKey?: TokenKey): boolean;
57
- /**
58
- * return expiration date from token
59
- *
60
- * @param {string} encodedToken - base 64 token received from server and stored in local storage
61
- * @returns {date | null} returns expiration date or null id expired props not found in decoded token
62
- */
63
- getTokenExpirationDate(encodedToken: string): Date;
64
- /**
65
- *
66
- * tell is token is expired (compared to now)
67
- *
68
- * @param {string} encodedToken - base 64 token received from server and stored in local storage
69
- * @returns {bool} returns true if expired else false
70
- */
71
- isExpiredToken(encodedToken: string): boolean;
72
- /**
73
- * get user info from localstorage
74
- *
75
- * @param {'localStorage' | 'sessionStorage'} [fromStorage='localStorage'] specify storage
76
- * @param {any} [userInfoKey='userInfo'] optionnal parameter to specify a token key
77
- * @returns {string} token value
78
- */
79
- getUserInfo(fromStorage?: Storage, userInfoKey?: UserInfoKey): any;
80
- /**
81
- * set the userInfo value into localstorage
82
- *
83
- * @param {object} [value=''] token value
84
- * @param {'localStorage' | 'sessionStorage'} [toStorage='localStorage'] specify storage
85
- * @param {any} [userInfoKey='userInfo'] token key
86
- * @returns {boolean} success/failure flag
87
- */
88
- setUserInfo(value: User, toStorage?: Storage, userInfoKey?: UserInfoKey): void;
89
- updateUserInfo(value: User, toStorage?: Storage, userInfoKey?: UserInfoKey): any;
90
- /**
91
- * delete userInfo
92
- *
93
- * @param {string} [userInfoKey='userInfo'] token key
94
- * @returns {bool} success/failure flag
95
- */
96
- clearUserInfo(userInfoKey?: UserInfoKey): any;
97
- /**
98
- * forget me method: clear all
99
- * @returns {bool} success/failure flag
100
- */
101
- clearAllAppStorage(): any;
102
- /**
103
- * set the context value into localstorage (managed by localforage)
104
- *
105
- * @param {string} [value=''] context value
106
- * @param {'localStorage' | 'sessionStorage'} [toStorage='localStorage'] specify storage
107
- * @param {any} [tokenKey='token'] token key
108
- * @returns {boolean} success/failure flag
109
- */
110
- setContext(value?: string, toStorage?: Storage, contextKey?: ContextKey): void;
111
- /**
112
- * get context from localstorage
113
- *
114
- * @param {'localStorage' | 'sessionStorage'} [fromStorage='localStorage'] specify storage
115
- * @param {any} [tokenKey=TOKEN_KEY] optionnal parameter to specify a token key
116
- * @returns {string} token value
117
- */
118
- getContext(fromStorage?: Storage, contextKey?: ContextKey): string | null;
119
- };
120
- export default auth;
1
+ type STORES_TYPES = 'localStorage' | 'sessionStorage';
2
+ type Storage = STORES_TYPES;
3
+ type TokenKey = string;
4
+ type ContextKey = string;
5
+ type UserInfoKey = string;
6
+ type User = {
7
+ name?: string;
8
+ surname?: string;
9
+ username?: string;
10
+ email?: string;
11
+ id: string;
12
+ };
13
+ export declare const auth: {
14
+ /**
15
+ * get token from localstorage
16
+ *
17
+ * @param {'localStorage' | 'sessionStorage'} [fromStorage='localStorage'] specify storage
18
+ * @param {any} [tokenKey=TOKEN_KEY] optionnal parameter to specify a token key
19
+ * @returns {string} token value
20
+ */
21
+ getToken(fromStorage?: Storage, tokenKey?: TokenKey): string | null;
22
+ /**
23
+ * set the token value into localstorage (managed by localforage)
24
+ *
25
+ * @param {string} [value=''] token value
26
+ * @param {'localStorage' | 'sessionStorage'} [toStorage='localStorage'] specify storage
27
+ * @param {any} [tokenKey='token'] token key
28
+ * @returns {boolean} success/failure flag
29
+ */
30
+ setToken(value?: string, toStorage?: Storage, tokenKey?: TokenKey): void;
31
+ /**
32
+ * check
33
+ * - if token key contains a valid token value (defined and not an empty value)
34
+ * - if the token expiration date is passed
35
+ *
36
+ *
37
+ * Note: 'isAuthenticated' just checks 'tokenKey' on store (localStorage by default or sessionStorage)
38
+ *
39
+ * You may think: 'ok I just put an empty token key and I have access to protected routes?''
40
+ * -> answer is: YES^^
41
+ * BUT
42
+ * -> : your backend will not recognize a wrong token so private data or safe and you protected view could be a bit ugly without any data.
43
+ *
44
+ * => ON CONCLUSION: this aim of 'isAuthenticated'
45
+ * -> is to help for a better "user experience" (= better than displaying a view with no data since server did not accept the user).
46
+ * -> it is not a security purpose (security comes from backend, since frontend is easily hackable => user has access to all your frontend)
47
+ *
48
+ * @param {'localStorage' | 'sessionStorage'} [fromStorage='localStorage'] specify storage
49
+ * @param {any} [tokenKey=TOKEN_KEY] token key
50
+ * @returns {bool} is authenticed response
51
+ */
52
+ isAuthenticated(fromStorage?: Storage, tokenKey?: TokenKey): boolean;
53
+ /**
54
+ * delete token
55
+ *
56
+ * @param {any} [tokenKey='token'] token key
57
+ * @returns {bool} success/failure flag
58
+ */
59
+ clearToken(storage?: Storage, tokenKey?: TokenKey): boolean;
60
+ /**
61
+ * return expiration date from token
62
+ *
63
+ * @param {string} encodedToken - base 64 token received from server and stored in local storage
64
+ * @returns {date | null} returns expiration date or null id expired props not found in decoded token
65
+ */
66
+ getTokenExpirationDate(encodedToken: string): Date;
67
+ /**
68
+ *
69
+ * tell is token is expired (compared to now)
70
+ *
71
+ * @param {string} encodedToken - base 64 token received from server and stored in local storage
72
+ * @returns {bool} returns true if expired else false
73
+ */
74
+ isExpiredToken(encodedToken: string): boolean;
75
+ /**
76
+ * get user info from localstorage
77
+ *
78
+ * @param {'localStorage' | 'sessionStorage'} [fromStorage='localStorage'] specify storage
79
+ * @param {any} [userInfoKey='userInfo'] optionnal parameter to specify a token key
80
+ * @returns {string} token value
81
+ */
82
+ getUserInfo(fromStorage?: Storage, userInfoKey?: UserInfoKey): any;
83
+ /**
84
+ * set the userInfo value into localstorage
85
+ *
86
+ * @param {object} [value=''] token value
87
+ * @param {'localStorage' | 'sessionStorage'} [toStorage='localStorage'] specify storage
88
+ * @param {any} [userInfoKey='userInfo'] token key
89
+ * @returns {boolean} success/failure flag
90
+ */
91
+ setUserInfo(value: User, toStorage?: Storage, userInfoKey?: UserInfoKey): void;
92
+ updateUserInfo(value: User, toStorage?: Storage, userInfoKey?: UserInfoKey): any;
93
+ /**
94
+ * delete userInfo
95
+ *
96
+ * @param {string} [userInfoKey='userInfo'] token key
97
+ * @returns {bool} success/failure flag
98
+ */
99
+ clearUserInfo(userInfoKey?: UserInfoKey): any;
100
+ /**
101
+ * forget me method: clear all
102
+ * @returns {bool} success/failure flag
103
+ */
104
+ clearAllAppStorage(): any;
105
+ /**
106
+ * set the context value into localstorage (managed by localforage)
107
+ *
108
+ * @param {string} [value=''] context value
109
+ * @param {'localStorage' | 'sessionStorage'} [toStorage='localStorage'] specify storage
110
+ * @param {any} [tokenKey='token'] token key
111
+ * @returns {boolean} success/failure flag
112
+ */
113
+ setContext(value?: string, toStorage?: Storage, contextKey?: ContextKey): void;
114
+ /**
115
+ * get context from localstorage
116
+ *
117
+ * @param {'localStorage' | 'sessionStorage'} [fromStorage='localStorage'] specify storage
118
+ * @param {any} [tokenKey=TOKEN_KEY] optionnal parameter to specify a token key
119
+ * @returns {string} token value
120
+ */
121
+ getContext(fromStorage?: Storage, contextKey?: ContextKey): string | null;
122
+ };
123
+ export default auth;
@@ -1,11 +1,11 @@
1
- export declare const LOCAL_STORAGE_I18N_STRING = "I18N_SELECTION";
2
- export declare const LangService: {
3
- init: () => void;
4
- changeLang: (lang: Languages) => void;
5
- getLang: () => string;
6
- };
7
- export declare enum Languages {
8
- EN = "en",
9
- AR = "ar",
10
- TR = "tr"
11
- }
1
+ export declare const LOCAL_STORAGE_I18N_STRING = "I18N_SELECTION";
2
+ export declare const LangService: {
3
+ init: () => void;
4
+ changeLang: (lang: Languages) => void;
5
+ getLang: () => string;
6
+ };
7
+ export declare enum Languages {
8
+ EN = "en",
9
+ AR = "ar",
10
+ TR = "tr"
11
+ }
@@ -1,20 +1,20 @@
1
- declare const Validators: {
2
- /**
3
- * validate image
4
- *
5
- * @param {any} [file=File] uploaded file
6
- * @param {func} [callBack=()=>{ }] the callback function
7
- */
8
- validateImage(file: any, callback: any): void;
9
- };
10
- export declare const ValidatorsConstants: {
11
- MaxFileSize: number;
12
- FileFormats: {
13
- TEXT: never[];
14
- IMAGE: string[];
15
- VIDEO: string[];
16
- AUDIO: string[];
17
- FILE: never[];
18
- };
19
- };
20
- export default Validators;
1
+ declare const Validators: {
2
+ /**
3
+ * validate image
4
+ *
5
+ * @param {any} [file=File] uploaded file
6
+ * @param {func} [callBack=()=>{ }] the callback function
7
+ */
8
+ validateImage(file: any, callback: any): void;
9
+ };
10
+ export declare const ValidatorsConstants: {
11
+ MaxFileSize: number;
12
+ FileFormats: {
13
+ TEXT: never[];
14
+ IMAGE: string[];
15
+ VIDEO: string[];
16
+ AUDIO: string[];
17
+ FILE: never[];
18
+ };
19
+ };
20
+ export default Validators;