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