@oondemand/oon-core-front 0.5.2 → 0.5.4
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 +8 -1
- package/dist/index.js +39 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
|
@@ -2513,6 +2532,12 @@ function initialReactiveValues(fields, initialValues) {
|
|
|
2513
2532
|
const initial = Object.fromEntries(fields.map((field) => [field.field, initialFieldValue(field, initialValues?.[field.field])]));
|
|
2514
2533
|
return applyReactiveFormulas(fields, initial);
|
|
2515
2534
|
}
|
|
2535
|
+
function remoteOptionValues(values, initialValues) {
|
|
2536
|
+
const inherited = Object.fromEntries(
|
|
2537
|
+
Object.entries(initialValues ?? {}).map(([field, value3]) => [field, toValue(value3)])
|
|
2538
|
+
);
|
|
2539
|
+
return { ...inherited, ...values };
|
|
2540
|
+
}
|
|
2516
2541
|
function validate(fields, values) {
|
|
2517
2542
|
const errors = {};
|
|
2518
2543
|
fields.forEach((field) => {
|
|
@@ -2626,6 +2651,10 @@ function DynamicForm({ title, eyebrow = "Cadastro", fields: rawFields, initialVa
|
|
|
2626
2651
|
() => new Set(remoteFieldKey ? remoteFieldKey.split("|") : [])
|
|
2627
2652
|
);
|
|
2628
2653
|
const items = useMemo6(() => buildItems(fields), [rawFields]);
|
|
2654
|
+
const optionValues = useMemo6(
|
|
2655
|
+
() => remoteOptionValues(values, initialValues),
|
|
2656
|
+
[values, initialValues]
|
|
2657
|
+
);
|
|
2629
2658
|
useEffect9(() => {
|
|
2630
2659
|
setPendingRemoteFields(new Set(remoteFieldKey ? remoteFieldKey.split("|") : []));
|
|
2631
2660
|
}, [remoteFieldKey]);
|
|
@@ -2733,7 +2762,7 @@ function DynamicForm({ title, eyebrow = "Cadastro", fields: rawFields, initialVa
|
|
|
2733
2762
|
inputId: id,
|
|
2734
2763
|
errorId,
|
|
2735
2764
|
value: values[field.field] ?? "",
|
|
2736
|
-
values,
|
|
2765
|
+
values: optionValues,
|
|
2737
2766
|
parent: contextValues,
|
|
2738
2767
|
invalid: !!message,
|
|
2739
2768
|
readonly,
|
|
@@ -6730,7 +6759,7 @@ function Sidebar({ app, menu, registry }) {
|
|
|
6730
6759
|
// package.json
|
|
6731
6760
|
var package_default = {
|
|
6732
6761
|
name: "@oondemand/oon-core-front",
|
|
6733
|
-
version: "0.5.
|
|
6762
|
+
version: "0.5.4",
|
|
6734
6763
|
repository: {
|
|
6735
6764
|
type: "git",
|
|
6736
6765
|
url: "git+https://github.com/oondemand/oon-platform.git",
|
|
@@ -7874,7 +7903,9 @@ function localLoginUrl() {
|
|
|
7874
7903
|
function OonApp({ config }) {
|
|
7875
7904
|
const { http, storage, tenantStorage, router } = useMemo13(() => {
|
|
7876
7905
|
const storage2 = createTokenStorage(config.app.id);
|
|
7877
|
-
const tenantStorage2 = createTenantStorage(config.app.id
|
|
7906
|
+
const tenantStorage2 = createTenantStorage(config.app.id, {
|
|
7907
|
+
enabled: config.app.tenancyModel !== "none"
|
|
7908
|
+
});
|
|
7878
7909
|
const externalLoginUrl = config.auth?.loginUrl ?? config.api.meusAppsUrl;
|
|
7879
7910
|
const http2 = createRestClient({
|
|
7880
7911
|
api: config.api,
|
|
@@ -10062,7 +10093,8 @@ function startCentralFromManifest(manifest, runtime) {
|
|
|
10062
10093
|
id: manifest.app.id,
|
|
10063
10094
|
name: manifest.app.name,
|
|
10064
10095
|
title: manifest.app.name,
|
|
10065
|
-
kind: manifest.app.appKind
|
|
10096
|
+
kind: manifest.app.appKind,
|
|
10097
|
+
tenancyModel: manifest.app.tenancyModel
|
|
10066
10098
|
};
|
|
10067
10099
|
const app = config.app;
|
|
10068
10100
|
app.schemaVersion = manifest.app.schemaVersion;
|