skapi-js 0.2.5 → 1.0.0-alpha.10
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.
- package/dist/skapi.js +1 -1
- package/dist/skapi.js.map +1 -1
- package/dist/skapi.module.js +1 -1
- package/dist/skapi.module.js.map +1 -1
- package/js/Types.d.ts +20 -2
- package/js/main/skapi.d.ts +199 -61
- package/js/main/skapi.js +115 -61
- package/js/methods/database.d.ts +13 -18
- package/js/methods/database.js +26 -30
- package/js/methods/request.d.ts +3 -7
- package/js/methods/request.js +37 -50
- package/js/methods/subscription.d.ts +2 -2
- package/js/methods/subscription.js +2 -2
- package/js/methods/user.d.ts +15 -14
- package/js/methods/user.js +46 -11
- package/package.json +5 -7
package/js/Types.d.ts
CHANGED
|
@@ -123,10 +123,28 @@ export type UserProfile = {
|
|
|
123
123
|
phone_number_verified?: boolean;
|
|
124
124
|
signup_ticket?: string;
|
|
125
125
|
} & UserAttributes;
|
|
126
|
-
export
|
|
126
|
+
export type PublicUser = {
|
|
127
|
+
name?: string;
|
|
128
|
+
email?: string;
|
|
129
|
+
phone_number?: string;
|
|
130
|
+
address?: string | {
|
|
131
|
+
formatted: string;
|
|
132
|
+
locality: string;
|
|
133
|
+
region: string;
|
|
134
|
+
postal_code: string;
|
|
135
|
+
country: string;
|
|
136
|
+
};
|
|
137
|
+
gender?: string;
|
|
138
|
+
birthdate?: string;
|
|
139
|
+
misc?: string;
|
|
127
140
|
subscribers: number;
|
|
128
141
|
timestamp: number;
|
|
129
|
-
|
|
142
|
+
service: string;
|
|
143
|
+
owner: string;
|
|
144
|
+
access_group?: number;
|
|
145
|
+
user_id: string;
|
|
146
|
+
locale: string;
|
|
147
|
+
};
|
|
130
148
|
export type QueryParams = {
|
|
131
149
|
searchFor: string;
|
|
132
150
|
value: string | number | boolean;
|
package/js/main/skapi.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatabaseResponse, Connection, ProgressCallback, GetRecordQuery, FetchOptions, RecordData, Condition, QueryParams, UserAttributes, UserProfile, Newsletters, FormSubmitCallback, Form, PostRecordConfig, PublicUser, SubscriptionGroup } from '../Types';
|
|
2
2
|
export default class Skapi {
|
|
3
3
|
version: string;
|
|
4
|
+
service: string;
|
|
5
|
+
owner: string;
|
|
6
|
+
session: Record<string, any> | null;
|
|
7
|
+
connection: Connection | null;
|
|
8
|
+
private host;
|
|
9
|
+
private hostDomain;
|
|
10
|
+
private target_cdn;
|
|
4
11
|
private __disabledAccount;
|
|
5
12
|
private __cached_requests;
|
|
6
13
|
private __startKeyHistory;
|
|
7
14
|
private __request_signup_confirmation;
|
|
8
|
-
service: string;
|
|
9
|
-
owner: string;
|
|
10
15
|
private __class_properties_has_been_cached;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
host: string;
|
|
17
|
-
hostDomain: string;
|
|
18
|
-
admin_endpoint: Promise<Record<string, any>>;
|
|
19
|
-
record_endpoint: Promise<Record<string, any>>;
|
|
16
|
+
private __user;
|
|
17
|
+
get user(): UserProfile | null;
|
|
18
|
+
set user(value: UserProfile | null);
|
|
19
|
+
private admin_endpoint;
|
|
20
|
+
private record_endpoint;
|
|
20
21
|
validate: {
|
|
21
22
|
userId(val: string): boolean;
|
|
22
23
|
url(val: string | string[]): boolean;
|
|
@@ -24,56 +25,193 @@ export default class Skapi {
|
|
|
24
25
|
birthdate(val: string): boolean;
|
|
25
26
|
email(val: string): boolean;
|
|
26
27
|
};
|
|
27
|
-
__connection
|
|
28
|
-
constructor(
|
|
28
|
+
private __connection;
|
|
29
|
+
constructor(service: string, owner: string, options?: {
|
|
29
30
|
autoLogin: boolean;
|
|
30
31
|
});
|
|
31
32
|
updateConnection(): Promise<Connection>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
33
|
+
private checkAdmin;
|
|
34
|
+
private request;
|
|
35
|
+
private getSubscribedTo;
|
|
36
|
+
private getSubscribers;
|
|
37
|
+
getConnection(): Promise<Connection>;
|
|
38
|
+
getProfile(options?: {
|
|
39
|
+
refreshToken: boolean;
|
|
40
|
+
}): Promise<UserProfile | null>;
|
|
41
|
+
getFile(url: string, config?: {
|
|
42
|
+
noCdn?: boolean;
|
|
43
|
+
dataType?: 'base64' | 'download' | 'endpoint' | 'blob';
|
|
44
|
+
expiration?: number;
|
|
45
|
+
progress?: ProgressCallback;
|
|
46
|
+
}): Promise<Blob | string>;
|
|
47
|
+
secureRequest<Params = {
|
|
48
|
+
url: string;
|
|
49
|
+
data?: any;
|
|
50
|
+
sync?: boolean;
|
|
51
|
+
}>(params: Params | Params[]): Promise<any>;
|
|
52
|
+
getFormResponse(): Promise<any>;
|
|
53
|
+
getRecords(query: GetRecordQuery, fetchOptions?: FetchOptions): Promise<DatabaseResponse<RecordData>>;
|
|
54
|
+
getTables(query: {
|
|
55
|
+
table: string;
|
|
56
|
+
condition?: Condition;
|
|
57
|
+
}, fetchOptions?: FetchOptions): Promise<DatabaseResponse<{
|
|
58
|
+
number_of_records: number;
|
|
59
|
+
table: string;
|
|
60
|
+
size: number;
|
|
61
|
+
}>>;
|
|
62
|
+
getIndexes(query: {
|
|
63
|
+
table: string;
|
|
64
|
+
index?: string;
|
|
65
|
+
order?: {
|
|
66
|
+
by: 'average_number' | 'total_number' | 'number_count' | 'average_bool' | 'total_bool' | 'bool_count' | 'string_count' | 'index_name';
|
|
67
|
+
value?: number | boolean | string;
|
|
68
|
+
condition?: Condition;
|
|
69
|
+
};
|
|
70
|
+
}, fetchOptions?: FetchOptions): Promise<DatabaseResponse<{
|
|
71
|
+
table: string;
|
|
72
|
+
index: string;
|
|
73
|
+
number_of_records: number;
|
|
74
|
+
string_count?: number;
|
|
75
|
+
number_count?: number;
|
|
76
|
+
boolean_count?: number;
|
|
77
|
+
total_number?: number;
|
|
78
|
+
total_bool?: number;
|
|
79
|
+
average_number?: number;
|
|
80
|
+
average_bool?: number;
|
|
81
|
+
}>>;
|
|
82
|
+
getTags(query: {
|
|
83
|
+
table: string;
|
|
84
|
+
tag?: string;
|
|
85
|
+
condition?: Condition;
|
|
86
|
+
}, fetchOptions?: FetchOptions): Promise<DatabaseResponse<{
|
|
87
|
+
table: string;
|
|
88
|
+
tag: string;
|
|
89
|
+
number_of_records: string;
|
|
90
|
+
}>>;
|
|
91
|
+
deleteRecords(params: {
|
|
92
|
+
record_id?: string | string[];
|
|
93
|
+
table?: {
|
|
94
|
+
name: string;
|
|
95
|
+
access_group?: number | 'private' | 'public' | 'authorized';
|
|
96
|
+
subscription_group?: number;
|
|
97
|
+
};
|
|
98
|
+
}): Promise<string>;
|
|
99
|
+
resendSignupConfirmation(redirect: string): Promise<'SUCCESS: Signup confirmation E-Mail has been sent.'>;
|
|
100
|
+
recoverAccount(redirect?: boolean | string): Promise<"SUCCESS: Recovery e-mail has been sent.">;
|
|
101
|
+
getUsers(params?: QueryParams | null, fetchOptions?: FetchOptions): Promise<DatabaseResponse<PublicUser>>;
|
|
102
|
+
disableAccount(): Promise<'SUCCESS: account has been disabled.'>;
|
|
103
|
+
lastVerifiedEmail(params?: {
|
|
104
|
+
revert: boolean;
|
|
105
|
+
}): Promise<string | UserProfile>;
|
|
106
|
+
getSubscriptions(params: {
|
|
107
|
+
subscriber?: string;
|
|
108
|
+
subscription?: string;
|
|
109
|
+
group?: number;
|
|
110
|
+
blocked?: boolean;
|
|
111
|
+
}, fetchOptions?: FetchOptions, _mapper?: (data: Record<string, any>) => any): Promise<DatabaseResponse<{
|
|
112
|
+
subscriber: string;
|
|
113
|
+
subscription: string;
|
|
114
|
+
group: number;
|
|
115
|
+
timestamp: number;
|
|
116
|
+
blocked: boolean;
|
|
117
|
+
}>>;
|
|
118
|
+
unsubscribeNewsletter(params: {
|
|
119
|
+
group: number | 'public' | 'authorized' | null;
|
|
120
|
+
}): Promise<string>;
|
|
121
|
+
getNewsletters(params?: {
|
|
122
|
+
searchFor: 'message_id' | 'timestamp' | 'read' | 'complaint' | 'subject';
|
|
123
|
+
value: string | number;
|
|
124
|
+
range: string | number;
|
|
125
|
+
condition?: '>' | '>=' | '=' | '<' | '<=' | 'gt' | 'gte' | 'eq' | 'lt' | 'lte';
|
|
126
|
+
group: 'public' | 'authorized' | number;
|
|
127
|
+
}, fetchOptions?: FetchOptions): Promise<Newsletters>;
|
|
128
|
+
getNewsletterSubscription(params: {
|
|
129
|
+
group?: number;
|
|
130
|
+
}): Promise<{
|
|
131
|
+
active: boolean;
|
|
132
|
+
timestamp: number;
|
|
133
|
+
group: number;
|
|
134
|
+
subscribed_email: string;
|
|
135
|
+
}[]>;
|
|
136
|
+
requestUsernameChange(params: {
|
|
137
|
+
redirect?: string;
|
|
138
|
+
username: string;
|
|
139
|
+
}): Promise<'SUCCESS: confirmation e-mail has been sent.'>;
|
|
140
|
+
grantPrivateRecordAccess(params: {
|
|
141
|
+
record_id: string;
|
|
142
|
+
user_id: string | string[];
|
|
143
|
+
}): Promise<string>;
|
|
144
|
+
removePrivateRecordAccess(params: {
|
|
145
|
+
record_id: string;
|
|
146
|
+
user_id: string | string[];
|
|
147
|
+
}): Promise<string>;
|
|
148
|
+
listPrivateRecordAccess(params: {
|
|
149
|
+
record_id: string;
|
|
150
|
+
user_id: string | string[];
|
|
151
|
+
}): Promise<string>;
|
|
152
|
+
requestPrivateRecordAccessKey(record_id: string): Promise<string>;
|
|
153
|
+
deleteFiles(params: {
|
|
154
|
+
endpoints: string | string[];
|
|
155
|
+
}): Promise<RecordData[]>;
|
|
156
|
+
uploadFiles(fileList: Form<FileList | File[]>, params: {
|
|
157
|
+
record_id: string;
|
|
158
|
+
} & FormSubmitCallback): Promise<{
|
|
159
|
+
completed: File[];
|
|
160
|
+
failed: File[];
|
|
161
|
+
}>;
|
|
162
|
+
mock(data: Form<any | {
|
|
163
|
+
raise: 'ERR_INVALID_REQUEST' | 'ERR_INVALID_PARAMETER' | 'SOMETHING_WENT_WRONG' | 'ERR_EXISTS' | 'ERR_NOT_EXISTS';
|
|
164
|
+
}>, options?: {
|
|
165
|
+
auth?: boolean;
|
|
166
|
+
method?: string;
|
|
167
|
+
meta?: Record<string, any>;
|
|
168
|
+
bypassAwaitConnection?: boolean;
|
|
169
|
+
responseType?: string;
|
|
170
|
+
contentType?: string;
|
|
171
|
+
} & FormSubmitCallback): Promise<{
|
|
172
|
+
mockResponse: Record<string, any>;
|
|
173
|
+
}>;
|
|
174
|
+
login(form: Form<{
|
|
175
|
+
username: string;
|
|
176
|
+
email: string;
|
|
177
|
+
password: string;
|
|
178
|
+
}>): Promise<UserProfile>;
|
|
179
|
+
logout(): Promise<'SUCCESS: The user has been logged out.'>;
|
|
180
|
+
signup(form: Form<UserAttributes & {
|
|
181
|
+
email: String;
|
|
182
|
+
password: String;
|
|
183
|
+
}>, option?: {
|
|
184
|
+
signup_confirmation?: boolean | string;
|
|
185
|
+
email_subscription?: boolean;
|
|
186
|
+
login?: boolean;
|
|
187
|
+
} & FormSubmitCallback): Promise<UserProfile | "SUCCESS: The account has been created. User's signup confirmation is required." | 'SUCCESS: The account has been created.'>;
|
|
188
|
+
resetPassword(form: Form<{
|
|
189
|
+
email: string;
|
|
190
|
+
code?: string | number;
|
|
191
|
+
new_password?: string;
|
|
192
|
+
}>): Promise<"SUCCESS: New password has been set.">;
|
|
193
|
+
verifyEmail(form?: Form<{
|
|
194
|
+
code: string;
|
|
195
|
+
}>): Promise<'SUCCESS: Verification code has been sent.' | 'SUCCESS: "email" is verified.'>;
|
|
196
|
+
verifyPhoneNumber(form?: Form<{
|
|
197
|
+
code: string;
|
|
198
|
+
}>): Promise<'SUCCESS: Verification code has been sent.' | 'SUCCESS: "phone_number" is verified.'>;
|
|
199
|
+
forgotPassword(form: Form<{
|
|
200
|
+
email: string;
|
|
201
|
+
}>): Promise<"SUCCESS: Verification code has been sent.">;
|
|
202
|
+
changePassword(params: {
|
|
203
|
+
new_password: string;
|
|
204
|
+
current_password: string;
|
|
205
|
+
}): Promise<'SUCCESS: Password has been changed.'>;
|
|
206
|
+
updateProfile(form: Form<UserAttributes>): Promise<UserProfile>;
|
|
207
|
+
postRecord(form: Form<Record<string, any>> | null | undefined, config: PostRecordConfig & FormSubmitCallback): Promise<RecordData>;
|
|
208
|
+
subscribe(option: SubscriptionGroup<number>): Promise<'SUCCESS: the user has subscribed.'>;
|
|
209
|
+
unsubscribe(option: SubscriptionGroup<number | '*'>): Promise<'SUCCESS: the user has unsubscribed.'>;
|
|
210
|
+
blockSubscriber(option: SubscriptionGroup<number | '*'>): Promise<'SUCCESS: blocked user id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".'>;
|
|
211
|
+
unblockSubscriber(option: SubscriptionGroup<number | '*'>): Promise<'SUCCESS: unblocked user id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".'>;
|
|
212
|
+
subscribeNewsletter(form: Form<{
|
|
213
|
+
email?: string;
|
|
214
|
+
group: number | 'public' | 'authorized';
|
|
215
|
+
redirect?: string;
|
|
216
|
+
}>): Promise<string>;
|
|
79
217
|
}
|
package/js/main/skapi.js
CHANGED
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import SkapiError from './error';
|
|
8
8
|
import validator from '../utils/validator';
|
|
9
9
|
import { getRecords, postRecord, deleteRecords, getTables, getIndexes, getTags, uploadFiles, getFile, grantPrivateRecordAccess, removePrivateRecordAccess, listPrivateRecordAccess, requestPrivateRecordAccessKey, deleteFiles } from '../methods/database';
|
|
10
|
-
import { request, secureRequest, mock, getFormResponse, formHandler, getConnection
|
|
10
|
+
import { request, secureRequest, mock, getFormResponse, formHandler, getConnection } from '../methods/request';
|
|
11
11
|
import { subscribe, unsubscribe, blockSubscriber, unblockSubscriber, getSubscribers, getSubscribedTo, getSubscriptions, subscribeNewsletter, getNewsletters, unsubscribeNewsletter, getNewsletterSubscription } from '../methods/subscription';
|
|
12
12
|
import { checkAdmin, getProfile, logout, recoverAccount, resendSignupConfirmation, authentication, login, signup, disableAccount, resetPassword, verifyEmail, verifyPhoneNumber, forgotPassword, changePassword, updateProfile, getUsers, setUserPool, userPool, lastVerifiedEmail, requestUsernameChange } from '../methods/user';
|
|
13
13
|
export default class Skapi {
|
|
@@ -21,18 +21,19 @@ export default class Skapi {
|
|
|
21
21
|
}
|
|
22
22
|
set user(value) {
|
|
23
23
|
}
|
|
24
|
-
constructor(
|
|
25
|
-
this.version = '0.
|
|
24
|
+
constructor(service, owner, options) {
|
|
25
|
+
this.version = '1.0.0-alpha.10';
|
|
26
|
+
this.session = null;
|
|
27
|
+
this.connection = null;
|
|
28
|
+
this.host = 'skapi';
|
|
29
|
+
this.hostDomain = 'skapi.app';
|
|
30
|
+
this.target_cdn = 'd1wrj5ymxrt2ir';
|
|
26
31
|
this.__disabledAccount = null;
|
|
27
32
|
this.__cached_requests = {};
|
|
28
33
|
this.__startKeyHistory = {};
|
|
29
34
|
this.__request_signup_confirmation = null;
|
|
30
35
|
this.__class_properties_has_been_cached = false;
|
|
31
|
-
this.session = null;
|
|
32
36
|
this.__user = null;
|
|
33
|
-
this.connection = null;
|
|
34
|
-
this.host = 'skapi';
|
|
35
|
-
this.hostDomain = 'skapi.com';
|
|
36
37
|
this.validate = {
|
|
37
38
|
userId(val) {
|
|
38
39
|
try {
|
|
@@ -80,51 +81,24 @@ export default class Skapi {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
|
-
this.getConnection = getConnection.bind(this);
|
|
84
|
-
this.getProfile = getProfile.bind(this);
|
|
85
84
|
this.checkAdmin = checkAdmin.bind(this);
|
|
86
|
-
this.getFile = getFile.bind(this);
|
|
87
85
|
this.request = request.bind(this);
|
|
88
|
-
this.secureRequest = secureRequest.bind(this);
|
|
89
|
-
this.getFormResponse = getFormResponse.bind(this);
|
|
90
|
-
this.getRecords = getRecords.bind(this);
|
|
91
|
-
this.getTables = getTables.bind(this);
|
|
92
|
-
this.getIndexes = getIndexes.bind(this);
|
|
93
|
-
this.getTags = getTags.bind(this);
|
|
94
|
-
this.deleteRecords = deleteRecords.bind(this);
|
|
95
|
-
this.resendSignupConfirmation = resendSignupConfirmation.bind(this);
|
|
96
|
-
this.recoverAccount = recoverAccount.bind(this);
|
|
97
|
-
this.getUsers = getUsers.bind(this);
|
|
98
|
-
this.disableAccount = disableAccount.bind(this);
|
|
99
|
-
this.lastVerifiedEmail = lastVerifiedEmail.bind(this);
|
|
100
86
|
this.getSubscribedTo = getSubscribedTo.bind(this);
|
|
101
87
|
this.getSubscribers = getSubscribers.bind(this);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.getNewsletters = getNewsletters.bind(this);
|
|
105
|
-
this.getNewsletterSubscription = getNewsletterSubscription.bind(this);
|
|
106
|
-
this.requestUsernameChange = requestUsernameChange.bind(this);
|
|
107
|
-
this.grantPrivateRecordAccess = grantPrivateRecordAccess.bind(this);
|
|
108
|
-
this.removePrivateRecordAccess = removePrivateRecordAccess.bind(this);
|
|
109
|
-
this.listPrivateRecordAccess = listPrivateRecordAccess.bind(this);
|
|
110
|
-
this.requestPrivateRecordAccessKey = requestPrivateRecordAccessKey.bind(this);
|
|
111
|
-
this.listHostDirectory = listHostDirectory.bind(this);
|
|
112
|
-
this.deleteFiles = deleteFiles.bind(this);
|
|
113
|
-
if (typeof service_id !== 'string' || typeof owner !== 'string') {
|
|
114
|
-
throw new SkapiError('"service_id" and "owner" should be type <string>.', { code: 'INVALID_PARAMETER' });
|
|
88
|
+
if (typeof service !== 'string' || typeof owner !== 'string') {
|
|
89
|
+
throw new SkapiError('"service" and "owner" should be type <string>.', { code: 'INVALID_PARAMETER' });
|
|
115
90
|
}
|
|
116
|
-
if (!
|
|
117
|
-
throw new SkapiError('"
|
|
91
|
+
if (!service || !owner) {
|
|
92
|
+
throw new SkapiError('"service" and "owner" is required', { code: 'INVALID_PARAMETER' });
|
|
118
93
|
}
|
|
119
94
|
if (owner !== this.host) {
|
|
120
95
|
validator.UserId(owner, '"owner"');
|
|
121
96
|
}
|
|
122
|
-
this.service =
|
|
97
|
+
this.service = service;
|
|
123
98
|
this.owner = owner;
|
|
124
99
|
let autoLogin = typeof options?.autoLogin === 'boolean' ? options.autoLogin : true;
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
let sreg = service_id.substring(0, 4);
|
|
100
|
+
const cdn_domain = `https://${this.target_cdn}.cloudfront.net`;
|
|
101
|
+
let sreg = service.substring(0, 4);
|
|
128
102
|
this.admin_endpoint = fetch(`${cdn_domain}/${sreg}/admin.json`)
|
|
129
103
|
.then(response => response.blob())
|
|
130
104
|
.then(blob => new Promise((resolve, reject) => {
|
|
@@ -147,7 +121,7 @@ export default class Skapi {
|
|
|
147
121
|
if (!window.sessionStorage) {
|
|
148
122
|
throw new Error(`This browser does not support skapi.`);
|
|
149
123
|
}
|
|
150
|
-
const restore = JSON.parse(window.sessionStorage.getItem(`${
|
|
124
|
+
const restore = JSON.parse(window.sessionStorage.getItem(`${service}#${owner}`) || 'null');
|
|
151
125
|
if (restore?.connection) {
|
|
152
126
|
for (let k in restore) {
|
|
153
127
|
this[k] = restore[k];
|
|
@@ -172,7 +146,6 @@ export default class Skapi {
|
|
|
172
146
|
process.push(authentication.bind(this)().getSession({ refreshToken: !restore?.connection }).catch(err => {
|
|
173
147
|
this.__user = null;
|
|
174
148
|
}));
|
|
175
|
-
this.updateConnection();
|
|
176
149
|
}
|
|
177
150
|
let awaitProcess;
|
|
178
151
|
if (process.length) {
|
|
@@ -194,7 +167,7 @@ export default class Skapi {
|
|
|
194
167
|
for (let k of to_be_cached) {
|
|
195
168
|
data[k] = this[k];
|
|
196
169
|
}
|
|
197
|
-
window.sessionStorage.setItem(`${
|
|
170
|
+
window.sessionStorage.setItem(`${service}#${owner}`, JSON.stringify(data));
|
|
198
171
|
this.__class_properties_has_been_cached = true;
|
|
199
172
|
}
|
|
200
173
|
};
|
|
@@ -214,23 +187,104 @@ export default class Skapi {
|
|
|
214
187
|
console.log(`Built with:\n${skapi}Version: ${this.version}\n\nDocumentation: https://docs.skapi.com`, `font-family: monospace; color:blue;`);
|
|
215
188
|
return this.connection;
|
|
216
189
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
190
|
+
getConnection() {
|
|
191
|
+
return getConnection.bind(this)();
|
|
192
|
+
}
|
|
193
|
+
getProfile(options) {
|
|
194
|
+
return getProfile.bind(this)(options);
|
|
195
|
+
}
|
|
196
|
+
getFile(url, config) {
|
|
197
|
+
return getFile.bind(this)(url, config);
|
|
198
|
+
}
|
|
199
|
+
secureRequest(params) {
|
|
200
|
+
return secureRequest.bind(this)(params);
|
|
201
|
+
}
|
|
202
|
+
getFormResponse() {
|
|
203
|
+
return getFormResponse.bind(this)();
|
|
204
|
+
}
|
|
205
|
+
getRecords(query, fetchOptions) {
|
|
206
|
+
return getRecords.bind(this)(query, fetchOptions);
|
|
207
|
+
}
|
|
208
|
+
getTables(query, fetchOptions) {
|
|
209
|
+
return getTables.bind(this)(query, fetchOptions);
|
|
210
|
+
}
|
|
211
|
+
getIndexes(query, fetchOptions) { return getIndexes.bind(this)(query, fetchOptions); }
|
|
212
|
+
getTags(query, fetchOptions) { return getTags.bind(this)(query, fetchOptions); }
|
|
213
|
+
deleteRecords(params) { return deleteRecords.bind(this)(params); }
|
|
214
|
+
resendSignupConfirmation(redirect) {
|
|
215
|
+
return resendSignupConfirmation.bind(this)(redirect);
|
|
216
|
+
}
|
|
217
|
+
recoverAccount(redirect = false) {
|
|
218
|
+
return recoverAccount.bind(this)(redirect);
|
|
219
|
+
}
|
|
220
|
+
getUsers(params, fetchOptions) {
|
|
221
|
+
return getUsers.bind(this)(params, fetchOptions);
|
|
222
|
+
}
|
|
223
|
+
disableAccount() {
|
|
224
|
+
return disableAccount.bind(this)();
|
|
225
|
+
}
|
|
226
|
+
lastVerifiedEmail(params) {
|
|
227
|
+
return lastVerifiedEmail.bind(this)(params);
|
|
228
|
+
}
|
|
229
|
+
getSubscriptions(params, fetchOptions, _mapper) {
|
|
230
|
+
return getSubscriptions.bind(this)(params, fetchOptions, _mapper);
|
|
231
|
+
}
|
|
232
|
+
unsubscribeNewsletter(params) {
|
|
233
|
+
return unsubscribeNewsletter.bind(this)(params);
|
|
234
|
+
}
|
|
235
|
+
getNewsletters(params, fetchOptions) {
|
|
236
|
+
return getNewsletters.bind(this)(params, fetchOptions);
|
|
237
|
+
}
|
|
238
|
+
getNewsletterSubscription(params) {
|
|
239
|
+
return getNewsletterSubscription.bind(this)(params);
|
|
240
|
+
}
|
|
241
|
+
requestUsernameChange(params) { return requestUsernameChange.bind(this)(params); }
|
|
242
|
+
grantPrivateRecordAccess(params) { return grantPrivateRecordAccess.bind(this)(params); }
|
|
243
|
+
removePrivateRecordAccess(params) {
|
|
244
|
+
return removePrivateRecordAccess.bind(this)(params);
|
|
245
|
+
}
|
|
246
|
+
listPrivateRecordAccess(params) { return listPrivateRecordAccess.bind(this)(params); }
|
|
247
|
+
requestPrivateRecordAccessKey(record_id) {
|
|
248
|
+
return requestPrivateRecordAccessKey.bind(this)(record_id);
|
|
249
|
+
}
|
|
250
|
+
deleteFiles(params) {
|
|
251
|
+
return deleteFiles.bind(this)(params);
|
|
252
|
+
}
|
|
253
|
+
uploadFiles(fileList, params) { return uploadFiles.bind(this)(fileList, params); }
|
|
254
|
+
mock(data, options) { return mock.bind(this)(data, options); }
|
|
255
|
+
login(form) { return login.bind(this)(form); }
|
|
256
|
+
logout() { return logout.bind(this)(); }
|
|
257
|
+
signup(form, option) {
|
|
258
|
+
return signup.bind(this)(form, option);
|
|
259
|
+
}
|
|
260
|
+
resetPassword(form) { return resetPassword.bind(this)(form); }
|
|
261
|
+
verifyEmail(form) {
|
|
262
|
+
return verifyEmail.bind(this)(form);
|
|
263
|
+
}
|
|
264
|
+
verifyPhoneNumber(form) {
|
|
265
|
+
return verifyPhoneNumber.bind(this)(form);
|
|
266
|
+
}
|
|
267
|
+
forgotPassword(form) {
|
|
268
|
+
return forgotPassword.bind(this)(form);
|
|
269
|
+
}
|
|
270
|
+
changePassword(params) { return changePassword.bind(this)(params); }
|
|
271
|
+
updateProfile(form) { return updateProfile.bind(this)(form); }
|
|
272
|
+
postRecord(form, config) { return postRecord.bind(this)(form, config); }
|
|
273
|
+
subscribe(option) {
|
|
274
|
+
return subscribe.bind(this)(option);
|
|
275
|
+
}
|
|
276
|
+
unsubscribe(option) {
|
|
277
|
+
return unsubscribe.bind(this)(option);
|
|
278
|
+
}
|
|
279
|
+
blockSubscriber(option) {
|
|
280
|
+
return blockSubscriber.bind(this)(option);
|
|
281
|
+
}
|
|
282
|
+
unblockSubscriber(option) {
|
|
283
|
+
return unblockSubscriber.bind(this)(option);
|
|
284
|
+
}
|
|
285
|
+
subscribeNewsletter(form) {
|
|
286
|
+
return subscribeNewsletter.bind(this)(form);
|
|
287
|
+
}
|
|
234
288
|
}
|
|
235
289
|
__decorate([
|
|
236
290
|
formHandler()
|
package/js/methods/database.d.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { RecordData, Form, FormSubmitCallback, FetchOptions, DatabaseResponse, GetRecordQuery, Condition, PostRecordConfig, ProgressCallback } from '../Types';
|
|
2
2
|
export declare function deleteFiles(params: {
|
|
3
|
-
service?: string;
|
|
4
3
|
endpoints: string | string[];
|
|
5
|
-
|
|
6
|
-
}): Promise<any>;
|
|
4
|
+
}): Promise<RecordData[]>;
|
|
7
5
|
export declare function uploadFiles(fileList: Form<FileList | File[]>, params: {
|
|
8
|
-
service?: string;
|
|
9
6
|
record_id: string;
|
|
10
|
-
|
|
11
|
-
progress: ProgressCallback;
|
|
12
|
-
}): Promise<{
|
|
7
|
+
} & FormSubmitCallback): Promise<{
|
|
13
8
|
completed: File[];
|
|
14
9
|
failed: File[];
|
|
15
10
|
}>;
|
|
@@ -41,13 +36,13 @@ export declare function getIndexes(query: {
|
|
|
41
36
|
table: string;
|
|
42
37
|
index: string;
|
|
43
38
|
number_of_records: number;
|
|
44
|
-
string_count
|
|
45
|
-
number_count
|
|
46
|
-
boolean_count
|
|
47
|
-
total_number
|
|
48
|
-
total_bool
|
|
49
|
-
average_number
|
|
50
|
-
average_bool
|
|
39
|
+
string_count?: number;
|
|
40
|
+
number_count?: number;
|
|
41
|
+
boolean_count?: number;
|
|
42
|
+
total_number?: number;
|
|
43
|
+
total_bool?: number;
|
|
44
|
+
average_number?: number;
|
|
45
|
+
average_bool?: number;
|
|
51
46
|
}>>;
|
|
52
47
|
export declare function getTags(query: {
|
|
53
48
|
table: string;
|
|
@@ -71,13 +66,13 @@ export declare function deleteRecords(params: {
|
|
|
71
66
|
export declare function grantPrivateRecordAccess(params: {
|
|
72
67
|
record_id: string;
|
|
73
68
|
user_id: string | string[];
|
|
74
|
-
}):
|
|
69
|
+
}): any;
|
|
75
70
|
export declare function removePrivateRecordAccess(params: {
|
|
76
71
|
record_id: string;
|
|
77
72
|
user_id: string | string[];
|
|
78
|
-
}):
|
|
73
|
+
}): any;
|
|
79
74
|
export declare function listPrivateRecordAccess(params: {
|
|
80
75
|
record_id: string;
|
|
81
76
|
user_id: string | string[];
|
|
82
|
-
}):
|
|
83
|
-
export declare function requestPrivateRecordAccessKey(record_id: string):
|
|
77
|
+
}): any;
|
|
78
|
+
export declare function requestPrivateRecordAccessKey(record_id: string): any;
|