tsv2-library 1.0.61-alpha.65 → 1.0.61-alpha.67

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.
@@ -19,7 +19,7 @@ interface TSFormContext<T> {
19
19
  declare const useForm: <T>() => TSFormContext<T>;
20
20
  declare const useField: <T>(path: MaybeRefOrGetter<string>, rules?: MaybeRef<RuleExpression<T>>, opts?: Partial<FieldOptions<T>> | undefined) => FieldContext<T>;
21
21
  import Presets from './presets';
22
- import { handleTokenExpiration, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, formatUserName, formatVowelSoundLabel, getImageURL, downloadFile, isObjectEmpty, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getHostName, getBaseURL, useI18n, getNestedProperyValue, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole } from './utils';
22
+ import { handleTokenExpiration, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, formatUserName, formatVowelSoundLabel, getImageURL, downloadFile, isObjectEmpty, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getHostName, getBaseURL, useI18n, getNestedProperyValue, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, isValidJSONString, buildBodyParams, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole } from './utils';
23
23
  import { flattenTreeNodeChildren, parseNodeKeys, filterNodeKeys } from './components/v2/Tree/helpers';
24
24
  import useLoadingStore from './components/v2/Loading/store/loading.store';
25
25
  import Tooltip from '../node_modules/primevue/tooltip';
@@ -31,4 +31,4 @@ declare const _default: {
31
31
  install: (app: App) => void;
32
32
  };
33
33
  export default _default;
34
- export { LibConfig, TSToastService, TSi18n, VueHtmlToPaper, Tooltip, Focus, DialogDamageLog, DialogMissingLog, DialogTransferLog, TSAssetInfo, TSApproverInfo, TSBadge, TSBadgeGroup, TSBreadcrumb, TSButton, TSButtonAddByScan, TSButtonBulkAction, TSButtonCopy, TSButtonDownload, TSButtonFilter, TSButtonLogHistory, TSButtonRadio, TSButtonViewLog, TSButtonScan, TSButtonSearch, TSButtonSearchByScan, TSButtonSelectTree, TSButtonSelectUser, TSButtonSync, TSButtonToggle, TSCalendar, TSCard, TSCarousel, TSCheckbox, TSCustomColumn, TSDatePicker, TSDataTable, TSDayPicker, TSDialog, TSDialogApprovalList, TSDialogAssetNameDetail, TSDialogConfirm, TSDialogForm, TSDialogLinkedAsset, TSDialogPrintQR, TSDialogReportDamage, TSDialogReportMissing, TSDialogReportTag, TSDialogSelectTree, TSDialogSelectAsset, TSDialogSelectUser, TSDisposalReport, TSDropdown, TSFilterContainer, TSFileUpload, TSForm, TSIcon, TSImage, TSImageCompressor, TSInlineMessage, TSInputBadge, TSInputCurrency, TSInputEmail, TSInputNumber, TSInputOTP, TSInputPassword, TSInputPhoneNumber, TSInputRangeNumber, TSInputText, TSInputSearch, TSInputURL, TSLoading, TSMenu, TSMultiSelect, TSOverlayPanel, TSPaginator, TSProgressBar, TSSteps, TSTabMenu, TSTagType, TSTextarea, TSTimeline, TSToast, TSTransactionRoles, TSTree, TSTreeSearchInput, TSUserWithIcon, TSValidatorMessage, handleTokenExpiration, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, formatUserName, formatVowelSoundLabel, getImageURL, downloadFile, isObjectEmpty, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getHostName, getBaseURL, useI18n, useForm, useField, getNestedProperyValue, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole, flattenTreeNodeChildren, parseNodeKeys, filterNodeKeys, TreeAPI, RoutineAPI, DisposalAPI, RoutineServices, AssetsServices, AssetNameService, AssetBrandService, DisposalServices, FilterMatchMode, useLoadingStore, Presets, };
34
+ export { LibConfig, TSToastService, TSi18n, VueHtmlToPaper, Tooltip, Focus, DialogDamageLog, DialogMissingLog, DialogTransferLog, TSAssetInfo, TSApproverInfo, TSBadge, TSBadgeGroup, TSBreadcrumb, TSButton, TSButtonAddByScan, TSButtonBulkAction, TSButtonCopy, TSButtonDownload, TSButtonFilter, TSButtonLogHistory, TSButtonRadio, TSButtonViewLog, TSButtonScan, TSButtonSearch, TSButtonSearchByScan, TSButtonSelectTree, TSButtonSelectUser, TSButtonSync, TSButtonToggle, TSCalendar, TSCard, TSCarousel, TSCheckbox, TSCustomColumn, TSDatePicker, TSDataTable, TSDayPicker, TSDialog, TSDialogApprovalList, TSDialogAssetNameDetail, TSDialogConfirm, TSDialogForm, TSDialogLinkedAsset, TSDialogPrintQR, TSDialogReportDamage, TSDialogReportMissing, TSDialogReportTag, TSDialogSelectTree, TSDialogSelectAsset, TSDialogSelectUser, TSDisposalReport, TSDropdown, TSFilterContainer, TSFileUpload, TSForm, TSIcon, TSImage, TSImageCompressor, TSInlineMessage, TSInputBadge, TSInputCurrency, TSInputEmail, TSInputNumber, TSInputOTP, TSInputPassword, TSInputPhoneNumber, TSInputRangeNumber, TSInputText, TSInputSearch, TSInputURL, TSLoading, TSMenu, TSMultiSelect, TSOverlayPanel, TSPaginator, TSProgressBar, TSSteps, TSTabMenu, TSTagType, TSTextarea, TSTimeline, TSToast, TSTransactionRoles, TSTree, TSTreeSearchInput, TSUserWithIcon, TSValidatorMessage, handleTokenExpiration, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, formatUserName, formatVowelSoundLabel, getImageURL, downloadFile, isObjectEmpty, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getHostName, getBaseURL, useI18n, useForm, useField, getNestedProperyValue, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, isValidJSONString, buildBodyParams, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole, flattenTreeNodeChildren, parseNodeKeys, filterNodeKeys, TreeAPI, RoutineAPI, DisposalAPI, RoutineServices, AssetsServices, AssetNameService, AssetBrandService, DisposalServices, FilterMatchMode, useLoadingStore, Presets, };
@@ -1,10 +1,11 @@
1
1
  export declare const buildFileURL: (name?: string, width?: number, height?: number) => string;
2
2
  /**
3
3
  *
4
- * @param fileUrl The full URL
4
+ * @param name The full URL, or the file token as it appears on the server
5
5
  * @param fileName Custom File name
6
6
  * @param immediateRevoke Immediately revoke the object URL after download - default to true
7
+ * @param viewNewTab View the file in a new tab - default to false
7
8
  * @returns
8
9
  */
9
- export declare const downloadFile: (fileUrl: string, customFileName?: string, immediateRevoke?: boolean, viewNewTab?: boolean) => Promise<string>;
10
+ export declare const downloadFile: (name: string, customFileName?: string, immediateRevoke?: boolean, viewNewTab?: boolean) => Promise<string>;
10
11
  export declare const getImageURL: (name?: string | null, width?: number, height?: number, returnURLOnly?: boolean) => Promise<string | undefined>;
@@ -13,6 +13,8 @@ import { getSeverityByAssetStatus } from './getSeverityByAssetStatus.util';
13
13
  import clearStorage from './clearStorage.util';
14
14
  import forceLogout from './forceLogout.util';
15
15
  import reLogin from './reLogin.util';
16
+ import { isValidJSONString } from './json.util';
17
+ import { buildBodyParams } from './request.util';
16
18
  declare const isObjectEmpty: (object: object) => boolean;
17
19
  declare const getNestedProperyValue: (object: object, property: string) => string | boolean | number | object;
18
- export { isObjectEmpty, getNestedProperyValue, handleTokenExpiration, getImageURL, downloadFile, formatUserName, formatVowelSoundLabel, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getBaseURL, getHostName, useI18n, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole, };
20
+ export { isObjectEmpty, getNestedProperyValue, handleTokenExpiration, getImageURL, downloadFile, formatUserName, formatVowelSoundLabel, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getBaseURL, getHostName, useI18n, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, isValidJSONString, buildBodyParams, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole, };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Checks if a given value is a valid JSON string that represents an object or array.
3
+ *
4
+ * @param value - The value to be checked
5
+ * @returns `true` if the value is a non-empty string that can be parsed into a valid JSON object or array,
6
+ * `false` otherwise
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * isValidJSONString('{"name": "John"}') // returns true
11
+ * isValidJSONString('[1, 2, 3]') // returns true
12
+ * isValidJSONString('123') // returns false (not an object/array)
13
+ * isValidJSONString('invalid json') // returns false
14
+ * isValidJSONString(null) // returns false
15
+ * ```
16
+ */
17
+ export declare const isValidJSONString: (value: unknown) => boolean;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Builds and transforms body parameters by parsing JSON strings if valid.
3
+ * @param params - Optional record of key-value pairs where values can be of any type
4
+ * @returns A new record with the same keys but JSON strings parsed into objects
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * // With JSON string value
9
+ * buildBodyParams({ data: '{"foo": "bar"}' })
10
+ * // Returns: { data: { foo: "bar" } }
11
+ *
12
+ * // With non-JSON value
13
+ * buildBodyParams({ data: "plain string" })
14
+ * // Returns: { data: "plain string" }
15
+ * ```
16
+ */
17
+ export declare const buildBodyParams: (params?: Record<string, unknown>) => Record<string, unknown>;
@@ -19616,7 +19616,9 @@ const getAuthToken = () => {
19616
19616
  const user = JSON.parse(localStorage.getItem("user") ?? "{}");
19617
19617
  return user.jwt ?? user.token ?? "";
19618
19618
  };
19619
- const fetchFile = async (url, token) => {
19619
+ const fetchFile = async (name) => {
19620
+ const token = getAuthToken();
19621
+ const url = name.startsWith("http") ? name : await getImageURL(name, void 0, void 0, true);
19620
19622
  const res = await axios.get(url, {
19621
19623
  responseType: "blob",
19622
19624
  headers: {
@@ -19630,9 +19632,8 @@ const fetchFile = async (url, token) => {
19630
19632
  fileName: getFilenameFromResponse(res)
19631
19633
  };
19632
19634
  };
19633
- const downloadFile = async (fileUrl, customFileName, immediateRevoke = true, viewNewTab = false) => {
19634
- const token = getAuthToken();
19635
- const { blob: blob2, fileName: fetchFileName } = await fetchFile(fileUrl, token);
19635
+ const downloadFile = async (name, customFileName, immediateRevoke = true, viewNewTab = false) => {
19636
+ const { blob: blob2, fileName: fetchFileName } = await fetchFile(name);
19636
19637
  let objectUrl = "";
19637
19638
  const isViewable = /^(image|application\/pdf)/i.test(blob2.type);
19638
19639
  const fileName = customFileName ?? fetchFileName;
@@ -19660,8 +19661,7 @@ const downloadFile = async (fileUrl, customFileName, immediateRevoke = true, vie
19660
19661
  };
19661
19662
  const createBlobURL = async (rawFileUrl) => {
19662
19663
  try {
19663
- const token = getAuthToken();
19664
- const { blob: blob2 } = await fetchFile(rawFileUrl, token);
19664
+ const { blob: blob2 } = await fetchFile(rawFileUrl);
19665
19665
  return URL.createObjectURL(blob2);
19666
19666
  } catch (err) {
19667
19667
  return void 0;
@@ -25834,6 +25834,30 @@ const reLogin = async () => {
25834
25834
  return error;
25835
25835
  }
25836
25836
  };
25837
+ const isValidJSONString = (value) => {
25838
+ if (typeof value !== "string")
25839
+ return false;
25840
+ const s = value.trim();
25841
+ if (!s)
25842
+ return false;
25843
+ try {
25844
+ const parsed = JSON.parse(s);
25845
+ return typeof parsed === "object" && parsed !== null;
25846
+ } catch {
25847
+ return false;
25848
+ }
25849
+ };
25850
+ const buildBodyParams = (params) => {
25851
+ if (!params) {
25852
+ return {};
25853
+ }
25854
+ const result = {};
25855
+ Object.keys(params).forEach((key) => {
25856
+ const val = params[key];
25857
+ result[key] = isValidJSONString(val) ? JSON.parse(val.trim()) : val;
25858
+ });
25859
+ return result;
25860
+ };
25837
25861
  const isObjectEmpty = (object) => {
25838
25862
  if (!object)
25839
25863
  return true;
@@ -52077,7 +52101,6 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
52077
52101
  selectedData.value = [];
52078
52102
  currentPageDataSelected.value = [];
52079
52103
  }
52080
- console.log("✨ ~ queryParams:", queryParams.value);
52081
52104
  loadingTable.value = true;
52082
52105
  const { data: data30, totalRecords: total = 0 } = await ((_a = props.fetchFunction) == null ? void 0 : _a.call(props, scanParams ?? queryParams.value)) ?? {};
52083
52106
  dispatchUpdateTotalRecordsEvent(total);
@@ -74035,6 +74058,7 @@ export {
74035
74058
  Tooltip,
74036
74059
  API$a as TreeAPI,
74037
74060
  VueHtmlToPaper,
74061
+ buildBodyParams,
74038
74062
  checkRouteAccess,
74039
74063
  clearStorage,
74040
74064
  buildEntry as default,
@@ -74068,6 +74092,7 @@ export {
74068
74092
  hasSystemRole,
74069
74093
  hasTransactionRole,
74070
74094
  isObjectEmpty,
74095
+ isValidJSONString,
74071
74096
  listenSidebarChanges,
74072
74097
  parseNodeKeys,
74073
74098
  reLogin,