@oondemand/oon-core-front 0.5.3 → 0.5.5

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
@@ -116,6 +116,7 @@ interface OonUser {
116
116
  [extra: string]: unknown;
117
117
  }
118
118
  type OonAppKind = "root-central" | "member-central" | "portal-cockpit";
119
+ type OonTenancyModel = "none" | "single_tenant" | "multi_tenant";
119
120
  interface OonAppConfig {
120
121
  id: string;
121
122
  name: string;
@@ -130,6 +131,8 @@ interface OonAppConfig {
130
131
  * - portal-cockpit: Portal/Cockpit como Meus Apps.
131
132
  */
132
133
  kind?: OonAppKind;
134
+ /** Define se o runtime pode selecionar e persistir tenant para este App. */
135
+ tenancyModel?: OonTenancyModel;
133
136
  capabilities?: string[];
134
137
  capabilitySettings?: Record<string, unknown>;
135
138
  }
@@ -888,6 +891,7 @@ interface CentralAppManifest {
888
891
  name: string;
889
892
  slug: string;
890
893
  appKind: OonAppKind;
894
+ tenancyModel?: OonTenancyModel;
891
895
  modules: Record<string, boolean>;
892
896
  capabilities: string[];
893
897
  capabilitySettings?: Record<string, unknown>;
@@ -1173,13 +1177,16 @@ interface TenantStorage {
1173
1177
  set(tenantId: string): void;
1174
1178
  clear(): void;
1175
1179
  }
1180
+ interface TenantStorageOptions {
1181
+ enabled?: boolean;
1182
+ }
1176
1183
  /**
1177
1184
  * Mantém o tenant no escopo da aba. Isso permite abrir Tenant A e Tenant B em
1178
1185
  * janelas diferentes sem uma aba trocar o contexto da outra. O query param
1179
1186
  * `tenant` transporta somente o identificador selecionado; o backend continua
1180
1187
  * validando o membership em todas as requisições.
1181
1188
  */
1182
- declare function createTenantStorage(appId: string): TenantStorage;
1189
+ declare function createTenantStorage(appId: string, options?: TenantStorageOptions): TenantStorage;
1183
1190
 
1184
1191
  interface OonTenantContextValue {
1185
1192
  activeTenantId: string | null;
package/dist/index.js CHANGED
@@ -185,8 +185,26 @@ function tenantFromUrl(key) {
185
185
  window.history.replaceState(window.history.state, "", `${url.pathname}${url.search}${url.hash}`);
186
186
  return tenantId;
187
187
  }
188
- function createTenantStorage(appId) {
188
+ function createTenantStorage(appId, options = {}) {
189
189
  const key = `oon:${appId}:tenant`;
190
+ const enabled = options.enabled !== false;
191
+ const clearStoredTenant = () => {
192
+ if (typeof window === "undefined") return;
193
+ window.sessionStorage.removeItem(key);
194
+ window.localStorage.removeItem(key);
195
+ };
196
+ if (!enabled) {
197
+ return {
198
+ get() {
199
+ clearStoredTenant();
200
+ return null;
201
+ },
202
+ set() {
203
+ clearStoredTenant();
204
+ },
205
+ clear: clearStoredTenant
206
+ };
207
+ }
190
208
  return {
191
209
  get() {
192
210
  if (typeof window === "undefined") return null;
@@ -1089,7 +1107,7 @@ function OonProviders({
1089
1107
  const queryClient = useMemo3(() => createOonQueryClient(), []);
1090
1108
  const system = useMemo3(() => createOonSystem(config.theme), [config.theme]);
1091
1109
  const loginUrl = config.auth?.loginUrl ?? config.api.meusAppsUrl;
1092
- return /* @__PURE__ */ jsx9(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx9(ChakraProvider, { value: system, children: /* @__PURE__ */ jsx9(ApiProvider, { http, children: /* @__PURE__ */ jsx9(ActivationProvider, { http, children: /* @__PURE__ */ jsx9(TenantProvider, { http, storage: tenantStorage, children: /* @__PURE__ */ jsx9(
1110
+ const authenticatedContent = /* @__PURE__ */ jsx9(
1093
1111
  AuthProvider,
1094
1112
  {
1095
1113
  http,
@@ -1099,7 +1117,8 @@ function OonProviders({
1099
1117
  runtimeMode: config.runtimeMode,
1100
1118
  children: config.runtimeMode === "local" ? /* @__PURE__ */ jsx9(LocalRuntimeBanner, { http, children }) : children
1101
1119
  }
1102
- ) }) }) }) }) });
1120
+ );
1121
+ return /* @__PURE__ */ jsx9(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx9(ChakraProvider, { value: system, children: /* @__PURE__ */ jsx9(ApiProvider, { http, children: /* @__PURE__ */ jsx9(ActivationProvider, { http, children: config.app.tenancyModel === "none" ? authenticatedContent : /* @__PURE__ */ jsx9(TenantProvider, { http, storage: tenantStorage, children: authenticatedContent }) }) }) }) });
1103
1122
  }
1104
1123
 
1105
1124
  // src/components/CoreCollection.tsx
@@ -6740,7 +6759,7 @@ function Sidebar({ app, menu, registry }) {
6740
6759
  // package.json
6741
6760
  var package_default = {
6742
6761
  name: "@oondemand/oon-core-front",
6743
- version: "0.5.3",
6762
+ version: "0.5.5",
6744
6763
  repository: {
6745
6764
  type: "git",
6746
6765
  url: "git+https://github.com/oondemand/oon-platform.git",
@@ -7884,7 +7903,9 @@ function localLoginUrl() {
7884
7903
  function OonApp({ config }) {
7885
7904
  const { http, storage, tenantStorage, router } = useMemo13(() => {
7886
7905
  const storage2 = createTokenStorage(config.app.id);
7887
- const tenantStorage2 = createTenantStorage(config.app.id);
7906
+ const tenantStorage2 = createTenantStorage(config.app.id, {
7907
+ enabled: config.app.tenancyModel !== "none"
7908
+ });
7888
7909
  const externalLoginUrl = config.auth?.loginUrl ?? config.api.meusAppsUrl;
7889
7910
  const http2 = createRestClient({
7890
7911
  api: config.api,
@@ -10072,7 +10093,8 @@ function startCentralFromManifest(manifest, runtime) {
10072
10093
  id: manifest.app.id,
10073
10094
  name: manifest.app.name,
10074
10095
  title: manifest.app.name,
10075
- kind: manifest.app.appKind
10096
+ kind: manifest.app.appKind,
10097
+ tenancyModel: manifest.app.tenancyModel
10076
10098
  };
10077
10099
  const app = config.app;
10078
10100
  app.schemaVersion = manifest.app.schemaVersion;