@squide/firefly 16.2.1 → 17.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/CHANGELOG.md +28 -0
- package/dist/AppRouter.js +0 -9
- package/dist/AppRouter.js.map +1 -1
- package/dist/AppRouterContext.js +0 -3
- package/dist/AppRouterContext.js.map +1 -1
- package/dist/AppRouterReducer.d.ts +17 -0
- package/dist/AppRouterReducer.js +0 -6
- package/dist/AppRouterReducer.js.map +1 -1
- package/dist/AppRouterStore.js +0 -2
- package/dist/AppRouterStore.js.map +1 -1
- package/dist/FireflyPlugin.js +0 -2
- package/dist/FireflyPlugin.js.map +1 -1
- package/dist/FireflyProvider.js +0 -3
- package/dist/FireflyProvider.js.map +1 -1
- package/dist/FireflyRuntime.js +0 -6
- package/dist/FireflyRuntime.js.map +1 -1
- package/dist/GlobalDataQueriesError.js +0 -2
- package/dist/GlobalDataQueriesError.js.map +1 -1
- package/dist/RootRoute.js +0 -6
- package/dist/RootRoute.js.map +1 -1
- package/dist/honeycomb/activeSpan.js +0 -4
- package/dist/honeycomb/activeSpan.js.map +1 -1
- package/dist/honeycomb/createTraceContextId.js +0 -2
- package/dist/honeycomb/createTraceContextId.js.map +1 -1
- package/dist/honeycomb/initializeHoneycomb.js +0 -2
- package/dist/honeycomb/initializeHoneycomb.js.map +1 -1
- package/dist/honeycomb/registerHoneycombInstrumentation.d.ts +2 -2
- package/dist/honeycomb/registerHoneycombInstrumentation.js +13 -26
- package/dist/honeycomb/registerHoneycombInstrumentation.js.map +1 -1
- package/dist/honeycomb/tracer.js +0 -2
- package/dist/honeycomb/tracer.js.map +1 -1
- package/dist/honeycomb/utils.js +0 -3
- package/dist/honeycomb/utils.js.map +1 -1
- package/dist/index.js +4 -11
- package/dist/index.js.map +1 -1
- package/dist/initializeFirefly.d.ts +5 -0
- package/dist/initializeFirefly.js +0 -8
- package/dist/initializeFirefly.js.map +1 -1
- package/dist/internal.js +5 -13
- package/dist/internal.js.map +1 -1
- package/dist/useAppRouterStore.js +0 -2
- package/dist/useAppRouterStore.js.map +1 -1
- package/dist/useCanFetchProtectedData.js +0 -2
- package/dist/useCanFetchProtectedData.js.map +1 -1
- package/dist/useCanFetchPublicData.js +0 -2
- package/dist/useCanFetchPublicData.js.map +1 -1
- package/dist/useCanRegisterDeferredRegistrations.js +0 -2
- package/dist/useCanRegisterDeferredRegistrations.js.map +1 -1
- package/dist/useCanUpdateDeferredRegistrations.js +0 -2
- package/dist/useCanUpdateDeferredRegistrations.js.map +1 -1
- package/dist/useDeferredRegistrations.js +0 -7
- package/dist/useDeferredRegistrations.js.map +1 -1
- package/dist/useExecuteOnce.js +0 -2
- package/dist/useExecuteOnce.js.map +1 -1
- package/dist/useIsActiveRouteProtected.js +0 -3
- package/dist/useIsActiveRouteProtected.js.map +1 -1
- package/dist/useIsBootstrapping.js +0 -2
- package/dist/useIsBootstrapping.js.map +1 -1
- package/dist/useNavigationItems.js +0 -3
- package/dist/useNavigationItems.js.map +1 -1
- package/dist/useProtectedDataHandler.js +0 -3
- package/dist/useProtectedDataHandler.js.map +1 -1
- package/dist/useProtectedDataQueries.d.ts +6 -0
- package/dist/useProtectedDataQueries.js +0 -8
- package/dist/useProtectedDataQueries.js.map +1 -1
- package/dist/usePublicDataHandler.js +0 -3
- package/dist/usePublicDataHandler.js.map +1 -1
- package/dist/usePublicDataQueries.d.ts +6 -0
- package/dist/usePublicDataQueries.js +0 -8
- package/dist/usePublicDataQueries.js.map +1 -1
- package/dist/useRegisterDeferredRegistrations.js +0 -3
- package/dist/useRegisterDeferredRegistrations.js.map +1 -1
- package/dist/useStrictRegistrationMode.js +0 -3
- package/dist/useStrictRegistrationMode.js.map +1 -1
- package/dist/useUpdateDeferredRegistrations.d.ts +6 -0
- package/dist/useUpdateDeferredRegistrations.js +0 -4
- package/dist/useUpdateDeferredRegistrations.js.map +1 -1
- package/package.json +24 -23
- package/src/AppRouterReducer.ts +18 -0
- package/src/honeycomb/registerHoneycombInstrumentation.ts +30 -42
- package/src/initializeFirefly.ts +6 -0
- package/src/useProtectedDataQueries.ts +7 -0
- package/src/usePublicDataQueries.ts +7 -0
- package/src/useUpdateDeferredRegistrations.ts +7 -0
|
@@ -2,25 +2,19 @@ import type { Span } from "@opentelemetry/api";
|
|
|
2
2
|
import {
|
|
3
3
|
type AddListenerOptions,
|
|
4
4
|
type EventCallbackFunction,
|
|
5
|
-
type
|
|
5
|
+
type EventMap,
|
|
6
|
+
type EventMapKey,
|
|
6
7
|
LocalModuleDeferredRegistrationFailedEvent,
|
|
7
8
|
LocalModuleDeferredRegistrationUpdateFailedEvent,
|
|
8
9
|
LocalModuleRegistrationFailedEvent,
|
|
9
10
|
LocalModulesDeferredRegistrationCompletedEvent,
|
|
10
|
-
type LocalModulesDeferredRegistrationCompletedEventPayload,
|
|
11
11
|
LocalModulesDeferredRegistrationStartedEvent,
|
|
12
|
-
type LocalModulesDeferredRegistrationStartedEventPayload,
|
|
13
12
|
LocalModulesDeferredRegistrationsUpdateCompletedEvent,
|
|
14
|
-
type LocalModulesDeferredRegistrationsUpdateCompletedEventPayload,
|
|
15
13
|
LocalModulesDeferredRegistrationsUpdateStartedEvent,
|
|
16
|
-
type LocalModulesDeferredRegistrationsUpdateStartedEventPayload,
|
|
17
14
|
LocalModulesRegistrationCompletedEvent,
|
|
18
|
-
|
|
19
|
-
LocalModulesRegistrationStartedEvent,
|
|
20
|
-
type LocalModulesRegistrationStartedEventPayload,
|
|
21
|
-
type ModuleRegistrationError
|
|
15
|
+
LocalModulesRegistrationStartedEvent
|
|
22
16
|
} from "@squide/core";
|
|
23
|
-
import { ApplicationBoostrappedEvent,
|
|
17
|
+
import { ApplicationBoostrappedEvent, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, PublicDataReadyEvent } from "../AppRouterReducer.ts";
|
|
24
18
|
import { FireflyPlugin } from "../FireflyPlugin.ts";
|
|
25
19
|
import type { FireflyRuntime } from "../FireflyRuntime.tsx";
|
|
26
20
|
import { ApplicationBootstrappingStartedEvent } from "../initializeFirefly.ts";
|
|
@@ -40,13 +34,13 @@ export interface AddProtectedListenerOptions extends AddListenerOptions {
|
|
|
40
34
|
onError?: (error: unknown) => void;
|
|
41
35
|
}
|
|
42
36
|
|
|
43
|
-
export function addProtectedListener(runtime: FireflyRuntime, eventName:
|
|
44
|
-
const protectedCallback
|
|
37
|
+
export function addProtectedListener<K extends EventMapKey>(runtime: FireflyRuntime, eventName: K, callback: EventCallbackFunction<EventMap[K]>, options?: AddProtectedListenerOptions) {
|
|
38
|
+
const protectedCallback: EventCallbackFunction<EventMap[K]> = data => {
|
|
45
39
|
try {
|
|
46
|
-
callback(
|
|
40
|
+
callback(data);
|
|
47
41
|
} catch (error: unknown) {
|
|
48
42
|
runtime.logger
|
|
49
|
-
.withText(`[squide] An unmanaged error occurred while handling event "${eventName
|
|
43
|
+
.withText(`[squide] An unmanaged error occurred while handling event "${String(eventName)}" for Honeycomb instrumentation:`)
|
|
50
44
|
.withError(error as Error)
|
|
51
45
|
.error();
|
|
52
46
|
}
|
|
@@ -89,7 +83,7 @@ export function reduceDataFetchEvents(
|
|
|
89
83
|
onPublicDataReady();
|
|
90
84
|
|
|
91
85
|
if (dataFetchState === "fetching-data") {
|
|
92
|
-
if (payload && !
|
|
86
|
+
if (payload && !payload.waitForProtectedData) {
|
|
93
87
|
dataFetchState = "data-ready";
|
|
94
88
|
onDataReady();
|
|
95
89
|
} else {
|
|
@@ -120,7 +114,7 @@ export function reduceDataFetchEvents(
|
|
|
120
114
|
onProtectedDataReady();
|
|
121
115
|
|
|
122
116
|
if (dataFetchState === "fetching-data") {
|
|
123
|
-
if (payload && !
|
|
117
|
+
if (payload && !payload.waitForPublicData) {
|
|
124
118
|
dataFetchState = "data-ready";
|
|
125
119
|
onDataReady();
|
|
126
120
|
} else {
|
|
@@ -135,11 +129,11 @@ export function reduceDataFetchEvents(
|
|
|
135
129
|
onError: onUnmanagedError
|
|
136
130
|
});
|
|
137
131
|
|
|
138
|
-
const handleDataFetchFailed =
|
|
132
|
+
const handleDataFetchFailed: EventCallbackFunction<Error[]> = payload => {
|
|
139
133
|
if (dataFetchState !== "data-fetch-failed") {
|
|
140
134
|
dataFetchState = "data-fetch-failed";
|
|
141
135
|
|
|
142
|
-
onDataFetchFailed(payload
|
|
136
|
+
onDataFetchFailed(payload ?? []);
|
|
143
137
|
}
|
|
144
138
|
};
|
|
145
139
|
|
|
@@ -224,9 +218,9 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
224
218
|
onError: handleUnmanagedError
|
|
225
219
|
});
|
|
226
220
|
|
|
227
|
-
addProtectedListener(runtime, LocalModulesRegistrationStartedEvent,
|
|
221
|
+
addProtectedListener(runtime, LocalModulesRegistrationStartedEvent, payload => {
|
|
228
222
|
const attributes = {
|
|
229
|
-
"app.squide.module_count":
|
|
223
|
+
"app.squide.module_count": payload?.moduleCount
|
|
230
224
|
};
|
|
231
225
|
|
|
232
226
|
if (bootstrappingSpan) {
|
|
@@ -241,10 +235,10 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
241
235
|
onError: handleUnmanagedError
|
|
242
236
|
});
|
|
243
237
|
|
|
244
|
-
addProtectedListener(runtime, LocalModulesRegistrationCompletedEvent,
|
|
238
|
+
addProtectedListener(runtime, LocalModulesRegistrationCompletedEvent, payload => {
|
|
245
239
|
if (bootstrappingSpan) {
|
|
246
240
|
bootstrappingSpan.addEvent("local-module-registration-completed", {
|
|
247
|
-
"app.squide.module_count":
|
|
241
|
+
"app.squide.module_count": payload?.moduleCount
|
|
248
242
|
});
|
|
249
243
|
}
|
|
250
244
|
|
|
@@ -257,19 +251,17 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
257
251
|
});
|
|
258
252
|
|
|
259
253
|
// Can occur multiple times.
|
|
260
|
-
addProtectedListener(runtime, LocalModuleRegistrationFailedEvent,
|
|
261
|
-
const registrationError = payload as ModuleRegistrationError;
|
|
262
|
-
|
|
254
|
+
addProtectedListener(runtime, LocalModuleRegistrationFailedEvent, payload => {
|
|
263
255
|
if (localModuleRegistrationSpan) {
|
|
264
|
-
traceError(localModuleRegistrationSpan,
|
|
256
|
+
traceError(localModuleRegistrationSpan, payload as Error);
|
|
265
257
|
}
|
|
266
258
|
}, {
|
|
267
259
|
onError: handleUnmanagedError
|
|
268
260
|
});
|
|
269
261
|
|
|
270
|
-
addProtectedListener(runtime, LocalModulesDeferredRegistrationStartedEvent,
|
|
262
|
+
addProtectedListener(runtime, LocalModulesDeferredRegistrationStartedEvent, payload => {
|
|
271
263
|
const attributes = {
|
|
272
|
-
"app.squide.registration_count":
|
|
264
|
+
"app.squide.registration_count": payload?.registrationCount
|
|
273
265
|
};
|
|
274
266
|
|
|
275
267
|
if (bootstrappingSpan) {
|
|
@@ -284,10 +276,10 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
284
276
|
onError: handleUnmanagedError
|
|
285
277
|
});
|
|
286
278
|
|
|
287
|
-
addProtectedListener(runtime, LocalModulesDeferredRegistrationCompletedEvent,
|
|
279
|
+
addProtectedListener(runtime, LocalModulesDeferredRegistrationCompletedEvent, payload => {
|
|
288
280
|
if (bootstrappingSpan) {
|
|
289
281
|
bootstrappingSpan.addEvent("local-module-deferred-registration-completed", {
|
|
290
|
-
"app.squide.registration_count":
|
|
282
|
+
"app.squide.registration_count": payload?.registrationCount
|
|
291
283
|
});
|
|
292
284
|
}
|
|
293
285
|
|
|
@@ -300,11 +292,9 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
300
292
|
});
|
|
301
293
|
|
|
302
294
|
// Can occur multiple times.
|
|
303
|
-
addProtectedListener(runtime, LocalModuleDeferredRegistrationFailedEvent,
|
|
304
|
-
const registrationError = payload as ModuleRegistrationError;
|
|
305
|
-
|
|
295
|
+
addProtectedListener(runtime, LocalModuleDeferredRegistrationFailedEvent, payload => {
|
|
306
296
|
if (localModuleDeferredRegistrationSpan) {
|
|
307
|
-
traceError(localModuleRegistrationSpan,
|
|
297
|
+
traceError(localModuleRegistrationSpan, payload as Error);
|
|
308
298
|
}
|
|
309
299
|
}, {
|
|
310
300
|
onError: handleUnmanagedError
|
|
@@ -416,9 +406,9 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
416
406
|
});
|
|
417
407
|
|
|
418
408
|
// Can occur multiple times.
|
|
419
|
-
addProtectedListener(runtime, LocalModulesDeferredRegistrationsUpdateStartedEvent,
|
|
409
|
+
addProtectedListener(runtime, LocalModulesDeferredRegistrationsUpdateStartedEvent, payload => {
|
|
420
410
|
const attributes = {
|
|
421
|
-
"app.squide.registration_count":
|
|
411
|
+
"app.squide.registration_count": payload?.registrationCount
|
|
422
412
|
};
|
|
423
413
|
|
|
424
414
|
if (deferredRegistrationsUpdateSpan) {
|
|
@@ -443,10 +433,10 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
443
433
|
});
|
|
444
434
|
|
|
445
435
|
// Can occur multiple times.
|
|
446
|
-
addProtectedListener(runtime, LocalModulesDeferredRegistrationsUpdateCompletedEvent,
|
|
436
|
+
addProtectedListener(runtime, LocalModulesDeferredRegistrationsUpdateCompletedEvent, payload => {
|
|
447
437
|
if (deferredRegistrationsUpdateSpan) {
|
|
448
438
|
deferredRegistrationsUpdateSpan.addEvent("local-module-deferred-registrations-update-completed", {
|
|
449
|
-
"app.squide.registration_count":
|
|
439
|
+
"app.squide.registration_count": payload?.registrationCount
|
|
450
440
|
});
|
|
451
441
|
}
|
|
452
442
|
|
|
@@ -458,11 +448,9 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
458
448
|
});
|
|
459
449
|
|
|
460
450
|
// Can occur multiple times.
|
|
461
|
-
addProtectedListener(runtime, LocalModuleDeferredRegistrationUpdateFailedEvent,
|
|
462
|
-
const registrationError = payload as ModuleRegistrationError;
|
|
463
|
-
|
|
451
|
+
addProtectedListener(runtime, LocalModuleDeferredRegistrationUpdateFailedEvent, payload => {
|
|
464
452
|
if (localModuleDeferredRegistrationsUpdateSpan) {
|
|
465
|
-
traceError(localModuleDeferredRegistrationsUpdateSpan.instance,
|
|
453
|
+
traceError(localModuleDeferredRegistrationsUpdateSpan.instance, payload as Error);
|
|
466
454
|
}
|
|
467
455
|
}, {
|
|
468
456
|
onError: handleUnmanagedError
|
package/src/initializeFirefly.ts
CHANGED
|
@@ -11,6 +11,12 @@ import { initializeHoneycomb } from "./honeycomb/initializeHoneycomb.ts";
|
|
|
11
11
|
|
|
12
12
|
export const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
|
|
13
13
|
|
|
14
|
+
declare module "@squide/core" {
|
|
15
|
+
interface EventMap {
|
|
16
|
+
"squide-app-bootstrapping-started": void;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
export type OnInitializationErrorFunction = (error: unknown) => void;
|
|
15
21
|
|
|
16
22
|
export type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;
|
|
@@ -9,6 +9,13 @@ import { useExecuteOnce } from "./useExecuteOnce.ts";
|
|
|
9
9
|
export const ProtectedDataFetchStartedEvent = "squide-protected-data-fetch-started";
|
|
10
10
|
export const ProtectedDataFetchFailedEvent = "squide-protected-data-fetch-failed";
|
|
11
11
|
|
|
12
|
+
declare module "@squide/core" {
|
|
13
|
+
interface EventMap {
|
|
14
|
+
"squide-protected-data-fetch-started": void;
|
|
15
|
+
"squide-protected-data-fetch-failed": Error[];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
export type IsUnauthorizedErrorCallback = (error: unknown) => boolean;
|
|
13
20
|
|
|
14
21
|
// This converts an array of UseQueryResult to an array of the data type of each query result.
|
|
@@ -9,6 +9,13 @@ import { useExecuteOnce } from "./useExecuteOnce.ts";
|
|
|
9
9
|
export const PublicDataFetchStartedEvent = "squide-public-data-fetch-started";
|
|
10
10
|
export const PublicDataFetchFailedEvent = "squide-public-data-fetch-failed";
|
|
11
11
|
|
|
12
|
+
declare module "@squide/core" {
|
|
13
|
+
interface EventMap {
|
|
14
|
+
"squide-public-data-fetch-started": void;
|
|
15
|
+
"squide-public-data-fetch-failed": Error[];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
// This converts an array of UseQueryResult to an array of the data type of each query result.
|
|
13
20
|
// For more information, view: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#mapped-types-on-tuples-and-arrays.
|
|
14
21
|
type MapUseQueryResultToData<T> = { [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never };
|
|
@@ -5,6 +5,13 @@ import { useAppRouterDispatcher } from "./AppRouterContext.ts";
|
|
|
5
5
|
export const DeferredRegistrationsUpdateStartedEvent = "squide-deferred-registrations-update-started";
|
|
6
6
|
export const DeferredRegistrationsUpdateCompletedEvent = "squide-deferred-registrations-update-completed-started";
|
|
7
7
|
|
|
8
|
+
declare module "@squide/core" {
|
|
9
|
+
interface EventMap {
|
|
10
|
+
"squide-deferred-registrations-update-started": void;
|
|
11
|
+
"squide-deferred-registrations-update-completed-started": void;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export function useUpdateDeferredRegistrations() {
|
|
9
16
|
const runtime = useRuntime();
|
|
10
17
|
const dispatch = useAppRouterDispatcher();
|