@native-systems/utility 2.1.0 → 2.1.2

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.cjs CHANGED
@@ -277,6 +277,66 @@ var PostgresError = /*#__PURE__*/ (function (PostgresError) {
277
277
  return PostgresError;
278
278
  })({});
279
279
 
280
+ var HttpStatus = /*#__PURE__*/ (function (HttpStatus) {
281
+ HttpStatus[(HttpStatus['CONTINUE'] = 100)] = 'CONTINUE';
282
+ HttpStatus[(HttpStatus['SWITCHING_PROTOCOLS'] = 101)] = 'SWITCHING_PROTOCOLS';
283
+ HttpStatus[(HttpStatus['PROCESSING'] = 102)] = 'PROCESSING';
284
+ HttpStatus[(HttpStatus['EARLYHINTS'] = 103)] = 'EARLYHINTS';
285
+ HttpStatus[(HttpStatus['OK'] = 200)] = 'OK';
286
+ HttpStatus[(HttpStatus['CREATED'] = 201)] = 'CREATED';
287
+ HttpStatus[(HttpStatus['ACCEPTED'] = 202)] = 'ACCEPTED';
288
+ HttpStatus[(HttpStatus['NON_AUTHORITATIVE_INFORMATION'] = 203)] =
289
+ 'NON_AUTHORITATIVE_INFORMATION';
290
+ HttpStatus[(HttpStatus['NO_CONTENT'] = 204)] = 'NO_CONTENT';
291
+ HttpStatus[(HttpStatus['RESET_CONTENT'] = 205)] = 'RESET_CONTENT';
292
+ HttpStatus[(HttpStatus['PARTIAL_CONTENT'] = 206)] = 'PARTIAL_CONTENT';
293
+ HttpStatus[(HttpStatus['AMBIGUOUS'] = 300)] = 'AMBIGUOUS';
294
+ HttpStatus[(HttpStatus['MOVED_PERMANENTLY'] = 301)] = 'MOVED_PERMANENTLY';
295
+ HttpStatus[(HttpStatus['FOUND'] = 302)] = 'FOUND';
296
+ HttpStatus[(HttpStatus['SEE_OTHER'] = 303)] = 'SEE_OTHER';
297
+ HttpStatus[(HttpStatus['NOT_MODIFIED'] = 304)] = 'NOT_MODIFIED';
298
+ HttpStatus[(HttpStatus['TEMPORARY_REDIRECT'] = 307)] = 'TEMPORARY_REDIRECT';
299
+ HttpStatus[(HttpStatus['PERMANENT_REDIRECT'] = 308)] = 'PERMANENT_REDIRECT';
300
+ HttpStatus[(HttpStatus['BAD_REQUEST'] = 400)] = 'BAD_REQUEST';
301
+ HttpStatus[(HttpStatus['UNAUTHORIZED'] = 401)] = 'UNAUTHORIZED';
302
+ HttpStatus[(HttpStatus['PAYMENT_REQUIRED'] = 402)] = 'PAYMENT_REQUIRED';
303
+ HttpStatus[(HttpStatus['FORBIDDEN'] = 403)] = 'FORBIDDEN';
304
+ HttpStatus[(HttpStatus['NOT_FOUND'] = 404)] = 'NOT_FOUND';
305
+ HttpStatus[(HttpStatus['METHOD_NOT_ALLOWED'] = 405)] = 'METHOD_NOT_ALLOWED';
306
+ HttpStatus[(HttpStatus['NOT_ACCEPTABLE'] = 406)] = 'NOT_ACCEPTABLE';
307
+ HttpStatus[(HttpStatus['PROXY_AUTHENTICATION_REQUIRED'] = 407)] =
308
+ 'PROXY_AUTHENTICATION_REQUIRED';
309
+ HttpStatus[(HttpStatus['REQUEST_TIMEOUT'] = 408)] = 'REQUEST_TIMEOUT';
310
+ HttpStatus[(HttpStatus['CONFLICT'] = 409)] = 'CONFLICT';
311
+ HttpStatus[(HttpStatus['GONE'] = 410)] = 'GONE';
312
+ HttpStatus[(HttpStatus['LENGTH_REQUIRED'] = 411)] = 'LENGTH_REQUIRED';
313
+ HttpStatus[(HttpStatus['PRECONDITION_FAILED'] = 412)] = 'PRECONDITION_FAILED';
314
+ HttpStatus[(HttpStatus['PAYLOAD_TOO_LARGE'] = 413)] = 'PAYLOAD_TOO_LARGE';
315
+ HttpStatus[(HttpStatus['URI_TOO_LONG'] = 414)] = 'URI_TOO_LONG';
316
+ HttpStatus[(HttpStatus['UNSUPPORTED_MEDIA_TYPE'] = 415)] =
317
+ 'UNSUPPORTED_MEDIA_TYPE';
318
+ HttpStatus[(HttpStatus['REQUESTED_RANGE_NOT_SATISFIABLE'] = 416)] =
319
+ 'REQUESTED_RANGE_NOT_SATISFIABLE';
320
+ HttpStatus[(HttpStatus['EXPECTATION_FAILED'] = 417)] = 'EXPECTATION_FAILED';
321
+ HttpStatus[(HttpStatus['I_AM_A_TEAPOT'] = 418)] = 'I_AM_A_TEAPOT';
322
+ HttpStatus[(HttpStatus['MISDIRECTED'] = 421)] = 'MISDIRECTED';
323
+ HttpStatus[(HttpStatus['UNPROCESSABLE_ENTITY'] = 422)] =
324
+ 'UNPROCESSABLE_ENTITY';
325
+ HttpStatus[(HttpStatus['FAILED_DEPENDENCY'] = 424)] = 'FAILED_DEPENDENCY';
326
+ HttpStatus[(HttpStatus['PRECONDITION_REQUIRED'] = 428)] =
327
+ 'PRECONDITION_REQUIRED';
328
+ HttpStatus[(HttpStatus['TOO_MANY_REQUESTS'] = 429)] = 'TOO_MANY_REQUESTS';
329
+ HttpStatus[(HttpStatus['INTERNAL_SERVER_ERROR'] = 500)] =
330
+ 'INTERNAL_SERVER_ERROR';
331
+ HttpStatus[(HttpStatus['NOT_IMPLEMENTED'] = 501)] = 'NOT_IMPLEMENTED';
332
+ HttpStatus[(HttpStatus['BAD_GATEWAY'] = 502)] = 'BAD_GATEWAY';
333
+ HttpStatus[(HttpStatus['SERVICE_UNAVAILABLE'] = 503)] = 'SERVICE_UNAVAILABLE';
334
+ HttpStatus[(HttpStatus['GATEWAY_TIMEOUT'] = 504)] = 'GATEWAY_TIMEOUT';
335
+ HttpStatus[(HttpStatus['HTTP_VERSION_NOT_SUPPORTED'] = 505)] =
336
+ 'HTTP_VERSION_NOT_SUPPORTED';
337
+ return HttpStatus;
338
+ })({});
339
+
280
340
  function _assert_this_initialized$1(self) {
281
341
  if (self === void 0) {
282
342
  throw new ReferenceError(
@@ -595,13 +655,22 @@ var PgException = /*#__PURE__*/ (function (Error1) {
595
655
  {
596
656
  key: 'getStatus',
597
657
  value: function getStatus() {
598
- var _this_err;
599
- var _this_err_code;
600
- return (_this_err_code =
601
- (_this_err = this.err) === null || _this_err === void 0
658
+ var _this_err_cause, _this_err, _this_err1;
659
+ var _this_err_cause_code, _ref;
660
+ return (_ref =
661
+ (_this_err_cause_code =
662
+ (_this_err = this.err) === null || _this_err === void 0
663
+ ? void 0
664
+ : (_this_err_cause = _this_err.cause) === null ||
665
+ _this_err_cause === void 0
666
+ ? void 0
667
+ : _this_err_cause.code) !== null &&
668
+ _this_err_cause_code !== void 0
669
+ ? _this_err_cause_code
670
+ : (_this_err1 = this.err) === null || _this_err1 === void 0
602
671
  ? void 0
603
- : _this_err.code) !== null && _this_err_code !== void 0
604
- ? _this_err_code
672
+ : _this_err1.code) !== null && _ref !== void 0
673
+ ? _ref
605
674
  : PostgresError.UNDEFINED_CODE;
606
675
  },
607
676
  },
@@ -770,7 +839,7 @@ var HttpHandler = /*#__PURE__*/ (function () {
770
839
  logger.error('Request failed because of a network error.');
771
840
  var _response_toString;
772
841
  var nativeError = new NativeException(
773
- 500,
842
+ HttpStatus.NOT_IMPLEMENTED,
774
843
  (_response_toString = response.toString()) !== null &&
775
844
  _response_toString !== void 0
776
845
  ? _response_toString
@@ -1386,6 +1455,7 @@ var userTimezonePlugin = function (handlebars, param) {
1386
1455
  exports.CookieHelper = CookieHelper;
1387
1456
  exports.DateFormatter = DateFormatter;
1388
1457
  exports.HttpHandler = HttpHandler;
1458
+ exports.HttpStatus = HttpStatus;
1389
1459
  exports.NativeException = NativeException;
1390
1460
  exports.PatternCompiler = PatternCompiler;
1391
1461
  exports.PgException = PgException;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,46 @@
1
+ declare module "@native-systems/utility" {
2
+ type Paginated<T> = {
3
+ hasNextPage: boolean;
4
+ hasPrevPage: boolean;
5
+ totalPages: number;
6
+ data: T;
7
+ };
8
+ export type { Paginated };
9
+ }
10
+
11
+ declare module "@native-systems/utility" {
12
+ type CancelableComponent<T> = {
13
+ value: T;
14
+ cancel: () => void;
15
+ };
16
+ export type { CancelableComponent };
17
+ }
18
+
19
+ declare module "@native-systems/utility" {
20
+ type CRUDCompontent<T, U = T, V = U> = {
21
+ value: T;
22
+ add: (value: U) => void;
23
+ delete: (id: string) => void;
24
+ update: (id: string, value: V) => void;
25
+ };
26
+ export type { CRUDCompontent };
27
+ }
28
+
29
+ declare module "@native-systems/utility" {
30
+ import { Dispatch, SetStateAction } from "react";
31
+ type UseStateComponent<T, U = T> = {
32
+ current: T;
33
+ update: (value: U) => void;
34
+ };
35
+ /** Same grouping type as the UseStateComponent type, with the difference,
36
+ * that here the update function is directly linked with the useState variable. */
37
+ type DirectUseStateComponent<T> = {
38
+ current: T;
39
+ update: Dispatch<SetStateAction<T>>;
40
+ };
41
+ export type { DirectUseStateComponent, UseStateComponent };
42
+ }
43
+
1
44
  declare module "@native-systems/utility" {
2
45
  export enum PostgresError {
3
46
  /** Class 00 - Successful Completion: [S] successful_completion */
@@ -594,6 +637,21 @@ declare module "@native-systems/utility" {
594
637
  }
595
638
  }
596
639
 
640
+ declare module "@native-systems/utility" {
641
+ namespace native {
642
+ type Error = ErrorConstructor & {
643
+ status: number;
644
+ message: string;
645
+ error: string;
646
+ };
647
+ interface ErrorResponse extends Response {
648
+ isNativeError: boolean;
649
+ }
650
+ export { Error, ErrorResponse };
651
+ }
652
+ export { type native, Paginated, CancelableComponent, CRUDCompontent, UseStateComponent, DirectUseStateComponent, HttpStatus, PostgresError, };
653
+ }
654
+
597
655
  declare module "@native-systems/utility" {
598
656
  /**
599
657
  * Custom exception object used by Native Systems, which extends the Error interface
@@ -664,65 +722,6 @@ declare module "@native-systems/utility" {
664
722
  }
665
723
 
666
724
  declare module "@native-systems/utility" {
667
- namespace native {
668
- type Error = ErrorConstructor & {
669
- status: number;
670
- message: string;
671
- error: string;
672
- };
673
- interface ErrorResponse extends Response {
674
- isNativeError: boolean;
675
- }
676
- export { Error, ErrorResponse };
677
- }
678
- export type { native };
679
- }
680
-
681
- declare module "@native-systems/utility" {
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";
726
725
  class HttpHandler {
727
726
  /**
728
727
  * Http request response handler, which checks if the given response is in status range 'ok'.
package/dist/index.esm.js CHANGED
@@ -275,6 +275,66 @@ var PostgresError = /*#__PURE__*/ (function (PostgresError) {
275
275
  return PostgresError;
276
276
  })({});
277
277
 
278
+ var HttpStatus = /*#__PURE__*/ (function (HttpStatus) {
279
+ HttpStatus[(HttpStatus['CONTINUE'] = 100)] = 'CONTINUE';
280
+ HttpStatus[(HttpStatus['SWITCHING_PROTOCOLS'] = 101)] = 'SWITCHING_PROTOCOLS';
281
+ HttpStatus[(HttpStatus['PROCESSING'] = 102)] = 'PROCESSING';
282
+ HttpStatus[(HttpStatus['EARLYHINTS'] = 103)] = 'EARLYHINTS';
283
+ HttpStatus[(HttpStatus['OK'] = 200)] = 'OK';
284
+ HttpStatus[(HttpStatus['CREATED'] = 201)] = 'CREATED';
285
+ HttpStatus[(HttpStatus['ACCEPTED'] = 202)] = 'ACCEPTED';
286
+ HttpStatus[(HttpStatus['NON_AUTHORITATIVE_INFORMATION'] = 203)] =
287
+ 'NON_AUTHORITATIVE_INFORMATION';
288
+ HttpStatus[(HttpStatus['NO_CONTENT'] = 204)] = 'NO_CONTENT';
289
+ HttpStatus[(HttpStatus['RESET_CONTENT'] = 205)] = 'RESET_CONTENT';
290
+ HttpStatus[(HttpStatus['PARTIAL_CONTENT'] = 206)] = 'PARTIAL_CONTENT';
291
+ HttpStatus[(HttpStatus['AMBIGUOUS'] = 300)] = 'AMBIGUOUS';
292
+ HttpStatus[(HttpStatus['MOVED_PERMANENTLY'] = 301)] = 'MOVED_PERMANENTLY';
293
+ HttpStatus[(HttpStatus['FOUND'] = 302)] = 'FOUND';
294
+ HttpStatus[(HttpStatus['SEE_OTHER'] = 303)] = 'SEE_OTHER';
295
+ HttpStatus[(HttpStatus['NOT_MODIFIED'] = 304)] = 'NOT_MODIFIED';
296
+ HttpStatus[(HttpStatus['TEMPORARY_REDIRECT'] = 307)] = 'TEMPORARY_REDIRECT';
297
+ HttpStatus[(HttpStatus['PERMANENT_REDIRECT'] = 308)] = 'PERMANENT_REDIRECT';
298
+ HttpStatus[(HttpStatus['BAD_REQUEST'] = 400)] = 'BAD_REQUEST';
299
+ HttpStatus[(HttpStatus['UNAUTHORIZED'] = 401)] = 'UNAUTHORIZED';
300
+ HttpStatus[(HttpStatus['PAYMENT_REQUIRED'] = 402)] = 'PAYMENT_REQUIRED';
301
+ HttpStatus[(HttpStatus['FORBIDDEN'] = 403)] = 'FORBIDDEN';
302
+ HttpStatus[(HttpStatus['NOT_FOUND'] = 404)] = 'NOT_FOUND';
303
+ HttpStatus[(HttpStatus['METHOD_NOT_ALLOWED'] = 405)] = 'METHOD_NOT_ALLOWED';
304
+ HttpStatus[(HttpStatus['NOT_ACCEPTABLE'] = 406)] = 'NOT_ACCEPTABLE';
305
+ HttpStatus[(HttpStatus['PROXY_AUTHENTICATION_REQUIRED'] = 407)] =
306
+ 'PROXY_AUTHENTICATION_REQUIRED';
307
+ HttpStatus[(HttpStatus['REQUEST_TIMEOUT'] = 408)] = 'REQUEST_TIMEOUT';
308
+ HttpStatus[(HttpStatus['CONFLICT'] = 409)] = 'CONFLICT';
309
+ HttpStatus[(HttpStatus['GONE'] = 410)] = 'GONE';
310
+ HttpStatus[(HttpStatus['LENGTH_REQUIRED'] = 411)] = 'LENGTH_REQUIRED';
311
+ HttpStatus[(HttpStatus['PRECONDITION_FAILED'] = 412)] = 'PRECONDITION_FAILED';
312
+ HttpStatus[(HttpStatus['PAYLOAD_TOO_LARGE'] = 413)] = 'PAYLOAD_TOO_LARGE';
313
+ HttpStatus[(HttpStatus['URI_TOO_LONG'] = 414)] = 'URI_TOO_LONG';
314
+ HttpStatus[(HttpStatus['UNSUPPORTED_MEDIA_TYPE'] = 415)] =
315
+ 'UNSUPPORTED_MEDIA_TYPE';
316
+ HttpStatus[(HttpStatus['REQUESTED_RANGE_NOT_SATISFIABLE'] = 416)] =
317
+ 'REQUESTED_RANGE_NOT_SATISFIABLE';
318
+ HttpStatus[(HttpStatus['EXPECTATION_FAILED'] = 417)] = 'EXPECTATION_FAILED';
319
+ HttpStatus[(HttpStatus['I_AM_A_TEAPOT'] = 418)] = 'I_AM_A_TEAPOT';
320
+ HttpStatus[(HttpStatus['MISDIRECTED'] = 421)] = 'MISDIRECTED';
321
+ HttpStatus[(HttpStatus['UNPROCESSABLE_ENTITY'] = 422)] =
322
+ 'UNPROCESSABLE_ENTITY';
323
+ HttpStatus[(HttpStatus['FAILED_DEPENDENCY'] = 424)] = 'FAILED_DEPENDENCY';
324
+ HttpStatus[(HttpStatus['PRECONDITION_REQUIRED'] = 428)] =
325
+ 'PRECONDITION_REQUIRED';
326
+ HttpStatus[(HttpStatus['TOO_MANY_REQUESTS'] = 429)] = 'TOO_MANY_REQUESTS';
327
+ HttpStatus[(HttpStatus['INTERNAL_SERVER_ERROR'] = 500)] =
328
+ 'INTERNAL_SERVER_ERROR';
329
+ HttpStatus[(HttpStatus['NOT_IMPLEMENTED'] = 501)] = 'NOT_IMPLEMENTED';
330
+ HttpStatus[(HttpStatus['BAD_GATEWAY'] = 502)] = 'BAD_GATEWAY';
331
+ HttpStatus[(HttpStatus['SERVICE_UNAVAILABLE'] = 503)] = 'SERVICE_UNAVAILABLE';
332
+ HttpStatus[(HttpStatus['GATEWAY_TIMEOUT'] = 504)] = 'GATEWAY_TIMEOUT';
333
+ HttpStatus[(HttpStatus['HTTP_VERSION_NOT_SUPPORTED'] = 505)] =
334
+ 'HTTP_VERSION_NOT_SUPPORTED';
335
+ return HttpStatus;
336
+ })({});
337
+
278
338
  function _assert_this_initialized$1(self) {
279
339
  if (self === void 0) {
280
340
  throw new ReferenceError(
@@ -593,13 +653,22 @@ var PgException = /*#__PURE__*/ (function (Error1) {
593
653
  {
594
654
  key: 'getStatus',
595
655
  value: function getStatus() {
596
- var _this_err;
597
- var _this_err_code;
598
- return (_this_err_code =
599
- (_this_err = this.err) === null || _this_err === void 0
656
+ var _this_err_cause, _this_err, _this_err1;
657
+ var _this_err_cause_code, _ref;
658
+ return (_ref =
659
+ (_this_err_cause_code =
660
+ (_this_err = this.err) === null || _this_err === void 0
661
+ ? void 0
662
+ : (_this_err_cause = _this_err.cause) === null ||
663
+ _this_err_cause === void 0
664
+ ? void 0
665
+ : _this_err_cause.code) !== null &&
666
+ _this_err_cause_code !== void 0
667
+ ? _this_err_cause_code
668
+ : (_this_err1 = this.err) === null || _this_err1 === void 0
600
669
  ? void 0
601
- : _this_err.code) !== null && _this_err_code !== void 0
602
- ? _this_err_code
670
+ : _this_err1.code) !== null && _ref !== void 0
671
+ ? _ref
603
672
  : PostgresError.UNDEFINED_CODE;
604
673
  },
605
674
  },
@@ -768,7 +837,7 @@ var HttpHandler = /*#__PURE__*/ (function () {
768
837
  logger.error('Request failed because of a network error.');
769
838
  var _response_toString;
770
839
  var nativeError = new NativeException(
771
- 500,
840
+ HttpStatus.NOT_IMPLEMENTED,
772
841
  (_response_toString = response.toString()) !== null &&
773
842
  _response_toString !== void 0
774
843
  ? _response_toString
@@ -1385,6 +1454,7 @@ export {
1385
1454
  CookieHelper,
1386
1455
  DateFormatter,
1387
1456
  HttpHandler,
1457
+ HttpStatus,
1388
1458
  NativeException,
1389
1459
  PatternCompiler,
1390
1460
  PgException,
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "version": "2.1.0",
13
+ "version": "2.1.2",
14
14
  "license": "MIT",
15
15
  "private": false,
16
16
  "engines": {
@@ -78,6 +78,7 @@
78
78
  "handlebars": "^4.7.8",
79
79
  "husky": "^9.1.6",
80
80
  "lint-staged": "^13.0.3",
81
+ "markdown-it": "^14.1.0",
81
82
  "npm-run-all": "^4.1.5",
82
83
  "prettier": "3.0.3",
83
84
  "rollup": "^4.26.0",
@@ -88,6 +89,7 @@
88
89
  "rollup-plugin-swc3": "^0.12.1",
89
90
  "rollup-plugin-tsconfig-paths": "^1.5.2",
90
91
  "rollup-plugin-typescript-paths": "^1.5.0",
92
+ "sanitize-html": "^2.17.0",
91
93
  "ts-node": "^10.9.1",
92
94
  "typescript": "5.6.3"
93
95
  },