Skip to content

Commit 331f2c7

Browse files
authored
Merge pull request #9 from ReforgeHQ/mfaga-expose-extract-hydrate
feat: retire deprecated methods and expose extract/hydrate properly o…
2 parents 5098986 + 2eb3081 commit 331f2c7

File tree

4 files changed

+21
-31
lines changed

4 files changed

+21
-31
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.0.0-pre.3 - 2025-09-05
4+
5+
- Remove deprecated methods and fix typing on public replacements
6+
37
## 0.0.0-pre.0 - 2025-08-03
48

59
- Reforge rebrand

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"packageManager": "yarn@4.9.2",
33
"name": "@reforge-com/javascript",
4-
"version": "0.0.0-pre.2",
4+
"version": "0.0.0-pre.3",
55
"description": "Feature Flags & Dynamic Configuration as a Service",
66
"main": "dist/index.cjs",
77
"module": "dist/index.mjs",

src/reforge.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fetchMock, { enableFetchMocks } from "jest-fetch-mock";
2-
import { Reforge, Config, Context, type ReforgeBootstrap } from "../index";
2+
import { Reforge, Context, type ReforgeBootstrap } from "../index";
33
import { Contexts } from "./context";
44
import { type EvaluationPayload } from "./config";
55
import { DEFAULT_TIMEOUT } from "./apiHelpers";
@@ -40,8 +40,8 @@ describe("init", () => {
4040

4141
await reforge.init(defaultTestInitParams);
4242

43-
expect(reforge.configs).toEqual({
44-
turbo: new Config("turbo", 2.5, "double", { double: 2.5 }),
43+
expect(reforge.extract()).toEqual({
44+
turbo: 2.5,
4545
});
4646
expect(reforge.loaded).toBe(true);
4747
});
@@ -53,7 +53,7 @@ describe("init", () => {
5353

5454
reforge.init(defaultTestInitParams).catch((reason: any) => {
5555
expect(reason.message).toEqual("Network error");
56-
expect(reforge.configs).toEqual({});
56+
expect(reforge.extract()).toEqual({});
5757

5858
expect(reforge.isEnabled("foo")).toBe(false);
5959
});
@@ -215,7 +215,7 @@ describe("poll", () => {
215215

216216
describe("hydrate", () => {
217217
it("works when types are not provided", () => {
218-
expect(reforge.configs).toEqual({});
218+
expect(reforge.extract()).toEqual({});
219219

220220
reforge.hydrate({
221221
turbo: 2.5,
@@ -224,11 +224,11 @@ describe("hydrate", () => {
224224
durationExample: { ms: 1884 * 1000, seconds: 1884 },
225225
});
226226

227-
expect(reforge.configs).toEqual({
228-
turbo: new Config("turbo", 2.5, "number"),
229-
foo: new Config("foo", true, "boolean"),
230-
jsonExample: new Config("jsonExample", { foo: "bar", baz: 123 }, "object"),
231-
durationExample: new Config("durationExample", { ms: 1884000, seconds: 1884 }, "object"),
227+
expect(reforge.extract()).toEqual({
228+
turbo: 2.5,
229+
foo: true,
230+
jsonExample: { foo: "bar", baz: 123 },
231+
durationExample: { ms: 1884000, seconds: 1884 },
232232
});
233233

234234
expect(reforge.isEnabled("foo")).toBe(true);
@@ -256,8 +256,8 @@ describe("bootstrapping", () => {
256256

257257
await reforge.init(defaultTestInitParams);
258258

259-
expect(reforge.configs).toEqual({
260-
turbo: new Config("turbo", 99.5, "double", { double: 99.5 }),
259+
expect(reforge.extract()).toEqual({
260+
turbo: 99.5,
261261
});
262262
expect(reforge.get("turbo")).toEqual(99.5);
263263
expect(reforge.loaded).toBe(true);
@@ -279,8 +279,8 @@ describe("bootstrapping", () => {
279279

280280
await reforge.init(defaultTestInitParams);
281281

282-
expect(reforge.configs).toEqual({
283-
turbo: new Config("turbo", 2.5, "double", { double: 2.5 }),
282+
expect(reforge.extract()).toEqual({
283+
turbo: 2.5,
284284
});
285285
expect(reforge.loaded).toBe(true);
286286
});

src/reforge.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class Reforge {
135135
return this.load();
136136
}
137137

138-
extract(): Record<string, Config["value"]> {
138+
public extract(): Record<string, Config["value"]> {
139139
return Object.entries(this._configs).reduce(
140140
(agg, [key, value]) => ({
141141
...agg,
@@ -145,17 +145,10 @@ export class Reforge {
145145
);
146146
}
147147

148-
hydrate(rawValues: RawConfigWithoutTypes | EvaluationPayload): void {
148+
public hydrate(rawValues: RawConfigWithoutTypes | EvaluationPayload): void {
149149
this.setConfigPrivate(rawValues);
150150
}
151151

152-
get configs(): Record<string, Config> {
153-
// eslint-disable-next-line no-console
154-
console.warn("\x1b[33m%s\x1b[0m", 'Deprecated: Use "prefab.extract" instead');
155-
156-
return this._configs;
157-
}
158-
159152
get context(): Context {
160153
return this._context;
161154
}
@@ -271,13 +264,6 @@ export class Reforge {
271264
}
272265
}
273266

274-
setConfig(rawValues: RawConfigWithoutTypes | EvaluationPayload) {
275-
// eslint-disable-next-line no-console
276-
console.warn("\x1b[33m%s\x1b[0m", 'Deprecated: Use "prefab.hydrate" instead');
277-
278-
this.setConfigPrivate(rawValues);
279-
}
280-
281267
private setConfigPrivate(rawValues: RawConfigWithoutTypes | EvaluationPayload) {
282268
this._configs = Config.digest(rawValues);
283269
this.loaded = true;

0 commit comments

Comments
 (0)