@native-systems/utility 1.2.0 → 2.0.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.
package/dist/index.d.ts CHANGED
@@ -664,7 +664,7 @@ declare module "@native-systems/utility" {
664
664
  }
665
665
 
666
666
  declare module "@native-systems/utility" {
667
- namespace Native {
667
+ namespace native {
668
668
  type Error = ErrorConstructor & {
669
669
  status: number;
670
670
  message: string;
@@ -675,11 +675,54 @@ declare module "@native-systems/utility" {
675
675
  }
676
676
  export { Error, ErrorResponse };
677
677
  }
678
- export type { Native };
678
+ export type { native };
679
679
  }
680
680
 
681
681
  declare module "@native-systems/utility" {
682
- import { Native } from "@/types";
682
+ type Paginated<T> = {
683
+ hasNextPage: boolean;
684
+ hasPrevPage: boolean;
685
+ totalPages: number;
686
+ data: T;
687
+ };
688
+ export type { Paginated };
689
+ }
690
+
691
+ declare module "@native-systems/utility" {
692
+ type CancelableComponent<T> = {
693
+ value: T;
694
+ cancel: () => void;
695
+ };
696
+ export type { CancelableComponent };
697
+ }
698
+
699
+ declare module "@native-systems/utility" {
700
+ type CRUDCompontent<T, U = T, V = U> = {
701
+ value: T;
702
+ add: (value: U) => void;
703
+ delete: (id: string) => void;
704
+ update: (id: string, value: V) => void;
705
+ };
706
+ export type { CRUDCompontent };
707
+ }
708
+
709
+ declare module "@native-systems/utility" {
710
+ import { Dispatch, SetStateAction } from "react";
711
+ type UseStateComponent<T, U = T> = {
712
+ current: T;
713
+ update: (value: U) => void;
714
+ };
715
+ /** Same grouping type as the UseStateComponent type, with the difference,
716
+ * that here the update function is directly linked with the useState variable. */
717
+ type DirectUseStateComponent<T> = {
718
+ current: T;
719
+ update: Dispatch<SetStateAction<T>>;
720
+ };
721
+ export type { DirectUseStateComponent, UseStateComponent };
722
+ }
723
+
724
+ declare module "@native-systems/utility" {
725
+ import { native } from "@/types";
683
726
  class HttpHandler {
684
727
  /**
685
728
  * Http request response handler, which checks if the given response is in status range 'ok'.
@@ -688,17 +731,17 @@ declare module "@native-systems/utility" {
688
731
  * This means, that the reason of the error is not a network error for example.
689
732
  * @param response {Response} The raw response data from the server, which could also be a Native.Error.
690
733
  * @returns {<T>} The expected data resource, if the status of the request is 'ok'.
691
- * @throws {Native.ErrorResponse} A modified version of the default Response object, to be able to detect if the error response is of the expected type.
734
+ * @throws {native.ErrorResponse} A modified version of the default Response object, to be able to detect if the error response is of the expected type.
692
735
  */
693
736
  static response<T>(response: Response): Promise<T>;
694
737
  /**
695
738
  * Http request error handler, that always returns the correct error object.
696
739
  * Either fast forwards the already correctly formatted naive error or set up a new native error, based on the provided info.
697
740
  * The generic typing is just used to prevent type errors.
698
- * @param response {Response | Native.ErrorResponse} The Response object that errored. Can either be a default object, or the modified native version.
699
- * @throws {Native.Error} Always throws an error, which is always of this type.
741
+ * @param response {Response | native.ErrorResponse} The Response object that errored. Can either be a default object, or the modified native version.
742
+ * @throws {native.Error} Always throws an error, which is always of this type.
700
743
  */
701
- static error<T>(response: Response | Native.ErrorResponse): Promise<T>;
744
+ static error<T>(response: Response | native.ErrorResponse): Promise<T>;
702
745
  }
703
746
  export { HttpHandler };
704
747
  }
@@ -722,3 +765,106 @@ declare module "@native-systems/utility" {
722
765
  }
723
766
  export { CookieHelper };
724
767
  }
768
+
769
+ declare module "@native-systems/utility" {
770
+ export function parseTemplate(template: string): {
771
+ expand: (context: Record<string, unknown>) => string;
772
+ };
773
+ }
774
+
775
+ declare module "@native-systems/utility" {
776
+ export type PatternView = Record<string | number, any>;
777
+ export type CompileFn = (source?: string | null, view?: PatternView) => string;
778
+ export interface IPatternCompiler {
779
+ compile: CompileFn;
780
+ keyToTemplate(key: string): string;
781
+ }
782
+ }
783
+
784
+ declare module "@native-systems/utility" {
785
+ import Handlebars from "handlebars";
786
+ export class PatternCompiler implements IPatternCompiler {
787
+ private defaultView;
788
+ private handlebars;
789
+ constructor(defaultView: PatternView, installPlugins: (handlebars: typeof Handlebars) => void);
790
+ compile(source?: string | null, partialView?: PatternView): string;
791
+ static keyToTemplate(key: string): string;
792
+ keyToTemplate(key: string): string;
793
+ }
794
+ }
795
+
796
+ declare module "@native-systems/utility" {
797
+ export type CompilerPlugin<T> = (handlebars: typeof Handlebars, data: T) => void;
798
+ }
799
+
800
+ declare module "@native-systems/utility" {
801
+ export const eqPlugin: CompilerPlugin<never>;
802
+ }
803
+
804
+ declare module "@native-systems/utility" {
805
+ export const markdownPlugin: CompilerPlugin<never>;
806
+ }
807
+
808
+ declare module "@native-systems/utility" {
809
+ export const stringPlugin: CompilerPlugin<never>;
810
+ }
811
+
812
+ declare module "@native-systems/utility" {
813
+ export class DateFormatter {
814
+ /**
815
+ * Formats a date with time in German format
816
+ * @param date Date object or date string to format
817
+ * @returns Formatted date string
818
+ * @example
819
+ * // Returns "14.08.2025, 15:30"
820
+ * DateFormatter.format(new Date('2025-08-14T15:30:00'))
821
+ */
822
+ static format(date: Date | string): string;
823
+ /**
824
+ * Formats a date in formal German format without time
825
+ * @param date Date object or date string to format
826
+ * @returns Formatted date string
827
+ * @example
828
+ * // Returns "14.08.2025"
829
+ * DateFormatter.formatFormal(new Date('2025-08-14T15:30:00'))
830
+ */
831
+ static formatFormal(date: Date | string): string;
832
+ /**
833
+ * Formats a date in German format with full month name
834
+ * @param date Date object or date string to format
835
+ * @returns Formatted date string
836
+ * @example
837
+ * // Returns "14. August 2025"
838
+ * DateFormatter.formatMini(new Date('2025-08-14T15:30:00'))
839
+ */
840
+ static formatMini(date: Date | string): string;
841
+ static getZoneAdjustedWeekday: (dateString: string, options: {
842
+ timezone: string;
843
+ locale: string | undefined;
844
+ }) => string;
845
+ static getZoneAdjustedDate: (dateString: string, options: {
846
+ timezone: string;
847
+ locale: string | undefined;
848
+ }) => string;
849
+ static getZoneAdjustedTime: (dateString: string, options: {
850
+ timezone: string;
851
+ locale: string | undefined;
852
+ }) => string;
853
+ }
854
+ }
855
+
856
+ declare module "@native-systems/utility" {
857
+ export type UserTimezone = {
858
+ timezone: string;
859
+ locale: string;
860
+ };
861
+ export const timezonePlugin: CompilerPlugin<UserTimezone>;
862
+ }
863
+
864
+ declare module "@native-systems/utility" {
865
+ export const urlPlugin: CompilerPlugin<never>;
866
+ }
867
+
868
+ declare module "@native-systems/utility" {
869
+ export const userTimezonePlugin: CompilerPlugin<UserTimezone>;
870
+ }