@bexis2/bexis2-core-ui 0.4.48 → 0.4.49

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.
@@ -2,10 +2,10 @@
2
2
  /** @typedef {typeof __propDef.events} DropdownKvPEvents */
3
3
  /** @typedef {typeof __propDef.slots} DropdownKvPSlots */
4
4
  export default class DropdownKvP extends SvelteComponent<{
5
- source: any;
6
- title: any;
7
5
  id: any;
8
6
  target: any;
7
+ title: any;
8
+ source: any;
9
9
  invalid?: boolean | undefined;
10
10
  feedback?: string[] | undefined;
11
11
  required?: boolean | undefined;
@@ -25,10 +25,10 @@ export type DropdownKvPSlots = typeof __propDef.slots;
25
25
  import { SvelteComponent } from "svelte";
26
26
  declare const __propDef: {
27
27
  props: {
28
- source: any;
29
- title: any;
30
28
  id: any;
31
29
  target: any;
30
+ title: any;
31
+ source: any;
32
32
  invalid?: boolean | undefined;
33
33
  feedback?: string[] | undefined;
34
34
  required?: boolean | undefined;
@@ -2,10 +2,10 @@
2
2
  /** @typedef {typeof __propDef.events} MultiSelectEvents */
3
3
  /** @typedef {typeof __propDef.slots} MultiSelectSlots */
4
4
  export default class MultiSelect extends SvelteComponent<{
5
- source: any;
6
- title: any;
7
5
  id: any;
8
6
  target: any;
7
+ title: any;
8
+ source: any;
9
9
  invalid?: boolean | undefined;
10
10
  feedback?: string[] | undefined;
11
11
  required?: boolean | undefined;
@@ -40,10 +40,10 @@ export type MultiSelectSlots = typeof __propDef.slots;
40
40
  import { SvelteComponent } from "svelte";
41
41
  declare const __propDef: {
42
42
  props: {
43
- source: any;
44
- title: any;
45
43
  id: any;
46
44
  target: any;
45
+ title: any;
46
+ source: any;
47
47
  invalid?: boolean | undefined;
48
48
  feedback?: string[] | undefined;
49
49
  required?: boolean | undefined;
@@ -10,10 +10,11 @@ import Notification from "./Notification.svelte";
10
10
  import { computePosition, autoUpdate, offset, shift, flip, arrow } from "@floating-ui/dom";
11
11
  import { storePopup } from "@skeletonlabs/skeleton";
12
12
  import { breadcrumbStore, notificationStore } from "../../stores/pageStores";
13
- import { errorStore } from "../../stores/apiStores";
13
+ import { errorStore, csrfTokenStore } from "../../stores/apiStores";
14
14
  storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
15
15
  import Docs from "./Docs.svelte";
16
16
  import GoToTop from "./GoToTop.svelte";
17
+ import { getAntiForgeryToken } from "./PageCaller";
17
18
  export let title = "";
18
19
  export let note = "";
19
20
  export let links = [];
@@ -33,6 +34,8 @@ onMount(async () => {
33
34
  console.log("page");
34
35
  breadcrumbStore.clean();
35
36
  breadcrumbStore.addItem({ label: title, link: window.location.pathname });
37
+ const data = await getAntiForgeryToken();
38
+ csrfTokenStore.set(data.csrfToken);
36
39
  });
37
40
  let app;
38
41
  function scrollToTop() {
@@ -1,2 +1,3 @@
1
1
  export function getFooter(): Promise<any>;
2
2
  export function getHeader(): Promise<any>;
3
+ export function getAntiForgeryToken(): Promise<any>;
@@ -17,3 +17,12 @@ export const getHeader = async () => {
17
17
  console.error(error);
18
18
  }
19
19
  };
20
+
21
+ export const getAntiForgeryToken = async () => {
22
+ try {
23
+ const response = await Api.get('/tokens/getAntiForgeryToken');
24
+ return response.data;
25
+ } catch (error) {
26
+ console.error(error);
27
+ }
28
+ };
@@ -1,6 +1,6 @@
1
1
  // Api.js
2
2
  import axios from 'axios';
3
- import { host, username, password, errorStore } from '../stores/apiStores';
3
+ import { host, username, password, errorStore, csrfToken } from '../stores/apiStores';
4
4
  console.log('setup axios');
5
5
  // implement a method to execute all the request from here.
6
6
  const apiRequest = (method, url, request) => {
@@ -11,18 +11,15 @@ const apiRequest = (method, url, request) => {
11
11
  const headers = {
12
12
  authorization: 'Basic ' + btoa(username + ':' + password)
13
13
  };
14
- const requestVerificationToken = document.querySelector('input[name="__RequestVerificationToken"]')?.getAttribute('value');
15
- var data = { ...request };
14
+ const requestVerificationToken = csrfToken;
16
15
  if (requestVerificationToken) {
17
16
  headers['__RequestVerificationToken'] = requestVerificationToken;
18
- data = { ...data, __RequestVerificationToken: requestVerificationToken };
19
17
  }
20
- console.log("🚀 ~ apiRequest ~ data:", data);
21
18
  //using the axios instance to perform the request that received from each http method
22
19
  return axiosAPI({
23
20
  method,
24
21
  url,
25
- data: data,
22
+ data: request,
26
23
  headers
27
24
  })
28
25
  .then((res) => {
@@ -2,5 +2,7 @@ import { errorType } from '../models/Models';
2
2
  export declare let host: string;
3
3
  export declare let username: string;
4
4
  export declare let password: string;
5
+ export declare let csrfToken: string;
6
+ export declare const csrfTokenStore: import("svelte/store").Writable<string>;
5
7
  export declare const errorStore: import("svelte/store").Writable<errorType>;
6
8
  export declare function setApiConfig(_host: string, _user: string, _pw: string): void;
@@ -3,6 +3,8 @@ import { errorType } from '../models/Models';
3
3
  export let host = 'window.location.origin';
4
4
  export let username = '';
5
5
  export let password = '';
6
+ export let csrfToken = '';
7
+ export const csrfTokenStore = writable('');
6
8
  const hostStore = writable(''); //writable(window.location.origin);
7
9
  const usernameStore = writable('');
8
10
  const passwordStore = writable('');
@@ -10,6 +12,9 @@ export const errorStore = writable(new errorType());
10
12
  hostStore.subscribe((value) => {
11
13
  host = value;
12
14
  });
15
+ csrfTokenStore.subscribe((value) => {
16
+ csrfToken = value;
17
+ });
13
18
  usernameStore.subscribe((value) => {
14
19
  username = value;
15
20
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bexis2/bexis2-core-ui",
3
- "version": "0.4.48",
3
+ "version": "0.4.49",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -17,7 +17,7 @@
17
17
  import { computePosition, autoUpdate, offset, shift, flip, arrow } from '@floating-ui/dom';
18
18
  import { storePopup } from '@skeletonlabs/skeleton';
19
19
  import { breadcrumbStore,notificationStore } from '$store/pageStores';
20
- import { errorStore } from '$store/apiStores';
20
+ import { errorStore,csrfTokenStore } from '$store/apiStores';
21
21
 
22
22
  storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
23
23
 
@@ -27,6 +27,7 @@ import type { helpItemType, helpStoreType } from '$models/Models';
27
27
 
28
28
  import Docs from './Docs.svelte';
29
29
  import GoToTop from './GoToTop.svelte';
30
+ import { getAntiForgeryToken } from './PageCaller';
30
31
 
31
32
  export let title = '';
32
33
  export let note = '';
@@ -51,6 +52,9 @@ import type { helpItemType, helpStoreType } from '$models/Models';
51
52
  console.log('page');
52
53
  breadcrumbStore.clean();
53
54
  breadcrumbStore.addItem({ label: title, link: window.location.pathname });
55
+
56
+ const data = await getAntiForgeryToken();
57
+ csrfTokenStore.set(data.csrfToken);
54
58
  });
55
59
 
56
60
  let app;
@@ -17,3 +17,12 @@ export const getHeader = async () => {
17
17
  console.error(error);
18
18
  }
19
19
  };
20
+
21
+ export const getAntiForgeryToken = async () => {
22
+ try {
23
+ const response = await Api.get('/tokens/getAntiForgeryToken');
24
+ return response.data;
25
+ } catch (error) {
26
+ console.error(error);
27
+ }
28
+ };
@@ -1,6 +1,6 @@
1
1
  // Api.js
2
2
  import axios from 'axios';
3
- import { host, username, password, errorStore } from '../stores/apiStores';
3
+ import { host, username, password, errorStore, csrfToken } from '../stores/apiStores';
4
4
  import type { errorType } from '$models/Models';
5
5
 
6
6
  console.log('setup axios');
@@ -16,23 +16,17 @@ const apiRequest = (method, url, request) => {
16
16
  authorization: 'Basic ' + btoa(username + ':' + password)
17
17
  };
18
18
 
19
- const requestVerificationToken = document.querySelector('input[name="__RequestVerificationToken"]')?.getAttribute('value');
20
-
21
-
22
- var data ={...request}
19
+ const requestVerificationToken = csrfToken;
23
20
 
24
21
  if (requestVerificationToken) {
25
22
  headers['__RequestVerificationToken'] = requestVerificationToken;
26
- data = {...data, __RequestVerificationToken: requestVerificationToken }
27
23
  }
28
24
 
29
- console.log("🚀 ~ apiRequest ~ data:", data)
30
-
31
25
  //using the axios instance to perform the request that received from each http method
32
26
  return axiosAPI({
33
27
  method,
34
28
  url,
35
- data: data,
29
+ data: request,
36
30
  headers
37
31
  })
38
32
  .then((res) => {
@@ -4,17 +4,28 @@ import { errorType } from '$models/Models'
4
4
  export let host = 'window.location.origin';
5
5
  export let username = '';
6
6
  export let password = '';
7
+ export let csrfToken = '';
8
+
9
+
10
+ export const csrfTokenStore = writable('');
11
+
7
12
 
8
13
  const hostStore = writable(''); //writable(window.location.origin);
9
14
  const usernameStore = writable('');
10
15
  const passwordStore = writable('');
11
16
 
17
+
12
18
  export const errorStore = writable(new errorType());
13
19
 
14
20
  hostStore.subscribe((value) => {
15
21
  host = value;
16
22
  });
17
23
 
24
+ csrfTokenStore.subscribe((value) => {
25
+ csrfToken = value;
26
+ });
27
+
28
+
18
29
  usernameStore.subscribe((value) => {
19
30
  username = value;
20
31
  });
@@ -214,3 +214,5 @@ function createNotificationStore() {
214
214
 
215
215
  //crate and export the instance of the store
216
216
  export const notificationStore = createNotificationStore();
217
+
218
+