@nubitio/core 1.1.0 → 1.1.1
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 +6 -6
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +6 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -812,7 +812,7 @@ var MercureManager = class {
|
|
|
812
812
|
/**
|
|
813
813
|
* Subscribe to a Mercure topic.
|
|
814
814
|
*
|
|
815
|
-
* @param topic
|
|
815
|
+
* @param topic A WHATWG URL Pattern, e.g. `https://host/api/products/*`.
|
|
816
816
|
* @param callback Called with the parsed JSON payload on each SSE message.
|
|
817
817
|
*
|
|
818
818
|
* If `hubUrl` is null (hub not configured), this is a no-op (graceful degradation).
|
|
@@ -835,7 +835,7 @@ var MercureManager = class {
|
|
|
835
835
|
return;
|
|
836
836
|
}
|
|
837
837
|
const url = new URL(this.hubUrl);
|
|
838
|
-
url.searchParams.append("
|
|
838
|
+
url.searchParams.append("match_urlpattern", topic);
|
|
839
839
|
const eventSource = new EventSource(url.toString(), { withCredentials: true });
|
|
840
840
|
const listener = (e) => {
|
|
841
841
|
try {
|
|
@@ -1437,8 +1437,8 @@ function resolveMercureTopicOrigin(apiBaseUrl = getCoreApiBaseUrl(), configuredO
|
|
|
1437
1437
|
return "";
|
|
1438
1438
|
}
|
|
1439
1439
|
/**
|
|
1440
|
-
* Wildcard collection topic (
|
|
1441
|
-
* e.g. `/api/products` → `http://localhost:8000/api/products
|
|
1440
|
+
* Wildcard collection topic (WHATWG URL Pattern) for a resource API path.
|
|
1441
|
+
* e.g. `/api/products` → `http://localhost:8000/api/products/*`
|
|
1442
1442
|
*/
|
|
1443
1443
|
function buildMercureCollectionTopic(apiUrl, configuredOrigin, apiBaseUrl = getCoreApiBaseUrl()) {
|
|
1444
1444
|
if (!apiUrl) return null;
|
|
@@ -1447,8 +1447,8 @@ function buildMercureCollectionTopic(apiUrl, configuredOrigin, apiBaseUrl = getC
|
|
|
1447
1447
|
const normalizedPath = apiUrl.replace(/^\//, "").replace(/\/+$/, "");
|
|
1448
1448
|
if (!normalizedPath) return null;
|
|
1449
1449
|
const tenantId = getMercureTenantId();
|
|
1450
|
-
if (tenantId !== void 0 && tenantId !== null && `${tenantId}` !== "") return `${origin}/api/tenants/${tenantId}/${normalizedPath.replace(/^api\//, "")}
|
|
1451
|
-
return `${origin}/${normalizedPath}
|
|
1450
|
+
if (tenantId !== void 0 && tenantId !== null && `${tenantId}` !== "") return `${origin}/api/tenants/${tenantId}/${normalizedPath.replace(/^api\//, "")}/*`;
|
|
1451
|
+
return `${origin}/${normalizedPath}/*`;
|
|
1452
1452
|
}
|
|
1453
1453
|
//#endregion
|
|
1454
1454
|
//#region packages/core/mercure/useDiscoveredMercureTopicOrigin.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -825,8 +825,8 @@ declare function useMercureSubscription(apiUrl: string | undefined, onUpdate: ()
|
|
|
825
825
|
*/
|
|
826
826
|
declare function resolveMercureTopicOrigin(apiBaseUrl?: string, configuredOrigin?: string, discoveredOrigin?: string | undefined): string;
|
|
827
827
|
/**
|
|
828
|
-
* Wildcard collection topic (
|
|
829
|
-
* e.g. `/api/products` → `http://localhost:8000/api/products
|
|
828
|
+
* Wildcard collection topic (WHATWG URL Pattern) for a resource API path.
|
|
829
|
+
* e.g. `/api/products` → `http://localhost:8000/api/products/*`
|
|
830
830
|
*/
|
|
831
831
|
declare function buildMercureCollectionTopic(apiUrl: string, configuredOrigin?: string, apiBaseUrl?: string): string | null;
|
|
832
832
|
//#endregion
|
|
@@ -872,8 +872,9 @@ declare function useDiscoveredMercureTopicOrigin(): string | undefined;
|
|
|
872
872
|
* Inspired by the `manager.ts` pattern from `api-platform/admin`, adapted for this project:
|
|
873
873
|
* - Ref-counting per topic: multiple subscribers to the same topic share one EventSource.
|
|
874
874
|
* - Graceful degradation: if hubUrl is null, subscribe() is a no-op.
|
|
875
|
-
* - Topic format:
|
|
876
|
-
* The hub receives it as a query param: `?
|
|
875
|
+
* - Topic format: a WHATWG URL Pattern, e.g. `https://host/api/products/*`.
|
|
876
|
+
* The hub receives it as a query param: `?match_urlpattern=<encoded-pattern>`
|
|
877
|
+
* (Mercure.rocks v1+ — the old `?topic=` RFC 6570 URI Template scheme is gone).
|
|
877
878
|
*/
|
|
878
879
|
declare class MercureManager {
|
|
879
880
|
private hubUrl;
|
|
@@ -903,7 +904,7 @@ declare class MercureManager {
|
|
|
903
904
|
/**
|
|
904
905
|
* Subscribe to a Mercure topic.
|
|
905
906
|
*
|
|
906
|
-
* @param topic
|
|
907
|
+
* @param topic A WHATWG URL Pattern, e.g. `https://host/api/products/*`.
|
|
907
908
|
* @param callback Called with the parsed JSON payload on each SSE message.
|
|
908
909
|
*
|
|
909
910
|
* If `hubUrl` is null (hub not configured), this is a no-op (graceful degradation).
|
package/dist/index.d.mts
CHANGED
|
@@ -825,8 +825,8 @@ declare function useMercureSubscription(apiUrl: string | undefined, onUpdate: ()
|
|
|
825
825
|
*/
|
|
826
826
|
declare function resolveMercureTopicOrigin(apiBaseUrl?: string, configuredOrigin?: string, discoveredOrigin?: string | undefined): string;
|
|
827
827
|
/**
|
|
828
|
-
* Wildcard collection topic (
|
|
829
|
-
* e.g. `/api/products` → `http://localhost:8000/api/products
|
|
828
|
+
* Wildcard collection topic (WHATWG URL Pattern) for a resource API path.
|
|
829
|
+
* e.g. `/api/products` → `http://localhost:8000/api/products/*`
|
|
830
830
|
*/
|
|
831
831
|
declare function buildMercureCollectionTopic(apiUrl: string, configuredOrigin?: string, apiBaseUrl?: string): string | null;
|
|
832
832
|
//#endregion
|
|
@@ -872,8 +872,9 @@ declare function useDiscoveredMercureTopicOrigin(): string | undefined;
|
|
|
872
872
|
* Inspired by the `manager.ts` pattern from `api-platform/admin`, adapted for this project:
|
|
873
873
|
* - Ref-counting per topic: multiple subscribers to the same topic share one EventSource.
|
|
874
874
|
* - Graceful degradation: if hubUrl is null, subscribe() is a no-op.
|
|
875
|
-
* - Topic format:
|
|
876
|
-
* The hub receives it as a query param: `?
|
|
875
|
+
* - Topic format: a WHATWG URL Pattern, e.g. `https://host/api/products/*`.
|
|
876
|
+
* The hub receives it as a query param: `?match_urlpattern=<encoded-pattern>`
|
|
877
|
+
* (Mercure.rocks v1+ — the old `?topic=` RFC 6570 URI Template scheme is gone).
|
|
877
878
|
*/
|
|
878
879
|
declare class MercureManager {
|
|
879
880
|
private hubUrl;
|
|
@@ -903,7 +904,7 @@ declare class MercureManager {
|
|
|
903
904
|
/**
|
|
904
905
|
* Subscribe to a Mercure topic.
|
|
905
906
|
*
|
|
906
|
-
* @param topic
|
|
907
|
+
* @param topic A WHATWG URL Pattern, e.g. `https://host/api/products/*`.
|
|
907
908
|
* @param callback Called with the parsed JSON payload on each SSE message.
|
|
908
909
|
*
|
|
909
910
|
* If `hubUrl` is null (hub not configured), this is a no-op (graceful degradation).
|
package/dist/index.mjs
CHANGED
|
@@ -787,7 +787,7 @@ var MercureManager = class {
|
|
|
787
787
|
/**
|
|
788
788
|
* Subscribe to a Mercure topic.
|
|
789
789
|
*
|
|
790
|
-
* @param topic
|
|
790
|
+
* @param topic A WHATWG URL Pattern, e.g. `https://host/api/products/*`.
|
|
791
791
|
* @param callback Called with the parsed JSON payload on each SSE message.
|
|
792
792
|
*
|
|
793
793
|
* If `hubUrl` is null (hub not configured), this is a no-op (graceful degradation).
|
|
@@ -810,7 +810,7 @@ var MercureManager = class {
|
|
|
810
810
|
return;
|
|
811
811
|
}
|
|
812
812
|
const url = new URL(this.hubUrl);
|
|
813
|
-
url.searchParams.append("
|
|
813
|
+
url.searchParams.append("match_urlpattern", topic);
|
|
814
814
|
const eventSource = new EventSource(url.toString(), { withCredentials: true });
|
|
815
815
|
const listener = (e) => {
|
|
816
816
|
try {
|
|
@@ -1412,8 +1412,8 @@ function resolveMercureTopicOrigin(apiBaseUrl = getCoreApiBaseUrl(), configuredO
|
|
|
1412
1412
|
return "";
|
|
1413
1413
|
}
|
|
1414
1414
|
/**
|
|
1415
|
-
* Wildcard collection topic (
|
|
1416
|
-
* e.g. `/api/products` → `http://localhost:8000/api/products
|
|
1415
|
+
* Wildcard collection topic (WHATWG URL Pattern) for a resource API path.
|
|
1416
|
+
* e.g. `/api/products` → `http://localhost:8000/api/products/*`
|
|
1417
1417
|
*/
|
|
1418
1418
|
function buildMercureCollectionTopic(apiUrl, configuredOrigin, apiBaseUrl = getCoreApiBaseUrl()) {
|
|
1419
1419
|
if (!apiUrl) return null;
|
|
@@ -1422,8 +1422,8 @@ function buildMercureCollectionTopic(apiUrl, configuredOrigin, apiBaseUrl = getC
|
|
|
1422
1422
|
const normalizedPath = apiUrl.replace(/^\//, "").replace(/\/+$/, "");
|
|
1423
1423
|
if (!normalizedPath) return null;
|
|
1424
1424
|
const tenantId = getMercureTenantId();
|
|
1425
|
-
if (tenantId !== void 0 && tenantId !== null && `${tenantId}` !== "") return `${origin}/api/tenants/${tenantId}/${normalizedPath.replace(/^api\//, "")}
|
|
1426
|
-
return `${origin}/${normalizedPath}
|
|
1425
|
+
if (tenantId !== void 0 && tenantId !== null && `${tenantId}` !== "") return `${origin}/api/tenants/${tenantId}/${normalizedPath.replace(/^api\//, "")}/*`;
|
|
1426
|
+
return `${origin}/${normalizedPath}/*`;
|
|
1427
1427
|
}
|
|
1428
1428
|
//#endregion
|
|
1429
1429
|
//#region packages/core/mercure/useDiscoveredMercureTopicOrigin.ts
|