@squide/firefly 17.1.0 → 17.2.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @squide/firefly
2
2
 
3
+ ## 17.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#631](https://github.com/workleap/wl-squide/pull/631) [`9bbcd7e`](https://github.com/workleap/wl-squide/commit/9bbcd7e1597d0c473a1477f608e3596390553bb4) Thanks [@patricklafrance](https://github.com/patricklafrance)! - `registerRequestHandlers` now accepts a `prepend` option (mirroring `registerRoute`'s `hoist` flag). Prepended handlers are placed before the appended ones, with registration order preserved within each group.
8
+
9
+ MSW evaluates handlers in registration order and a handler returning nothing falls through to the next matching handler, so `prepend` enables middleware-like fall-through handlers (artificial latency, request logging, chaos testing) that must run before the regular handlers — regardless of module registration timing:
10
+
11
+ ```ts
12
+ runtime.registerRequestHandlers([latencyRequestHandler], { prepend: true });
13
+ ```
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [[`9bbcd7e`](https://github.com/workleap/wl-squide/commit/9bbcd7e1597d0c473a1477f608e3596390553bb4)]:
18
+ - @squide/msw@4.1.0
19
+
3
20
  ## 17.1.0
4
21
 
5
22
  ### Minor Changes
@@ -12,11 +12,12 @@ export interface FireflyRuntimeOptions<TRuntime extends FireflyRuntime = Firefly
12
12
  honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;
13
13
  }
14
14
  export interface RegisterRequestHandlersOptions extends RuntimeMethodOptions {
15
+ prepend?: true;
15
16
  }
16
17
  export interface IFireflyRuntime extends IReactRouterRuntime {
17
18
  get isMswEnabled(): boolean;
18
19
  get mswState(): MswState;
19
- registerRequestHandlers: (handlers: RequestHandler[]) => void;
20
+ registerRequestHandlers: (handlers: RequestHandler[], options?: RegisterRequestHandlersOptions) => void;
20
21
  get requestHandlers(): RequestHandler[];
21
22
  registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]): void;
22
23
  registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;
@@ -41,13 +41,15 @@ class FireflyRuntime extends ReactRouterRuntime {
41
41
  return getMswPlugin(this).mswState;
42
42
  }
43
43
  registerRequestHandlers(handlers, options = {}) {
44
+ const { prepend } = options;
44
45
  const logger = this._getLogger(options);
45
46
  const plugin = getMswPlugin(this);
46
47
  if (this.moduleManager.getAreModulesRegistered()) {
47
- throw new Error("[squide] Cannot register an MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.");
48
+ throw new Error("[squide] Cannot register MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.");
48
49
  }
49
50
  plugin.registerRequestHandlers(handlers, {
50
- logger
51
+ logger,
52
+ prepend
51
53
  });
52
54
  }
53
55
  // Must define a return type otherwise we get an "error TS2742: The inferred type of 'requestHandlers' cannot be named" error.
@@ -1 +1 @@
1
- {"version":3,"file":"FireflyRuntime.js","sources":["../src/FireflyRuntime.tsx"],"sourcesContent":["import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from \"@squide/core\";\nimport { EnvironmentVariableKey, EnvironmentVariables, getEnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { FeatureFlagKey, FeatureFlags, FeatureFlagSetSnapshot, getLaunchDarklyPlugin, LaunchDarklyPluginName } from \"@squide/launch-darkly\";\nimport { getMswPlugin, MswPluginName, MswState } from \"@squide/msw\";\nimport { type IReactRouterRuntime, ReactRouterRuntime, ReactRouterRuntimeScope, type Route } from \"@squide/react-router\";\nimport type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\nimport type { Logger } from \"@workleap/logging\";\nimport { LDClient } from \"launchdarkly-js-client-sdk\";\nimport type { RequestHandler } from \"msw\";\nimport { type AppRouterStore, createAppRouterStore } from \"./AppRouterStore.ts\";\n\nexport interface FireflyRuntimeOptions<TRuntime extends FireflyRuntime = FireflyRuntime> extends RuntimeOptions<TRuntime> {\n honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;\n}\n\nexport interface RegisterRequestHandlersOptions extends RuntimeMethodOptions {}\n\nexport interface IFireflyRuntime extends IReactRouterRuntime {\n get isMswEnabled(): boolean;\n get mswState(): MswState;\n registerRequestHandlers: (handlers: RequestHandler[]) => void;\n get requestHandlers(): RequestHandler[];\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]): void;\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;\n getEnvironmentVariable<T extends EnvironmentVariableKey>(key: T): EnvironmentVariables[T];\n get environmentVariables(): EnvironmentVariables;\n get appRouterStore(): AppRouterStore;\n get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;\n get isLaunchDarklyEnabled(): boolean;\n get launchDarklyClient(): LDClient;\n get featureFlags(): FeatureFlags;\n getFeatureFlag(key: string, defaultValue?: unknown): unknown;\n get featureFlagSetSnapshot(): FeatureFlagSetSnapshot;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends ReactRouterRuntime<TRuntime> implements IFireflyRuntime {\n readonly #appRouterStore: AppRouterStore;\n readonly #honeycombInstrumentationClient: HoneycombInstrumentationPartialClient | undefined;\n readonly #isMswEnabled: boolean;\n readonly #isLaunchDarklyEnabled: boolean;\n\n constructor(options: FireflyRuntimeOptions = {}) {\n const {\n honeycombInstrumentationClient\n } = options;\n\n super(options);\n\n this.#appRouterStore = createAppRouterStore(this._logger);\n this.#honeycombInstrumentationClient = honeycombInstrumentationClient;\n this.#isMswEnabled = this._plugins.some(x => x.name === MswPluginName);\n this.#isLaunchDarklyEnabled = this._plugins.some(x => x.name === LaunchDarklyPluginName);\n }\n\n registerRoute(route: Route, options: RegisterRouteOptions = {}) {\n if (this.moduleManager.getAreModulesRegistered()) {\n throw new Error(\"[squide] Cannot register a route once the modules are registered. Are you trying to register a route in a deferred registration function? Only navigation items can be registered in a deferred registration function.\");\n }\n\n super.registerRoute(route, options);\n }\n\n get isMswEnabled() {\n return this.#isMswEnabled;\n }\n\n get mswState() {\n return getMswPlugin(this).mswState;\n }\n\n registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {\n const logger = this._getLogger(options);\n const plugin = getMswPlugin(this);\n\n if (this.moduleManager.getAreModulesRegistered()) {\n throw new Error(\"[squide] Cannot register an MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.\");\n }\n\n plugin.registerRequestHandlers(handlers, {\n logger\n });\n }\n\n // Must define a return type otherwise we get an \"error TS2742: The inferred type of 'requestHandlers' cannot be named\" error.\n get requestHandlers(): RequestHandler[] {\n return getMswPlugin(this).requestHandlers;\n }\n\n getEnvironmentVariable(key: EnvironmentVariableKey) {\n return getEnvironmentVariablesPlugin(this).getVariable(key);\n }\n\n get environmentVariables() {\n return getEnvironmentVariablesPlugin(this).getVariables();\n }\n\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]) {\n return getEnvironmentVariablesPlugin(this).registerVariable(key, value);\n }\n\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {\n return getEnvironmentVariablesPlugin(this).registerVariables(variables);\n }\n\n get appRouterStore() {\n return this.#appRouterStore;\n }\n\n get honeycombInstrumentationClient() {\n return this.#honeycombInstrumentationClient;\n }\n\n get isLaunchDarklyEnabled() {\n return this.#isLaunchDarklyEnabled;\n }\n\n get launchDarklyClient() {\n return getLaunchDarklyPlugin(this).client;\n }\n\n get featureFlags() {\n return this.featureFlagSetSnapshot.value;\n }\n\n getFeatureFlag<T extends FeatureFlagKey>(key: T, defaultValue?: FeatureFlags[T]) {\n return getLaunchDarklyPlugin(this).getFeatureFlag(key, defaultValue);\n }\n\n get featureFlagSetSnapshot() {\n return getLaunchDarklyPlugin(this).featureFlagSetSnapshot;\n }\n\n startScope(logger: Logger): TRuntime {\n return (new FireflyRuntimeScope(this, logger) as unknown) as TRuntime;\n }\n}\n\nexport class FireflyRuntimeScope<TRuntime extends FireflyRuntime = FireflyRuntime> extends ReactRouterRuntimeScope<TRuntime> implements IFireflyRuntime {\n get isMswEnabled() {\n return this._runtime.isMswEnabled;\n }\n\n get mswState() {\n return this._runtime.mswState;\n }\n\n registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {\n this._runtime.registerRequestHandlers(handlers, {\n ...options,\n logger: this._getLogger(options)\n });\n }\n\n // Must define a return type otherwise we get an \"error TS2742: The inferred type of 'requestHandlers' cannot be named\" error.\n get requestHandlers(): RequestHandler[] {\n return this._runtime.requestHandlers;\n }\n\n getEnvironmentVariable(key: EnvironmentVariableKey) {\n return this._runtime.getEnvironmentVariable(key);\n }\n\n get environmentVariables() {\n return this._runtime.environmentVariables;\n }\n\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]) {\n this._runtime.registerEnvironmentVariable(key, value);\n }\n\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {\n this._runtime.registerEnvironmentVariables(variables);\n }\n\n get appRouterStore(): AppRouterStore {\n throw new Error(\"[squide] Cannot retrieve the app router store from a runtime scope instance.\");\n }\n\n get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient {\n throw new Error(\"[squide] Cannot retrieve the Honeycomb instrumentation client from a runtime scope instance.\");\n }\n\n get isLaunchDarklyEnabled() {\n return this._runtime.isLaunchDarklyEnabled;\n }\n\n get launchDarklyClient() {\n return this._runtime.launchDarklyClient;\n }\n\n get featureFlags() {\n return this._runtime.featureFlags;\n }\n\n getFeatureFlag<T extends FeatureFlagKey>(key: T, defaultValue?: FeatureFlags[T]) {\n // The error is because the FeatureFlags interface is empty as it is expected to be augmented by the\n // consumer application.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return this._runtime.getFeatureFlag(key, defaultValue);\n }\n\n get featureFlagSetSnapshot() {\n return this._runtime.featureFlagSetSnapshot;\n }\n}\n"],"names":["getEnvironmentVariablesPlugin","getLaunchDarklyPlugin","LaunchDarklyPluginName","getMswPlugin","MswPluginName","ReactRouterRuntime","ReactRouterRuntimeScope","createAppRouterStore","FireflyRuntime","options","honeycombInstrumentationClient","x","route","Error","handlers","logger","plugin","key","value","variables","defaultValue","FireflyRuntimeScope"],"mappings":";;;;;;;;;;;AAC+G;AAC6B;AACxE;AACqD;AAKzC;AA0BhF,8DAA8D;AACvD,MAAMQ,cAAcA,SAAgDH,kBAAkBA;IAChF,eAAe,CAAiB;IAChC,+BAA+B,CAAoD;IACnF,aAAa,CAAU;IACvB,sBAAsB,CAAU;IAEzC,YAAYI,UAAiC,CAAC,CAAC,CAAE;QAC7C,MAAM,EACFC,8BAA8B,EACjC,GAAGD;QAEJ,KAAK,CAACA;QAEN,IAAI,CAAC,eAAe,GAAGF,oBAAoBA,CAAC,IAAI,CAAC,OAAO;QACxD,IAAI,CAAC,+BAA+B,GAAGG;QACvC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAACC,CAAAA,IAAKA,EAAE,IAAI,KAAKP,aAAaA;QACrE,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAACO,CAAAA,IAAKA,EAAE,IAAI,KAAKT,sBAAsBA;IAC3F;IAEA,cAAcU,KAAY,EAAEH,UAAgC,CAAC,CAAC,EAAE;QAC5D,IAAI,IAAI,CAAC,aAAa,CAAC,uBAAuB,IAAI;YAC9C,MAAM,IAAII,MAAM;QACpB;QAEA,KAAK,CAAC,cAAcD,OAAOH;IAC/B;IAEA,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,aAAa;IAC7B;IAEA,IAAI,WAAW;QACX,OAAON,YAAYA,CAAC,IAAI,EAAE,QAAQ;IACtC;IAEA,wBAAwBW,QAA0B,EAAEL,UAA0C,CAA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BAAwB;QACxB,6DAA6D;QAC7D,aAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAACH,KAAKG;IAC7C;IAEA,IAAI,yBAAyB;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB;IAC/C;AACJ"}
1
+ {"version":3,"file":"FireflyRuntime.js","sources":["../src/FireflyRuntime.tsx"],"sourcesContent":["import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from \"@squide/core\";\nimport { EnvironmentVariableKey, EnvironmentVariables, getEnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { FeatureFlagKey, FeatureFlags, FeatureFlagSetSnapshot, getLaunchDarklyPlugin, LaunchDarklyPluginName } from \"@squide/launch-darkly\";\nimport { getMswPlugin, MswPluginName, MswState } from \"@squide/msw\";\nimport { type IReactRouterRuntime, ReactRouterRuntime, ReactRouterRuntimeScope, type Route } from \"@squide/react-router\";\nimport type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\nimport type { Logger } from \"@workleap/logging\";\nimport { LDClient } from \"launchdarkly-js-client-sdk\";\nimport type { RequestHandler } from \"msw\";\nimport { type AppRouterStore, createAppRouterStore } from \"./AppRouterStore.ts\";\n\nexport interface FireflyRuntimeOptions<TRuntime extends FireflyRuntime = FireflyRuntime> extends RuntimeOptions<TRuntime> {\n honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;\n}\n\nexport interface RegisterRequestHandlersOptions extends RuntimeMethodOptions {\n prepend?: true;\n}\n\nexport interface IFireflyRuntime extends IReactRouterRuntime {\n get isMswEnabled(): boolean;\n get mswState(): MswState;\n registerRequestHandlers: (handlers: RequestHandler[], options?: RegisterRequestHandlersOptions) => void;\n get requestHandlers(): RequestHandler[];\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]): void;\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;\n getEnvironmentVariable<T extends EnvironmentVariableKey>(key: T): EnvironmentVariables[T];\n get environmentVariables(): EnvironmentVariables;\n get appRouterStore(): AppRouterStore;\n get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;\n get isLaunchDarklyEnabled(): boolean;\n get launchDarklyClient(): LDClient;\n get featureFlags(): FeatureFlags;\n getFeatureFlag(key: string, defaultValue?: unknown): unknown;\n get featureFlagSetSnapshot(): FeatureFlagSetSnapshot;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends ReactRouterRuntime<TRuntime> implements IFireflyRuntime {\n readonly #appRouterStore: AppRouterStore;\n readonly #honeycombInstrumentationClient: HoneycombInstrumentationPartialClient | undefined;\n readonly #isMswEnabled: boolean;\n readonly #isLaunchDarklyEnabled: boolean;\n\n constructor(options: FireflyRuntimeOptions = {}) {\n const {\n honeycombInstrumentationClient\n } = options;\n\n super(options);\n\n this.#appRouterStore = createAppRouterStore(this._logger);\n this.#honeycombInstrumentationClient = honeycombInstrumentationClient;\n this.#isMswEnabled = this._plugins.some(x => x.name === MswPluginName);\n this.#isLaunchDarklyEnabled = this._plugins.some(x => x.name === LaunchDarklyPluginName);\n }\n\n registerRoute(route: Route, options: RegisterRouteOptions = {}) {\n if (this.moduleManager.getAreModulesRegistered()) {\n throw new Error(\"[squide] Cannot register a route once the modules are registered. Are you trying to register a route in a deferred registration function? Only navigation items can be registered in a deferred registration function.\");\n }\n\n super.registerRoute(route, options);\n }\n\n get isMswEnabled() {\n return this.#isMswEnabled;\n }\n\n get mswState() {\n return getMswPlugin(this).mswState;\n }\n\n registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {\n const {\n prepend\n } = options;\n\n const logger = this._getLogger(options);\n const plugin = getMswPlugin(this);\n\n if (this.moduleManager.getAreModulesRegistered()) {\n throw new Error(\"[squide] Cannot register MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.\");\n }\n\n plugin.registerRequestHandlers(handlers, {\n logger,\n prepend\n });\n }\n\n // Must define a return type otherwise we get an \"error TS2742: The inferred type of 'requestHandlers' cannot be named\" error.\n get requestHandlers(): RequestHandler[] {\n return getMswPlugin(this).requestHandlers;\n }\n\n getEnvironmentVariable(key: EnvironmentVariableKey) {\n return getEnvironmentVariablesPlugin(this).getVariable(key);\n }\n\n get environmentVariables() {\n return getEnvironmentVariablesPlugin(this).getVariables();\n }\n\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]) {\n return getEnvironmentVariablesPlugin(this).registerVariable(key, value);\n }\n\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {\n return getEnvironmentVariablesPlugin(this).registerVariables(variables);\n }\n\n get appRouterStore() {\n return this.#appRouterStore;\n }\n\n get honeycombInstrumentationClient() {\n return this.#honeycombInstrumentationClient;\n }\n\n get isLaunchDarklyEnabled() {\n return this.#isLaunchDarklyEnabled;\n }\n\n get launchDarklyClient() {\n return getLaunchDarklyPlugin(this).client;\n }\n\n get featureFlags() {\n return this.featureFlagSetSnapshot.value;\n }\n\n getFeatureFlag<T extends FeatureFlagKey>(key: T, defaultValue?: FeatureFlags[T]) {\n return getLaunchDarklyPlugin(this).getFeatureFlag(key, defaultValue);\n }\n\n get featureFlagSetSnapshot() {\n return getLaunchDarklyPlugin(this).featureFlagSetSnapshot;\n }\n\n startScope(logger: Logger): TRuntime {\n return (new FireflyRuntimeScope(this, logger) as unknown) as TRuntime;\n }\n}\n\nexport class FireflyRuntimeScope<TRuntime extends FireflyRuntime = FireflyRuntime> extends ReactRouterRuntimeScope<TRuntime> implements IFireflyRuntime {\n get isMswEnabled() {\n return this._runtime.isMswEnabled;\n }\n\n get mswState() {\n return this._runtime.mswState;\n }\n\n registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {\n this._runtime.registerRequestHandlers(handlers, {\n ...options,\n logger: this._getLogger(options)\n });\n }\n\n // Must define a return type otherwise we get an \"error TS2742: The inferred type of 'requestHandlers' cannot be named\" error.\n get requestHandlers(): RequestHandler[] {\n return this._runtime.requestHandlers;\n }\n\n getEnvironmentVariable(key: EnvironmentVariableKey) {\n return this._runtime.getEnvironmentVariable(key);\n }\n\n get environmentVariables() {\n return this._runtime.environmentVariables;\n }\n\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]) {\n this._runtime.registerEnvironmentVariable(key, value);\n }\n\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {\n this._runtime.registerEnvironmentVariables(variables);\n }\n\n get appRouterStore(): AppRouterStore {\n throw new Error(\"[squide] Cannot retrieve the app router store from a runtime scope instance.\");\n }\n\n get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient {\n throw new Error(\"[squide] Cannot retrieve the Honeycomb instrumentation client from a runtime scope instance.\");\n }\n\n get isLaunchDarklyEnabled() {\n return this._runtime.isLaunchDarklyEnabled;\n }\n\n get launchDarklyClient() {\n return this._runtime.launchDarklyClient;\n }\n\n get featureFlags() {\n return this._runtime.featureFlags;\n }\n\n getFeatureFlag<T extends FeatureFlagKey>(key: T, defaultValue?: FeatureFlags[T]) {\n // The error is because the FeatureFlags interface is empty as it is expected to be augmented by the\n // consumer application.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return this._runtime.getFeatureFlag(key, defaultValue);\n }\n\n get featureFlagSetSnapshot() {\n return this._runtime.featureFlagSetSnapshot;\n }\n}\n"],"names":["getEnvironmentVariablesPlugin","getLaunchDarklyPlugin","LaunchDarklyPluginName","getMswPlugin","MswPluginName","ReactRouterRuntime","ReactRouterRuntimeScope","createAppRouterStore","FireflyRuntime","options","honeycombInstrumentationClient","x","route","Error","handlers","prepend","logger","plugin","key","value","variables","defaultValue","FireflyRuntimeScope"],"mappings":";;;;;;;;;;;AAC+G;AAC6B;AACxE;AACqD;AAKzC;AA4BhF,8DAA8D;AACvD,MAAMQ,cAAcA,SAAgDH,kBAAkBA;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ACK,UAAU;YAC5C,GAAGL,OAAO;YACV,QAAQ,IAAI,CAAC,UAAU,CAACA;QAC5B;IACJ;IAEA,8HAA8H;IAC9H,IAAI,kBAAoC;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe;IACxC;IAEA,uBAAuBS,GAA2B,EAAE;QAChD,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAACA;IAChD;IAEA,IAAI,uBAAuB;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,oBAAoB;IAC7C;IAEA,4BAA8DA,GAAM,EAAEC,KAA8B,EAAE;QAClG,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAACD,KAAKC;IACnD;IAEA,6BAA6BC,SAAwC,EAAE;QACnE,IAAI,CAAC,QAAQ,CAAC,4BAA4B,CAACA;IAC/C;IAEA,IAAI,iBAAiC;QACjC,MAAM,IAAIP,MAAM;IACpB;IAEA,IAAI,iCAAwE;QACxE,MAAM,IAAIA,MAAM;IACpB;IAEA,IAAI,wBAAwB;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,qBAAqB;IAC9C;IAEA,IAAI,qBAAqB;QACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB;IAC3C;IAEA,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY;IACrC;IAEA,eAAyCK,GAAM,EAAEG,YAA8B,EAAE;QAC7E,oGAAoG;QACpG,wBAAwB;QACxB,6DAA6D;QAC7D,aAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAACH,KAAKG;IAC7C;IAEA,IAAI,yBAAyB;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB;IAC/C;AACJ"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly",
3
3
  "author": "Workleap",
4
- "version": "17.1.0",
4
+ "version": "17.2.0",
5
5
  "description": "Squide bundle for the firefly technology stack.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -51,9 +51,9 @@
51
51
  "uuid": "^14.0.0",
52
52
  "@squide/core": "^7.1.0",
53
53
  "@squide/env-vars": "^1.4.22",
54
- "@squide/launch-darkly": "^1.0.15",
55
- "@squide/msw": "^4.0.20",
56
- "@squide/react-router": "^8.2.0"
54
+ "@squide/react-router": "^8.2.0",
55
+ "@squide/msw": "^4.1.0",
56
+ "@squide/launch-darkly": "^1.0.15"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@eslint/js": "9.39.2",
@@ -13,12 +13,14 @@ export interface FireflyRuntimeOptions<TRuntime extends FireflyRuntime = Firefly
13
13
  honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;
14
14
  }
15
15
 
16
- export interface RegisterRequestHandlersOptions extends RuntimeMethodOptions {}
16
+ export interface RegisterRequestHandlersOptions extends RuntimeMethodOptions {
17
+ prepend?: true;
18
+ }
17
19
 
18
20
  export interface IFireflyRuntime extends IReactRouterRuntime {
19
21
  get isMswEnabled(): boolean;
20
22
  get mswState(): MswState;
21
- registerRequestHandlers: (handlers: RequestHandler[]) => void;
23
+ registerRequestHandlers: (handlers: RequestHandler[], options?: RegisterRequestHandlersOptions) => void;
22
24
  get requestHandlers(): RequestHandler[];
23
25
  registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]): void;
24
26
  registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;
@@ -70,15 +72,20 @@ export class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends React
70
72
  }
71
73
 
72
74
  registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {
75
+ const {
76
+ prepend
77
+ } = options;
78
+
73
79
  const logger = this._getLogger(options);
74
80
  const plugin = getMswPlugin(this);
75
81
 
76
82
  if (this.moduleManager.getAreModulesRegistered()) {
77
- throw new Error("[squide] Cannot register an MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.");
83
+ throw new Error("[squide] Cannot register MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.");
78
84
  }
79
85
 
80
86
  plugin.registerRequestHandlers(handlers, {
81
- logger
87
+ logger,
88
+ prepend
82
89
  });
83
90
  }
84
91