@ram_28/kf-ai-sdk 1.0.20 → 1.0.22

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.
Files changed (53) hide show
  1. package/dist/api/client.d.ts.map +1 -1
  2. package/dist/api/datetime.d.ts +59 -10
  3. package/dist/api/datetime.d.ts.map +1 -1
  4. package/dist/api/index.d.ts +3 -2
  5. package/dist/api/index.d.ts.map +1 -1
  6. package/dist/api.cjs +1 -1
  7. package/dist/api.d.ts +1 -1
  8. package/dist/api.d.ts.map +1 -1
  9. package/dist/api.mjs +43 -21
  10. package/dist/api.types.d.ts +2 -1
  11. package/dist/api.types.d.ts.map +1 -1
  12. package/dist/auth/AuthProvider.d.ts.map +1 -1
  13. package/dist/auth.cjs +1 -1
  14. package/dist/auth.mjs +34 -34
  15. package/dist/base-types.d.ts +1 -1
  16. package/dist/base-types.d.ts.map +1 -1
  17. package/dist/client-BIkaIr2y.js +217 -0
  18. package/dist/client-DxjRcEtN.cjs +1 -0
  19. package/dist/components/hooks/useForm/apiClient.d.ts +45 -4
  20. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
  21. package/dist/components/hooks/useForm/types.d.ts +8 -0
  22. package/dist/components/hooks/useForm/types.d.ts.map +1 -1
  23. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  24. package/dist/form.cjs +1 -1
  25. package/dist/form.mjs +1028 -1051
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/kanban.cjs +1 -1
  29. package/dist/kanban.mjs +1 -1
  30. package/dist/{metadata-0lZAfuTP.cjs → metadata-Bz8zJqC1.cjs} +1 -1
  31. package/dist/{metadata-B88D_pVS.js → metadata-VbQzyD2C.js} +1 -1
  32. package/dist/table.cjs +1 -1
  33. package/dist/table.mjs +1 -1
  34. package/dist/types/base-fields.d.ts +71 -17
  35. package/dist/types/base-fields.d.ts.map +1 -1
  36. package/dist/types/common.d.ts +0 -12
  37. package/dist/types/common.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/sdk/api/client.ts +3 -41
  40. package/sdk/api/datetime.ts +98 -14
  41. package/sdk/api/index.ts +12 -6
  42. package/sdk/api.ts +6 -3
  43. package/sdk/api.types.ts +3 -4
  44. package/sdk/auth/AuthProvider.tsx +22 -24
  45. package/sdk/base-types.ts +2 -0
  46. package/sdk/components/hooks/useForm/apiClient.ts +118 -4
  47. package/sdk/components/hooks/useForm/types.ts +9 -0
  48. package/sdk/components/hooks/useForm/useForm.ts +79 -60
  49. package/sdk/index.ts +3 -0
  50. package/sdk/types/base-fields.ts +71 -17
  51. package/sdk/types/common.ts +2 -13
  52. package/dist/client-DgtkT50N.cjs +0 -1
  53. package/dist/client-V-WzUb8H.js +0 -237
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../sdk/api/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAEhB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EAGjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EAErB,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,GAAG;IAKrC,8BAA8B;IAC9B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE5B,wBAAwB;IACxB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAE/E,6BAA6B;IAC7B,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAExE,0BAA0B;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,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;CAClF;AAoBD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEnD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAEvE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE1D;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,CAuR7D"}
@@ -1,21 +1,70 @@
1
- import type { DateTimeEncodedType, DateEncodedType } from '../types/common';
1
+ import type { DateEncodedType, DateTimeEncodedType } from "../types/base-fields";
2
2
  /**
3
- * Utility functions for datetime encoding/decoding
3
+ * Date format constants matching backend DatetimeFormat class
4
+ * Source: kf-ai-base/core/util/datetime_utils.py
4
5
  */
6
+ export declare const DatetimeFormat: {
7
+ /** Date format: "YYYY-MM-DD" */
8
+ readonly DATE: "%Y-%m-%d";
9
+ /** Time format: "HH:MM:SS" */
10
+ readonly TIME: "%H:%M:%S";
11
+ /** DateTime format: "YYYY-MM-DD HH:MM:SS" */
12
+ readonly DATE_TIME: "%Y-%m-%d %H:%M:%S";
13
+ };
5
14
  /**
6
- * Encode a Date object to API datetime format
15
+ * Decode API date response to Date object
16
+ * @param encoded - API response format { "$__d__": "YYYY-MM-DD" }
17
+ * @returns JavaScript Date object
18
+ *
19
+ * @example
20
+ * const apiResponse = { "$__d__": "2025-03-15" };
21
+ * const date = decodeDate(apiResponse); // => Date object
7
22
  */
8
- export declare function encodeDatetime(date: Date): DateTimeEncodedType;
23
+ export declare function decodeDate(encoded: DateEncodedType): Date;
9
24
  /**
10
- * Decode API datetime format to Date object
25
+ * Decode API datetime response to Date object
26
+ * @param encoded - API response format { "$__dt__": unix_timestamp_seconds }
27
+ * @returns JavaScript Date object
28
+ *
29
+ * @example
30
+ * const apiResponse = { "$__dt__": 1769110463 };
31
+ * const date = decodeDateTime(apiResponse); // => Date object
11
32
  */
12
- export declare function decodeDatetime(encoded: DateTimeEncodedType): Date;
33
+ export declare function decodeDateTime(encoded: DateTimeEncodedType): Date;
13
34
  /**
14
- * Encode a Date object to API date format (YYYY-MM-DD)
35
+ * Format a Date object to API request date string
36
+ * @param date - JavaScript Date object
37
+ * @returns "YYYY-MM-DD" formatted string for API requests
38
+ *
39
+ * @example
40
+ * formatDate(new Date(2025, 2, 15)) // => "2025-03-15"
15
41
  */
16
- export declare function encodeDate(date: Date): DateEncodedType;
42
+ export declare function formatDate(date: Date): string;
17
43
  /**
18
- * Decode API date format to Date object
44
+ * Format a Date object to API request datetime string
45
+ * @param date - JavaScript Date object
46
+ * @returns "YYYY-MM-DD HH:MM:SS" formatted string for API requests
47
+ *
48
+ * @example
49
+ * formatDateTime(new Date(2025, 2, 15, 10, 30, 45)) // => "2025-03-15 10:30:45"
19
50
  */
20
- export declare function decodeDate(encoded: DateEncodedType): Date;
51
+ export declare function formatDateTime(date: Date): string;
52
+ /**
53
+ * Parse date string to Date object
54
+ * @param dateStr - "YYYY-MM-DD" formatted string
55
+ * @returns JavaScript Date object
56
+ *
57
+ * @example
58
+ * parseDate("2025-03-15") // => Date object for March 15, 2025
59
+ */
60
+ export declare function parseDate(dateStr: string): Date;
61
+ /**
62
+ * Parse datetime string to Date object
63
+ * @param dateTimeStr - "YYYY-MM-DD HH:MM:SS" formatted string
64
+ * @returns JavaScript Date object
65
+ *
66
+ * @example
67
+ * parseDateTime("2025-03-15 10:30:45") // => Date object
68
+ */
69
+ export declare function parseDateTime(dateTimeStr: string): Date;
21
70
  //# sourceMappingURL=datetime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../sdk/api/datetime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE5E;;GAEG;AAEH;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,mBAAmB,CAE9D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAEjE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CAEtD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAEzD"}
1
+ {"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../sdk/api/datetime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,cAAc;IACzB,gCAAgC;;IAEhC,8BAA8B;;IAE9B,6CAA6C;;CAErC,CAAC;AAOX;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAGzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAEjE;AAOD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAK7C;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQjD;AAOD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG/C;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAKvD"}
@@ -1,7 +1,8 @@
1
1
  export { api, setApiBaseUrl, setDefaultHeaders, getDefaultHeaders, getApiBaseUrl, } from "./client";
2
2
  export type { ResourceClient } from "./client";
3
- export { encodeDatetime, decodeDatetime, encodeDate, decodeDate, } from "./datetime";
3
+ export { DatetimeFormat, decodeDate, decodeDateTime, formatDate, formatDateTime, parseDate, parseDateTime, } from "./datetime";
4
4
  export { getBdoSchema, listMetadata } from "./metadata";
5
5
  export type { BackendSchema, MetadataItem, FieldMetadata } from "./metadata";
6
- export type { SortDirectionType, SortOptionType, SortType, ConditionType, ConditionGroupType, ConditionGroupOperatorType, FilterType, FilterRHSTypeType, ConditionOperatorType, ListOptionsType, ListResponseType, ReadResponseType, CreateUpdateResponseType, DeleteResponseType, CountResponseType, DateTimeEncodedType, DateEncodedType, MetricTypeType, MetricFieldType, MetricOptionsType, MetricResponseType, PivotHeaderItemType, PivotResponseDataType, PivotOptionsType, PivotResponseType, DraftResponseType, FieldsResponseType, } from "../types/common";
6
+ export type { SortDirectionType, SortOptionType, SortType, ConditionType, ConditionGroupType, ConditionGroupOperatorType, FilterType, FilterRHSTypeType, ConditionOperatorType, ListOptionsType, ListResponseType, ReadResponseType, CreateUpdateResponseType, DeleteResponseType, CountResponseType, MetricTypeType, MetricFieldType, MetricOptionsType, MetricResponseType, PivotHeaderItemType, PivotResponseDataType, PivotOptionsType, PivotResponseType, DraftResponseType, FieldsResponseType, } from "../types/common";
7
+ export type { DateEncodedType, DateTimeEncodedType, } from "../types/base-fields";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../sdk/api/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,GAAG,EACH,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EACL,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,GACX,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG7E,YAAY,EAEV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EAER,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EAErB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EAEjB,mBAAmB,EACnB,eAAe,EAEf,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAElB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAEjB,iBAAiB,EAEjB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../sdk/api/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,GAAG,EACH,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EACL,cAAc,EACd,UAAU,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG7E,YAAY,EAEV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EAER,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EAErB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EAEjB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAElB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAEjB,iBAAiB,EAEjB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAC"}
package/dist/api.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./client-DgtkT50N.cjs"),a=require("./metadata-0lZAfuTP.cjs");function d(e){return{$__dt__:e.getTime()/1e3}}function i(e){return new Date(e.$__dt__*1e3)}function r(e){return{$__d__:e.toISOString().split("T")[0]}}function n(e){return new Date(e.$__d__)}exports.api=t.api;exports.getApiBaseUrl=t.getApiBaseUrl;exports.getDefaultHeaders=t.getDefaultHeaders;exports.setApiBaseUrl=t.setApiBaseUrl;exports.setDefaultHeaders=t.setDefaultHeaders;exports.getBdoSchema=a.getBdoSchema;exports.listMetadata=a.listMetadata;exports.decodeDate=n;exports.decodeDatetime=i;exports.encodeDate=r;exports.encodeDatetime=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./client-DxjRcEtN.cjs"),m=require("./metadata-Bz8zJqC1.cjs"),d={DATE:"%Y-%m-%d",TIME:"%H:%M:%S",DATE_TIME:"%Y-%m-%d %H:%M:%S"};function p(t){const[e,a,r]=t.$__d__.split("-").map(Number);return new Date(e,a-1,r)}function D(t){return new Date(t.$__dt__*1e3)}function g(t){const e=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${a}-${r}`}function l(t){const e=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0"),i=String(t.getSeconds()).padStart(2,"0");return`${e}-${a}-${r} ${s}:${o}:${i}`}function S(t){const[e,a,r]=t.split("-").map(Number);return new Date(e,a-1,r)}function f(t){const[e,a]=t.split(" "),[r,s,o]=e.split("-").map(Number),[i,c,u]=a.split(":").map(Number);return new Date(r,s-1,o,i,c,u)}exports.api=n.api;exports.getApiBaseUrl=n.getApiBaseUrl;exports.getDefaultHeaders=n.getDefaultHeaders;exports.setApiBaseUrl=n.setApiBaseUrl;exports.setDefaultHeaders=n.setDefaultHeaders;exports.getBdoSchema=m.getBdoSchema;exports.listMetadata=m.listMetadata;exports.DatetimeFormat=d;exports.decodeDate=p;exports.decodeDateTime=D;exports.formatDate=g;exports.formatDateTime=l;exports.parseDate=S;exports.parseDateTime=f;
package/dist/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { api, setApiBaseUrl, setDefaultHeaders, getDefaultHeaders, getApiBaseUrl, } from './api/client';
2
- export { encodeDatetime, decodeDatetime, encodeDate, decodeDate, } from './api/datetime';
2
+ export { formatDateTime, decodeDateTime, formatDate, decodeDate, parseDate, parseDateTime, DatetimeFormat, } from './api/datetime';
3
3
  export { getBdoSchema, listMetadata } from './api/metadata';
4
4
  //# sourceMappingURL=api.d.ts.map
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../sdk/api.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,GAAG,EACH,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,GACX,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../sdk/api.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,GAAG,EACH,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACb,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/api.mjs CHANGED
@@ -1,27 +1,49 @@
1
- import { a as o, c as d, g as i, s as c, b as u } from "./client-V-WzUb8H.js";
2
- import { g as D, l as g } from "./metadata-B88D_pVS.js";
3
- function t(e) {
4
- return { $__dt__: e.getTime() / 1e3 };
1
+ import { a as $, c as h, g as y, s as _, b as M } from "./client-BIkaIr2y.js";
2
+ import { g as b, l as H } from "./metadata-VbQzyD2C.js";
3
+ const m = {
4
+ /** Date format: "YYYY-MM-DD" */
5
+ DATE: "%Y-%m-%d",
6
+ /** Time format: "HH:MM:SS" */
7
+ TIME: "%H:%M:%S",
8
+ /** DateTime format: "YYYY-MM-DD HH:MM:SS" */
9
+ DATE_TIME: "%Y-%m-%d %H:%M:%S"
10
+ };
11
+ function u(t) {
12
+ const [e, a, n] = t.$__d__.split("-").map(Number);
13
+ return new Date(e, a - 1, n);
14
+ }
15
+ function p(t) {
16
+ return new Date(t.$__dt__ * 1e3);
17
+ }
18
+ function d(t) {
19
+ const e = t.getFullYear(), a = String(t.getMonth() + 1).padStart(2, "0"), n = String(t.getDate()).padStart(2, "0");
20
+ return `${e}-${a}-${n}`;
5
21
  }
6
- function a(e) {
7
- return new Date(e.$__dt__ * 1e3);
22
+ function g(t) {
23
+ const e = t.getFullYear(), a = String(t.getMonth() + 1).padStart(2, "0"), n = String(t.getDate()).padStart(2, "0"), r = String(t.getHours()).padStart(2, "0"), s = String(t.getMinutes()).padStart(2, "0"), o = String(t.getSeconds()).padStart(2, "0");
24
+ return `${e}-${a}-${n} ${r}:${s}:${o}`;
8
25
  }
9
- function r(e) {
10
- return { $__d__: e.toISOString().split("T")[0] };
26
+ function S(t) {
27
+ const [e, a, n] = t.split("-").map(Number);
28
+ return new Date(e, a - 1, n);
11
29
  }
12
- function n(e) {
13
- return new Date(e.$__d__);
30
+ function D(t) {
31
+ const [e, a] = t.split(" "), [n, r, s] = e.split("-").map(Number), [o, i, c] = a.split(":").map(Number);
32
+ return new Date(n, r - 1, s, o, i, c);
14
33
  }
15
34
  export {
16
- o as api,
17
- n as decodeDate,
18
- a as decodeDatetime,
19
- r as encodeDate,
20
- t as encodeDatetime,
21
- d as getApiBaseUrl,
22
- D as getBdoSchema,
23
- i as getDefaultHeaders,
24
- g as listMetadata,
25
- c as setApiBaseUrl,
26
- u as setDefaultHeaders
35
+ m as DatetimeFormat,
36
+ $ as api,
37
+ u as decodeDate,
38
+ p as decodeDateTime,
39
+ d as formatDate,
40
+ g as formatDateTime,
41
+ h as getApiBaseUrl,
42
+ b as getBdoSchema,
43
+ y as getDefaultHeaders,
44
+ H as listMetadata,
45
+ S as parseDate,
46
+ D as parseDateTime,
47
+ _ as setApiBaseUrl,
48
+ M as setDefaultHeaders
27
49
  };
@@ -1,4 +1,5 @@
1
1
  export type { ResourceClient } from './api/client';
2
2
  export type { BackendSchema, MetadataItem, FieldMetadata } from './api/metadata';
3
- export type { SortDirectionType, SortOptionType, SortType, ConditionType, ConditionGroupType, ConditionGroupOperatorType, ConditionOperatorType, FilterType, FilterRHSTypeType, ListOptionsType, ListResponseType, ReadResponseType, CreateUpdateResponseType, DeleteResponseType, CountResponseType, DateTimeEncodedType, DateEncodedType, MetricTypeType, MetricFieldType, MetricOptionsType, MetricResponseType, PivotHeaderItemType, PivotResponseDataType, PivotOptionsType, PivotResponseType, DraftResponseType, FieldsResponseType, FetchFieldOptionType, FetchFieldResponseType, } from './types/common';
3
+ export type { DateTimeEncodedType, DateEncodedType } from './types/base-fields';
4
+ export type { SortDirectionType, SortOptionType, SortType, ConditionType, ConditionGroupType, ConditionGroupOperatorType, ConditionOperatorType, FilterType, FilterRHSTypeType, ListOptionsType, ListResponseType, ReadResponseType, CreateUpdateResponseType, DeleteResponseType, CountResponseType, MetricTypeType, MetricFieldType, MetricOptionsType, MetricResponseType, PivotHeaderItemType, PivotResponseDataType, PivotOptionsType, PivotResponseType, DraftResponseType, FieldsResponseType, FetchFieldOptionType, FetchFieldResponseType, } from './types/common';
4
5
  //# sourceMappingURL=api.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.types.d.ts","sourceRoot":"","sources":["../sdk/api.types.ts"],"names":[],"mappings":"AAMA,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGjF,YAAY,EAEV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EAGR,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EAGjB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EAGjB,mBAAmB,EACnB,eAAe,EAGf,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAGlB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAGjB,iBAAiB,EAGjB,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"api.types.d.ts","sourceRoot":"","sources":["../sdk/api.types.ts"],"names":[],"mappings":"AAMA,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGjF,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGhF,YAAY,EAEV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EAGR,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EAGjB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EAGjB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAGlB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAGjB,iBAAiB,EAGjB,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../sdk/auth/AuthProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,KAQN,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EAOtB,MAAM,SAAS,CAAC;AAsBjB,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,MAAM,EAAE,cAAc,EACtB,YAAY,EACZ,OAAO,EACP,gBAAgB,EAChB,wBAAwB,EACxB,gBAAwB,GACzB,EAAE,qBAAqB,GAAG,KAAK,CAAC,YAAY,CAiN5C;AAMD,wBAAgB,cAAc,IAAI,oBAAoB,CAMrD"}
1
+ {"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../sdk/auth/AuthProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,KAQN,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EAOtB,MAAM,SAAS,CAAC;AAsBjB,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,MAAM,EAAE,cAAc,EACtB,YAAY,EACZ,OAAO,EACP,gBAAgB,EAChB,wBAAwB,EACxB,gBAAwB,GACzB,EAAE,qBAAqB,GAAG,KAAK,CAAC,YAAY,CA+M5C;AAMD,wBAAgB,cAAc,IAAI,oBAAoB,CAMrD"}
package/dist/auth.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var z=Object.defineProperty;var J=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var M=(e,t,n)=>J(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react/jsx-runtime"),r=require("react"),K=require("@tanstack/react-query"),x=require("./client-DgtkT50N.cjs"),H={sessionEndpoint:"/api/id",providers:{google:{loginPath:"/api/auth/google/login",logoutPath:"/api/auth/logout"}},defaultProvider:"google",autoRedirect:!1,sessionCheckInterval:0,retry:{count:3,delay:1e3},staleTime:5*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!0};let h={...H};function N(e){h={...h,...e,providers:{...h.providers,...e.providers},retry:{...h.retry,...e.retry}}}function X(e,t){h.providers[e]=t}function b(){return{...h}}function k(){return h.baseUrl||x.getApiBaseUrl()||(typeof window<"u"?window.location.origin:"")}function Y(e){return h.providers[e]}function Z(){h={...H}}class m extends Error{constructor(n,o){super(n);M(this,"statusCode");this.name="AuthenticationError",this.statusCode=o}}async function D(){const e=b(),t=k(),n=x.getDefaultHeaders(),o=await fetch(`${t}${e.sessionEndpoint}`,{method:"GET",headers:n,credentials:"include"});if(!o.ok)throw o.status===401||o.status===403?new m("Not authenticated",o.status):new m(`Session check failed: ${o.statusText}`,o.status);return await o.json()}function W(e,t){return new Promise(()=>{const n=b(),o=k();if(!o)throw new Error('Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.');const i=e||n.defaultProvider,c=Y(i);if(!c){const w=Object.keys(n.providers||{}).join(", ")||"none";throw new Error(`Auth provider "${i}" is not configured. Available providers: ${w}`)}if(!c.loginPath)throw new Error(`Login path not configured for provider "${i}". Configure it with: configureAuth({ providers: { ${i}: { loginPath: '/api/auth/...' } } })`);let f;try{f=new URL(`${o}${c.loginPath}`)}catch{throw new Error(`Failed to construct login URL. Base URL: "${o}", Login path: "${c.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`)}(t!=null&&t.callbackUrl||n.callbackUrl)&&f.searchParams.set("callbackUrl",(t==null?void 0:t.callbackUrl)||n.callbackUrl||window.location.href),t!=null&&t.params&&Object.entries(t.params).forEach(([w,v])=>{f.searchParams.set(w,v)}),window.location.href=f.toString()})}async function ee(e){const t=b(),n=k(),o=x.getDefaultHeaders(),i=Y(t.defaultProvider),c=i==null?void 0:i.logoutPath;if(c&&(e==null?void 0:e.callLogoutEndpoint)!==!1)try{await fetch(`${n}${c}`,{method:"POST",headers:o,credentials:"include"})}catch(f){console.warn("Logout endpoint call failed:",f)}e!=null&&e.redirectUrl?window.location.href=e.redirectUrl:t.loginRedirectUrl&&(window.location.href=t.loginRedirectUrl)}const G=r.createContext(null),_=["auth","session"];function te({children:e,config:t,onAuthChange:n,onError:o,loadingComponent:i,unauthenticatedComponent:c,skipInitialCheck:f=!1}){const w=r.useRef(!1);t&&!w.current&&(N(t),w.current=!0);const v=K.useQueryClient(),l=b(),{data:a,isLoading:g,error:U,refetch:R,isFetching:C}=K.useQuery({queryKey:_,queryFn:D,enabled:!f,retry:(s,y)=>y instanceof m&&(y.statusCode===401||y.statusCode===403)?!1:s<l.retry.count,retryDelay:l.retry.delay,staleTime:l.staleTime,gcTime:l.staleTime*2,refetchOnWindowFocus:l.refetchOnWindowFocus??!0,refetchOnReconnect:l.refetchOnReconnect??!0,refetchInterval:l.sessionCheckInterval||!1}),[S,L]=r.useState(null),d=r.useMemo(()=>g||C?"loading":a!=null&&a.userDetails?"authenticated":"unauthenticated",[g,C,a]),u=(a==null?void 0:a.userDetails)||null,$=(a==null?void 0:a.staticBaseUrl)||null,B=(a==null?void 0:a.buildId)||null,O=d==="authenticated",E=r.useRef(n);E.current=n;const P=r.useRef(o);P.current=o,r.useEffect(()=>{var s;g||(s=E.current)==null||s.call(E,d,u)},[d,u,g]),r.useEffect(()=>{var s;U&&(L(U),(s=P.current)==null||s.call(P,U))},[U]),r.useEffect(()=>{d==="unauthenticated"&&l.autoRedirect&&!g&&W()},[d,g,l.autoRedirect]);const j=r.useCallback((s,y)=>{W(s,y)},[]),p=r.useCallback(async s=>{v.removeQueries({queryKey:_}),await ee(s)},[v]),q=r.useCallback(async()=>{if(C)return a||null;try{return(await R()).data||null}catch(s){return L(s),null}},[R,C,a]),I=r.useCallback(s=>(u==null?void 0:u.Role)===s,[u]),T=r.useCallback(s=>s.includes((u==null?void 0:u.Role)||""),[u]),F=r.useCallback(()=>{L(null)},[]),Q=r.useCallback(()=>{R()},[R]),V=r.useMemo(()=>({user:u,staticBaseUrl:$,buildId:B,status:d,isAuthenticated:O,isLoading:g,login:j,logout:p,refreshSession:q,hasRole:I,hasAnyRole:T,error:S,clearError:F,_forceCheck:Q}),[u,$,B,d,O,g,j,p,q,I,T,S,F,Q]);return d==="loading"&&i?A.jsx(A.Fragment,{children:i}):d==="unauthenticated"&&!l.autoRedirect&&c?A.jsx(A.Fragment,{children:c}):A.jsx(G.Provider,{value:V,children:e})}function re(){const e=r.useContext(G);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function ne(){const e=re();return r.useMemo(()=>({user:e.user,staticBaseUrl:e.staticBaseUrl,buildId:e.buildId,status:e.status,isAuthenticated:e.isAuthenticated,isLoading:e.isLoading,login:e.login,logout:e.logout,refreshSession:e.refreshSession,hasRole:e.hasRole,hasAnyRole:e.hasAnyRole,error:e.error,clearError:e.clearError}),[e.user,e.staticBaseUrl,e.buildId,e.status,e.isAuthenticated,e.isLoading,e.login,e.logout,e.refreshSession,e.hasRole,e.hasAnyRole,e.error,e.clearError])}exports.AuthProvider=te;exports.AuthenticationError=m;exports.configureAuth=N;exports.getAuthBaseUrl=k;exports.getAuthConfig=b;exports.resetAuthConfig=Z;exports.setAuthProvider=X;exports.useAuth=ne;
1
+ "use strict";var z=Object.defineProperty;var J=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var M=(e,t,n)=>J(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react/jsx-runtime"),r=require("react"),K=require("@tanstack/react-query"),x=require("./client-DxjRcEtN.cjs"),H={sessionEndpoint:"/api/id",providers:{google:{loginPath:"/api/auth/google/login",logoutPath:"/api/auth/logout"}},defaultProvider:"google",autoRedirect:!1,sessionCheckInterval:0,retry:{count:3,delay:1e3},staleTime:5*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!0};let h={...H};function N(e){h={...h,...e,providers:{...h.providers,...e.providers},retry:{...h.retry,...e.retry}}}function X(e,t){h.providers[e]=t}function b(){return{...h}}function k(){return h.baseUrl||x.getApiBaseUrl()||(typeof window<"u"?window.location.origin:"")}function Y(e){return h.providers[e]}function Z(){h={...H}}class m extends Error{constructor(n,o){super(n);M(this,"statusCode");this.name="AuthenticationError",this.statusCode=o}}async function D(){const e=b(),t=k(),n=x.getDefaultHeaders(),o=await fetch(`${t}${e.sessionEndpoint}`,{method:"GET",headers:n,credentials:"include"});if(!o.ok)throw o.status===401||o.status===403?new m("Not authenticated",o.status):new m(`Session check failed: ${o.statusText}`,o.status);return await o.json()}function W(e,t){return new Promise(()=>{const n=b(),o=k();if(!o)throw new Error('Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.');const i=e||n.defaultProvider,c=Y(i);if(!c){const w=Object.keys(n.providers||{}).join(", ")||"none";throw new Error(`Auth provider "${i}" is not configured. Available providers: ${w}`)}if(!c.loginPath)throw new Error(`Login path not configured for provider "${i}". Configure it with: configureAuth({ providers: { ${i}: { loginPath: '/api/auth/...' } } })`);let f;try{f=new URL(`${o}${c.loginPath}`)}catch{throw new Error(`Failed to construct login URL. Base URL: "${o}", Login path: "${c.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`)}(t!=null&&t.callbackUrl||n.callbackUrl)&&f.searchParams.set("callbackUrl",(t==null?void 0:t.callbackUrl)||n.callbackUrl||window.location.href),t!=null&&t.params&&Object.entries(t.params).forEach(([w,v])=>{f.searchParams.set(w,v)}),window.location.href=f.toString()})}async function ee(e){const t=b(),n=k(),o=x.getDefaultHeaders(),i=Y(t.defaultProvider),c=i==null?void 0:i.logoutPath;if(c&&(e==null?void 0:e.callLogoutEndpoint)!==!1)try{await fetch(`${n}${c}`,{method:"POST",headers:o,credentials:"include"})}catch(f){console.warn("Logout endpoint call failed:",f)}e!=null&&e.redirectUrl?window.location.href=e.redirectUrl:t.loginRedirectUrl&&(window.location.href=t.loginRedirectUrl)}const G=r.createContext(null),_=["auth","session"];function te({children:e,config:t,onAuthChange:n,onError:o,loadingComponent:i,unauthenticatedComponent:c,skipInitialCheck:f=!1}){const w=r.useRef(!1);t&&!w.current&&(N(t),w.current=!0);const v=K.useQueryClient(),l=b(),{data:a,isLoading:g,error:U,refetch:R,isFetching:C}=K.useQuery({queryKey:_,queryFn:D,enabled:!f,retry:(s,y)=>y instanceof m&&(y.statusCode===401||y.statusCode===403)?!1:s<l.retry.count,retryDelay:l.retry.delay,staleTime:l.staleTime,gcTime:l.staleTime*2,refetchOnWindowFocus:l.refetchOnWindowFocus??!0,refetchOnReconnect:l.refetchOnReconnect??!0,refetchInterval:l.sessionCheckInterval||!1}),[S,L]=r.useState(null),d=r.useMemo(()=>g||C?"loading":Object.keys((a==null?void 0:a.userDetails)||{}).length>0?"authenticated":"unauthenticated",[g,C,a]),u=(a==null?void 0:a.userDetails)||null,$=(a==null?void 0:a.staticBaseUrl)||null,O=(a==null?void 0:a.buildId)||null,j=d==="authenticated",E=r.useRef(n);E.current=n;const P=r.useRef(o);P.current=o,r.useEffect(()=>{var s;g||(s=E.current)==null||s.call(E,d,u)},[d,u,g]),r.useEffect(()=>{var s;U&&(L(U),(s=P.current)==null||s.call(P,U))},[U]),r.useEffect(()=>{d==="unauthenticated"&&l.autoRedirect&&!g&&W()},[d,g,l.autoRedirect]);const B=r.useCallback((s,y)=>{W(s,y)},[]),p=r.useCallback(async s=>{v.removeQueries({queryKey:_}),await ee(s)},[v]),q=r.useCallback(async()=>{if(C)return a||null;try{return(await R()).data||null}catch(s){return L(s),null}},[R,C,a]),I=r.useCallback(s=>(u==null?void 0:u.Role)===s,[u]),T=r.useCallback(s=>s.includes((u==null?void 0:u.Role)||""),[u]),F=r.useCallback(()=>{L(null)},[]),Q=r.useCallback(()=>{R()},[R]),V=r.useMemo(()=>({user:u,staticBaseUrl:$,buildId:O,status:d,isAuthenticated:j,isLoading:g,login:B,logout:p,refreshSession:q,hasRole:I,hasAnyRole:T,error:S,clearError:F,_forceCheck:Q}),[u,$,O,d,j,g,B,p,q,I,T,S,F,Q]);return d==="loading"&&i?A.jsx(A.Fragment,{children:i}):d==="unauthenticated"&&!l.autoRedirect&&c?A.jsx(A.Fragment,{children:c}):A.jsx(G.Provider,{value:V,children:e})}function re(){const e=r.useContext(G);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function ne(){const e=re();return r.useMemo(()=>({user:e.user,staticBaseUrl:e.staticBaseUrl,buildId:e.buildId,status:e.status,isAuthenticated:e.isAuthenticated,isLoading:e.isLoading,login:e.login,logout:e.logout,refreshSession:e.refreshSession,hasRole:e.hasRole,hasAnyRole:e.hasAnyRole,error:e.error,clearError:e.clearError}),[e.user,e.staticBaseUrl,e.buildId,e.status,e.isAuthenticated,e.isLoading,e.login,e.logout,e.refreshSession,e.hasRole,e.hasAnyRole,e.error,e.clearError])}exports.AuthProvider=te;exports.AuthenticationError=m;exports.configureAuth=N;exports.getAuthBaseUrl=k;exports.getAuthConfig=b;exports.resetAuthConfig=Z;exports.setAuthProvider=X;exports.useAuth=ne;
package/dist/auth.mjs CHANGED
@@ -2,9 +2,9 @@ var X = Object.defineProperty;
2
2
  var Z = (e, t, r) => t in e ? X(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var _ = (e, t, r) => Z(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { jsx as C, Fragment as N } from "react/jsx-runtime";
5
- import { useRef as L, useState as D, useMemo as $, useEffect as p, useCallback as g, createContext as ee, useContext as te } from "react";
5
+ import { useRef as L, useState as D, useMemo as p, useEffect as k, useCallback as g, createContext as ee, useContext as te } from "react";
6
6
  import { useQueryClient as re, useQuery as ne } from "@tanstack/react-query";
7
- import { c as oe, g as H } from "./client-V-WzUb8H.js";
7
+ import { c as oe, g as H } from "./client-BIkaIr2y.js";
8
8
  const M = {
9
9
  sessionEndpoint: "/api/id",
10
10
  providers: {
@@ -54,21 +54,21 @@ function V(e) {
54
54
  function we() {
55
55
  d = { ...M };
56
56
  }
57
- class k extends Error {
57
+ class $ extends Error {
58
58
  constructor(r, n) {
59
59
  super(r);
60
60
  _(this, "statusCode");
61
61
  this.name = "AuthenticationError", this.statusCode = n;
62
62
  }
63
63
  }
64
- async function ae() {
64
+ async function se() {
65
65
  const e = E(), t = x(), r = H(), n = await fetch(`${t}${e.sessionEndpoint}`, {
66
66
  method: "GET",
67
67
  headers: r,
68
68
  credentials: "include"
69
69
  });
70
70
  if (!n.ok)
71
- throw n.status === 401 || n.status === 403 ? new k("Not authenticated", n.status) : new k(
71
+ throw n.status === 401 || n.status === 403 ? new $("Not authenticated", n.status) : new $(
72
72
  `Session check failed: ${n.statusText}`,
73
73
  n.status
74
74
  );
@@ -81,16 +81,16 @@ function Y(e, t) {
81
81
  throw new Error(
82
82
  'Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.'
83
83
  );
84
- const a = e || r.defaultProvider, c = V(a);
84
+ const s = e || r.defaultProvider, c = V(s);
85
85
  if (!c) {
86
86
  const w = Object.keys(r.providers || {}).join(", ") || "none";
87
87
  throw new Error(
88
- `Auth provider "${a}" is not configured. Available providers: ${w}`
88
+ `Auth provider "${s}" is not configured. Available providers: ${w}`
89
89
  );
90
90
  }
91
91
  if (!c.loginPath)
92
92
  throw new Error(
93
- `Login path not configured for provider "${a}". Configure it with: configureAuth({ providers: { ${a}: { loginPath: '/api/auth/...' } } })`
93
+ `Login path not configured for provider "${s}". Configure it with: configureAuth({ providers: { ${s}: { loginPath: '/api/auth/...' } } })`
94
94
  );
95
95
  let h;
96
96
  try {
@@ -108,8 +108,8 @@ function Y(e, t) {
108
108
  }), window.location.href = h.toString();
109
109
  });
110
110
  }
111
- async function se(e) {
112
- const t = E(), r = x(), n = H(), a = V(t.defaultProvider), c = a == null ? void 0 : a.logoutPath;
111
+ async function ae(e) {
112
+ const t = E(), r = x(), n = H(), s = V(t.defaultProvider), c = s == null ? void 0 : s.logoutPath;
113
113
  if (c && (e == null ? void 0 : e.callLogoutEndpoint) !== !1)
114
114
  try {
115
115
  await fetch(`${r}${c}`, {
@@ -128,7 +128,7 @@ function ye({
128
128
  config: t,
129
129
  onAuthChange: r,
130
130
  onError: n,
131
- loadingComponent: a,
131
+ loadingComponent: s,
132
132
  unauthenticatedComponent: c,
133
133
  skipInitialCheck: h = !1
134
134
  }) {
@@ -142,25 +142,25 @@ function ye({
142
142
  isFetching: m
143
143
  } = ne({
144
144
  queryKey: G,
145
- queryFn: ae,
145
+ queryFn: se,
146
146
  enabled: !h,
147
- retry: (o, y) => y instanceof k && (y.statusCode === 401 || y.statusCode === 403) ? !1 : o < u.retry.count,
147
+ retry: (o, y) => y instanceof $ && (y.statusCode === 401 || y.statusCode === 403) ? !1 : o < u.retry.count,
148
148
  retryDelay: u.retry.delay,
149
149
  staleTime: u.staleTime,
150
150
  gcTime: u.staleTime * 2,
151
151
  refetchOnWindowFocus: u.refetchOnWindowFocus ?? !0,
152
152
  refetchOnReconnect: u.refetchOnReconnect ?? !0,
153
153
  refetchInterval: u.sessionCheckInterval || !1
154
- }), [S, P] = D(null), l = $(() => f || m ? "loading" : i != null && i.userDetails ? "authenticated" : "unauthenticated", [f, m, i]), s = (i == null ? void 0 : i.userDetails) || null, B = (i == null ? void 0 : i.staticBaseUrl) || null, I = (i == null ? void 0 : i.buildId) || null, O = l === "authenticated", b = L(r);
154
+ }), [S, P] = D(null), l = p(() => f || m ? "loading" : Object.keys((i == null ? void 0 : i.userDetails) || {}).length > 0 ? "authenticated" : "unauthenticated", [f, m, i]), a = (i == null ? void 0 : i.userDetails) || null, O = (i == null ? void 0 : i.staticBaseUrl) || null, B = (i == null ? void 0 : i.buildId) || null, I = l === "authenticated", b = L(r);
155
155
  b.current = r;
156
156
  const R = L(n);
157
- R.current = n, p(() => {
157
+ R.current = n, k(() => {
158
158
  var o;
159
- f || (o = b.current) == null || o.call(b, l, s);
160
- }, [l, s, f]), p(() => {
159
+ f || (o = b.current) == null || o.call(b, l, a);
160
+ }, [l, a, f]), k(() => {
161
161
  var o;
162
162
  v && (P(v), (o = R.current) == null || o.call(R, v));
163
- }, [v]), p(() => {
163
+ }, [v]), k(() => {
164
164
  l === "unauthenticated" && u.autoRedirect && !f && Y();
165
165
  }, [l, f, u.autoRedirect]);
166
166
  const T = g(
@@ -170,7 +170,7 @@ function ye({
170
170
  []
171
171
  ), F = g(
172
172
  async (o) => {
173
- U.removeQueries({ queryKey: G }), await se(o);
173
+ U.removeQueries({ queryKey: G }), await ae(o);
174
174
  },
175
175
  [U]
176
176
  ), j = g(async () => {
@@ -182,22 +182,22 @@ function ye({
182
182
  return P(o), null;
183
183
  }
184
184
  }, [A, m, i]), q = g(
185
- (o) => (s == null ? void 0 : s.Role) === o,
186
- [s]
185
+ (o) => (a == null ? void 0 : a.Role) === o,
186
+ [a]
187
187
  ), Q = g(
188
- (o) => o.includes((s == null ? void 0 : s.Role) || ""),
189
- [s]
188
+ (o) => o.includes((a == null ? void 0 : a.Role) || ""),
189
+ [a]
190
190
  ), K = g(() => {
191
191
  P(null);
192
192
  }, []), W = g(() => {
193
193
  A();
194
- }, [A]), J = $(
194
+ }, [A]), J = p(
195
195
  () => ({
196
- user: s,
197
- staticBaseUrl: B,
198
- buildId: I,
196
+ user: a,
197
+ staticBaseUrl: O,
198
+ buildId: B,
199
199
  status: l,
200
- isAuthenticated: O,
200
+ isAuthenticated: I,
201
201
  isLoading: f,
202
202
  login: T,
203
203
  logout: F,
@@ -209,11 +209,11 @@ function ye({
209
209
  _forceCheck: W
210
210
  }),
211
211
  [
212
- s,
212
+ a,
213
+ O,
213
214
  B,
214
- I,
215
215
  l,
216
- O,
216
+ I,
217
217
  f,
218
218
  T,
219
219
  F,
@@ -225,7 +225,7 @@ function ye({
225
225
  W
226
226
  ]
227
227
  );
228
- return l === "loading" && a ? /* @__PURE__ */ C(N, { children: a }) : l === "unauthenticated" && !u.autoRedirect && c ? /* @__PURE__ */ C(N, { children: c }) : /* @__PURE__ */ C(z.Provider, { value: J, children: e });
228
+ return l === "loading" && s ? /* @__PURE__ */ C(N, { children: s }) : l === "unauthenticated" && !u.autoRedirect && c ? /* @__PURE__ */ C(N, { children: c }) : /* @__PURE__ */ C(z.Provider, { value: J, children: e });
229
229
  }
230
230
  function ce() {
231
231
  const e = te(z);
@@ -235,7 +235,7 @@ function ce() {
235
235
  }
236
236
  function Ue() {
237
237
  const e = ce();
238
- return $(
238
+ return p(
239
239
  () => ({
240
240
  user: e.user,
241
241
  staticBaseUrl: e.staticBaseUrl,
@@ -270,7 +270,7 @@ function Ue() {
270
270
  }
271
271
  export {
272
272
  ye as AuthProvider,
273
- k as AuthenticationError,
273
+ $ as AuthenticationError,
274
274
  ie as configureAuth,
275
275
  x as getAuthBaseUrl,
276
276
  E as getAuthConfig,
@@ -1,2 +1,2 @@
1
- export type { IdFieldType, StringFieldType, TextAreaFieldType, NumberFieldType, LongFieldType, BooleanFieldType, DateFieldType, DateTimeFieldType, CurrencyFieldType, CurrencyValueType, JSONFieldType, ReferenceFieldType, JSONValueType, JSONObjectType, JSONArrayType, SelectFieldType, LookupFieldType, ArrayFieldType, ObjectFieldType, OptionalFieldType, ExtractFieldTypeType, } from './types/base-fields';
1
+ export type { IdFieldType, StringFieldType, TextAreaFieldType, NumberFieldType, LongFieldType, BooleanFieldType, DateFieldType, DateTimeFieldType, CurrencyFieldType, CurrencyValueType, JSONFieldType, ReferenceFieldType, ExtractReferenceType, ExtractFetchFieldType, JSONValueType, JSONObjectType, JSONArrayType, SelectFieldType, LookupFieldType, ArrayFieldType, ObjectFieldType, OptionalFieldType, ExtractFieldTypeType, } from './types/base-fields';
2
2
  //# sourceMappingURL=base-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-types.d.ts","sourceRoot":"","sources":["../sdk/base-types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,WAAW,EACX,eAAe,EACf,iBAAiB,EAGjB,eAAe,EACf,aAAa,EAGb,gBAAgB,EAGhB,aAAa,EACb,iBAAiB,EAGjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAGlB,aAAa,EACb,cAAc,EACd,aAAa,EAGb,eAAe,EACf,eAAe,EAGf,cAAc,EACd,eAAe,EACf,iBAAiB,EAGjB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"base-types.d.ts","sourceRoot":"","sources":["../sdk/base-types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,WAAW,EACX,eAAe,EACf,iBAAiB,EAGjB,eAAe,EACf,aAAa,EAGb,gBAAgB,EAGhB,aAAa,EACb,iBAAiB,EAGjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EAGrB,aAAa,EACb,cAAc,EACd,aAAa,EAGb,eAAe,EACf,eAAe,EAGf,cAAc,EACd,eAAe,EACf,iBAAiB,EAGjB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC"}