@nubitio/core 1.3.1 → 2.0.0
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 +29 -51
- package/dist/index.d.cts +61 -113
- package/dist/index.d.mts +61 -113
- package/dist/index.mjs +27 -48
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -20,14 +20,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
23
|
let react = require("react");
|
|
25
|
-
react = __toESM(react, 1);
|
|
26
24
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
-
let react_i18next = require("react-i18next");
|
|
28
25
|
let i18next = require("i18next");
|
|
26
|
+
let react_i18next = require("react-i18next");
|
|
27
|
+
react = __toESM(react, 1);
|
|
29
28
|
i18next = __toESM(i18next, 1);
|
|
30
|
-
|
|
29
|
+
// packages/core/config/CoreConfig.tsx
|
|
31
30
|
const _coreConfig = {
|
|
32
31
|
locale: "en",
|
|
33
32
|
timezone: "UTC",
|
|
@@ -105,8 +104,7 @@ const CoreConfigProvider = ({ locale, timezone, apiBaseUrl, currency, mercureTop
|
|
|
105
104
|
function useCoreConfig() {
|
|
106
105
|
return react.default.useContext(CoreConfigContext);
|
|
107
106
|
}
|
|
108
|
-
|
|
109
|
-
//#region packages/core/date/DateUtils.ts
|
|
107
|
+
// packages/core/date/DateUtils.ts
|
|
110
108
|
/**
|
|
111
109
|
* Recommended default for new projects using @nubitio/core.
|
|
112
110
|
* You should almost always override this via CoreConfigProvider.
|
|
@@ -180,8 +178,7 @@ var DateUtils = class {
|
|
|
180
178
|
return months <= 0 ? 0 : months;
|
|
181
179
|
}
|
|
182
180
|
};
|
|
183
|
-
|
|
184
|
-
//#region packages/core/money/Money.ts
|
|
181
|
+
// packages/core/money/Money.ts
|
|
185
182
|
const DECIMAL_PATTERN = /^[+-]?\d+(\.\d+)?$/;
|
|
186
183
|
/**
|
|
187
184
|
* Reads a value coming off the wire.
|
|
@@ -323,8 +320,7 @@ function decimalsOf(decimal) {
|
|
|
323
320
|
const index = decimal.indexOf(".");
|
|
324
321
|
return index === -1 ? 0 : decimal.length - index - 1;
|
|
325
322
|
}
|
|
326
|
-
|
|
327
|
-
//#region packages/core/event/EventHook.ts
|
|
323
|
+
// packages/core/event/EventHook.ts
|
|
328
324
|
const listeners = /* @__PURE__ */ new Map();
|
|
329
325
|
function subscribe(name, handler) {
|
|
330
326
|
if (!listeners.has(name)) listeners.set(name, /* @__PURE__ */ new Set());
|
|
@@ -370,8 +366,7 @@ const dispatch = (name, payload) => {
|
|
|
370
366
|
} catch {}
|
|
371
367
|
});
|
|
372
368
|
};
|
|
373
|
-
|
|
374
|
-
//#region packages/core/event/createCrudEvents.ts
|
|
369
|
+
// packages/core/event/createCrudEvents.ts
|
|
375
370
|
/**
|
|
376
371
|
* Generic factory that builds a typed set of CRUD event name strings for a
|
|
377
372
|
* given `prefix`. The returned object is `const`-asserted so every value is
|
|
@@ -395,8 +390,7 @@ const createCrudEvents = (prefix) => ({
|
|
|
395
390
|
SUCCESS: `${prefix}:success`,
|
|
396
391
|
LOADING: `${prefix}:loading`
|
|
397
392
|
});
|
|
398
|
-
|
|
399
|
-
//#region packages/core/event/createScopedEventBus.ts
|
|
393
|
+
// packages/core/event/createScopedEventBus.ts
|
|
400
394
|
/**
|
|
401
395
|
* Creates a scoped event bus for the given resource.
|
|
402
396
|
*
|
|
@@ -417,8 +411,7 @@ function createScopedEventBus(resourceId) {
|
|
|
417
411
|
_scopeId: scopeId
|
|
418
412
|
};
|
|
419
413
|
}
|
|
420
|
-
|
|
421
|
-
//#region packages/core/i18n/coreTranslations.ts
|
|
414
|
+
// packages/core/i18n/coreTranslations.ts
|
|
422
415
|
const coreTranslationsEs = {
|
|
423
416
|
"crudPage.selectedCount": "{{count}} seleccionados",
|
|
424
417
|
"crudPage.auditTrailButton": "Historial",
|
|
@@ -537,6 +530,7 @@ const coreTranslationsEs = {
|
|
|
537
530
|
"grid.clearFilters": "Limpiar filtros",
|
|
538
531
|
"grid.done": "Listo",
|
|
539
532
|
"grid.searchPlaceholder": "Buscar por {{column}}",
|
|
533
|
+
"grid.quickSearch": "Buscar registros",
|
|
540
534
|
"grid.showMore": "Ver más",
|
|
541
535
|
"grid.presentation": "Presentación",
|
|
542
536
|
"grid.tableView": "Tabla",
|
|
@@ -719,6 +713,7 @@ const coreTranslationsEn = {
|
|
|
719
713
|
"grid.clearFilters": "Clear filters",
|
|
720
714
|
"grid.done": "Done",
|
|
721
715
|
"grid.searchPlaceholder": "Search by {{column}}",
|
|
716
|
+
"grid.quickSearch": "Search records",
|
|
722
717
|
"grid.showMore": "Show more",
|
|
723
718
|
"grid.presentation": "Presentation",
|
|
724
719
|
"grid.tableView": "Table",
|
|
@@ -783,20 +778,17 @@ const coreTranslationsEn = {
|
|
|
783
778
|
"form.fileUploadEmpty": "No file",
|
|
784
779
|
"crudPage.confirmActionTitle": "Confirm action"
|
|
785
780
|
};
|
|
786
|
-
|
|
787
|
-
//#region packages/core/i18n/useCoreTranslation.ts
|
|
781
|
+
// packages/core/i18n/useCoreTranslation.ts
|
|
788
782
|
function useCoreTranslation() {
|
|
789
783
|
const { t } = (0, react_i18next.useTranslation)("core");
|
|
790
|
-
return { t: (key, options) => t(key, options) };
|
|
784
|
+
return { t: (key, options) => t(key, options ?? {}) };
|
|
791
785
|
}
|
|
792
|
-
|
|
793
|
-
//#region packages/core/i18n/initCoreI18n.ts
|
|
786
|
+
// packages/core/i18n/initCoreI18n.ts
|
|
794
787
|
function initCoreI18n() {
|
|
795
788
|
i18next.default.addResourceBundle("es", "core", coreTranslationsEs, true, false);
|
|
796
789
|
i18next.default.addResourceBundle("en", "core", coreTranslationsEn, true, false);
|
|
797
790
|
}
|
|
798
|
-
|
|
799
|
-
//#region packages/core/mercure/MercureManager.ts
|
|
791
|
+
// packages/core/mercure/MercureManager.ts
|
|
800
792
|
var MercureManager = class {
|
|
801
793
|
hubUrl = null;
|
|
802
794
|
topics = /* @__PURE__ */ new Map();
|
|
@@ -913,8 +905,7 @@ var MercureManager = class {
|
|
|
913
905
|
};
|
|
914
906
|
/** Singleton instance — shared across the entire application. */
|
|
915
907
|
const mercureManager = new MercureManager();
|
|
916
|
-
|
|
917
|
-
//#region packages/core/mercure/mercureDiscovery.ts
|
|
908
|
+
// packages/core/mercure/mercureDiscovery.ts
|
|
918
909
|
let discoveredTopicOrigin;
|
|
919
910
|
const topicOriginListeners = /* @__PURE__ */ new Set();
|
|
920
911
|
/**
|
|
@@ -1019,8 +1010,7 @@ function discoverMercureFromResponse(response, data) {
|
|
|
1019
1010
|
const topicOrigin = extractTopicOriginFromPayload(data);
|
|
1020
1011
|
if (topicOrigin) setDiscoveredTopicOrigin(topicOrigin);
|
|
1021
1012
|
}
|
|
1022
|
-
|
|
1023
|
-
//#region packages/core/http/correlationId.ts
|
|
1013
|
+
// packages/core/http/correlationId.ts
|
|
1024
1014
|
/**
|
|
1025
1015
|
* Generates a client-side correlation id for one logical HTTP request.
|
|
1026
1016
|
*
|
|
@@ -1040,8 +1030,7 @@ function generateCorrelationId() {
|
|
|
1040
1030
|
if (cryptoRef && typeof cryptoRef.randomUUID === "function") return cryptoRef.randomUUID();
|
|
1041
1031
|
return `req-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
1042
1032
|
}
|
|
1043
|
-
|
|
1044
|
-
//#region packages/core/http/CoreHttpClient.ts
|
|
1033
|
+
// packages/core/http/CoreHttpClient.ts
|
|
1045
1034
|
/** Default value of {@link CoreHttpClientConfig.csrfHeaderName}. */
|
|
1046
1035
|
const DEFAULT_CSRF_HEADER_NAME = "X-CSRF-Token";
|
|
1047
1036
|
/** Default value of {@link CoreHttpClientConfig.correlationIdHeaderName}. */
|
|
@@ -1254,8 +1243,7 @@ var CoreHttpClient = class {
|
|
|
1254
1243
|
function createCoreHttpClient(config) {
|
|
1255
1244
|
return new CoreHttpClient(config);
|
|
1256
1245
|
}
|
|
1257
|
-
|
|
1258
|
-
//#region packages/core/http/CoreHttpContext.tsx
|
|
1246
|
+
// packages/core/http/CoreHttpContext.tsx
|
|
1259
1247
|
const defaultHttpClient = createCoreHttpClient();
|
|
1260
1248
|
const CoreHttpContext = (0, react.createContext)(defaultHttpClient);
|
|
1261
1249
|
function CoreHttpProvider({ children, client, config }) {
|
|
@@ -1274,8 +1262,7 @@ function CoreHttpProvider({ children, client, config }) {
|
|
|
1274
1262
|
function useCoreHttpClient() {
|
|
1275
1263
|
return (0, react.useContext)(CoreHttpContext);
|
|
1276
1264
|
}
|
|
1277
|
-
|
|
1278
|
-
//#region packages/core/http/csrf.ts
|
|
1265
|
+
// packages/core/http/csrf.ts
|
|
1279
1266
|
/** Name of the cookie the Nubit backend sets for the double-submit CSRF policy. */
|
|
1280
1267
|
const CSRF_COOKIE_NAME = "CSRF_TOKEN";
|
|
1281
1268
|
/**
|
|
@@ -1301,8 +1288,7 @@ function readCsrfToken(cookieName = CSRF_COOKIE_NAME) {
|
|
|
1301
1288
|
}
|
|
1302
1289
|
}
|
|
1303
1290
|
}
|
|
1304
|
-
|
|
1305
|
-
//#region packages/core/runtime/CoreRuntimeContext.tsx
|
|
1291
|
+
// packages/core/runtime/CoreRuntimeContext.tsx
|
|
1306
1292
|
const defaultRuntime = {
|
|
1307
1293
|
notify: () => void 0,
|
|
1308
1294
|
confirm: (message) => {
|
|
@@ -1324,8 +1310,7 @@ function CoreRuntimeProvider({ children, runtime }) {
|
|
|
1324
1310
|
function useCoreRuntime() {
|
|
1325
1311
|
return (0, react.useContext)(CoreRuntimeContext);
|
|
1326
1312
|
}
|
|
1327
|
-
|
|
1328
|
-
//#region packages/core/provider/CoreProvider.tsx
|
|
1313
|
+
// packages/core/provider/CoreProvider.tsx
|
|
1329
1314
|
function CoreProvider({ children, http, httpClient, runtime }) {
|
|
1330
1315
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CoreHttpProvider, {
|
|
1331
1316
|
client: httpClient,
|
|
@@ -1336,8 +1321,7 @@ function CoreProvider({ children, http, httpClient, runtime }) {
|
|
|
1336
1321
|
})
|
|
1337
1322
|
});
|
|
1338
1323
|
}
|
|
1339
|
-
|
|
1340
|
-
//#region packages/core/featureFlags/FeatureFlags.tsx
|
|
1324
|
+
// packages/core/featureFlags/FeatureFlags.tsx
|
|
1341
1325
|
var StaticFeatureFlagClient = class {
|
|
1342
1326
|
flags;
|
|
1343
1327
|
context;
|
|
@@ -1390,8 +1374,7 @@ function useNumberFlag(key, defaultValue = 0) {
|
|
|
1390
1374
|
function useObjectFlag(key, defaultValue) {
|
|
1391
1375
|
return useFeatureFlags().getObjectValue(key, defaultValue);
|
|
1392
1376
|
}
|
|
1393
|
-
|
|
1394
|
-
//#region packages/core/mercure/MercureProvider.tsx
|
|
1377
|
+
// packages/core/mercure/MercureProvider.tsx
|
|
1395
1378
|
/**
|
|
1396
1379
|
* MercureProvider — React context provider for the Mercure hub URL.
|
|
1397
1380
|
*
|
|
@@ -1439,8 +1422,7 @@ function MercureProvider({ hubUrl: hubUrlOverride, children }) {
|
|
|
1439
1422
|
children
|
|
1440
1423
|
});
|
|
1441
1424
|
}
|
|
1442
|
-
|
|
1443
|
-
//#region packages/core/mercure/useMercureHub.ts
|
|
1425
|
+
// packages/core/mercure/useMercureHub.ts
|
|
1444
1426
|
/**
|
|
1445
1427
|
* useMercureHub — Hook that returns the Mercure hub URL from context.
|
|
1446
1428
|
*
|
|
@@ -1467,8 +1449,7 @@ function MercureProvider({ hubUrl: hubUrlOverride, children }) {
|
|
|
1467
1449
|
function useMercureHub() {
|
|
1468
1450
|
return (0, react.useContext)(MercureContext);
|
|
1469
1451
|
}
|
|
1470
|
-
|
|
1471
|
-
//#region packages/core/mercure/mercureTopics.ts
|
|
1452
|
+
// packages/core/mercure/mercureTopics.ts
|
|
1472
1453
|
/**
|
|
1473
1454
|
* Resolves the origin used to build Mercure collection topic URIs.
|
|
1474
1455
|
*
|
|
@@ -1504,8 +1485,7 @@ function buildMercureCollectionTopic(apiUrl, configuredOrigin, apiBaseUrl = getC
|
|
|
1504
1485
|
if (tenantId !== void 0 && tenantId !== null && `${tenantId}` !== "") return `${origin}/api/tenants/${tenantId}/${normalizedPath.replace(/^api\//, "")}/*`;
|
|
1505
1486
|
return `${origin}/${normalizedPath}/*`;
|
|
1506
1487
|
}
|
|
1507
|
-
|
|
1508
|
-
//#region packages/core/mercure/useDiscoveredMercureTopicOrigin.ts
|
|
1488
|
+
// packages/core/mercure/useDiscoveredMercureTopicOrigin.ts
|
|
1509
1489
|
/**
|
|
1510
1490
|
* Returns the Mercure topic origin autodiscovered from Hydra `@id` IRIs.
|
|
1511
1491
|
* Re-renders when a new origin is discovered from a subsequent API response.
|
|
@@ -1515,8 +1495,7 @@ function useDiscoveredMercureTopicOrigin() {
|
|
|
1515
1495
|
(0, react.useEffect)(() => onMercureTopicOriginChange(setOrigin), []);
|
|
1516
1496
|
return origin;
|
|
1517
1497
|
}
|
|
1518
|
-
|
|
1519
|
-
//#region packages/core/mercure/useMercureSubscription.ts
|
|
1498
|
+
// packages/core/mercure/useMercureSubscription.ts
|
|
1520
1499
|
/**
|
|
1521
1500
|
* useMercureSubscription — Hook that subscribes to a Mercure topic and calls
|
|
1522
1501
|
* a callback whenever an SSE message is received for that topic.
|
|
@@ -1569,7 +1548,6 @@ function useMercureSubscription(apiUrl, onUpdate, enabled = true) {
|
|
|
1569
1548
|
apiBaseUrl
|
|
1570
1549
|
]);
|
|
1571
1550
|
}
|
|
1572
|
-
//#endregion
|
|
1573
1551
|
exports.CSRF_COOKIE_NAME = CSRF_COOKIE_NAME;
|
|
1574
1552
|
exports.CoreConfigProvider = CoreConfigProvider;
|
|
1575
1553
|
exports.CoreHttpClient = CoreHttpClient;
|