@scalemule/sdk 0.0.7 → 0.0.11
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 +325 -30
- package/dist/index.d.ts +325 -30
- package/dist/index.js +209 -21
- package/dist/index.mjs +207 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -312,6 +312,7 @@ __export(index_exports, {
|
|
|
312
312
|
ErrorCodes: () => ErrorCodes,
|
|
313
313
|
EventsService: () => EventsService,
|
|
314
314
|
FlagContentService: () => FlagContentService,
|
|
315
|
+
FlagsService: () => FlagsService,
|
|
315
316
|
FunctionsService: () => FunctionsService,
|
|
316
317
|
GraphService: () => GraphService,
|
|
317
318
|
IdentityService: () => IdentityService,
|
|
@@ -337,6 +338,7 @@ __export(index_exports, {
|
|
|
337
338
|
UploadTelemetry: () => UploadTelemetry,
|
|
338
339
|
VideoService: () => VideoService,
|
|
339
340
|
WebhooksService: () => WebhooksService,
|
|
341
|
+
WorkspacesService: () => WorkspacesService,
|
|
340
342
|
buildClientContextHeaders: () => buildClientContextHeaders,
|
|
341
343
|
calculateTotalParts: () => calculateTotalParts,
|
|
342
344
|
canPerform: () => canPerform,
|
|
@@ -462,6 +464,7 @@ var MAX_BACKOFF_MS = 3e4;
|
|
|
462
464
|
var SESSION_STORAGE_KEY = "scalemule_session";
|
|
463
465
|
var USER_ID_STORAGE_KEY = "scalemule_user_id";
|
|
464
466
|
var OFFLINE_QUEUE_KEY = "scalemule_offline_queue";
|
|
467
|
+
var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
|
|
465
468
|
var GATEWAY_URLS = {
|
|
466
469
|
dev: "https://api-dev.scalemule.com",
|
|
467
470
|
prod: "https://api.scalemule.com"
|
|
@@ -653,6 +656,7 @@ var ScaleMuleClient = class {
|
|
|
653
656
|
this.userId = null;
|
|
654
657
|
this.rateLimitQueue = null;
|
|
655
658
|
this.offlineQueue = null;
|
|
659
|
+
this.workspaceId = null;
|
|
656
660
|
this.apiKey = config.apiKey;
|
|
657
661
|
this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
|
|
658
662
|
this.debug = config.debug || false;
|
|
@@ -676,6 +680,8 @@ var ScaleMuleClient = class {
|
|
|
676
680
|
const userId = await this.storage.getItem(USER_ID_STORAGE_KEY);
|
|
677
681
|
if (token) this.sessionToken = token;
|
|
678
682
|
if (userId) this.userId = userId;
|
|
683
|
+
const wsId = await this.storage.getItem(WORKSPACE_STORAGE_KEY);
|
|
684
|
+
if (wsId) this.workspaceId = wsId;
|
|
679
685
|
if (this.debug) console.log("[ScaleMule] Initialized, session:", !!token);
|
|
680
686
|
}
|
|
681
687
|
async setSession(token, userId) {
|
|
@@ -687,8 +693,10 @@ var ScaleMuleClient = class {
|
|
|
687
693
|
async clearSession() {
|
|
688
694
|
this.sessionToken = null;
|
|
689
695
|
this.userId = null;
|
|
696
|
+
this.workspaceId = null;
|
|
690
697
|
await this.storage.removeItem(SESSION_STORAGE_KEY);
|
|
691
698
|
await this.storage.removeItem(USER_ID_STORAGE_KEY);
|
|
699
|
+
await this.storage.removeItem(WORKSPACE_STORAGE_KEY);
|
|
692
700
|
}
|
|
693
701
|
setAccessToken(token) {
|
|
694
702
|
this.sessionToken = token;
|
|
@@ -724,6 +732,17 @@ var ScaleMuleClient = class {
|
|
|
724
732
|
isRateLimited() {
|
|
725
733
|
return this.rateLimitQueue?.isRateLimited || false;
|
|
726
734
|
}
|
|
735
|
+
setWorkspaceContext(id) {
|
|
736
|
+
this.workspaceId = id;
|
|
737
|
+
if (id) {
|
|
738
|
+
this.storage.setItem(WORKSPACE_STORAGE_KEY, id);
|
|
739
|
+
} else {
|
|
740
|
+
this.storage.removeItem(WORKSPACE_STORAGE_KEY);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
getWorkspaceId() {
|
|
744
|
+
return this.workspaceId;
|
|
745
|
+
}
|
|
727
746
|
// --------------------------------------------------------------------------
|
|
728
747
|
// Core Request Method
|
|
729
748
|
// --------------------------------------------------------------------------
|
|
@@ -740,6 +759,9 @@ var ScaleMuleClient = class {
|
|
|
740
759
|
if (!init.skipAuth && this.sessionToken) {
|
|
741
760
|
headers["Authorization"] = `Bearer ${this.sessionToken}`;
|
|
742
761
|
}
|
|
762
|
+
if (this.workspaceId) {
|
|
763
|
+
headers["x-sm-workspace-id"] = this.workspaceId;
|
|
764
|
+
}
|
|
743
765
|
let bodyStr;
|
|
744
766
|
if (init.body !== void 0 && init.body !== null) {
|
|
745
767
|
bodyStr = typeof init.body === "string" ? init.body : JSON.stringify(init.body);
|
|
@@ -891,6 +913,7 @@ var ScaleMuleClient = class {
|
|
|
891
913
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
892
914
|
const headers = { "x-api-key": this.apiKey };
|
|
893
915
|
if (this.sessionToken) headers["Authorization"] = `Bearer ${this.sessionToken}`;
|
|
916
|
+
if (this.workspaceId) headers["x-sm-workspace-id"] = this.workspaceId;
|
|
894
917
|
try {
|
|
895
918
|
const response = await fetch(url, {
|
|
896
919
|
method: "POST",
|
|
@@ -985,6 +1008,9 @@ var ScaleMuleClient = class {
|
|
|
985
1008
|
if (this.sessionToken) {
|
|
986
1009
|
xhr.setRequestHeader("Authorization", `Bearer ${this.sessionToken}`);
|
|
987
1010
|
}
|
|
1011
|
+
if (this.workspaceId) {
|
|
1012
|
+
xhr.setRequestHeader("x-sm-workspace-id", this.workspaceId);
|
|
1013
|
+
}
|
|
988
1014
|
xhr.send(buildFormData());
|
|
989
1015
|
});
|
|
990
1016
|
if (result.error === null) {
|
|
@@ -3706,6 +3732,105 @@ var AnalyticsService = class extends ServiceModule {
|
|
|
3706
3732
|
}
|
|
3707
3733
|
};
|
|
3708
3734
|
|
|
3735
|
+
// src/services/flags.ts
|
|
3736
|
+
var FlagsService = class extends ServiceModule {
|
|
3737
|
+
constructor() {
|
|
3738
|
+
super(...arguments);
|
|
3739
|
+
this.basePath = "/v1/flags";
|
|
3740
|
+
}
|
|
3741
|
+
async evaluate(flagKey, context = {}, environment = "prod", options) {
|
|
3742
|
+
return this.post("/evaluate", { flag_key: flagKey, environment, context }, options);
|
|
3743
|
+
}
|
|
3744
|
+
async evaluateBatch(flagKeys, context = {}, environment = "prod", options) {
|
|
3745
|
+
return this.post(
|
|
3746
|
+
"/evaluate/batch",
|
|
3747
|
+
{ flag_keys: flagKeys, environment, context },
|
|
3748
|
+
options
|
|
3749
|
+
);
|
|
3750
|
+
}
|
|
3751
|
+
async evaluateAll(context = {}, environment = "prod", options) {
|
|
3752
|
+
return this.post("/evaluate/all", { environment, context }, options);
|
|
3753
|
+
}
|
|
3754
|
+
async list(params, options) {
|
|
3755
|
+
return this._get(
|
|
3756
|
+
this.withQuery("", {
|
|
3757
|
+
application_id: params?.applicationId,
|
|
3758
|
+
status: params?.status,
|
|
3759
|
+
search: params?.search
|
|
3760
|
+
}),
|
|
3761
|
+
options
|
|
3762
|
+
);
|
|
3763
|
+
}
|
|
3764
|
+
async get(id, options) {
|
|
3765
|
+
return this._get(`/${id}`, options);
|
|
3766
|
+
}
|
|
3767
|
+
async create(data, params, options) {
|
|
3768
|
+
const path = this.withQuery("", { application_id: params?.applicationId });
|
|
3769
|
+
return this.post(path, data, options);
|
|
3770
|
+
}
|
|
3771
|
+
async update(id, data, options) {
|
|
3772
|
+
return this.patch(`/${id}`, data, options);
|
|
3773
|
+
}
|
|
3774
|
+
async archive(id, options) {
|
|
3775
|
+
return this.del(`/${id}`, options);
|
|
3776
|
+
}
|
|
3777
|
+
async activate(id, options) {
|
|
3778
|
+
return this.post(`/${id}/activate`, void 0, options);
|
|
3779
|
+
}
|
|
3780
|
+
async deactivate(id, options) {
|
|
3781
|
+
return this.post(`/${id}/deactivate`, void 0, options);
|
|
3782
|
+
}
|
|
3783
|
+
async listRules(id, options) {
|
|
3784
|
+
return this._get(`/${id}/rules`, options);
|
|
3785
|
+
}
|
|
3786
|
+
async createRule(id, data, options) {
|
|
3787
|
+
return this.post(`/${id}/rules`, data, options);
|
|
3788
|
+
}
|
|
3789
|
+
async updateRule(id, data, options) {
|
|
3790
|
+
return this.patch(`/rules/${id}`, data, options);
|
|
3791
|
+
}
|
|
3792
|
+
async deleteRule(id, options) {
|
|
3793
|
+
return this.del(`/rules/${id}`, options);
|
|
3794
|
+
}
|
|
3795
|
+
async listVariants(id, options) {
|
|
3796
|
+
return this._get(`/${id}/variants`, options);
|
|
3797
|
+
}
|
|
3798
|
+
async createVariant(id, data, options) {
|
|
3799
|
+
return this.post(`/${id}/variants`, data, options);
|
|
3800
|
+
}
|
|
3801
|
+
async updateVariant(id, data, options) {
|
|
3802
|
+
return this.patch(`/variants/${id}`, data, options);
|
|
3803
|
+
}
|
|
3804
|
+
async deleteVariant(id, options) {
|
|
3805
|
+
return this.del(`/variants/${id}`, options);
|
|
3806
|
+
}
|
|
3807
|
+
async listSegments(params, options) {
|
|
3808
|
+
return this._get(this.withQuery("/segments", { application_id: params?.applicationId }), options);
|
|
3809
|
+
}
|
|
3810
|
+
async createSegment(data, params, options) {
|
|
3811
|
+
return this.post(
|
|
3812
|
+
this.withQuery("/segments", { application_id: params?.applicationId }),
|
|
3813
|
+
data,
|
|
3814
|
+
options
|
|
3815
|
+
);
|
|
3816
|
+
}
|
|
3817
|
+
async updateSegment(id, data, options) {
|
|
3818
|
+
return this.patch(`/segments/${id}`, data, options);
|
|
3819
|
+
}
|
|
3820
|
+
async deleteSegment(id, options) {
|
|
3821
|
+
return this.del(`/segments/${id}`, options);
|
|
3822
|
+
}
|
|
3823
|
+
async listEnvironments(id, options) {
|
|
3824
|
+
return this._get(`/${id}/environments`, options);
|
|
3825
|
+
}
|
|
3826
|
+
async upsertEnvironment(id, environment, data, options) {
|
|
3827
|
+
return this.put(`/${id}/environments/${encodeURIComponent(environment)}`, data, options);
|
|
3828
|
+
}
|
|
3829
|
+
async listAudit(id, limit, options) {
|
|
3830
|
+
return this._get(this.withQuery(`/${id}/audit`, { limit }), options);
|
|
3831
|
+
}
|
|
3832
|
+
};
|
|
3833
|
+
|
|
3709
3834
|
// src/services/communication.ts
|
|
3710
3835
|
var CommunicationService = class extends ServiceModule {
|
|
3711
3836
|
constructor() {
|
|
@@ -3904,6 +4029,74 @@ var PermissionsService = class extends ServiceModule {
|
|
|
3904
4029
|
}
|
|
3905
4030
|
};
|
|
3906
4031
|
|
|
4032
|
+
// src/services/workspaces.ts
|
|
4033
|
+
var WorkspacesService = class extends ServiceModule {
|
|
4034
|
+
constructor() {
|
|
4035
|
+
super(...arguments);
|
|
4036
|
+
this.basePath = "/v1/workspaces";
|
|
4037
|
+
}
|
|
4038
|
+
// --------------------------------------------------------------------------
|
|
4039
|
+
// Workspace CRUD
|
|
4040
|
+
// --------------------------------------------------------------------------
|
|
4041
|
+
async create(data, options) {
|
|
4042
|
+
return this.post("", data, options);
|
|
4043
|
+
}
|
|
4044
|
+
async list(params, requestOptions) {
|
|
4045
|
+
return this._list("", params, requestOptions);
|
|
4046
|
+
}
|
|
4047
|
+
async mine(params, options) {
|
|
4048
|
+
return this._list("/mine", params, options);
|
|
4049
|
+
}
|
|
4050
|
+
async get(id, options) {
|
|
4051
|
+
return this._get(`/${id}`, options);
|
|
4052
|
+
}
|
|
4053
|
+
async update(id, data, options) {
|
|
4054
|
+
return this.patch(`/${id}`, data, options);
|
|
4055
|
+
}
|
|
4056
|
+
async delete(id, options) {
|
|
4057
|
+
return this.del(`/${id}`, options);
|
|
4058
|
+
}
|
|
4059
|
+
// --------------------------------------------------------------------------
|
|
4060
|
+
// Members
|
|
4061
|
+
// --------------------------------------------------------------------------
|
|
4062
|
+
async listMembers(workspaceId, params, requestOptions) {
|
|
4063
|
+
return this._list(`/${workspaceId}/members`, params, requestOptions);
|
|
4064
|
+
}
|
|
4065
|
+
async addMember(workspaceId, data, options) {
|
|
4066
|
+
return this.post(`/${workspaceId}/members`, data, options);
|
|
4067
|
+
}
|
|
4068
|
+
async updateMember(workspaceId, userId, data, options) {
|
|
4069
|
+
return this.patch(`/${workspaceId}/members/${userId}`, data, options);
|
|
4070
|
+
}
|
|
4071
|
+
async removeMember(workspaceId, userId, options) {
|
|
4072
|
+
return this.del(`/${workspaceId}/members/${userId}`, options);
|
|
4073
|
+
}
|
|
4074
|
+
// --------------------------------------------------------------------------
|
|
4075
|
+
// Invitations
|
|
4076
|
+
// --------------------------------------------------------------------------
|
|
4077
|
+
async invite(workspaceId, data, options) {
|
|
4078
|
+
return this.post(`/${workspaceId}/invitations`, data, options);
|
|
4079
|
+
}
|
|
4080
|
+
async listInvitations(workspaceId, options) {
|
|
4081
|
+
return this._get(`/${workspaceId}/invitations`, options);
|
|
4082
|
+
}
|
|
4083
|
+
async acceptInvitation(token, options) {
|
|
4084
|
+
return this.post(`/invitations/${token}/accept`, void 0, options);
|
|
4085
|
+
}
|
|
4086
|
+
async cancelInvitation(id, options) {
|
|
4087
|
+
return this.del(`/invitations/${id}`, options);
|
|
4088
|
+
}
|
|
4089
|
+
// --------------------------------------------------------------------------
|
|
4090
|
+
// SSO (workspace-only)
|
|
4091
|
+
// --------------------------------------------------------------------------
|
|
4092
|
+
async configureSso(workspaceId, data, options) {
|
|
4093
|
+
return this.post(`/${workspaceId}/sso/configure`, data, options);
|
|
4094
|
+
}
|
|
4095
|
+
async getSso(workspaceId, options) {
|
|
4096
|
+
return this._get(`/${workspaceId}/sso`, options);
|
|
4097
|
+
}
|
|
4098
|
+
};
|
|
4099
|
+
|
|
3907
4100
|
// src/services/teams.ts
|
|
3908
4101
|
var TeamsService = class extends ServiceModule {
|
|
3909
4102
|
constructor() {
|
|
@@ -3961,26 +4154,6 @@ var TeamsService = class extends ServiceModule {
|
|
|
3961
4154
|
async cancelInvitation(id, options) {
|
|
3962
4155
|
return this.del(`/invitations/${id}`, options);
|
|
3963
4156
|
}
|
|
3964
|
-
// --------------------------------------------------------------------------
|
|
3965
|
-
// SSO
|
|
3966
|
-
// --------------------------------------------------------------------------
|
|
3967
|
-
async configureSso(teamId, data, options) {
|
|
3968
|
-
return this.post(`/${teamId}/sso/configure`, data, options);
|
|
3969
|
-
}
|
|
3970
|
-
async getSso(teamId, options) {
|
|
3971
|
-
return this._get(`/${teamId}/sso`, options);
|
|
3972
|
-
}
|
|
3973
|
-
// --------------------------------------------------------------------------
|
|
3974
|
-
// Legacy methods (backward compat)
|
|
3975
|
-
// --------------------------------------------------------------------------
|
|
3976
|
-
/** @deprecated Use create() instead */
|
|
3977
|
-
async createTeam(data) {
|
|
3978
|
-
return this.create(data);
|
|
3979
|
-
}
|
|
3980
|
-
/** @deprecated Use invite() instead */
|
|
3981
|
-
async inviteMember(teamId, email, role) {
|
|
3982
|
-
return this.invite(teamId, { email, role });
|
|
3983
|
-
}
|
|
3984
4157
|
};
|
|
3985
4158
|
|
|
3986
4159
|
// src/services/graph.ts
|
|
@@ -5102,6 +5275,10 @@ var AgentSessionsService = class extends ServiceModule {
|
|
|
5102
5275
|
|
|
5103
5276
|
// src/index.ts
|
|
5104
5277
|
var ScaleMule = class {
|
|
5278
|
+
/** @deprecated Use `workspaces` instead */
|
|
5279
|
+
get teams() {
|
|
5280
|
+
return this.workspaces;
|
|
5281
|
+
}
|
|
5105
5282
|
constructor(config) {
|
|
5106
5283
|
this._client = new ScaleMuleClient(config);
|
|
5107
5284
|
this.auth = new AuthService(this._client);
|
|
@@ -5113,10 +5290,11 @@ var ScaleMule = class {
|
|
|
5113
5290
|
this.social = new SocialService(this._client);
|
|
5114
5291
|
this.billing = new BillingService(this._client);
|
|
5115
5292
|
this.analytics = new AnalyticsService(this._client);
|
|
5293
|
+
this.flags = new FlagsService(this._client);
|
|
5116
5294
|
this.communication = new CommunicationService(this._client);
|
|
5117
5295
|
this.scheduler = new SchedulerService(this._client);
|
|
5118
5296
|
this.permissions = new PermissionsService(this._client);
|
|
5119
|
-
this.
|
|
5297
|
+
this.workspaces = new WorkspacesService(this._client);
|
|
5120
5298
|
this.accounts = new AccountsService(this._client);
|
|
5121
5299
|
this.identity = new IdentityService(this._client);
|
|
5122
5300
|
this.catalog = new CatalogService(this._client);
|
|
@@ -5183,6 +5361,14 @@ var ScaleMule = class {
|
|
|
5183
5361
|
getBaseUrl() {
|
|
5184
5362
|
return this._client.getBaseUrl();
|
|
5185
5363
|
}
|
|
5364
|
+
/** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
|
|
5365
|
+
setWorkspaceContext(id) {
|
|
5366
|
+
this._client.setWorkspaceContext(id);
|
|
5367
|
+
}
|
|
5368
|
+
/** Get the current workspace ID, or null. */
|
|
5369
|
+
getWorkspaceId() {
|
|
5370
|
+
return this._client.getWorkspaceId();
|
|
5371
|
+
}
|
|
5186
5372
|
/** Access the underlying ScaleMuleClient for advanced usage. */
|
|
5187
5373
|
getClient() {
|
|
5188
5374
|
return this._client;
|
|
@@ -5210,6 +5396,7 @@ var index_default = ScaleMule;
|
|
|
5210
5396
|
ErrorCodes,
|
|
5211
5397
|
EventsService,
|
|
5212
5398
|
FlagContentService,
|
|
5399
|
+
FlagsService,
|
|
5213
5400
|
FunctionsService,
|
|
5214
5401
|
GraphService,
|
|
5215
5402
|
IdentityService,
|
|
@@ -5235,6 +5422,7 @@ var index_default = ScaleMule;
|
|
|
5235
5422
|
UploadTelemetry,
|
|
5236
5423
|
VideoService,
|
|
5237
5424
|
WebhooksService,
|
|
5425
|
+
WorkspacesService,
|
|
5238
5426
|
buildClientContextHeaders,
|
|
5239
5427
|
calculateTotalParts,
|
|
5240
5428
|
canPerform,
|
package/dist/index.mjs
CHANGED
|
@@ -103,6 +103,7 @@ var MAX_BACKOFF_MS = 3e4;
|
|
|
103
103
|
var SESSION_STORAGE_KEY = "scalemule_session";
|
|
104
104
|
var USER_ID_STORAGE_KEY = "scalemule_user_id";
|
|
105
105
|
var OFFLINE_QUEUE_KEY = "scalemule_offline_queue";
|
|
106
|
+
var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
|
|
106
107
|
var GATEWAY_URLS = {
|
|
107
108
|
dev: "https://api-dev.scalemule.com",
|
|
108
109
|
prod: "https://api.scalemule.com"
|
|
@@ -294,6 +295,7 @@ var ScaleMuleClient = class {
|
|
|
294
295
|
this.userId = null;
|
|
295
296
|
this.rateLimitQueue = null;
|
|
296
297
|
this.offlineQueue = null;
|
|
298
|
+
this.workspaceId = null;
|
|
297
299
|
this.apiKey = config.apiKey;
|
|
298
300
|
this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
|
|
299
301
|
this.debug = config.debug || false;
|
|
@@ -317,6 +319,8 @@ var ScaleMuleClient = class {
|
|
|
317
319
|
const userId = await this.storage.getItem(USER_ID_STORAGE_KEY);
|
|
318
320
|
if (token) this.sessionToken = token;
|
|
319
321
|
if (userId) this.userId = userId;
|
|
322
|
+
const wsId = await this.storage.getItem(WORKSPACE_STORAGE_KEY);
|
|
323
|
+
if (wsId) this.workspaceId = wsId;
|
|
320
324
|
if (this.debug) console.log("[ScaleMule] Initialized, session:", !!token);
|
|
321
325
|
}
|
|
322
326
|
async setSession(token, userId) {
|
|
@@ -328,8 +332,10 @@ var ScaleMuleClient = class {
|
|
|
328
332
|
async clearSession() {
|
|
329
333
|
this.sessionToken = null;
|
|
330
334
|
this.userId = null;
|
|
335
|
+
this.workspaceId = null;
|
|
331
336
|
await this.storage.removeItem(SESSION_STORAGE_KEY);
|
|
332
337
|
await this.storage.removeItem(USER_ID_STORAGE_KEY);
|
|
338
|
+
await this.storage.removeItem(WORKSPACE_STORAGE_KEY);
|
|
333
339
|
}
|
|
334
340
|
setAccessToken(token) {
|
|
335
341
|
this.sessionToken = token;
|
|
@@ -365,6 +371,17 @@ var ScaleMuleClient = class {
|
|
|
365
371
|
isRateLimited() {
|
|
366
372
|
return this.rateLimitQueue?.isRateLimited || false;
|
|
367
373
|
}
|
|
374
|
+
setWorkspaceContext(id) {
|
|
375
|
+
this.workspaceId = id;
|
|
376
|
+
if (id) {
|
|
377
|
+
this.storage.setItem(WORKSPACE_STORAGE_KEY, id);
|
|
378
|
+
} else {
|
|
379
|
+
this.storage.removeItem(WORKSPACE_STORAGE_KEY);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
getWorkspaceId() {
|
|
383
|
+
return this.workspaceId;
|
|
384
|
+
}
|
|
368
385
|
// --------------------------------------------------------------------------
|
|
369
386
|
// Core Request Method
|
|
370
387
|
// --------------------------------------------------------------------------
|
|
@@ -381,6 +398,9 @@ var ScaleMuleClient = class {
|
|
|
381
398
|
if (!init.skipAuth && this.sessionToken) {
|
|
382
399
|
headers["Authorization"] = `Bearer ${this.sessionToken}`;
|
|
383
400
|
}
|
|
401
|
+
if (this.workspaceId) {
|
|
402
|
+
headers["x-sm-workspace-id"] = this.workspaceId;
|
|
403
|
+
}
|
|
384
404
|
let bodyStr;
|
|
385
405
|
if (init.body !== void 0 && init.body !== null) {
|
|
386
406
|
bodyStr = typeof init.body === "string" ? init.body : JSON.stringify(init.body);
|
|
@@ -532,6 +552,7 @@ var ScaleMuleClient = class {
|
|
|
532
552
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
533
553
|
const headers = { "x-api-key": this.apiKey };
|
|
534
554
|
if (this.sessionToken) headers["Authorization"] = `Bearer ${this.sessionToken}`;
|
|
555
|
+
if (this.workspaceId) headers["x-sm-workspace-id"] = this.workspaceId;
|
|
535
556
|
try {
|
|
536
557
|
const response = await fetch(url, {
|
|
537
558
|
method: "POST",
|
|
@@ -626,6 +647,9 @@ var ScaleMuleClient = class {
|
|
|
626
647
|
if (this.sessionToken) {
|
|
627
648
|
xhr.setRequestHeader("Authorization", `Bearer ${this.sessionToken}`);
|
|
628
649
|
}
|
|
650
|
+
if (this.workspaceId) {
|
|
651
|
+
xhr.setRequestHeader("x-sm-workspace-id", this.workspaceId);
|
|
652
|
+
}
|
|
629
653
|
xhr.send(buildFormData());
|
|
630
654
|
});
|
|
631
655
|
if (result.error === null) {
|
|
@@ -3354,6 +3378,105 @@ var AnalyticsService = class extends ServiceModule {
|
|
|
3354
3378
|
}
|
|
3355
3379
|
};
|
|
3356
3380
|
|
|
3381
|
+
// src/services/flags.ts
|
|
3382
|
+
var FlagsService = class extends ServiceModule {
|
|
3383
|
+
constructor() {
|
|
3384
|
+
super(...arguments);
|
|
3385
|
+
this.basePath = "/v1/flags";
|
|
3386
|
+
}
|
|
3387
|
+
async evaluate(flagKey, context = {}, environment = "prod", options) {
|
|
3388
|
+
return this.post("/evaluate", { flag_key: flagKey, environment, context }, options);
|
|
3389
|
+
}
|
|
3390
|
+
async evaluateBatch(flagKeys, context = {}, environment = "prod", options) {
|
|
3391
|
+
return this.post(
|
|
3392
|
+
"/evaluate/batch",
|
|
3393
|
+
{ flag_keys: flagKeys, environment, context },
|
|
3394
|
+
options
|
|
3395
|
+
);
|
|
3396
|
+
}
|
|
3397
|
+
async evaluateAll(context = {}, environment = "prod", options) {
|
|
3398
|
+
return this.post("/evaluate/all", { environment, context }, options);
|
|
3399
|
+
}
|
|
3400
|
+
async list(params, options) {
|
|
3401
|
+
return this._get(
|
|
3402
|
+
this.withQuery("", {
|
|
3403
|
+
application_id: params?.applicationId,
|
|
3404
|
+
status: params?.status,
|
|
3405
|
+
search: params?.search
|
|
3406
|
+
}),
|
|
3407
|
+
options
|
|
3408
|
+
);
|
|
3409
|
+
}
|
|
3410
|
+
async get(id, options) {
|
|
3411
|
+
return this._get(`/${id}`, options);
|
|
3412
|
+
}
|
|
3413
|
+
async create(data, params, options) {
|
|
3414
|
+
const path = this.withQuery("", { application_id: params?.applicationId });
|
|
3415
|
+
return this.post(path, data, options);
|
|
3416
|
+
}
|
|
3417
|
+
async update(id, data, options) {
|
|
3418
|
+
return this.patch(`/${id}`, data, options);
|
|
3419
|
+
}
|
|
3420
|
+
async archive(id, options) {
|
|
3421
|
+
return this.del(`/${id}`, options);
|
|
3422
|
+
}
|
|
3423
|
+
async activate(id, options) {
|
|
3424
|
+
return this.post(`/${id}/activate`, void 0, options);
|
|
3425
|
+
}
|
|
3426
|
+
async deactivate(id, options) {
|
|
3427
|
+
return this.post(`/${id}/deactivate`, void 0, options);
|
|
3428
|
+
}
|
|
3429
|
+
async listRules(id, options) {
|
|
3430
|
+
return this._get(`/${id}/rules`, options);
|
|
3431
|
+
}
|
|
3432
|
+
async createRule(id, data, options) {
|
|
3433
|
+
return this.post(`/${id}/rules`, data, options);
|
|
3434
|
+
}
|
|
3435
|
+
async updateRule(id, data, options) {
|
|
3436
|
+
return this.patch(`/rules/${id}`, data, options);
|
|
3437
|
+
}
|
|
3438
|
+
async deleteRule(id, options) {
|
|
3439
|
+
return this.del(`/rules/${id}`, options);
|
|
3440
|
+
}
|
|
3441
|
+
async listVariants(id, options) {
|
|
3442
|
+
return this._get(`/${id}/variants`, options);
|
|
3443
|
+
}
|
|
3444
|
+
async createVariant(id, data, options) {
|
|
3445
|
+
return this.post(`/${id}/variants`, data, options);
|
|
3446
|
+
}
|
|
3447
|
+
async updateVariant(id, data, options) {
|
|
3448
|
+
return this.patch(`/variants/${id}`, data, options);
|
|
3449
|
+
}
|
|
3450
|
+
async deleteVariant(id, options) {
|
|
3451
|
+
return this.del(`/variants/${id}`, options);
|
|
3452
|
+
}
|
|
3453
|
+
async listSegments(params, options) {
|
|
3454
|
+
return this._get(this.withQuery("/segments", { application_id: params?.applicationId }), options);
|
|
3455
|
+
}
|
|
3456
|
+
async createSegment(data, params, options) {
|
|
3457
|
+
return this.post(
|
|
3458
|
+
this.withQuery("/segments", { application_id: params?.applicationId }),
|
|
3459
|
+
data,
|
|
3460
|
+
options
|
|
3461
|
+
);
|
|
3462
|
+
}
|
|
3463
|
+
async updateSegment(id, data, options) {
|
|
3464
|
+
return this.patch(`/segments/${id}`, data, options);
|
|
3465
|
+
}
|
|
3466
|
+
async deleteSegment(id, options) {
|
|
3467
|
+
return this.del(`/segments/${id}`, options);
|
|
3468
|
+
}
|
|
3469
|
+
async listEnvironments(id, options) {
|
|
3470
|
+
return this._get(`/${id}/environments`, options);
|
|
3471
|
+
}
|
|
3472
|
+
async upsertEnvironment(id, environment, data, options) {
|
|
3473
|
+
return this.put(`/${id}/environments/${encodeURIComponent(environment)}`, data, options);
|
|
3474
|
+
}
|
|
3475
|
+
async listAudit(id, limit, options) {
|
|
3476
|
+
return this._get(this.withQuery(`/${id}/audit`, { limit }), options);
|
|
3477
|
+
}
|
|
3478
|
+
};
|
|
3479
|
+
|
|
3357
3480
|
// src/services/communication.ts
|
|
3358
3481
|
var CommunicationService = class extends ServiceModule {
|
|
3359
3482
|
constructor() {
|
|
@@ -3552,6 +3675,74 @@ var PermissionsService = class extends ServiceModule {
|
|
|
3552
3675
|
}
|
|
3553
3676
|
};
|
|
3554
3677
|
|
|
3678
|
+
// src/services/workspaces.ts
|
|
3679
|
+
var WorkspacesService = class extends ServiceModule {
|
|
3680
|
+
constructor() {
|
|
3681
|
+
super(...arguments);
|
|
3682
|
+
this.basePath = "/v1/workspaces";
|
|
3683
|
+
}
|
|
3684
|
+
// --------------------------------------------------------------------------
|
|
3685
|
+
// Workspace CRUD
|
|
3686
|
+
// --------------------------------------------------------------------------
|
|
3687
|
+
async create(data, options) {
|
|
3688
|
+
return this.post("", data, options);
|
|
3689
|
+
}
|
|
3690
|
+
async list(params, requestOptions) {
|
|
3691
|
+
return this._list("", params, requestOptions);
|
|
3692
|
+
}
|
|
3693
|
+
async mine(params, options) {
|
|
3694
|
+
return this._list("/mine", params, options);
|
|
3695
|
+
}
|
|
3696
|
+
async get(id, options) {
|
|
3697
|
+
return this._get(`/${id}`, options);
|
|
3698
|
+
}
|
|
3699
|
+
async update(id, data, options) {
|
|
3700
|
+
return this.patch(`/${id}`, data, options);
|
|
3701
|
+
}
|
|
3702
|
+
async delete(id, options) {
|
|
3703
|
+
return this.del(`/${id}`, options);
|
|
3704
|
+
}
|
|
3705
|
+
// --------------------------------------------------------------------------
|
|
3706
|
+
// Members
|
|
3707
|
+
// --------------------------------------------------------------------------
|
|
3708
|
+
async listMembers(workspaceId, params, requestOptions) {
|
|
3709
|
+
return this._list(`/${workspaceId}/members`, params, requestOptions);
|
|
3710
|
+
}
|
|
3711
|
+
async addMember(workspaceId, data, options) {
|
|
3712
|
+
return this.post(`/${workspaceId}/members`, data, options);
|
|
3713
|
+
}
|
|
3714
|
+
async updateMember(workspaceId, userId, data, options) {
|
|
3715
|
+
return this.patch(`/${workspaceId}/members/${userId}`, data, options);
|
|
3716
|
+
}
|
|
3717
|
+
async removeMember(workspaceId, userId, options) {
|
|
3718
|
+
return this.del(`/${workspaceId}/members/${userId}`, options);
|
|
3719
|
+
}
|
|
3720
|
+
// --------------------------------------------------------------------------
|
|
3721
|
+
// Invitations
|
|
3722
|
+
// --------------------------------------------------------------------------
|
|
3723
|
+
async invite(workspaceId, data, options) {
|
|
3724
|
+
return this.post(`/${workspaceId}/invitations`, data, options);
|
|
3725
|
+
}
|
|
3726
|
+
async listInvitations(workspaceId, options) {
|
|
3727
|
+
return this._get(`/${workspaceId}/invitations`, options);
|
|
3728
|
+
}
|
|
3729
|
+
async acceptInvitation(token, options) {
|
|
3730
|
+
return this.post(`/invitations/${token}/accept`, void 0, options);
|
|
3731
|
+
}
|
|
3732
|
+
async cancelInvitation(id, options) {
|
|
3733
|
+
return this.del(`/invitations/${id}`, options);
|
|
3734
|
+
}
|
|
3735
|
+
// --------------------------------------------------------------------------
|
|
3736
|
+
// SSO (workspace-only)
|
|
3737
|
+
// --------------------------------------------------------------------------
|
|
3738
|
+
async configureSso(workspaceId, data, options) {
|
|
3739
|
+
return this.post(`/${workspaceId}/sso/configure`, data, options);
|
|
3740
|
+
}
|
|
3741
|
+
async getSso(workspaceId, options) {
|
|
3742
|
+
return this._get(`/${workspaceId}/sso`, options);
|
|
3743
|
+
}
|
|
3744
|
+
};
|
|
3745
|
+
|
|
3555
3746
|
// src/services/teams.ts
|
|
3556
3747
|
var TeamsService = class extends ServiceModule {
|
|
3557
3748
|
constructor() {
|
|
@@ -3609,26 +3800,6 @@ var TeamsService = class extends ServiceModule {
|
|
|
3609
3800
|
async cancelInvitation(id, options) {
|
|
3610
3801
|
return this.del(`/invitations/${id}`, options);
|
|
3611
3802
|
}
|
|
3612
|
-
// --------------------------------------------------------------------------
|
|
3613
|
-
// SSO
|
|
3614
|
-
// --------------------------------------------------------------------------
|
|
3615
|
-
async configureSso(teamId, data, options) {
|
|
3616
|
-
return this.post(`/${teamId}/sso/configure`, data, options);
|
|
3617
|
-
}
|
|
3618
|
-
async getSso(teamId, options) {
|
|
3619
|
-
return this._get(`/${teamId}/sso`, options);
|
|
3620
|
-
}
|
|
3621
|
-
// --------------------------------------------------------------------------
|
|
3622
|
-
// Legacy methods (backward compat)
|
|
3623
|
-
// --------------------------------------------------------------------------
|
|
3624
|
-
/** @deprecated Use create() instead */
|
|
3625
|
-
async createTeam(data) {
|
|
3626
|
-
return this.create(data);
|
|
3627
|
-
}
|
|
3628
|
-
/** @deprecated Use invite() instead */
|
|
3629
|
-
async inviteMember(teamId, email, role) {
|
|
3630
|
-
return this.invite(teamId, { email, role });
|
|
3631
|
-
}
|
|
3632
3803
|
};
|
|
3633
3804
|
|
|
3634
3805
|
// src/services/graph.ts
|
|
@@ -4750,6 +4921,10 @@ var AgentSessionsService = class extends ServiceModule {
|
|
|
4750
4921
|
|
|
4751
4922
|
// src/index.ts
|
|
4752
4923
|
var ScaleMule = class {
|
|
4924
|
+
/** @deprecated Use `workspaces` instead */
|
|
4925
|
+
get teams() {
|
|
4926
|
+
return this.workspaces;
|
|
4927
|
+
}
|
|
4753
4928
|
constructor(config) {
|
|
4754
4929
|
this._client = new ScaleMuleClient(config);
|
|
4755
4930
|
this.auth = new AuthService(this._client);
|
|
@@ -4761,10 +4936,11 @@ var ScaleMule = class {
|
|
|
4761
4936
|
this.social = new SocialService(this._client);
|
|
4762
4937
|
this.billing = new BillingService(this._client);
|
|
4763
4938
|
this.analytics = new AnalyticsService(this._client);
|
|
4939
|
+
this.flags = new FlagsService(this._client);
|
|
4764
4940
|
this.communication = new CommunicationService(this._client);
|
|
4765
4941
|
this.scheduler = new SchedulerService(this._client);
|
|
4766
4942
|
this.permissions = new PermissionsService(this._client);
|
|
4767
|
-
this.
|
|
4943
|
+
this.workspaces = new WorkspacesService(this._client);
|
|
4768
4944
|
this.accounts = new AccountsService(this._client);
|
|
4769
4945
|
this.identity = new IdentityService(this._client);
|
|
4770
4946
|
this.catalog = new CatalogService(this._client);
|
|
@@ -4831,6 +5007,14 @@ var ScaleMule = class {
|
|
|
4831
5007
|
getBaseUrl() {
|
|
4832
5008
|
return this._client.getBaseUrl();
|
|
4833
5009
|
}
|
|
5010
|
+
/** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
|
|
5011
|
+
setWorkspaceContext(id) {
|
|
5012
|
+
this._client.setWorkspaceContext(id);
|
|
5013
|
+
}
|
|
5014
|
+
/** Get the current workspace ID, or null. */
|
|
5015
|
+
getWorkspaceId() {
|
|
5016
|
+
return this._client.getWorkspaceId();
|
|
5017
|
+
}
|
|
4834
5018
|
/** Access the underlying ScaleMuleClient for advanced usage. */
|
|
4835
5019
|
getClient() {
|
|
4836
5020
|
return this._client;
|
|
@@ -4857,6 +5041,7 @@ export {
|
|
|
4857
5041
|
ErrorCodes,
|
|
4858
5042
|
EventsService,
|
|
4859
5043
|
FlagContentService,
|
|
5044
|
+
FlagsService,
|
|
4860
5045
|
FunctionsService,
|
|
4861
5046
|
GraphService,
|
|
4862
5047
|
IdentityService,
|
|
@@ -4882,6 +5067,7 @@ export {
|
|
|
4882
5067
|
UploadTelemetry,
|
|
4883
5068
|
VideoService,
|
|
4884
5069
|
WebhooksService,
|
|
5070
|
+
WorkspacesService,
|
|
4885
5071
|
buildClientContextHeaders,
|
|
4886
5072
|
calculateTotalParts,
|
|
4887
5073
|
canPerform,
|