@axa-fr/slimfaas-planet-saver 0.36.20-pr.1081138 → 0.36.20

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/README.md CHANGED
@@ -41,9 +41,9 @@ const PlanetSaver = ({ children, baseUrl, fetch, noActivityTimeout=60000, behavi
41
41
  fetch,
42
42
  behavior,
43
43
  updateCallback: (data) => {
44
- // Filter only the items that block the UI (WakeUp+BockUI)
44
+ // Filter only the items that block the UI (WakeUp+BlockUI)
45
45
  const blockingItems = data.filter(
46
- (item) => instance.getBehavior(item.Name) === 'WakeUp+BockUI'
46
+ (item) => instance.getBehavior(item.Name) === 'WakeUp+BlockUI'
47
47
  );
48
48
 
49
49
  // If all blocking items are ready, set isFirstStart to false
@@ -89,6 +89,20 @@ export default PlanetSaver;
89
89
 
90
90
 
91
91
 
92
+ ```
93
+
94
+ ### Usage:
95
+
96
+ ```jsx
97
+ const behavior: {
98
+ "api-speech-to-text": "WakeUp",
99
+ "heavy-pdf-service": "WakeUp+BlockUI",
100
+ "deprecated-service": "None"
101
+ }
102
+
103
+ <PlanetSaver baseUrl="http://slimfaas.mycompany.com" fetch={window.fetch} behavior={behavior}>
104
+ <App />
105
+ </PlanetSaver>
92
106
  ```
93
107
 
94
108
  ---
@@ -108,26 +122,26 @@ This will launch a local dev server, letting you see `SlimFaasPlanetSaver` in ac
108
122
  ## Configuration Options
109
123
  When you create a `new SlimFaasPlanetSaver(baseUrl, options)`, you can provide the following optional properties in the `options` object:
110
124
 
111
- | Property | Type | Default | Description |
112
- |---------------------------|------------------------------------------------|-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
113
- | updateCallback | `(data: any[]) => void` | `() => {}` | Function called after a successful fetch of the functions’ status. The array data includes objects with info about each function, for example: `[{ Name: 'myFunc', NumberReady: 1 }, ...]`. |
114
- | errorCallback | `(errorMessage: string) => void` | `() => {}` | Function called if an error occurs during the status fetch (e.g., network error). Receives an errorMessage string. |
115
- | interval | `number` | `5000` | How frequently (in ms) the polling should run. |
116
- | overlayStartingMessage | `string` | `"🌳 Starting the environment.... 🌳"` | Main message shown on the overlay when the environment is waking up. |
117
- | overlayNoActivityMessage | `string` | `"Waiting activity to start environment..."` | Message shown if there is no user activity (mouse movement) for too long, but the environment is not ready yet. |
118
- | overlayErrorMessage | `string` | `"An error occurred while starting the environment."` | Main message shown on the overlay if an error occurs (e.g., network error). |
119
- | overlaySecondaryMessage | `string` | `"Startup should be fast, but if no machines are available it can take several minutes."` | Secondary message shown on the overlay when the environment is waking up. |
120
- | overlayErrorSecondaryMessage | `string` | `"If the error persists, please contact an administrator."` | Secondary message shown on the overlay when an error occurs. |
121
- | overlayLoadingIcon | `string` | `"🌍"` | Text or icon shown on the overlay. By default, it is animated to spin. |
122
- | noActivityTimeout | `number` | `60000` | How long (in ms) to wait for mouse movement before concluding there is no activity. If no activity is detected, a different overlay message is displayed. |
123
- | wakeUpTimeout | `number` | `60000` | If a function was recently “woken up,” we’ll skip re-calling wake-up for that function within this timeout window (in ms). |
124
- | fetch | `typeof fetch` | Global fetch | Custom fetch function if you want to provide your own (e.g., for SSR, or if your environment doesn't have a global fetch). |
125
- | behavior | `{ [functionName: string]: 'WakeUp+BockUI' \| 'WakeUp' \| 'None' }` | *Not set; defaults each function to "WakeUp+BockUI" if unspecified* | Allows you to override how each function is handled: 1. `"WakeUp+BockUI"`: wakes the function and blocks the UI with the overlay until it’s ready. 2. `"WakeUp"`: wakes without blocking the UI. 3. `"None"`: no wake-up call. |
125
+ | Property | Type | Default | Description |
126
+ |---------------------------|----------------------------------------------------------------------|-------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
127
+ | updateCallback | `(data: any[]) => void` | `() => {}` | Function called after a successful fetch of the functions’ status. The array data includes objects with info about each function, for example: `[{ Name: 'myFunc', NumberReady: 1 }, ...]`. |
128
+ | errorCallback | `(errorMessage: string) => void` | `() => {}` | Function called if an error occurs during the status fetch (e.g., network error). Receives an errorMessage string. |
129
+ | interval | `number` | `5000` | How frequently (in ms) the polling should run. |
130
+ | overlayStartingMessage | `string` | `"🌳 Starting the environment.... 🌳"` | Main message shown on the overlay when the environment is waking up. |
131
+ | overlayNoActivityMessage | `string` | `"Waiting activity to start environment..."` | Message shown if there is no user activity (mouse movement) for too long, but the environment is not ready yet. |
132
+ | overlayErrorMessage | `string` | `"An error occurred while starting the environment."` | Main message shown on the overlay if an error occurs (e.g., network error). |
133
+ | overlaySecondaryMessage | `string` | `"Startup should be fast, but if no machines are available it can take several minutes."` | Secondary message shown on the overlay when the environment is waking up. |
134
+ | overlayErrorSecondaryMessage | `string` | `"If the error persists, please contact an administrator."` | Secondary message shown on the overlay when an error occurs. |
135
+ | overlayLoadingIcon | `string` | `"🌍"` | Text or icon shown on the overlay. By default, it is animated to spin. |
136
+ | noActivityTimeout | `number` | `60000` | How long (in ms) to wait for mouse movement before concluding there is no activity. If no activity is detected, a different overlay message is displayed. |
137
+ | wakeUpTimeout | `number` | `60000` | If a function was recently “woken up,” we’ll skip re-calling wake-up for that function within this timeout window (in ms). |
138
+ | fetch | `typeof fetch` | Global fetch | Custom fetch function if you want to provide your own (e.g., for SSR, or if your environment doesn't have a global fetch). |
139
+ | behavior | `{ [functionName: string]: 'WakeUp+BlockUI' \| 'WakeUp' \| 'None' }` | *Not set; defaults each function to "WakeUp+BlockUI" if unspecified* | Allows you to override how each function is handled: 1. `"WakeUp+BlockUI"`: wakes the function and blocks the UI with the overlay until it’s ready. 2. `"WakeUp"`: wakes without blocking the UI. 3. `"None"`: no wake-up call. |
126
140
 
127
141
  ### Notes on Behavior
128
- If a function is **not** specified in the behavior map, it defaults to `"WakeUp+BockUI"`.
142
+ If a function is **not** specified in the behavior map, it defaults to `"WakeUp+BlockUI"`.
129
143
 
130
- - `"WakeUp+BockUI"` means the overlay will be shown until that function is `NumberReady >= 1`.
144
+ - `"WakeUp+BlockUI"` means the overlay will be shown until that function is `NumberReady >= 1`.
131
145
  - `"WakeUp"` means we attempt to wake up the function, but do not keep the overlay shown specifically for that function.
132
146
  - `"None"` means the function will neither be woken up nor block the UI.
133
147
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@axa-fr/slimfaas-planet-saver",
3
3
  "private": false,
4
- "version": "0.36.20-pr.1081138",
4
+ "version": "0.36.20",
5
5
  "type": "module",
6
6
  "main": "./src/SlimFaasPlanetSaver.js",
7
7
  "module": "./src/SlimFaasPlanetSaver.js",
@@ -1,4 +1,4 @@
1
- export type BehaviorValue = 'WakeUp+BockUI' | 'WakeUp' | 'None';
1
+ export type BehaviorValue = 'WakeUp+BlockUI' | 'WakeUp' | 'None';
2
2
 
3
3
  export interface BehaviorMap {
4
4
  [functionName: string]: BehaviorValue;
@@ -23,7 +23,7 @@ export default class SlimFaasPlanetSaver {
23
23
  this.fetch = options.fetch || fetch;
24
24
 
25
25
  // Ajout de la configuration de comportement
26
- // Les valeurs possibles sont "WakeUp+BockUI", "WakeUp", "None"
26
+ // Les valeurs possibles sont "WakeUp+BlockUI", "WakeUp", "None"
27
27
  this.behavior = options.behavior || {};
28
28
 
29
29
  this.intervalId = null;
@@ -39,10 +39,10 @@ export default class SlimFaasPlanetSaver {
39
39
 
40
40
  /**
41
41
  * Retourne le comportement à appliquer pour une fonction donnée
42
- * S'il n'est pas renseigné, renvoie "WakeUp+BockUI" par défaut
42
+ * S'il n'est pas renseigné, renvoie "WakeUp+BlockUI" par défaut
43
43
  */
44
44
  getBehavior(name) {
45
- return this.behavior[name] || 'WakeUp+BockUI';
45
+ return this.behavior[name] || 'WakeUp+BlockUI';
46
46
  }
47
47
 
48
48
  initialize() {
@@ -78,7 +78,7 @@ export default class SlimFaasPlanetSaver {
78
78
  // On évite de rappeler trop souvent la même fonction
79
79
  const shouldFilter = lastWakeUpTime && (currentTime - lastWakeUpTime) <= this.wakeUpTimeout;
80
80
 
81
- // On ne fait un wake-up que pour les fonctions dont le comportement est "WakeUp" ou "WakeUp+BockUI"
81
+ // On ne fait un wake-up que pour les fonctions dont le comportement est "WakeUp" ou "WakeUp+BlockUI"
82
82
  const wakePromises = data
83
83
  .filter((item) => this.getBehavior(item.Name) !== 'None')
84
84
  .filter((item) => item.NumberReady === 0 || !shouldFilter)
@@ -113,8 +113,8 @@ export default class SlimFaasPlanetSaver {
113
113
  }
114
114
  const data = await response.json();
115
115
 
116
- // On ne considère comme bloquantes que les fonctions dont le comportement est "WakeUp+BockUI"
117
- const blockingItems = data.filter((item) => this.getBehavior(item.Name) === 'WakeUp+BockUI');
116
+ // On ne considère comme bloquantes que les fonctions dont le comportement est "WakeUp+BlockUI"
117
+ const blockingItems = data.filter((item) => this.getBehavior(item.Name) === 'WakeUp+BlockUI');
118
118
  const allBlockingReady = blockingItems.every((item) => item.NumberReady >= 1);
119
119
 
120
120
  // Si toutes les fonctions "bloquantes" sont prêtes, on estime que c'est "ready".