@rolloutctrl/js-sdk 0.0.2 → 0.0.4
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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -2
- package/dist/index.mjs +14 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -97,6 +97,7 @@ declare class HttpConfigurationRepository implements ConfigurationRepository {
|
|
|
97
97
|
subscribe(listener: (configuration: Configuration) => void): () => void;
|
|
98
98
|
private notify;
|
|
99
99
|
private fetchBootstrap;
|
|
100
|
+
private normalizeConfiguration;
|
|
100
101
|
private fetchChanges;
|
|
101
102
|
private request;
|
|
102
103
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -97,6 +97,7 @@ declare class HttpConfigurationRepository implements ConfigurationRepository {
|
|
|
97
97
|
subscribe(listener: (configuration: Configuration) => void): () => void;
|
|
98
98
|
private notify;
|
|
99
99
|
private fetchBootstrap;
|
|
100
|
+
private normalizeConfiguration;
|
|
100
101
|
private fetchChanges;
|
|
101
102
|
private request;
|
|
102
103
|
}
|
package/dist/index.js
CHANGED
|
@@ -167,10 +167,22 @@ var HttpConfigurationRepository = class {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
async fetchBootstrap() {
|
|
170
|
-
|
|
170
|
+
const raw = await this.request(`${this.apiUrl}/sdk/config?environment=${encodeURIComponent(this.environment)}`);
|
|
171
|
+
return this.normalizeConfiguration(raw);
|
|
172
|
+
}
|
|
173
|
+
normalizeConfiguration(raw) {
|
|
174
|
+
const flags = Array.isArray(raw.flags) ? raw.flags : Object.entries(raw.flags ?? {}).map(([key, value]) => ({ key, ...value }));
|
|
175
|
+
const actions = Array.isArray(raw.actions) ? raw.actions : Object.values(raw.actions ?? {});
|
|
176
|
+
return {
|
|
177
|
+
projectId: raw.project?.id ?? raw.projectId ?? "",
|
|
178
|
+
environmentId: raw.environmentId ?? "",
|
|
179
|
+
version: raw.version,
|
|
180
|
+
flags,
|
|
181
|
+
actions
|
|
182
|
+
};
|
|
171
183
|
}
|
|
172
184
|
async fetchChanges() {
|
|
173
|
-
const url = `${this.apiUrl}/config/changes?environment=${encodeURIComponent(this.environment)}&since=${this.version}`;
|
|
185
|
+
const url = `${this.apiUrl}/sdk/config/changes?environment=${encodeURIComponent(this.environment)}&since=${this.version}`;
|
|
174
186
|
return this.request(url);
|
|
175
187
|
}
|
|
176
188
|
async request(url) {
|
package/dist/index.mjs
CHANGED
|
@@ -139,10 +139,22 @@ var HttpConfigurationRepository = class {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
async fetchBootstrap() {
|
|
142
|
-
|
|
142
|
+
const raw = await this.request(`${this.apiUrl}/sdk/config?environment=${encodeURIComponent(this.environment)}`);
|
|
143
|
+
return this.normalizeConfiguration(raw);
|
|
144
|
+
}
|
|
145
|
+
normalizeConfiguration(raw) {
|
|
146
|
+
const flags = Array.isArray(raw.flags) ? raw.flags : Object.entries(raw.flags ?? {}).map(([key, value]) => ({ key, ...value }));
|
|
147
|
+
const actions = Array.isArray(raw.actions) ? raw.actions : Object.values(raw.actions ?? {});
|
|
148
|
+
return {
|
|
149
|
+
projectId: raw.project?.id ?? raw.projectId ?? "",
|
|
150
|
+
environmentId: raw.environmentId ?? "",
|
|
151
|
+
version: raw.version,
|
|
152
|
+
flags,
|
|
153
|
+
actions
|
|
154
|
+
};
|
|
143
155
|
}
|
|
144
156
|
async fetchChanges() {
|
|
145
|
-
const url = `${this.apiUrl}/config/changes?environment=${encodeURIComponent(this.environment)}&since=${this.version}`;
|
|
157
|
+
const url = `${this.apiUrl}/sdk/config/changes?environment=${encodeURIComponent(this.environment)}&since=${this.version}`;
|
|
146
158
|
return this.request(url);
|
|
147
159
|
}
|
|
148
160
|
async request(url) {
|