@ptkl/sdk 0.9.4 → 0.9.6

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,11 +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
+ var project_uuid = null;
40
41
  if (isBrowser) {
41
- if (localStorage.getItem('protokol_context') == "forge") {
42
- headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
42
+ console.log("DEBUG", sessionStorage.getItem('protokol_context'));
43
+ if (sessionStorage.getItem('protokol_context') == "forge") {
44
+ headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
43
45
  }
44
46
  else {
45
47
  // this potentially means that it is running as dev server in local
@@ -48,11 +50,12 @@ class PlatformBaseClient extends BaseClient {
48
50
  }
49
51
  if (typeof window !== "undefined") {
50
52
  // @ts-ignore
51
- const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
52
- 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;
53
55
  // @ts-ignore
54
- env = env !== null && env !== undefined ? env : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_ENV;
55
- token = token !== null && token !== undefined ? token : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_API_TOKEN;
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;
56
59
  }
57
60
  if (token) {
58
61
  headers['Authorization'] = `Bearer ${token}`;
@@ -60,9 +63,12 @@ class PlatformBaseClient extends BaseClient {
60
63
  if (env) {
61
64
  headers['X-Project-Env'] = env;
62
65
  }
66
+ if (project_uuid) {
67
+ headers['X-Project-Uuid'] = project_uuid;
68
+ }
63
69
  const client = axios.create({
64
- baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io",
65
- timeout: 15000,
70
+ baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
71
+ timeout: 30000,
66
72
  headers: {
67
73
  ...headers,
68
74
  'Content-Type': 'application/json',
@@ -198,7 +204,11 @@ class Apps extends PlatformBaseClient {
198
204
  }
199
205
  async upload(formData) {
200
206
  return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/upload`, formData, {
201
- timeout: 60000
207
+ timeout: 60000,
208
+ headers: {
209
+ // set form data headers
210
+ 'Content-Type': 'multipart/form-data'
211
+ }
202
212
  });
203
213
  }
204
214
  }
@@ -230,7 +240,7 @@ class Component extends PlatformBaseClient {
230
240
  * )
231
241
  **/
232
242
  async find(filters, opts) {
233
- const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== undefined ? opts : {};
243
+ const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== void 0 ? opts : {};
234
244
  let payload = {
235
245
  context: filters,
236
246
  ref: this.ref,
@@ -270,6 +280,9 @@ class Component extends PlatformBaseClient {
270
280
  }
271
281
  if (opts) {
272
282
  Object.keys(opts).forEach(k => {
283
+ if (['cache', 'buildttl', 'locale'].includes(k)) {
284
+ return;
285
+ }
273
286
  params[`_opt_${k}`] = opts ? opts[k] : null;
274
287
  });
275
288
  }
@@ -394,7 +407,7 @@ class Component extends PlatformBaseClient {
394
407
  });
395
408
  }
396
409
  async workflow(event, input) {
397
- return await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
410
+ return await this.client.post(`/v3/system/component/${this.ref}/workflow/event`, {
398
411
  event,
399
412
  input
400
413
  });
@@ -525,7 +538,7 @@ class Platform extends PlatformBaseClient {
525
538
  }
526
539
  getPlatformBaseURL() {
527
540
  var _a;
528
- return (_a = this.client.defaults.baseURL) !== null && _a !== undefined ? _a : "";
541
+ return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
529
542
  }
530
543
  apiUser() {
531
544
  return (new APIUser()).setClient(this.client);
@@ -596,11 +609,12 @@ class Invoicing extends PlatformBaseClient {
596
609
  class IntegrationsBaseClient extends BaseClient {
597
610
  constructor(options) {
598
611
  var _a, _b;
599
- let { env = null, token, host, } = options !== null && options !== undefined ? options : {};
612
+ let { env = null, token, host, } = options !== null && options !== void 0 ? options : {};
600
613
  let headers = {};
614
+ var project_uuid = null;
601
615
  if (isBrowser) {
602
- if (localStorage.getItem('protokol_context') == "forge") {
603
- headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
616
+ if (sessionStorage.getItem('protokol_context') == "forge") {
617
+ headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
604
618
  }
605
619
  else {
606
620
  // this potentially means that it is running as dev server in local
@@ -609,12 +623,13 @@ class IntegrationsBaseClient extends BaseClient {
609
623
  }
610
624
  if (typeof window !== "undefined") {
611
625
  // @ts-ignore
612
- const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
613
- host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== undefined ? _b : host;
626
+ const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
627
+ host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== void 0 ? _b : host;
614
628
  // @ts-ignore
615
- token = token !== null && token !== undefined ? token : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_API_TOKEN;
629
+ token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
616
630
  // @ts-ignore
617
- env = env !== null && env !== undefined ? env : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_ENV;
631
+ env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
632
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
618
633
  }
619
634
  if (token) {
620
635
  headers['Authorization'] = `Bearer ${token}`;
@@ -622,9 +637,12 @@ class IntegrationsBaseClient extends BaseClient {
622
637
  if (env) {
623
638
  headers['X-Project-Env'] = env;
624
639
  }
640
+ if (project_uuid) {
641
+ headers['X-Project-Uuid'] = project_uuid;
642
+ }
625
643
  const client = axios.create({
626
- baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io/luma/integrations",
627
- timeout: 15000,
644
+ baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
645
+ timeout: 30000,
628
646
  headers: {
629
647
  ...headers,
630
648
  },
@@ -701,7 +719,7 @@ class DMS extends IntegrationsBaseClient {
701
719
  return this.request('GET', `media/library/${lib}/exif/${key}`);
702
720
  }
703
721
  async html2pdf(lib, data) {
704
- const { output_pdf = false, input_path, input_html, output_path, output_file_name, data: templateData } = data;
722
+ const { output_pdf = false, input_path, input_html, output_path, output_file_name, output_type, data: templateData } = data;
705
723
  const type = output_pdf ? 'arraybuffer' : 'json';
706
724
  const contentType = output_pdf ? 'application/pdf' : 'application/json';
707
725
  return this.request('POST', `media/library/${lib}/html2pdf`, {
@@ -711,6 +729,7 @@ class DMS extends IntegrationsBaseClient {
711
729
  output_path,
712
730
  input_html,
713
731
  output_file_name,
732
+ output_type,
714
733
  data: templateData
715
734
  },
716
735
  headers: {
@@ -793,7 +812,7 @@ class Payments extends IntegrationsBaseClient {
793
812
  return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, {
794
813
  totalAmount: options.totalAmount.toString(),
795
814
  description: options.description,
796
- redirectUrl: (_a = options.redirectUrl) !== null && _a !== undefined ? _a : null,
815
+ redirectUrl: (_a = options.redirectUrl) !== null && _a !== void 0 ? _a : null,
797
816
  });
798
817
  }
799
818
  }
@@ -36,11 +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
+ var project_uuid = null;
41
42
  if (isBrowser) {
42
- if (localStorage.getItem('protokol_context') == "forge") {
43
- headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
43
+ console.log("DEBUG", sessionStorage.getItem('protokol_context'));
44
+ if (sessionStorage.getItem('protokol_context') == "forge") {
45
+ headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
44
46
  }
45
47
  else {
46
48
  // this potentially means that it is running as dev server in local
@@ -49,11 +51,12 @@ var ProtokolSDK09 = (function (exports, axios) {
49
51
  }
50
52
  if (typeof window !== "undefined") {
51
53
  // @ts-ignore
52
- const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
53
- 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;
54
56
  // @ts-ignore
55
- env = env !== null && env !== undefined ? env : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_ENV;
56
- token = token !== null && token !== undefined ? token : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_API_TOKEN;
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;
57
60
  }
58
61
  if (token) {
59
62
  headers['Authorization'] = `Bearer ${token}`;
@@ -61,9 +64,12 @@ var ProtokolSDK09 = (function (exports, axios) {
61
64
  if (env) {
62
65
  headers['X-Project-Env'] = env;
63
66
  }
67
+ if (project_uuid) {
68
+ headers['X-Project-Uuid'] = project_uuid;
69
+ }
64
70
  const client = axios.create({
65
- baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io",
66
- timeout: 15000,
71
+ baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
72
+ timeout: 30000,
67
73
  headers: {
68
74
  ...headers,
69
75
  'Content-Type': 'application/json',
@@ -199,7 +205,11 @@ var ProtokolSDK09 = (function (exports, axios) {
199
205
  }
200
206
  async upload(formData) {
201
207
  return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/upload`, formData, {
202
- timeout: 60000
208
+ timeout: 60000,
209
+ headers: {
210
+ // set form data headers
211
+ 'Content-Type': 'multipart/form-data'
212
+ }
203
213
  });
204
214
  }
205
215
  }
@@ -231,7 +241,7 @@ var ProtokolSDK09 = (function (exports, axios) {
231
241
  * )
232
242
  **/
233
243
  async find(filters, opts) {
234
- const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== undefined ? opts : {};
244
+ const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== void 0 ? opts : {};
235
245
  let payload = {
236
246
  context: filters,
237
247
  ref: this.ref,
@@ -271,6 +281,9 @@ var ProtokolSDK09 = (function (exports, axios) {
271
281
  }
272
282
  if (opts) {
273
283
  Object.keys(opts).forEach(k => {
284
+ if (['cache', 'buildttl', 'locale'].includes(k)) {
285
+ return;
286
+ }
274
287
  params[`_opt_${k}`] = opts ? opts[k] : null;
275
288
  });
276
289
  }
@@ -395,7 +408,7 @@ var ProtokolSDK09 = (function (exports, axios) {
395
408
  });
396
409
  }
397
410
  async workflow(event, input) {
398
- return await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
411
+ return await this.client.post(`/v3/system/component/${this.ref}/workflow/event`, {
399
412
  event,
400
413
  input
401
414
  });
@@ -526,7 +539,7 @@ var ProtokolSDK09 = (function (exports, axios) {
526
539
  }
527
540
  getPlatformBaseURL() {
528
541
  var _a;
529
- return (_a = this.client.defaults.baseURL) !== null && _a !== undefined ? _a : "";
542
+ return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
530
543
  }
531
544
  apiUser() {
532
545
  return (new APIUser()).setClient(this.client);
@@ -597,11 +610,12 @@ var ProtokolSDK09 = (function (exports, axios) {
597
610
  class IntegrationsBaseClient extends BaseClient {
598
611
  constructor(options) {
599
612
  var _a, _b;
600
- let { env = null, token, host, } = options !== null && options !== undefined ? options : {};
613
+ let { env = null, token, host, } = options !== null && options !== void 0 ? options : {};
601
614
  let headers = {};
615
+ var project_uuid = null;
602
616
  if (isBrowser) {
603
- if (localStorage.getItem('protokol_context') == "forge") {
604
- headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
617
+ if (sessionStorage.getItem('protokol_context') == "forge") {
618
+ headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
605
619
  }
606
620
  else {
607
621
  // this potentially means that it is running as dev server in local
@@ -610,12 +624,13 @@ var ProtokolSDK09 = (function (exports, axios) {
610
624
  }
611
625
  if (typeof window !== "undefined") {
612
626
  // @ts-ignore
613
- const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
614
- host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== undefined ? _b : host;
627
+ const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
628
+ host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== void 0 ? _b : host;
615
629
  // @ts-ignore
616
- token = token !== null && token !== undefined ? token : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_API_TOKEN;
630
+ token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
617
631
  // @ts-ignore
618
- env = env !== null && env !== undefined ? env : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_ENV;
632
+ env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
633
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
619
634
  }
620
635
  if (token) {
621
636
  headers['Authorization'] = `Bearer ${token}`;
@@ -623,9 +638,12 @@ var ProtokolSDK09 = (function (exports, axios) {
623
638
  if (env) {
624
639
  headers['X-Project-Env'] = env;
625
640
  }
641
+ if (project_uuid) {
642
+ headers['X-Project-Uuid'] = project_uuid;
643
+ }
626
644
  const client = axios.create({
627
- baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io/luma/integrations",
628
- timeout: 15000,
645
+ baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
646
+ timeout: 30000,
629
647
  headers: {
630
648
  ...headers,
631
649
  },
@@ -702,7 +720,7 @@ var ProtokolSDK09 = (function (exports, axios) {
702
720
  return this.request('GET', `media/library/${lib}/exif/${key}`);
703
721
  }
704
722
  async html2pdf(lib, data) {
705
- const { output_pdf = false, input_path, input_html, output_path, output_file_name, data: templateData } = data;
723
+ const { output_pdf = false, input_path, input_html, output_path, output_file_name, output_type, data: templateData } = data;
706
724
  const type = output_pdf ? 'arraybuffer' : 'json';
707
725
  const contentType = output_pdf ? 'application/pdf' : 'application/json';
708
726
  return this.request('POST', `media/library/${lib}/html2pdf`, {
@@ -712,6 +730,7 @@ var ProtokolSDK09 = (function (exports, axios) {
712
730
  output_path,
713
731
  input_html,
714
732
  output_file_name,
733
+ output_type,
715
734
  data: templateData
716
735
  },
717
736
  headers: {
@@ -794,7 +813,7 @@ var ProtokolSDK09 = (function (exports, axios) {
794
813
  return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, {
795
814
  totalAmount: options.totalAmount.toString(),
796
815
  description: options.description,
797
- redirectUrl: (_a = options.redirectUrl) !== null && _a !== undefined ? _a : null,
816
+ redirectUrl: (_a = options.redirectUrl) !== null && _a !== void 0 ? _a : null,
798
817
  });
799
818
  }
800
819
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "0.9.3",
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
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "0.9.4",
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
  },