skapi-js 1.0.52 → 1.0.53-beta.1
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/main/skapi.d.ts +10 -4
- package/js/main/skapi.js +11 -5
- package/js/methods/user.d.ts +54 -2
- package/js/methods/user.js +48 -6
- package/package.json +1 -1
package/js/main/skapi.d.ts
CHANGED
|
@@ -59,13 +59,19 @@ export default class Skapi {
|
|
|
59
59
|
}): Promise<any>;
|
|
60
60
|
consumeTicket(params: {
|
|
61
61
|
ticket_id: string;
|
|
62
|
-
|
|
62
|
+
placeholder?: {
|
|
63
|
+
[key: string]: string;
|
|
64
|
+
};
|
|
65
|
+
}): Promise<any>;
|
|
63
66
|
releaseTicket(params: {
|
|
64
67
|
ticket_id: string;
|
|
65
68
|
}): Promise<string>;
|
|
66
|
-
|
|
67
|
-
ticket_id
|
|
68
|
-
}): Promise<
|
|
69
|
+
getConsumedTickets(params: {
|
|
70
|
+
ticket_id?: string;
|
|
71
|
+
}, fetchOptions: FetchOptions): Promise<DatabaseResponse<any[]>>;
|
|
72
|
+
getTickets(params: {
|
|
73
|
+
ticket_id?: string;
|
|
74
|
+
}, fetchOptions: FetchOptions): Promise<DatabaseResponse<any[]>>;
|
|
69
75
|
closeRealtime(): Promise<void>;
|
|
70
76
|
getRealtimeUsers(params: {
|
|
71
77
|
group: string;
|
package/js/main/skapi.js
CHANGED
|
@@ -10,7 +10,7 @@ import { getRecords, postRecord, deleteRecords, getTables, getIndexes, getTags,
|
|
|
10
10
|
import { connectRealtime, joinRealtime, postRealtime, closeRealtime, getRealtimeUsers, getRealtimeGroups } from '../methods/realtime';
|
|
11
11
|
import { request, secureRequest, mock, getFormResponse, formHandler, getConnection, clientSecretRequest } from '../methods/request';
|
|
12
12
|
import { subscribe, unsubscribe, blockSubscriber, unblockSubscriber, getSubscriptions, subscribeNewsletter, getNewsletters, unsubscribeNewsletter, getNewsletterSubscription } from '../methods/subscription';
|
|
13
|
-
import { checkAdmin, getProfile, logout, recoverAccount, resendSignupConfirmation, authentication, login, signup, disableAccount, resetPassword, verifyEmail, verifyPhoneNumber, forgotPassword, changePassword, updateProfile, getUsers, setUserPool, userPool, lastVerifiedEmail, requestUsernameChange, consumeTicket, releaseTicket,
|
|
13
|
+
import { checkAdmin, getProfile, logout, recoverAccount, resendSignupConfirmation, authentication, login, signup, disableAccount, resetPassword, verifyEmail, verifyPhoneNumber, forgotPassword, changePassword, updateProfile, getUsers, setUserPool, userPool, lastVerifiedEmail, requestUsernameChange, consumeTicket, releaseTicket, getConsumedTickets, jwtLogin } from '../methods/user';
|
|
14
14
|
export default class Skapi {
|
|
15
15
|
get user() {
|
|
16
16
|
if (this.__user && Object.keys(this.__user).length) {
|
|
@@ -23,7 +23,7 @@ export default class Skapi {
|
|
|
23
23
|
set user(value) {
|
|
24
24
|
}
|
|
25
25
|
constructor(service, owner, options, __etc) {
|
|
26
|
-
this.version = '1.0.
|
|
26
|
+
this.version = '1.0.53';
|
|
27
27
|
this.session = null;
|
|
28
28
|
this.connection = null;
|
|
29
29
|
this.host = 'skapi';
|
|
@@ -213,8 +213,11 @@ export default class Skapi {
|
|
|
213
213
|
releaseTicket(params) {
|
|
214
214
|
return releaseTicket.bind(this)(params);
|
|
215
215
|
}
|
|
216
|
-
|
|
217
|
-
return
|
|
216
|
+
getConsumedTickets(params, fetchOptions) {
|
|
217
|
+
return getConsumedTickets.bind(this)(params, fetchOptions);
|
|
218
|
+
}
|
|
219
|
+
getTickets(params, fetchOptions) {
|
|
220
|
+
return getConsumedTickets.bind(this)(params, fetchOptions);
|
|
218
221
|
}
|
|
219
222
|
closeRealtime() {
|
|
220
223
|
return closeRealtime.bind(this)();
|
|
@@ -338,7 +341,10 @@ __decorate([
|
|
|
338
341
|
], Skapi.prototype, "releaseTicket", null);
|
|
339
342
|
__decorate([
|
|
340
343
|
formHandler()
|
|
341
|
-
], Skapi.prototype, "
|
|
344
|
+
], Skapi.prototype, "getConsumedTickets", null);
|
|
345
|
+
__decorate([
|
|
346
|
+
formHandler()
|
|
347
|
+
], Skapi.prototype, "getTickets", null);
|
|
342
348
|
__decorate([
|
|
343
349
|
formHandler()
|
|
344
350
|
], Skapi.prototype, "getRealtimeUsers", null);
|
package/js/methods/user.d.ts
CHANGED
|
@@ -7,11 +7,63 @@ export declare function setUserPool(params: {
|
|
|
7
7
|
}): void;
|
|
8
8
|
export declare function consumeTicket(params: {
|
|
9
9
|
ticket_id: string;
|
|
10
|
-
|
|
10
|
+
placeholder?: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
}): Promise<any>;
|
|
11
14
|
export declare function releaseTicket(params: {
|
|
12
15
|
ticket_id: string;
|
|
13
16
|
}): Promise<string>;
|
|
14
|
-
export declare function
|
|
17
|
+
export declare function getTickets(params: {
|
|
18
|
+
ticket_id?: string;
|
|
19
|
+
}, fetchOptions?: FetchOptions): Promise<DatabaseResponse<any[]>>;
|
|
20
|
+
export declare function getConsumedTickets(params: {
|
|
21
|
+
ticket_id?: string;
|
|
22
|
+
}, fetchOptions?: FetchOptions): Promise<DatabaseResponse<any[]>>;
|
|
23
|
+
export declare function registerTicket(serviceId: string, params: {
|
|
24
|
+
ticket_id: string;
|
|
25
|
+
condition?: {
|
|
26
|
+
user?: {
|
|
27
|
+
[key: string]: {
|
|
28
|
+
value: string;
|
|
29
|
+
operator: 'gt' | 'gte' | 'lt' | 'lte' | 'eq' | 'ne' | '>' | '>=' | '<' | '<=' | '=' | '!=';
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
record_access?: string;
|
|
33
|
+
request?: {
|
|
34
|
+
url: string;
|
|
35
|
+
method: 'GET' | 'POST';
|
|
36
|
+
headers?: {
|
|
37
|
+
[key: string]: string;
|
|
38
|
+
};
|
|
39
|
+
data?: Record<string, any>;
|
|
40
|
+
params?: Record<string, any>;
|
|
41
|
+
match: {
|
|
42
|
+
target_key: string;
|
|
43
|
+
operator: 'gt' | 'gte' | 'lt' | 'lte' | 'eq' | 'ne' | '>' | '>=' | '<' | '<=' | '=' | '!=';
|
|
44
|
+
value: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
action?: {
|
|
49
|
+
access_group: number;
|
|
50
|
+
record_access?: string;
|
|
51
|
+
request?: {
|
|
52
|
+
url: string;
|
|
53
|
+
method: 'GET' | 'POST';
|
|
54
|
+
headers?: {
|
|
55
|
+
[key: string]: string;
|
|
56
|
+
};
|
|
57
|
+
data?: Record<string, any>;
|
|
58
|
+
params?: Record<string, any>;
|
|
59
|
+
};
|
|
60
|
+
upgrade_service?: number;
|
|
61
|
+
};
|
|
62
|
+
desc: string;
|
|
63
|
+
count?: number;
|
|
64
|
+
time_to_live?: number;
|
|
65
|
+
}): Promise<string>;
|
|
66
|
+
export declare function unregisterTicket(serviceId: string, params: {
|
|
15
67
|
ticket_id: string;
|
|
16
68
|
}): Promise<string>;
|
|
17
69
|
export declare function authentication(): {
|
package/js/methods/user.js
CHANGED
|
@@ -12,19 +12,61 @@ export function consumeTicket(params) {
|
|
|
12
12
|
if (!params.ticket_id) {
|
|
13
13
|
throw new SkapiError('Ticket ID is required.', { code: 'INVALID_PARAMETER' });
|
|
14
14
|
}
|
|
15
|
-
return request.bind(this)('ticket', {
|
|
15
|
+
return request.bind(this)('ticket', Object.assign({ exec: 'consume' }, params), { auth: true });
|
|
16
16
|
}
|
|
17
17
|
export function releaseTicket(params) {
|
|
18
18
|
if (!params.ticket_id) {
|
|
19
19
|
throw new SkapiError('Ticket ID is required.', { code: 'INVALID_PARAMETER' });
|
|
20
20
|
}
|
|
21
|
-
return request.bind(this)('ticket', {
|
|
21
|
+
return request.bind(this)('ticket', Object.assign({ exec: 'release' }, params), { auth: true });
|
|
22
22
|
}
|
|
23
|
-
export function
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export async function getTickets(params, fetchOptions) {
|
|
24
|
+
let tickets = await request.bind(this)('ticket', Object.assign({ exec: 'list' }, params), { auth: true, fetchOptions });
|
|
25
|
+
for (let t of tickets.list) {
|
|
26
|
+
let mapper = {
|
|
27
|
+
"tkid": 'ticket_id',
|
|
28
|
+
"cond": 'condition',
|
|
29
|
+
"actn": 'action',
|
|
30
|
+
"cnt": 'count',
|
|
31
|
+
"ttl": 'time_to_live',
|
|
32
|
+
"stmp": 'timestamp',
|
|
33
|
+
'plch': 'placeholder'
|
|
34
|
+
};
|
|
35
|
+
for (let k in t) {
|
|
36
|
+
if (mapper[k]) {
|
|
37
|
+
t[mapper[k]] = t[k];
|
|
38
|
+
delete t[k];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return tickets;
|
|
43
|
+
}
|
|
44
|
+
export async function getConsumedTickets(params, fetchOptions) {
|
|
45
|
+
let tickets = await request.bind(this)('ticket', { ticket_id: params.ticket_id, exec: 'request' }, { auth: true, fetchOptions });
|
|
46
|
+
for (let t of tickets.list) {
|
|
47
|
+
let mapper = {
|
|
48
|
+
"tkid": 'ticket_id',
|
|
49
|
+
"cond": 'condition',
|
|
50
|
+
"actn": 'action',
|
|
51
|
+
"cnt": 'count',
|
|
52
|
+
"ttl": 'time_to_live',
|
|
53
|
+
"stmp": 'timestamp',
|
|
54
|
+
'plch': 'placeholder'
|
|
55
|
+
};
|
|
56
|
+
for (let k in t) {
|
|
57
|
+
if (mapper[k]) {
|
|
58
|
+
t[mapper[k]] = t[k];
|
|
59
|
+
delete t[k];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
26
62
|
}
|
|
27
|
-
return
|
|
63
|
+
return tickets;
|
|
64
|
+
}
|
|
65
|
+
export function registerTicket(serviceId, params) {
|
|
66
|
+
return this.request('ticket', Object.assign({ exec: 'reg' }, params, { service: serviceId }), { auth: true });
|
|
67
|
+
}
|
|
68
|
+
export function unregisterTicket(serviceId, params) {
|
|
69
|
+
return this.request('ticket', Object.assign({ exec: 'unreg' }, params, { service: serviceId }), { auth: true });
|
|
28
70
|
}
|
|
29
71
|
export function authentication() {
|
|
30
72
|
if (!userPool)
|