@replanejs/sdk 0.7.6 → 0.8.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/README.md +12 -5
- package/dist/index.cjs +826 -39
- package/dist/index.d.cts +9 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -27
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Replane JavaScript SDK
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@replanejs/sdk)
|
|
4
|
+
[](https://github.com/replane-dev/replane-javascript/blob/main/LICENSE)
|
|
5
|
+
[](https://github.com/orgs/replane-dev/discussions)
|
|
6
|
+
|
|
3
7
|
Small TypeScript client for watching configuration values from a Replane API with realtime updates and context-based override evaluation.
|
|
4
8
|
|
|
5
9
|
Part of the Replane project: [replane-dev/replane](https://github.com/replane-dev/replane).
|
|
@@ -114,13 +118,15 @@ Parameters:
|
|
|
114
118
|
- `name` (K extends keyof T) – config name to fetch. TypeScript will enforce that this is a valid config name from your `Configs` interface.
|
|
115
119
|
- `options` (object) – optional configuration:
|
|
116
120
|
- `context` (object) – context merged with client-level context for override evaluation.
|
|
121
|
+
- `default` (T[K]) – default value to return if the config is not found. When provided, the method will not throw.
|
|
117
122
|
|
|
118
123
|
Returns the config value of type `T[K]` (synchronous). The return type is automatically inferred from your `Configs` interface.
|
|
119
124
|
|
|
120
125
|
Notes:
|
|
121
126
|
|
|
122
127
|
- The Replane client receives realtime updates via SSE in the background.
|
|
123
|
-
- If the config is not found, throws a `ReplaneError` with code `not_found`.
|
|
128
|
+
- If the config is not found and no default is provided, throws a `ReplaneError` with code `not_found`.
|
|
129
|
+
- If the config is not found and a default is provided, returns the default value without throwing.
|
|
124
130
|
- Context-based overrides are evaluated automatically based on context.
|
|
125
131
|
|
|
126
132
|
Example:
|
|
@@ -144,6 +150,9 @@ const userEnabled = replane.get("billing-enabled", {
|
|
|
144
150
|
context: { userId: "user-123", plan: "premium" },
|
|
145
151
|
});
|
|
146
152
|
|
|
153
|
+
// Get value with default - won't throw if config doesn't exist
|
|
154
|
+
const maxConnections = replane.get("max-connections", { default: 10 });
|
|
155
|
+
|
|
147
156
|
// Clean up when done
|
|
148
157
|
replane.close();
|
|
149
158
|
```
|
|
@@ -469,12 +478,10 @@ unsubscribeMaxUsers();
|
|
|
469
478
|
replane.close();
|
|
470
479
|
```
|
|
471
480
|
|
|
472
|
-
##
|
|
481
|
+
## Community
|
|
473
482
|
|
|
474
|
-
|
|
475
|
-
- Config invalidation
|
|
483
|
+
Have questions or want to discuss Replane? Join the conversation in [GitHub Discussions](https://github.com/orgs/replane-dev/discussions).
|
|
476
484
|
|
|
477
485
|
## License
|
|
478
486
|
|
|
479
487
|
MIT
|
|
480
|
-
|