@envsync-cloud/envsync-ts-sdk 0.1.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/dist/index.mjs ADDED
@@ -0,0 +1,1163 @@
1
+ // src/core/BaseHttpRequest.ts
2
+ var BaseHttpRequest = class {
3
+ constructor(config) {
4
+ this.config = config;
5
+ }
6
+ };
7
+
8
+ // src/core/ApiError.ts
9
+ var ApiError = class extends Error {
10
+ url;
11
+ status;
12
+ statusText;
13
+ body;
14
+ request;
15
+ constructor(request2, response, message) {
16
+ super(message);
17
+ this.name = "ApiError";
18
+ this.url = response.url;
19
+ this.status = response.status;
20
+ this.statusText = response.statusText;
21
+ this.body = response.body;
22
+ this.request = request2;
23
+ }
24
+ };
25
+
26
+ // src/core/CancelablePromise.ts
27
+ var CancelError = class extends Error {
28
+ constructor(message) {
29
+ super(message);
30
+ this.name = "CancelError";
31
+ }
32
+ get isCancelled() {
33
+ return true;
34
+ }
35
+ };
36
+ var CancelablePromise = class {
37
+ #isResolved;
38
+ #isRejected;
39
+ #isCancelled;
40
+ #cancelHandlers;
41
+ #promise;
42
+ #resolve;
43
+ #reject;
44
+ constructor(executor) {
45
+ this.#isResolved = false;
46
+ this.#isRejected = false;
47
+ this.#isCancelled = false;
48
+ this.#cancelHandlers = [];
49
+ this.#promise = new Promise((resolve2, reject) => {
50
+ this.#resolve = resolve2;
51
+ this.#reject = reject;
52
+ const onResolve = (value) => {
53
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
54
+ return;
55
+ }
56
+ this.#isResolved = true;
57
+ if (this.#resolve) this.#resolve(value);
58
+ };
59
+ const onReject = (reason) => {
60
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
61
+ return;
62
+ }
63
+ this.#isRejected = true;
64
+ if (this.#reject) this.#reject(reason);
65
+ };
66
+ const onCancel = (cancelHandler) => {
67
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
68
+ return;
69
+ }
70
+ this.#cancelHandlers.push(cancelHandler);
71
+ };
72
+ Object.defineProperty(onCancel, "isResolved", {
73
+ get: () => this.#isResolved
74
+ });
75
+ Object.defineProperty(onCancel, "isRejected", {
76
+ get: () => this.#isRejected
77
+ });
78
+ Object.defineProperty(onCancel, "isCancelled", {
79
+ get: () => this.#isCancelled
80
+ });
81
+ return executor(onResolve, onReject, onCancel);
82
+ });
83
+ }
84
+ get [Symbol.toStringTag]() {
85
+ return "Cancellable Promise";
86
+ }
87
+ then(onFulfilled, onRejected) {
88
+ return this.#promise.then(onFulfilled, onRejected);
89
+ }
90
+ catch(onRejected) {
91
+ return this.#promise.catch(onRejected);
92
+ }
93
+ finally(onFinally) {
94
+ return this.#promise.finally(onFinally);
95
+ }
96
+ cancel() {
97
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
98
+ return;
99
+ }
100
+ this.#isCancelled = true;
101
+ if (this.#cancelHandlers.length) {
102
+ try {
103
+ for (const cancelHandler of this.#cancelHandlers) {
104
+ cancelHandler();
105
+ }
106
+ } catch (error) {
107
+ console.warn("Cancellation threw an error", error);
108
+ return;
109
+ }
110
+ }
111
+ this.#cancelHandlers.length = 0;
112
+ if (this.#reject) this.#reject(new CancelError("Request aborted"));
113
+ }
114
+ get isCancelled() {
115
+ return this.#isCancelled;
116
+ }
117
+ };
118
+
119
+ // src/core/request.ts
120
+ var isDefined = (value) => {
121
+ return value !== void 0 && value !== null;
122
+ };
123
+ var isString = (value) => {
124
+ return typeof value === "string";
125
+ };
126
+ var isStringWithValue = (value) => {
127
+ return isString(value) && value !== "";
128
+ };
129
+ var isBlob = (value) => {
130
+ return typeof value === "object" && typeof value.type === "string" && typeof value.stream === "function" && typeof value.arrayBuffer === "function" && typeof value.constructor === "function" && typeof value.constructor.name === "string" && /^(Blob|File)$/.test(value.constructor.name) && /^(Blob|File)$/.test(value[Symbol.toStringTag]);
131
+ };
132
+ var isFormData = (value) => {
133
+ return value instanceof FormData;
134
+ };
135
+ var base64 = (str) => {
136
+ try {
137
+ return btoa(str);
138
+ } catch (err) {
139
+ return Buffer.from(str).toString("base64");
140
+ }
141
+ };
142
+ var getQueryString = (params) => {
143
+ const qs = [];
144
+ const append = (key, value) => {
145
+ qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
146
+ };
147
+ const process = (key, value) => {
148
+ if (isDefined(value)) {
149
+ if (Array.isArray(value)) {
150
+ value.forEach((v) => {
151
+ process(key, v);
152
+ });
153
+ } else if (typeof value === "object") {
154
+ Object.entries(value).forEach(([k, v]) => {
155
+ process(`${key}[${k}]`, v);
156
+ });
157
+ } else {
158
+ append(key, value);
159
+ }
160
+ }
161
+ };
162
+ Object.entries(params).forEach(([key, value]) => {
163
+ process(key, value);
164
+ });
165
+ if (qs.length > 0) {
166
+ return `?${qs.join("&")}`;
167
+ }
168
+ return "";
169
+ };
170
+ var getUrl = (config, options) => {
171
+ const encoder = config.ENCODE_PATH || encodeURI;
172
+ const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
173
+ if (options.path?.hasOwnProperty(group)) {
174
+ return encoder(String(options.path[group]));
175
+ }
176
+ return substring;
177
+ });
178
+ const url = `${config.BASE}${path}`;
179
+ if (options.query) {
180
+ return `${url}${getQueryString(options.query)}`;
181
+ }
182
+ return url;
183
+ };
184
+ var getFormData = (options) => {
185
+ if (options.formData) {
186
+ const formData = new FormData();
187
+ const process = (key, value) => {
188
+ if (isString(value) || isBlob(value)) {
189
+ formData.append(key, value);
190
+ } else {
191
+ formData.append(key, JSON.stringify(value));
192
+ }
193
+ };
194
+ Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
195
+ if (Array.isArray(value)) {
196
+ value.forEach((v) => process(key, v));
197
+ } else {
198
+ process(key, value);
199
+ }
200
+ });
201
+ return formData;
202
+ }
203
+ return void 0;
204
+ };
205
+ var resolve = async (options, resolver) => {
206
+ if (typeof resolver === "function") {
207
+ return resolver(options);
208
+ }
209
+ return resolver;
210
+ };
211
+ var getHeaders = async (config, options) => {
212
+ const [token, username, password, additionalHeaders] = await Promise.all([
213
+ resolve(options, config.TOKEN),
214
+ resolve(options, config.USERNAME),
215
+ resolve(options, config.PASSWORD),
216
+ resolve(options, config.HEADERS)
217
+ ]);
218
+ const headers = Object.entries({
219
+ Accept: "application/json",
220
+ ...additionalHeaders,
221
+ ...options.headers
222
+ }).filter(([_, value]) => isDefined(value)).reduce((headers2, [key, value]) => ({
223
+ ...headers2,
224
+ [key]: String(value)
225
+ }), {});
226
+ if (isStringWithValue(token)) {
227
+ headers["Authorization"] = `Bearer ${token}`;
228
+ }
229
+ if (isStringWithValue(username) && isStringWithValue(password)) {
230
+ const credentials = base64(`${username}:${password}`);
231
+ headers["Authorization"] = `Basic ${credentials}`;
232
+ }
233
+ if (options.body !== void 0) {
234
+ if (options.mediaType) {
235
+ headers["Content-Type"] = options.mediaType;
236
+ } else if (isBlob(options.body)) {
237
+ headers["Content-Type"] = options.body.type || "application/octet-stream";
238
+ } else if (isString(options.body)) {
239
+ headers["Content-Type"] = "text/plain";
240
+ } else if (!isFormData(options.body)) {
241
+ headers["Content-Type"] = "application/json";
242
+ }
243
+ }
244
+ return new Headers(headers);
245
+ };
246
+ var getRequestBody = (options) => {
247
+ if (options.body !== void 0) {
248
+ if (options.mediaType?.includes("/json")) {
249
+ return JSON.stringify(options.body);
250
+ } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
251
+ return options.body;
252
+ } else {
253
+ return JSON.stringify(options.body);
254
+ }
255
+ }
256
+ return void 0;
257
+ };
258
+ var sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
259
+ const controller = new AbortController();
260
+ const request2 = {
261
+ headers,
262
+ body: body ?? formData,
263
+ method: options.method,
264
+ signal: controller.signal
265
+ };
266
+ if (config.WITH_CREDENTIALS) {
267
+ request2.credentials = config.CREDENTIALS;
268
+ }
269
+ onCancel(() => controller.abort());
270
+ return await fetch(url, request2);
271
+ };
272
+ var getResponseHeader = (response, responseHeader) => {
273
+ if (responseHeader) {
274
+ const content = response.headers.get(responseHeader);
275
+ if (isString(content)) {
276
+ return content;
277
+ }
278
+ }
279
+ return void 0;
280
+ };
281
+ var getResponseBody = async (response) => {
282
+ if (response.status !== 204) {
283
+ try {
284
+ const contentType = response.headers.get("Content-Type");
285
+ if (contentType) {
286
+ const jsonTypes = ["application/json", "application/problem+json"];
287
+ const isJSON = jsonTypes.some((type) => contentType.toLowerCase().startsWith(type));
288
+ if (isJSON) {
289
+ return await response.json();
290
+ } else {
291
+ return await response.text();
292
+ }
293
+ }
294
+ } catch (error) {
295
+ console.error(error);
296
+ }
297
+ }
298
+ return void 0;
299
+ };
300
+ var catchErrorCodes = (options, result) => {
301
+ const errors = {
302
+ 400: "Bad Request",
303
+ 401: "Unauthorized",
304
+ 403: "Forbidden",
305
+ 404: "Not Found",
306
+ 500: "Internal Server Error",
307
+ 502: "Bad Gateway",
308
+ 503: "Service Unavailable",
309
+ ...options.errors
310
+ };
311
+ const error = errors[result.status];
312
+ if (error) {
313
+ throw new ApiError(options, result, error);
314
+ }
315
+ if (!result.ok) {
316
+ const errorStatus = result.status ?? "unknown";
317
+ const errorStatusText = result.statusText ?? "unknown";
318
+ const errorBody = (() => {
319
+ try {
320
+ return JSON.stringify(result.body, null, 2);
321
+ } catch (e) {
322
+ return void 0;
323
+ }
324
+ })();
325
+ throw new ApiError(
326
+ options,
327
+ result,
328
+ `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`
329
+ );
330
+ }
331
+ };
332
+ var request = (config, options) => {
333
+ return new CancelablePromise(async (resolve2, reject, onCancel) => {
334
+ try {
335
+ const url = getUrl(config, options);
336
+ const formData = getFormData(options);
337
+ const body = getRequestBody(options);
338
+ const headers = await getHeaders(config, options);
339
+ if (!onCancel.isCancelled) {
340
+ const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
341
+ const responseBody = await getResponseBody(response);
342
+ const responseHeader = getResponseHeader(response, options.responseHeader);
343
+ const result = {
344
+ url,
345
+ ok: response.ok,
346
+ status: response.status,
347
+ statusText: response.statusText,
348
+ body: responseHeader ?? responseBody
349
+ };
350
+ catchErrorCodes(options, result);
351
+ resolve2(result.body);
352
+ }
353
+ } catch (error) {
354
+ reject(error);
355
+ }
356
+ });
357
+ };
358
+
359
+ // src/core/FetchHttpRequest.ts
360
+ var FetchHttpRequest = class extends BaseHttpRequest {
361
+ constructor(config) {
362
+ super(config);
363
+ }
364
+ /**
365
+ * Request method
366
+ * @param options The request options from the service
367
+ * @returns CancelablePromise<T>
368
+ * @throws ApiError
369
+ */
370
+ request(options) {
371
+ return request(this.config, options);
372
+ }
373
+ };
374
+
375
+ // src/services/ApplicationsService.ts
376
+ var ApplicationsService = class {
377
+ constructor(httpRequest) {
378
+ this.httpRequest = httpRequest;
379
+ }
380
+ /**
381
+ * Get All Applications
382
+ * Retrieve all applications for the organization
383
+ * @returns GetAppsResponse Applications retrieved successfully
384
+ * @throws ApiError
385
+ */
386
+ getApps() {
387
+ return this.httpRequest.request({
388
+ method: "GET",
389
+ url: "/api/app",
390
+ errors: {
391
+ 500: `Internal server error`
392
+ }
393
+ });
394
+ }
395
+ /**
396
+ * Create Application
397
+ * Create a new application
398
+ * @param requestBody
399
+ * @returns CreateAppResponse Application created successfully
400
+ * @throws ApiError
401
+ */
402
+ createApp(requestBody) {
403
+ return this.httpRequest.request({
404
+ method: "POST",
405
+ url: "/api/app",
406
+ body: requestBody,
407
+ mediaType: "application/json",
408
+ errors: {
409
+ 500: `Internal server error`
410
+ }
411
+ });
412
+ }
413
+ /**
414
+ * Get Application
415
+ * Retrieve a specific application by ID
416
+ * @param id
417
+ * @returns GetAppResponse Application retrieved successfully
418
+ * @throws ApiError
419
+ */
420
+ getApp(id) {
421
+ return this.httpRequest.request({
422
+ method: "GET",
423
+ url: "/api/app/{id}",
424
+ path: {
425
+ "id": id
426
+ },
427
+ errors: {
428
+ 500: `Internal server error`
429
+ }
430
+ });
431
+ }
432
+ /**
433
+ * Update Application
434
+ * Update an existing application
435
+ * @param id
436
+ * @param requestBody
437
+ * @returns UpdateAppResponse Application updated successfully
438
+ * @throws ApiError
439
+ */
440
+ updateApp(id, requestBody) {
441
+ return this.httpRequest.request({
442
+ method: "PATCH",
443
+ url: "/api/app/{id}",
444
+ path: {
445
+ "id": id
446
+ },
447
+ body: requestBody,
448
+ mediaType: "application/json",
449
+ errors: {
450
+ 500: `Internal server error`
451
+ }
452
+ });
453
+ }
454
+ /**
455
+ * Delete Application
456
+ * Delete an existing application
457
+ * @param id
458
+ * @returns DeleteAppResponse Application deleted successfully
459
+ * @throws ApiError
460
+ */
461
+ deleteApp(id) {
462
+ return this.httpRequest.request({
463
+ method: "DELETE",
464
+ url: "/api/app/{id}",
465
+ path: {
466
+ "id": id
467
+ },
468
+ errors: {
469
+ 500: `Internal server error`
470
+ }
471
+ });
472
+ }
473
+ };
474
+
475
+ // src/services/AuditLogsService.ts
476
+ var AuditLogsService = class {
477
+ constructor(httpRequest) {
478
+ this.httpRequest = httpRequest;
479
+ }
480
+ /**
481
+ * Get Audit Logs
482
+ * Retrieve audit logs for the organization with pagination
483
+ * @param page
484
+ * @param perPage
485
+ * @returns GetAuditLogsResponse Audit logs retrieved successfully
486
+ * @throws ApiError
487
+ */
488
+ getAuditLogs(page = 1, perPage = 20) {
489
+ return this.httpRequest.request({
490
+ method: "GET",
491
+ url: "/api/audit_log",
492
+ query: {
493
+ "page": page,
494
+ "per_page": perPage
495
+ },
496
+ errors: {
497
+ 500: `Internal server error`
498
+ }
499
+ });
500
+ }
501
+ };
502
+
503
+ // src/services/AuthenticationService.ts
504
+ var AuthenticationService = class {
505
+ constructor(httpRequest) {
506
+ this.httpRequest = httpRequest;
507
+ }
508
+ /**
509
+ * Get Current User
510
+ * Retrieve the current authenticated user's information and their organization details
511
+ * @returns WhoAmIResponse User information retrieved successfully
512
+ * @throws ApiError
513
+ */
514
+ whoami() {
515
+ return this.httpRequest.request({
516
+ method: "GET",
517
+ url: "/api/auth/me",
518
+ errors: {
519
+ 500: `Internal server error`
520
+ }
521
+ });
522
+ }
523
+ };
524
+
525
+ // src/services/EnvironmentTypesService.ts
526
+ var EnvironmentTypesService = class {
527
+ constructor(httpRequest) {
528
+ this.httpRequest = httpRequest;
529
+ }
530
+ /**
531
+ * Get Environment Types
532
+ * Retrieve all environment types for the organization
533
+ * @returns EnvTypesResponse Environment types retrieved successfully
534
+ * @throws ApiError
535
+ */
536
+ getEnvTypes() {
537
+ return this.httpRequest.request({
538
+ method: "GET",
539
+ url: "/api/env_type",
540
+ errors: {
541
+ 500: `Internal server error`
542
+ }
543
+ });
544
+ }
545
+ /**
546
+ * Create Environment Type
547
+ * Create a new environment type
548
+ * @param requestBody
549
+ * @returns EnvTypeResponse Environment type created successfully
550
+ * @throws ApiError
551
+ */
552
+ createEnvType(requestBody) {
553
+ return this.httpRequest.request({
554
+ method: "POST",
555
+ url: "/api/env_type",
556
+ body: requestBody,
557
+ mediaType: "application/json",
558
+ errors: {
559
+ 500: `Internal server error`
560
+ }
561
+ });
562
+ }
563
+ /**
564
+ * Get Environment Type
565
+ * Retrieve a specific environment type
566
+ * @param id
567
+ * @returns EnvTypeResponse Environment type retrieved successfully
568
+ * @throws ApiError
569
+ */
570
+ getEnvType(id) {
571
+ return this.httpRequest.request({
572
+ method: "GET",
573
+ url: "/api/env_type/{id}",
574
+ path: {
575
+ "id": id
576
+ },
577
+ errors: {
578
+ 500: `Internal server error`
579
+ }
580
+ });
581
+ }
582
+ /**
583
+ * Update Environment Type
584
+ * Update an existing environment type
585
+ * @param id
586
+ * @param requestBody
587
+ * @returns EnvTypeResponse Environment type updated successfully
588
+ * @throws ApiError
589
+ */
590
+ updateEnvType(id, requestBody) {
591
+ return this.httpRequest.request({
592
+ method: "PATCH",
593
+ url: "/api/env_type/{id}",
594
+ path: {
595
+ "id": id
596
+ },
597
+ body: requestBody,
598
+ mediaType: "application/json",
599
+ errors: {
600
+ 500: `Internal server error`
601
+ }
602
+ });
603
+ }
604
+ /**
605
+ * Delete Environment Type
606
+ * Delete an existing environment type
607
+ * @param id
608
+ * @returns DeleteEnvTypeRequest Environment type deleted successfully
609
+ * @throws ApiError
610
+ */
611
+ deleteEnvType(id) {
612
+ return this.httpRequest.request({
613
+ method: "DELETE",
614
+ url: "/api/env_type/{id}",
615
+ path: {
616
+ "id": id
617
+ },
618
+ errors: {
619
+ 500: `Internal server error`
620
+ }
621
+ });
622
+ }
623
+ };
624
+
625
+ // src/services/EnvironmentVariablesService.ts
626
+ var EnvironmentVariablesService = class {
627
+ constructor(httpRequest) {
628
+ this.httpRequest = httpRequest;
629
+ }
630
+ /**
631
+ * Get Environment Variables
632
+ * Retrieve all environment variables for an application and environment type
633
+ * @param requestBody
634
+ * @returns EnvsResponse Environment variables retrieved successfully
635
+ * @throws ApiError
636
+ */
637
+ getEnvs(requestBody) {
638
+ return this.httpRequest.request({
639
+ method: "POST",
640
+ url: "/api/env",
641
+ body: requestBody,
642
+ mediaType: "application/json",
643
+ errors: {
644
+ 500: `Internal server error`
645
+ }
646
+ });
647
+ }
648
+ /**
649
+ * Delete Environment Variable
650
+ * Delete an existing environment variable
651
+ * @param requestBody
652
+ * @returns DeleteEnvRequest Environment variable deleted successfully
653
+ * @throws ApiError
654
+ */
655
+ deleteEnv(requestBody) {
656
+ return this.httpRequest.request({
657
+ method: "DELETE",
658
+ url: "/api/env",
659
+ body: requestBody,
660
+ mediaType: "application/json",
661
+ errors: {
662
+ 500: `Internal server error`
663
+ }
664
+ });
665
+ }
666
+ /**
667
+ * Get Single Environment Variable
668
+ * Retrieve a specific environment variable
669
+ * @param key
670
+ * @param requestBody
671
+ * @returns EnvResponse Environment variable retrieved successfully
672
+ * @throws ApiError
673
+ */
674
+ getEnv(key, requestBody) {
675
+ return this.httpRequest.request({
676
+ method: "POST",
677
+ url: "/api/env/{key}",
678
+ path: {
679
+ "key": key
680
+ },
681
+ body: requestBody,
682
+ mediaType: "application/json",
683
+ errors: {
684
+ 500: `Internal server error`
685
+ }
686
+ });
687
+ }
688
+ /**
689
+ * Update Environment Variable
690
+ * Update an existing environment variable
691
+ * @param key
692
+ * @param requestBody
693
+ * @returns EnvResponse Environment variable updated successfully
694
+ * @throws ApiError
695
+ */
696
+ updateEnv(key, requestBody) {
697
+ return this.httpRequest.request({
698
+ method: "PATCH",
699
+ url: "/api/env/{key}",
700
+ path: {
701
+ "key": key
702
+ },
703
+ body: requestBody,
704
+ mediaType: "application/json",
705
+ errors: {
706
+ 500: `Internal server error`
707
+ }
708
+ });
709
+ }
710
+ /**
711
+ * Create Environment Variable
712
+ * Create a new environment variable
713
+ * @param requestBody
714
+ * @returns EnvResponse Environment variable created successfully
715
+ * @throws ApiError
716
+ */
717
+ createEnv(requestBody) {
718
+ return this.httpRequest.request({
719
+ method: "PUT",
720
+ url: "/api/env/single",
721
+ body: requestBody,
722
+ mediaType: "application/json",
723
+ errors: {
724
+ 500: `Internal server error`
725
+ }
726
+ });
727
+ }
728
+ /**
729
+ * Batch Create Environment Variables
730
+ * Create multiple environment variables in a single request
731
+ * @param requestBody
732
+ * @returns EnvsResponse Environment variables created successfully
733
+ * @throws ApiError
734
+ */
735
+ batchCreateEnvs(requestBody) {
736
+ return this.httpRequest.request({
737
+ method: "PUT",
738
+ url: "/api/env/batch",
739
+ body: requestBody,
740
+ mediaType: "application/json",
741
+ errors: {
742
+ 500: `Internal server error`
743
+ }
744
+ });
745
+ }
746
+ };
747
+
748
+ // src/services/OnboardingService.ts
749
+ var OnboardingService = class {
750
+ constructor(httpRequest) {
751
+ this.httpRequest = httpRequest;
752
+ }
753
+ /**
754
+ * Create Organization Invite
755
+ * Create an organization invite
756
+ * @param requestBody
757
+ * @returns CreateOrgInviteResponse Successful greeting response
758
+ * @throws ApiError
759
+ */
760
+ createOrgInvite(requestBody) {
761
+ return this.httpRequest.request({
762
+ method: "POST",
763
+ url: "/api/onboarding/org",
764
+ body: requestBody,
765
+ mediaType: "application/json",
766
+ errors: {
767
+ 500: `Internal server error`
768
+ }
769
+ });
770
+ }
771
+ /**
772
+ * Get Organization Invite by Code
773
+ * Get organization invite by code
774
+ * @param inviteCode
775
+ * @returns GetOrgInviteByCodeResponse Organization invite retrieved successfully
776
+ * @throws ApiError
777
+ */
778
+ getOrgInviteByCode(inviteCode) {
779
+ return this.httpRequest.request({
780
+ method: "GET",
781
+ url: "/api/onboarding/org/{invite_code}",
782
+ path: {
783
+ "invite_code": inviteCode
784
+ },
785
+ errors: {
786
+ 500: `Internal server error`
787
+ }
788
+ });
789
+ }
790
+ /**
791
+ * Accept Organization Invite
792
+ * Accept organization invite
793
+ * @param inviteCode
794
+ * @param requestBody
795
+ * @returns AcceptOrgInviteResponse Organization invite accepted successfully
796
+ * @throws ApiError
797
+ */
798
+ acceptOrgInvite(inviteCode, requestBody) {
799
+ return this.httpRequest.request({
800
+ method: "PUT",
801
+ url: "/api/onboarding/org/{invite_code}/accept",
802
+ path: {
803
+ "invite_code": inviteCode
804
+ },
805
+ body: requestBody,
806
+ mediaType: "application/json",
807
+ errors: {
808
+ 500: `Internal server error`
809
+ }
810
+ });
811
+ }
812
+ /**
813
+ * Get User Invite by Code
814
+ * Get user invite by code
815
+ * @param inviteCode
816
+ * @returns GetUserInviteByTokenResponse User invite retrieved successfully
817
+ * @throws ApiError
818
+ */
819
+ getUserInviteByCode(inviteCode) {
820
+ return this.httpRequest.request({
821
+ method: "GET",
822
+ url: "/api/onboarding/user/{invite_code}",
823
+ path: {
824
+ "invite_code": inviteCode
825
+ },
826
+ errors: {
827
+ 500: `Internal server error`
828
+ }
829
+ });
830
+ }
831
+ /**
832
+ * Update User Invite
833
+ * Update user invite
834
+ * @param inviteCode
835
+ * @param requestBody
836
+ * @returns UpdateUserInviteResponse User invite updated successfully
837
+ * @throws ApiError
838
+ */
839
+ updateUserInvite(inviteCode, requestBody) {
840
+ return this.httpRequest.request({
841
+ method: "PATCH",
842
+ url: "/api/onboarding/user/{invite_code}",
843
+ path: {
844
+ "invite_code": inviteCode
845
+ },
846
+ body: requestBody,
847
+ mediaType: "application/json",
848
+ errors: {
849
+ 500: `Internal server error`
850
+ }
851
+ });
852
+ }
853
+ /**
854
+ * Accept User Invite
855
+ * Accept user invite
856
+ * @param inviteCode
857
+ * @param requestBody
858
+ * @returns AcceptUserInviteResponse User invite accepted successfully
859
+ * @throws ApiError
860
+ */
861
+ acceptUserInvite(inviteCode, requestBody) {
862
+ return this.httpRequest.request({
863
+ method: "PUT",
864
+ url: "/api/onboarding/user/{invite_code}/accept",
865
+ path: {
866
+ "invite_code": inviteCode
867
+ },
868
+ body: requestBody,
869
+ mediaType: "application/json",
870
+ errors: {
871
+ 500: `Internal server error`
872
+ }
873
+ });
874
+ }
875
+ /**
876
+ * Create User Invite
877
+ * Create a user invite
878
+ * @param requestBody
879
+ * @returns CreateUserInviteResponse User invite created successfully
880
+ * @throws ApiError
881
+ */
882
+ createUserInvite(requestBody) {
883
+ return this.httpRequest.request({
884
+ method: "POST",
885
+ url: "/api/onboarding/user",
886
+ body: requestBody,
887
+ mediaType: "application/json",
888
+ errors: {
889
+ 500: `Internal server error`
890
+ }
891
+ });
892
+ }
893
+ /**
894
+ * Delete User Invite
895
+ * Delete user invite
896
+ * @param inviteId
897
+ * @param requestBody
898
+ * @returns DeleteUserInviteResponse User invite deleted successfully
899
+ * @throws ApiError
900
+ */
901
+ deleteUserInvite(inviteId, requestBody) {
902
+ return this.httpRequest.request({
903
+ method: "DELETE",
904
+ url: "/api/onboarding/user/{invite_id}",
905
+ path: {
906
+ "invite_id": inviteId
907
+ },
908
+ body: requestBody,
909
+ mediaType: "application/json",
910
+ errors: {
911
+ 500: `Internal server error`
912
+ }
913
+ });
914
+ }
915
+ };
916
+
917
+ // src/services/OrganizationsService.ts
918
+ var OrganizationsService = class {
919
+ constructor(httpRequest) {
920
+ this.httpRequest = httpRequest;
921
+ }
922
+ /**
923
+ * Get Organization
924
+ * Retrieve the current organization's details
925
+ * @returns OrgResponse Organization retrieved successfully
926
+ * @throws ApiError
927
+ */
928
+ getOrg() {
929
+ return this.httpRequest.request({
930
+ method: "GET",
931
+ url: "/api/org",
932
+ errors: {
933
+ 500: `Internal server error`
934
+ }
935
+ });
936
+ }
937
+ /**
938
+ * Update Organization
939
+ * Update the current organization's details
940
+ * @param requestBody
941
+ * @returns OrgResponse Organization updated successfully
942
+ * @throws ApiError
943
+ */
944
+ updateOrg(requestBody) {
945
+ return this.httpRequest.request({
946
+ method: "PATCH",
947
+ url: "/api/org",
948
+ body: requestBody,
949
+ mediaType: "application/json",
950
+ errors: {
951
+ 500: `Internal server error`
952
+ }
953
+ });
954
+ }
955
+ /**
956
+ * Check Slug Availability
957
+ * Check if an organization slug is available
958
+ * @param slug
959
+ * @returns CheckSlugResponse Slug availability checked successfully
960
+ * @throws ApiError
961
+ */
962
+ checkIfSlugExists(slug) {
963
+ return this.httpRequest.request({
964
+ method: "GET",
965
+ url: "/api/org/check-slug",
966
+ query: {
967
+ "slug": slug
968
+ },
969
+ errors: {
970
+ 500: `Internal server error`
971
+ }
972
+ });
973
+ }
974
+ };
975
+
976
+ // src/services/UsersService.ts
977
+ var UsersService = class {
978
+ constructor(httpRequest) {
979
+ this.httpRequest = httpRequest;
980
+ }
981
+ /**
982
+ * Get All Users
983
+ * Retrieve all users in the organization
984
+ * @returns UsersResponse Users retrieved successfully
985
+ * @throws ApiError
986
+ */
987
+ getUsers() {
988
+ return this.httpRequest.request({
989
+ method: "GET",
990
+ url: "/api/user",
991
+ errors: {
992
+ 500: `Internal server error`
993
+ }
994
+ });
995
+ }
996
+ /**
997
+ * Get User by ID
998
+ * Retrieve a specific user by their ID
999
+ * @param id
1000
+ * @returns UserResponse User retrieved successfully
1001
+ * @throws ApiError
1002
+ */
1003
+ getUserById(id) {
1004
+ return this.httpRequest.request({
1005
+ method: "GET",
1006
+ url: "/api/user/{id}",
1007
+ path: {
1008
+ "id": id
1009
+ },
1010
+ errors: {
1011
+ 500: `Internal server error`
1012
+ }
1013
+ });
1014
+ }
1015
+ /**
1016
+ * Update User
1017
+ * Update a user's profile information
1018
+ * @param id
1019
+ * @param requestBody
1020
+ * @returns UserResponse User updated successfully
1021
+ * @throws ApiError
1022
+ */
1023
+ updateUser(id, requestBody) {
1024
+ return this.httpRequest.request({
1025
+ method: "PATCH",
1026
+ url: "/api/user/{id}",
1027
+ path: {
1028
+ "id": id
1029
+ },
1030
+ body: requestBody,
1031
+ mediaType: "application/json",
1032
+ errors: {
1033
+ 500: `Internal server error`
1034
+ }
1035
+ });
1036
+ }
1037
+ /**
1038
+ * Delete User
1039
+ * Delete a user from the organization (Admin only)
1040
+ * @param id
1041
+ * @returns UserResponse User deleted successfully
1042
+ * @throws ApiError
1043
+ */
1044
+ deleteUser(id) {
1045
+ return this.httpRequest.request({
1046
+ method: "DELETE",
1047
+ url: "/api/user/{id}",
1048
+ path: {
1049
+ "id": id
1050
+ },
1051
+ errors: {
1052
+ 500: `Internal server error`
1053
+ }
1054
+ });
1055
+ }
1056
+ /**
1057
+ * Update User Role
1058
+ * Update a user's role (Admin only)
1059
+ * @param id
1060
+ * @param requestBody
1061
+ * @returns UserResponse User role updated successfully
1062
+ * @throws ApiError
1063
+ */
1064
+ updateRole(id, requestBody) {
1065
+ return this.httpRequest.request({
1066
+ method: "PATCH",
1067
+ url: "/api/user/role/{id}",
1068
+ path: {
1069
+ "id": id
1070
+ },
1071
+ body: requestBody,
1072
+ mediaType: "application/json",
1073
+ errors: {
1074
+ 500: `Internal server error`
1075
+ }
1076
+ });
1077
+ }
1078
+ /**
1079
+ * Update User Password
1080
+ * Update a user's password (Admin only)
1081
+ * @param id
1082
+ * @param requestBody
1083
+ * @returns UserResponse Password update request sent successfully
1084
+ * @throws ApiError
1085
+ */
1086
+ updatePassword(id, requestBody) {
1087
+ return this.httpRequest.request({
1088
+ method: "PATCH",
1089
+ url: "/api/user/password/{id}",
1090
+ path: {
1091
+ "id": id
1092
+ },
1093
+ body: requestBody,
1094
+ mediaType: "application/json",
1095
+ errors: {
1096
+ 500: `Internal server error`
1097
+ }
1098
+ });
1099
+ }
1100
+ };
1101
+
1102
+ // src/EnvSyncAPISDK.ts
1103
+ var EnvSyncAPISDK = class {
1104
+ applications;
1105
+ auditLogs;
1106
+ authentication;
1107
+ environmentTypes;
1108
+ environmentVariables;
1109
+ onboarding;
1110
+ organizations;
1111
+ users;
1112
+ request;
1113
+ constructor(config, HttpRequest = FetchHttpRequest) {
1114
+ this.request = new HttpRequest({
1115
+ BASE: config?.BASE ?? "http://localhost:8600",
1116
+ VERSION: config?.VERSION ?? "0.0.0",
1117
+ WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
1118
+ CREDENTIALS: config?.CREDENTIALS ?? "include",
1119
+ TOKEN: config?.TOKEN,
1120
+ USERNAME: config?.USERNAME,
1121
+ PASSWORD: config?.PASSWORD,
1122
+ HEADERS: config?.HEADERS,
1123
+ ENCODE_PATH: config?.ENCODE_PATH
1124
+ });
1125
+ this.applications = new ApplicationsService(this.request);
1126
+ this.auditLogs = new AuditLogsService(this.request);
1127
+ this.authentication = new AuthenticationService(this.request);
1128
+ this.environmentTypes = new EnvironmentTypesService(this.request);
1129
+ this.environmentVariables = new EnvironmentVariablesService(this.request);
1130
+ this.onboarding = new OnboardingService(this.request);
1131
+ this.organizations = new OrganizationsService(this.request);
1132
+ this.users = new UsersService(this.request);
1133
+ }
1134
+ };
1135
+
1136
+ // src/core/OpenAPI.ts
1137
+ var OpenAPI = {
1138
+ BASE: "http://localhost:8600",
1139
+ VERSION: "0.0.0",
1140
+ WITH_CREDENTIALS: false,
1141
+ CREDENTIALS: "include",
1142
+ TOKEN: void 0,
1143
+ USERNAME: void 0,
1144
+ PASSWORD: void 0,
1145
+ HEADERS: void 0,
1146
+ ENCODE_PATH: void 0
1147
+ };
1148
+ export {
1149
+ ApiError,
1150
+ ApplicationsService,
1151
+ AuditLogsService,
1152
+ AuthenticationService,
1153
+ BaseHttpRequest,
1154
+ CancelError,
1155
+ CancelablePromise,
1156
+ EnvSyncAPISDK,
1157
+ EnvironmentTypesService,
1158
+ EnvironmentVariablesService,
1159
+ OnboardingService,
1160
+ OpenAPI,
1161
+ OrganizationsService,
1162
+ UsersService
1163
+ };