skapi-js 1.0.62 → 1.0.63-beta.0

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,4 +1,5 @@
1
1
  import { DatabaseResponse, Connection, ProgressCallback, GetRecordQuery, FetchOptions, RecordData, Condition, UserAttributes, UserProfile, Newsletters, Form, PostRecordConfig, PublicUser } from '../Types';
2
+ import { extractFormData } from '../utils/utils';
2
3
  export default class Skapi {
3
4
  version: string;
4
5
  service: string;
@@ -26,6 +27,7 @@ export default class Skapi {
26
27
  birthdate(val: string): boolean;
27
28
  email(val: string): boolean;
28
29
  };
30
+ extractFormData: typeof extractFormData;
29
31
  private __connection;
30
32
  private __authConnection;
31
33
  private __socket;
package/js/main/skapi.js CHANGED
@@ -12,6 +12,7 @@ import { secureRequest, mock, clientSecretRequest } from '../methods/request';
12
12
  import { request, getFormResponse, formHandler, uploadFiles, hostFiles, } from '../utils/network';
13
13
  import { subscribe, unsubscribe, blockSubscriber, unblockSubscriber, getSubscriptions, subscribeNewsletter, getNewsletters, unsubscribeNewsletter, getNewsletterSubscription } from '../methods/subscription';
14
14
  import { checkAdmin, getProfile, logout, recoverAccount, resendSignupConfirmation, authentication, login, signup, disableAccount, resetPassword, verifyEmail, verifyPhoneNumber, forgotPassword, changePassword, updateProfile, getUsers, setUserPool, userPool, lastVerifiedEmail, requestUsernameChange, consumeTicket, getConsumedTickets, getTickets, registerTicket, unregisterTicket, jwtLogin } from '../methods/user';
15
+ import { extractFormData } from '../utils/utils';
15
16
  export default class Skapi {
16
17
  get user() {
17
18
  if (this.__user && Object.keys(this.__user).length) {
@@ -24,7 +25,7 @@ export default class Skapi {
24
25
  set user(value) {
25
26
  }
26
27
  constructor(service, owner, options, __etc) {
27
- this.version = '1.0.62';
28
+ this.version = '1.0.63';
28
29
  this.session = null;
29
30
  this.connection = null;
30
31
  this.host = 'skapi';
@@ -84,6 +85,7 @@ export default class Skapi {
84
85
  }
85
86
  }
86
87
  };
88
+ this.extractFormData = extractFormData;
87
89
  this.checkAdmin = checkAdmin.bind(this);
88
90
  this.request = request.bind(this);
89
91
  this.registerTicket = registerTicket.bind(this);
@@ -66,10 +66,10 @@ export async function getConsumedTickets(params, fetchOptions) {
66
66
  return tickets;
67
67
  }
68
68
  export async function registerTicket(params) {
69
- return this.request('register-ticket', Object.assign({ exec: 'reg' }, params), { auth: true });
69
+ return request.bind(this)('register-ticket', Object.assign({ exec: 'reg' }, params), { auth: true });
70
70
  }
71
71
  export async function unregisterTicket(params) {
72
- return this.request('register-ticket', Object.assign({ exec: 'unreg' }, params), { auth: true });
72
+ return request.bind(this)('register-ticket', Object.assign({ exec: 'unreg' }, params), { auth: true });
73
73
  }
74
74
  export function authentication() {
75
75
  if (!userPool)
@@ -1,10 +1,10 @@
1
1
  import { Form, FetchOptions, ProgressCallback } from '../Types';
2
- export declare function request(url: string, data?: Form<any> | null, options?: {
2
+ export declare function request(url: string, data?: Form<any>, options?: {
3
3
  fetchOptions?: FetchOptions;
4
4
  auth?: boolean;
5
5
  method?: string;
6
6
  bypassAwaitConnection?: boolean;
7
- responseType?: 'json' | 'blob' | 'text' | 'arrayBuffer' | 'formData' | 'document' | null;
7
+ responseType?: 'json' | 'blob' | 'text' | 'arrayBuffer' | 'formData' | 'document';
8
8
  contentType?: string;
9
9
  }): Promise<any>;
10
10
  export declare function hostFiles(fileList: FormData, params: {
package/js/utils/utils.js CHANGED
@@ -168,11 +168,11 @@ function extractFormData(form) {
168
168
  function appendData(data, key, val) {
169
169
  let keys = key.split('[').map(k => {
170
170
  let key = k.replace(']', '');
171
- if (key.match(/\d+/)) {
171
+ if (key.match(/\d+/) && !key.includes('.')) {
172
172
  key = Number(key);
173
173
  }
174
174
  else if (key[0] === '"' && key[key.length - 1] === '"' || key[0] === "'" && key[key.length - 1] === "'") {
175
- key = key.replace(/"/g, '');
175
+ key = key.replace(/"/g, '').replace(/'/g, '');
176
176
  }
177
177
  return key;
178
178
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skapi-js",
3
- "version": "1.0.62",
3
+ "version": "1.0.63-beta.0",
4
4
  "description": "Skapi: Backend API Library for HTML frontend.",
5
5
  "main": "dist/skapi.module.js",
6
6
  "types": "js/Main.d.ts",