@ptkl/sdk 0.9.5 → 0.9.7

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/index.esm.js CHANGED
@@ -35,13 +35,13 @@ const isBrowser = typeof window !== "undefined" &&
35
35
  class PlatformBaseClient extends BaseClient {
36
36
  constructor(options) {
37
37
  var _a, _b;
38
- let { env = null, token = null, host = null, } = options !== null && options !== undefined ? options : {};
38
+ let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
39
39
  let headers = {};
40
40
  var project_uuid = null;
41
41
  if (isBrowser) {
42
42
  console.log("DEBUG", sessionStorage.getItem('protokol_context'));
43
43
  if (sessionStorage.getItem('protokol_context') == "forge") {
44
- headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
44
+ headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
45
45
  }
46
46
  else {
47
47
  // this potentially means that it is running as dev server in local
@@ -50,12 +50,12 @@ class PlatformBaseClient extends BaseClient {
50
50
  }
51
51
  if (typeof window !== "undefined") {
52
52
  // @ts-ignore
53
- const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
54
- host = (_b = __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.API_HOST) !== null && _b !== undefined ? _b : host;
53
+ const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
54
+ host = (_b = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _b !== void 0 ? _b : host;
55
55
  // @ts-ignore
56
- env = env !== null && env !== undefined ? env : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_ENV;
57
- token = token !== null && token !== undefined ? token : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_API_TOKEN;
58
- project_uuid = __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_UUID;
56
+ env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
57
+ token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
58
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
59
59
  }
60
60
  if (token) {
61
61
  headers['Authorization'] = `Bearer ${token}`;
@@ -67,8 +67,8 @@ class PlatformBaseClient extends BaseClient {
67
67
  headers['X-Project-Uuid'] = project_uuid;
68
68
  }
69
69
  const client = axios.create({
70
- baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io",
71
- timeout: 15000,
70
+ baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
71
+ timeout: 30000,
72
72
  headers: {
73
73
  ...headers,
74
74
  'Content-Type': 'application/json',
@@ -171,6 +171,14 @@ class Users extends PlatformBaseClient {
171
171
  roles,
172
172
  });
173
173
  }
174
+ //Gets the current user's claims
175
+ async getClaims() {
176
+ return await this.client.get("/v1/user/claims");
177
+ }
178
+ //Gets the current user's model
179
+ async getUser() {
180
+ return await this.client.get("/v1/user/model");
181
+ }
174
182
  async delete(uuid) {
175
183
  return await this.client.delete(`/v1/project/user/${uuid}`);
176
184
  }
@@ -240,7 +248,7 @@ class Component extends PlatformBaseClient {
240
248
  * )
241
249
  **/
242
250
  async find(filters, opts) {
243
- const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== undefined ? opts : {};
251
+ const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== void 0 ? opts : {};
244
252
  let payload = {
245
253
  context: filters,
246
254
  ref: this.ref,
@@ -280,6 +288,9 @@ class Component extends PlatformBaseClient {
280
288
  }
281
289
  if (opts) {
282
290
  Object.keys(opts).forEach(k => {
291
+ if (['cache', 'buildttl', 'locale'].includes(k)) {
292
+ return;
293
+ }
283
294
  params[`_opt_${k}`] = opts ? opts[k] : null;
284
295
  });
285
296
  }
@@ -535,7 +546,7 @@ class Platform extends PlatformBaseClient {
535
546
  }
536
547
  getPlatformBaseURL() {
537
548
  var _a;
538
- return (_a = this.client.defaults.baseURL) !== null && _a !== undefined ? _a : "";
549
+ return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
539
550
  }
540
551
  apiUser() {
541
552
  return (new APIUser()).setClient(this.client);
@@ -606,12 +617,12 @@ class Invoicing extends PlatformBaseClient {
606
617
  class IntegrationsBaseClient extends BaseClient {
607
618
  constructor(options) {
608
619
  var _a, _b;
609
- let { env = null, token, host, } = options !== null && options !== undefined ? options : {};
620
+ let { env = null, token, host, } = options !== null && options !== void 0 ? options : {};
610
621
  let headers = {};
611
622
  var project_uuid = null;
612
623
  if (isBrowser) {
613
624
  if (sessionStorage.getItem('protokol_context') == "forge") {
614
- headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
625
+ headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
615
626
  }
616
627
  else {
617
628
  // this potentially means that it is running as dev server in local
@@ -620,13 +631,13 @@ class IntegrationsBaseClient extends BaseClient {
620
631
  }
621
632
  if (typeof window !== "undefined") {
622
633
  // @ts-ignore
623
- const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
624
- host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== undefined ? _b : host;
634
+ const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
635
+ host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== void 0 ? _b : host;
625
636
  // @ts-ignore
626
- token = token !== null && token !== undefined ? token : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_API_TOKEN;
637
+ token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
627
638
  // @ts-ignore
628
- env = env !== null && env !== undefined ? env : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_ENV;
629
- project_uuid = __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_UUID;
639
+ env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
640
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
630
641
  }
631
642
  if (token) {
632
643
  headers['Authorization'] = `Bearer ${token}`;
@@ -638,8 +649,8 @@ class IntegrationsBaseClient extends BaseClient {
638
649
  headers['X-Project-Uuid'] = project_uuid;
639
650
  }
640
651
  const client = axios.create({
641
- baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io/luma/integrations",
642
- timeout: 15000,
652
+ baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
653
+ timeout: 30000,
643
654
  headers: {
644
655
  ...headers,
645
656
  },
@@ -809,7 +820,7 @@ class Payments extends IntegrationsBaseClient {
809
820
  return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, {
810
821
  totalAmount: options.totalAmount.toString(),
811
822
  description: options.description,
812
- redirectUrl: (_a = options.redirectUrl) !== null && _a !== undefined ? _a : null,
823
+ redirectUrl: (_a = options.redirectUrl) !== null && _a !== void 0 ? _a : null,
813
824
  });
814
825
  }
815
826
  }
@@ -36,13 +36,13 @@ var ProtokolSDK09 = (function (exports, axios) {
36
36
  class PlatformBaseClient extends BaseClient {
37
37
  constructor(options) {
38
38
  var _a, _b;
39
- let { env = null, token = null, host = null, } = options !== null && options !== undefined ? options : {};
39
+ let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
40
40
  let headers = {};
41
41
  var project_uuid = null;
42
42
  if (isBrowser) {
43
43
  console.log("DEBUG", sessionStorage.getItem('protokol_context'));
44
44
  if (sessionStorage.getItem('protokol_context') == "forge") {
45
- headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
45
+ headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
46
46
  }
47
47
  else {
48
48
  // this potentially means that it is running as dev server in local
@@ -51,12 +51,12 @@ var ProtokolSDK09 = (function (exports, axios) {
51
51
  }
52
52
  if (typeof window !== "undefined") {
53
53
  // @ts-ignore
54
- const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
55
- host = (_b = __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.API_HOST) !== null && _b !== undefined ? _b : host;
54
+ const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
55
+ host = (_b = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _b !== void 0 ? _b : host;
56
56
  // @ts-ignore
57
- env = env !== null && env !== undefined ? env : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_ENV;
58
- token = token !== null && token !== undefined ? token : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_API_TOKEN;
59
- project_uuid = __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_UUID;
57
+ env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
58
+ token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
59
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
60
60
  }
61
61
  if (token) {
62
62
  headers['Authorization'] = `Bearer ${token}`;
@@ -68,8 +68,8 @@ var ProtokolSDK09 = (function (exports, axios) {
68
68
  headers['X-Project-Uuid'] = project_uuid;
69
69
  }
70
70
  const client = axios.create({
71
- baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io",
72
- timeout: 15000,
71
+ baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
72
+ timeout: 30000,
73
73
  headers: {
74
74
  ...headers,
75
75
  'Content-Type': 'application/json',
@@ -172,6 +172,14 @@ var ProtokolSDK09 = (function (exports, axios) {
172
172
  roles,
173
173
  });
174
174
  }
175
+ //Gets the current user's claims
176
+ async getClaims() {
177
+ return await this.client.get("/v1/user/claims");
178
+ }
179
+ //Gets the current user's model
180
+ async getUser() {
181
+ return await this.client.get("/v1/user/model");
182
+ }
175
183
  async delete(uuid) {
176
184
  return await this.client.delete(`/v1/project/user/${uuid}`);
177
185
  }
@@ -241,7 +249,7 @@ var ProtokolSDK09 = (function (exports, axios) {
241
249
  * )
242
250
  **/
243
251
  async find(filters, opts) {
244
- const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== undefined ? opts : {};
252
+ const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== void 0 ? opts : {};
245
253
  let payload = {
246
254
  context: filters,
247
255
  ref: this.ref,
@@ -281,6 +289,9 @@ var ProtokolSDK09 = (function (exports, axios) {
281
289
  }
282
290
  if (opts) {
283
291
  Object.keys(opts).forEach(k => {
292
+ if (['cache', 'buildttl', 'locale'].includes(k)) {
293
+ return;
294
+ }
284
295
  params[`_opt_${k}`] = opts ? opts[k] : null;
285
296
  });
286
297
  }
@@ -536,7 +547,7 @@ var ProtokolSDK09 = (function (exports, axios) {
536
547
  }
537
548
  getPlatformBaseURL() {
538
549
  var _a;
539
- return (_a = this.client.defaults.baseURL) !== null && _a !== undefined ? _a : "";
550
+ return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
540
551
  }
541
552
  apiUser() {
542
553
  return (new APIUser()).setClient(this.client);
@@ -607,12 +618,12 @@ var ProtokolSDK09 = (function (exports, axios) {
607
618
  class IntegrationsBaseClient extends BaseClient {
608
619
  constructor(options) {
609
620
  var _a, _b;
610
- let { env = null, token, host, } = options !== null && options !== undefined ? options : {};
621
+ let { env = null, token, host, } = options !== null && options !== void 0 ? options : {};
611
622
  let headers = {};
612
623
  var project_uuid = null;
613
624
  if (isBrowser) {
614
625
  if (sessionStorage.getItem('protokol_context') == "forge") {
615
- headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
626
+ headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
616
627
  }
617
628
  else {
618
629
  // this potentially means that it is running as dev server in local
@@ -621,13 +632,13 @@ var ProtokolSDK09 = (function (exports, axios) {
621
632
  }
622
633
  if (typeof window !== "undefined") {
623
634
  // @ts-ignore
624
- const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
625
- host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== undefined ? _b : host;
635
+ const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
636
+ host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== void 0 ? _b : host;
626
637
  // @ts-ignore
627
- token = token !== null && token !== undefined ? token : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_API_TOKEN;
638
+ token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
628
639
  // @ts-ignore
629
- env = env !== null && env !== undefined ? env : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_ENV;
630
- project_uuid = __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_UUID;
640
+ env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
641
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
631
642
  }
632
643
  if (token) {
633
644
  headers['Authorization'] = `Bearer ${token}`;
@@ -639,8 +650,8 @@ var ProtokolSDK09 = (function (exports, axios) {
639
650
  headers['X-Project-Uuid'] = project_uuid;
640
651
  }
641
652
  const client = axios.create({
642
- baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io/luma/integrations",
643
- timeout: 15000,
653
+ baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
654
+ timeout: 30000,
644
655
  headers: {
645
656
  ...headers,
646
657
  },
@@ -810,7 +821,7 @@ var ProtokolSDK09 = (function (exports, axios) {
810
821
  return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, {
811
822
  totalAmount: options.totalAmount.toString(),
812
823
  description: options.description,
813
- redirectUrl: (_a = options.redirectUrl) !== null && _a !== undefined ? _a : null,
824
+ redirectUrl: (_a = options.redirectUrl) !== null && _a !== void 0 ? _a : null,
814
825
  });
815
826
  }
816
827
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "docs": "typedoc"
@@ -33,6 +33,7 @@
33
33
  "rollup": "^4.30.1",
34
34
  "rollup-plugin-copy": "^3.5.0",
35
35
  "rollup-plugin-polyfill-node": "^0.13.0",
36
+ "tslib": "^2.8.1",
36
37
  "typedoc": "^0.28.4",
37
38
  "typescript": "^5.6.3"
38
39
  },
@@ -1,7 +1,11 @@
1
1
  import PlatformBaseClient from "./platformBaseClient";
2
+ import { UserClaims, UserModel } from "../types/users";
3
+ import { AxiosResponse } from "axios";
2
4
  export default class Users extends PlatformBaseClient {
3
- invite(email: string, roles: string[]): Promise<import("axios").AxiosResponse<any, any>>;
4
- delete(uuid: string): Promise<import("axios").AxiosResponse<any, any>>;
5
- permissions(): Promise<import("axios").AxiosResponse<any, any>>;
6
- auth(username: string, password: string, project: string): Promise<import("axios").AxiosResponse<any, any>>;
5
+ invite(email: string, roles: string[]): Promise<AxiosResponse<any, any>>;
6
+ getClaims(): Promise<AxiosResponse<UserClaims>>;
7
+ getUser(): Promise<AxiosResponse<UserModel>>;
8
+ delete(uuid: string): Promise<AxiosResponse<any, any>>;
9
+ permissions(): Promise<AxiosResponse<any, any>>;
10
+ auth(username: string, password: string, project: string): Promise<AxiosResponse<any, any>>;
7
11
  }
@@ -21,4 +21,5 @@ export { default as SerbiaUtil } from './api/integrations/serbiaUtil';
21
21
  export { default as VPFR } from './api/integrations/vpfr';
22
22
  export type * from './types/component';
23
23
  export type * from './types/integrations';
24
+ export type * from './types/users';
24
25
  export default Platform;
@@ -0,0 +1,34 @@
1
+ export interface UserModel {
2
+ uuid: string;
3
+ name: string;
4
+ email: string;
5
+ login_at: string;
6
+ credits: number;
7
+ ref: string;
8
+ expires_at: string | null;
9
+ settings: {
10
+ uuid: string;
11
+ CreatedAt: string;
12
+ UpdatedAt: string;
13
+ DeletedAt: string | null;
14
+ user_uuid: string;
15
+ timezone: string;
16
+ two_auth: boolean;
17
+ billing_address: string | null;
18
+ };
19
+ custom_fields: unknown[];
20
+ }
21
+ export interface UserClaims {
22
+ Entity: {
23
+ uuid: string;
24
+ identificator: string;
25
+ name: string;
26
+ };
27
+ Type: string;
28
+ TwoFactor: boolean;
29
+ ProjectUUID: string;
30
+ IsAdmin: boolean;
31
+ Metadata: unknown | null;
32
+ Version: string;
33
+ exp: number;
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "docs": "typedoc"
@@ -33,6 +33,7 @@
33
33
  "rollup": "^4.30.1",
34
34
  "rollup-plugin-copy": "^3.5.0",
35
35
  "rollup-plugin-polyfill-node": "^0.13.0",
36
+ "tslib": "^2.8.1",
36
37
  "typedoc": "^0.28.4",
37
38
  "typescript": "^5.6.3"
38
39
  },