@nubitio/core 0.5.20 → 0.5.23

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
@@ -33,7 +33,8 @@ const _coreConfig = {
33
33
  timezone: "UTC",
34
34
  apiBaseUrl: "/api/",
35
35
  currency: void 0,
36
- mercureTopicOrigin: void 0
36
+ mercureTopicOrigin: void 0,
37
+ mercureTenantId: void 0
37
38
  };
38
39
  /**
39
40
  * Configure core runtime values (locale, timezone, apiBaseUrl).
@@ -46,6 +47,7 @@ function configureCore(config) {
46
47
  if (config.apiBaseUrl !== void 0) _coreConfig.apiBaseUrl = config.apiBaseUrl;
47
48
  if ("currency" in config) _coreConfig.currency = config.currency;
48
49
  if ("mercureTopicOrigin" in config) _coreConfig.mercureTopicOrigin = config.mercureTopicOrigin;
50
+ if ("mercureTenantId" in config) _coreConfig.mercureTenantId = config.mercureTenantId;
49
51
  }
50
52
  /**
51
53
  * @deprecated Use configureCore() instead.
@@ -67,27 +69,33 @@ function getCoreCurrency() {
67
69
  function getMercureTopicOrigin() {
68
70
  return _coreConfig.mercureTopicOrigin;
69
71
  }
72
+ function getMercureTenantId() {
73
+ return _coreConfig.mercureTenantId;
74
+ }
70
75
  const CoreConfigContext = react.default.createContext(_coreConfig);
71
- const CoreConfigProvider = ({ locale, timezone, apiBaseUrl, currency, mercureTopicOrigin, children }) => {
76
+ const CoreConfigProvider = ({ locale, timezone, apiBaseUrl, currency, mercureTopicOrigin, mercureTenantId, children }) => {
72
77
  configureCore({
73
78
  locale,
74
79
  timezone,
75
80
  apiBaseUrl,
76
81
  currency,
77
- mercureTopicOrigin
82
+ mercureTopicOrigin,
83
+ mercureTenantId
78
84
  });
79
85
  const value = react.default.useMemo(() => ({
80
86
  locale,
81
87
  timezone,
82
88
  apiBaseUrl,
83
89
  currency,
84
- mercureTopicOrigin
90
+ mercureTopicOrigin,
91
+ mercureTenantId
85
92
  }), [
86
93
  locale,
87
94
  timezone,
88
95
  apiBaseUrl,
89
96
  currency,
90
- mercureTopicOrigin
97
+ mercureTopicOrigin,
98
+ mercureTenantId
91
99
  ]);
92
100
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CoreConfigContext.Provider, {
93
101
  value,
@@ -1058,6 +1066,8 @@ function buildMercureCollectionTopic(apiUrl, configuredOrigin, apiBaseUrl = getC
1058
1066
  if (!origin) return null;
1059
1067
  const normalizedPath = apiUrl.replace(/^\//, "").replace(/\/+$/, "");
1060
1068
  if (!normalizedPath) return null;
1069
+ const tenantId = getMercureTenantId();
1070
+ if (tenantId !== void 0 && tenantId !== null && `${tenantId}` !== "") return `${origin}/api/tenants/${tenantId}/${normalizedPath.replace(/^api\//, "")}/{id}`;
1061
1071
  return `${origin}/${normalizedPath}/{id}`;
1062
1072
  }
1063
1073
  //#endregion
package/dist/index.d.cts CHANGED
@@ -8,6 +8,8 @@ interface GridData<T> {
8
8
  data: T[];
9
9
  totalCount: number;
10
10
  summary: T[] | null;
11
+ /** Server-computed column aggregates (from X-Grid-Summary header). */
12
+ gridSummary?: Record<string, unknown> | null;
11
13
  }
12
14
  //#endregion
13
15
  //#region packages/core/date/DateUtils.d.ts
@@ -43,6 +45,8 @@ interface CoreConfig {
43
45
  * Hydra `@id` cannot infer the API origin (e.g. relative IRIs only).
44
46
  */
45
47
  mercureTopicOrigin?: string;
48
+ /** Tenant id prefix for Mercure collection topics (SaaS column isolation). */
49
+ mercureTenantId?: number | string;
46
50
  }
47
51
  /**
48
52
  * Configure core runtime values (locale, timezone, apiBaseUrl).
@@ -68,6 +72,7 @@ interface CoreConfigProviderProps {
68
72
  currency?: string;
69
73
  /** Mercure topic origin override — see {@link CoreConfig.mercureTopicOrigin}. */
70
74
  mercureTopicOrigin?: string;
75
+ mercureTenantId?: number | string;
71
76
  children: React.ReactNode;
72
77
  }
73
78
  declare const CoreConfigProvider: ({
@@ -76,6 +81,7 @@ declare const CoreConfigProvider: ({
76
81
  apiBaseUrl,
77
82
  currency,
78
83
  mercureTopicOrigin,
84
+ mercureTenantId,
79
85
  children
80
86
  }: CoreConfigProviderProps) => React.JSX.Element;
81
87
  declare function useCoreConfig(): CoreConfig;
package/dist/index.d.mts CHANGED
@@ -8,6 +8,8 @@ interface GridData<T> {
8
8
  data: T[];
9
9
  totalCount: number;
10
10
  summary: T[] | null;
11
+ /** Server-computed column aggregates (from X-Grid-Summary header). */
12
+ gridSummary?: Record<string, unknown> | null;
11
13
  }
12
14
  //#endregion
13
15
  //#region packages/core/date/DateUtils.d.ts
@@ -43,6 +45,8 @@ interface CoreConfig {
43
45
  * Hydra `@id` cannot infer the API origin (e.g. relative IRIs only).
44
46
  */
45
47
  mercureTopicOrigin?: string;
48
+ /** Tenant id prefix for Mercure collection topics (SaaS column isolation). */
49
+ mercureTenantId?: number | string;
46
50
  }
47
51
  /**
48
52
  * Configure core runtime values (locale, timezone, apiBaseUrl).
@@ -68,6 +72,7 @@ interface CoreConfigProviderProps {
68
72
  currency?: string;
69
73
  /** Mercure topic origin override — see {@link CoreConfig.mercureTopicOrigin}. */
70
74
  mercureTopicOrigin?: string;
75
+ mercureTenantId?: number | string;
71
76
  children: React.ReactNode;
72
77
  }
73
78
  declare const CoreConfigProvider: ({
@@ -76,6 +81,7 @@ declare const CoreConfigProvider: ({
76
81
  apiBaseUrl,
77
82
  currency,
78
83
  mercureTopicOrigin,
84
+ mercureTenantId,
79
85
  children
80
86
  }: CoreConfigProviderProps) => React.JSX.Element;
81
87
  declare function useCoreConfig(): CoreConfig;
package/dist/index.mjs CHANGED
@@ -8,7 +8,8 @@ const _coreConfig = {
8
8
  timezone: "UTC",
9
9
  apiBaseUrl: "/api/",
10
10
  currency: void 0,
11
- mercureTopicOrigin: void 0
11
+ mercureTopicOrigin: void 0,
12
+ mercureTenantId: void 0
12
13
  };
13
14
  /**
14
15
  * Configure core runtime values (locale, timezone, apiBaseUrl).
@@ -21,6 +22,7 @@ function configureCore(config) {
21
22
  if (config.apiBaseUrl !== void 0) _coreConfig.apiBaseUrl = config.apiBaseUrl;
22
23
  if ("currency" in config) _coreConfig.currency = config.currency;
23
24
  if ("mercureTopicOrigin" in config) _coreConfig.mercureTopicOrigin = config.mercureTopicOrigin;
25
+ if ("mercureTenantId" in config) _coreConfig.mercureTenantId = config.mercureTenantId;
24
26
  }
25
27
  /**
26
28
  * @deprecated Use configureCore() instead.
@@ -42,27 +44,33 @@ function getCoreCurrency() {
42
44
  function getMercureTopicOrigin() {
43
45
  return _coreConfig.mercureTopicOrigin;
44
46
  }
47
+ function getMercureTenantId() {
48
+ return _coreConfig.mercureTenantId;
49
+ }
45
50
  const CoreConfigContext = React.createContext(_coreConfig);
46
- const CoreConfigProvider = ({ locale, timezone, apiBaseUrl, currency, mercureTopicOrigin, children }) => {
51
+ const CoreConfigProvider = ({ locale, timezone, apiBaseUrl, currency, mercureTopicOrigin, mercureTenantId, children }) => {
47
52
  configureCore({
48
53
  locale,
49
54
  timezone,
50
55
  apiBaseUrl,
51
56
  currency,
52
- mercureTopicOrigin
57
+ mercureTopicOrigin,
58
+ mercureTenantId
53
59
  });
54
60
  const value = React.useMemo(() => ({
55
61
  locale,
56
62
  timezone,
57
63
  apiBaseUrl,
58
64
  currency,
59
- mercureTopicOrigin
65
+ mercureTopicOrigin,
66
+ mercureTenantId
60
67
  }), [
61
68
  locale,
62
69
  timezone,
63
70
  apiBaseUrl,
64
71
  currency,
65
- mercureTopicOrigin
72
+ mercureTopicOrigin,
73
+ mercureTenantId
66
74
  ]);
67
75
  return /* @__PURE__ */ jsx(CoreConfigContext.Provider, {
68
76
  value,
@@ -1033,6 +1041,8 @@ function buildMercureCollectionTopic(apiUrl, configuredOrigin, apiBaseUrl = getC
1033
1041
  if (!origin) return null;
1034
1042
  const normalizedPath = apiUrl.replace(/^\//, "").replace(/\/+$/, "");
1035
1043
  if (!normalizedPath) return null;
1044
+ const tenantId = getMercureTenantId();
1045
+ if (tenantId !== void 0 && tenantId !== null && `${tenantId}` !== "") return `${origin}/api/tenants/${tenantId}/${normalizedPath.replace(/^api\//, "")}/{id}`;
1036
1046
  return `${origin}/${normalizedPath}/{id}`;
1037
1047
  }
1038
1048
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubitio/core",
3
- "version": "0.5.20",
3
+ "version": "0.5.23",
4
4
  "type": "module",
5
5
  "description": "Runtime foundation for Nubit: HTTP client, event bus, i18n, Mercure SSE, CoreProvider, and date utilities.",
6
6
  "license": "MIT",