@centia-io/sdk 0.0.43 → 0.0.45
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/LICENSE +21 -21
- package/README.md +570 -570
- package/dist/centia-io-sdk.cjs +859 -61
- package/dist/centia-io-sdk.d.cts +803 -58
- package/dist/centia-io-sdk.d.cts.map +1 -1
- package/dist/centia-io-sdk.d.ts +803 -58
- package/dist/centia-io-sdk.d.ts.map +1 -1
- package/dist/centia-io-sdk.js +854 -61
- package/dist/centia-io-sdk.js.map +1 -1
- package/dist/centia-io-sdk.umd.js +2037 -1239
- package/package.json +33 -36
package/dist/centia-io-sdk.js
CHANGED
|
@@ -79,6 +79,12 @@ function getStorage() {
|
|
|
79
79
|
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/util/utils.ts
|
|
82
|
+
/**
|
|
83
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
84
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
85
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
82
88
|
const generatePkceChallenge = async () => {
|
|
83
89
|
const generateRandomString = () => {
|
|
84
90
|
const array = new Uint32Array(28);
|
|
@@ -160,7 +166,8 @@ const setOptions = (options) => {
|
|
|
160
166
|
getStorage().setItem("gc2_options", JSON.stringify({
|
|
161
167
|
"clientId": options.clientId,
|
|
162
168
|
"host": options.host,
|
|
163
|
-
"redirectUri": options.redirectUri
|
|
169
|
+
"redirectUri": options.redirectUri,
|
|
170
|
+
"clientSecret": options.clientSecret || null
|
|
164
171
|
}));
|
|
165
172
|
};
|
|
166
173
|
const getOptions = () => {
|
|
@@ -187,6 +194,12 @@ const clearNonce = () => {
|
|
|
187
194
|
|
|
188
195
|
//#endregion
|
|
189
196
|
//#region src/services/gc2.services.ts
|
|
197
|
+
/**
|
|
198
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
199
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
200
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
201
|
+
*
|
|
202
|
+
*/
|
|
190
203
|
var Gc2Service = class {
|
|
191
204
|
constructor(options) {
|
|
192
205
|
this.options = options;
|
|
@@ -297,6 +310,7 @@ var Gc2Service = class {
|
|
|
297
310
|
const path = `${this.host}/api/v4/oauth`;
|
|
298
311
|
return this.request(this.buildUrl(path), "POST", {
|
|
299
312
|
client_id: this.options.clientId,
|
|
313
|
+
client_secret: this.options.clientSecret,
|
|
300
314
|
grant_type: "password",
|
|
301
315
|
username,
|
|
302
316
|
password,
|
|
@@ -322,6 +336,12 @@ var Gc2Service = class {
|
|
|
322
336
|
|
|
323
337
|
//#endregion
|
|
324
338
|
//#region src/CodeFlow.ts
|
|
339
|
+
/**
|
|
340
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
341
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
342
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
343
|
+
*
|
|
344
|
+
*/
|
|
325
345
|
var CodeFlow = class {
|
|
326
346
|
constructor(options) {
|
|
327
347
|
this.options = options;
|
|
@@ -380,6 +400,12 @@ var CodeFlow = class {
|
|
|
380
400
|
|
|
381
401
|
//#endregion
|
|
382
402
|
//#region src/PasswordFlow.ts
|
|
403
|
+
/**
|
|
404
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
405
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
406
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
407
|
+
*
|
|
408
|
+
*/
|
|
383
409
|
var PasswordFlow = class {
|
|
384
410
|
constructor(options) {
|
|
385
411
|
this.options = options;
|
|
@@ -394,7 +420,8 @@ var PasswordFlow = class {
|
|
|
394
420
|
setOptions({
|
|
395
421
|
clientId: this.options.clientId,
|
|
396
422
|
host: this.options.host,
|
|
397
|
-
redirectUri: ""
|
|
423
|
+
redirectUri: "",
|
|
424
|
+
clientSecret: this.options.clientSecret
|
|
398
425
|
});
|
|
399
426
|
}
|
|
400
427
|
signOut() {
|
|
@@ -408,79 +435,242 @@ var PasswordFlow = class {
|
|
|
408
435
|
};
|
|
409
436
|
|
|
410
437
|
//#endregion
|
|
411
|
-
//#region src/
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
438
|
+
//#region src/http/errors.ts
|
|
439
|
+
/**
|
|
440
|
+
* Normalized error thrown by all SDK HTTP operations.
|
|
441
|
+
* CLI and Web should catch this type for consistent error handling.
|
|
442
|
+
*/
|
|
443
|
+
var CentiaApiError = class extends Error {
|
|
444
|
+
constructor(opts) {
|
|
445
|
+
super(opts.message);
|
|
446
|
+
this.name = "CentiaApiError";
|
|
447
|
+
if (opts.cause !== void 0) this.cause = opts.cause;
|
|
448
|
+
this.status = opts.status;
|
|
449
|
+
this.code = opts.code;
|
|
450
|
+
this.details = opts.details;
|
|
451
|
+
this.requestId = opts.requestId;
|
|
452
|
+
this.method = opts.method;
|
|
453
|
+
this.url = opts.url;
|
|
454
|
+
}
|
|
422
455
|
};
|
|
423
|
-
|
|
456
|
+
/** Type guard for CentiaApiError. */
|
|
457
|
+
function isCentiaApiError(e) {
|
|
458
|
+
return e instanceof CentiaApiError;
|
|
459
|
+
}
|
|
424
460
|
|
|
425
461
|
//#endregion
|
|
426
|
-
//#region src/
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
462
|
+
//#region src/http/client.ts
|
|
463
|
+
/**
|
|
464
|
+
* Unified HTTP client for the Centia API.
|
|
465
|
+
* Works in both Node.js and browser environments.
|
|
466
|
+
*/
|
|
467
|
+
var CentiaHttpClient = class {
|
|
468
|
+
constructor(config) {
|
|
469
|
+
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
470
|
+
this.auth = config.auth ?? {};
|
|
471
|
+
this.fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
472
|
+
this.userAgent = config.userAgent;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Execute an HTTP request against the Centia API.
|
|
476
|
+
* Returns parsed JSON on success. Throws CentiaApiError on non-expected status.
|
|
477
|
+
*/
|
|
478
|
+
async request(opts) {
|
|
479
|
+
return (await this.requestFull(opts)).body;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Execute an HTTP request and return the full response including headers.
|
|
483
|
+
* Useful for operations that return Location headers (POST 201, PATCH 303).
|
|
484
|
+
*/
|
|
485
|
+
async requestFull(opts) {
|
|
486
|
+
const url = this.buildUrl(opts.path, opts.query);
|
|
487
|
+
const headers = await this.buildHeaders(opts);
|
|
488
|
+
const init = {
|
|
489
|
+
method: opts.method,
|
|
490
|
+
headers,
|
|
491
|
+
redirect: "manual"
|
|
492
|
+
};
|
|
493
|
+
if (opts.body !== void 0 && opts.body !== null) init.body = this.resolveContentType(opts.contentType) === "application/json" ? JSON.stringify(opts.body) : opts.body;
|
|
494
|
+
const response = await this.fetchFn(url, init);
|
|
495
|
+
if (response.type === "opaqueredirect") {
|
|
496
|
+
if ((opts.expectedStatus ?? 200) === 303) return {
|
|
497
|
+
body: null,
|
|
498
|
+
status: 303,
|
|
499
|
+
getHeader: (name) => name.toLowerCase() === "location" ? response.url : null
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
return {
|
|
503
|
+
body: await this.handleResponse(response, opts, url),
|
|
504
|
+
status: response.status,
|
|
505
|
+
getHeader: (name) => response.headers.get(name)
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
buildUrl(path, query) {
|
|
509
|
+
const cleanPath = path.replace(/^\/+/, "");
|
|
510
|
+
let url = `${this.baseUrl}/${cleanPath}`;
|
|
511
|
+
if (query) {
|
|
512
|
+
const params = new URLSearchParams(query);
|
|
513
|
+
url += `?${params.toString()}`;
|
|
514
|
+
}
|
|
515
|
+
return url;
|
|
516
|
+
}
|
|
517
|
+
async buildHeaders(opts) {
|
|
518
|
+
const headers = { "Accept": opts.accept ?? "application/json" };
|
|
519
|
+
if (this.auth.getAccessToken) {
|
|
520
|
+
const token = await this.auth.getAccessToken();
|
|
521
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
522
|
+
}
|
|
523
|
+
if (this.auth.getHeaders) {
|
|
524
|
+
const authHeaders = await this.auth.getHeaders();
|
|
525
|
+
Object.assign(headers, authHeaders);
|
|
526
|
+
}
|
|
527
|
+
if (this.userAgent && typeof navigator === "undefined") headers["User-Agent"] = this.userAgent;
|
|
528
|
+
const ct = this.resolveContentType(opts.contentType);
|
|
529
|
+
if (ct) headers["Content-Type"] = ct;
|
|
530
|
+
return headers;
|
|
531
|
+
}
|
|
532
|
+
resolveContentType(contentType) {
|
|
533
|
+
if (contentType === null) return null;
|
|
534
|
+
return contentType ?? "application/json";
|
|
535
|
+
}
|
|
536
|
+
async handleResponse(response, opts, url) {
|
|
537
|
+
const expectedStatus = opts.expectedStatus ?? 200;
|
|
538
|
+
let bodyText = "";
|
|
539
|
+
try {
|
|
540
|
+
bodyText = await response.text();
|
|
541
|
+
} catch {}
|
|
542
|
+
let parsed = null;
|
|
543
|
+
if (bodyText) try {
|
|
544
|
+
parsed = JSON.parse(bodyText);
|
|
545
|
+
} catch {}
|
|
546
|
+
if (response.status !== expectedStatus) throw new CentiaApiError({
|
|
547
|
+
message: (parsed?.message ?? parsed?.error ?? bodyText) || `Unexpected status ${response.status}`,
|
|
548
|
+
status: response.status,
|
|
549
|
+
code: parsed?.code,
|
|
550
|
+
details: parsed,
|
|
551
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
552
|
+
method: opts.method,
|
|
553
|
+
url
|
|
554
|
+
});
|
|
555
|
+
return parsed ?? (bodyText || null);
|
|
556
|
+
}
|
|
436
557
|
};
|
|
437
|
-
|
|
558
|
+
/**
|
|
559
|
+
* Create a new Centia HTTP client.
|
|
560
|
+
*
|
|
561
|
+
* Node.js usage:
|
|
562
|
+
* ```ts
|
|
563
|
+
* const client = createCentiaClient({
|
|
564
|
+
* baseUrl: 'https://example.centia.io',
|
|
565
|
+
* auth: { getAccessToken: async () => process.env.CENTIA_TOKEN },
|
|
566
|
+
* });
|
|
567
|
+
* ```
|
|
568
|
+
*
|
|
569
|
+
* Browser usage:
|
|
570
|
+
* ```ts
|
|
571
|
+
* const client = createCentiaClient({
|
|
572
|
+
* baseUrl: 'https://example.centia.io',
|
|
573
|
+
* auth: { getAccessToken: async () => getStoredToken() },
|
|
574
|
+
* });
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
function createCentiaClient(config) {
|
|
578
|
+
return new CentiaHttpClient(config);
|
|
579
|
+
}
|
|
438
580
|
|
|
439
581
|
//#endregion
|
|
440
|
-
//#region src/
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
582
|
+
//#region src/http/legacy.ts
|
|
583
|
+
/**
|
|
584
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
585
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
586
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
587
|
+
*
|
|
588
|
+
* Legacy bridge: creates a CentiaHttpClient from storage-based options/tokens.
|
|
589
|
+
* Used by existing SDK modules when no explicit client is provided.
|
|
590
|
+
*/
|
|
591
|
+
/**
|
|
592
|
+
* Create a CentiaHttpClient backed by the legacy storage-based auth.
|
|
593
|
+
* The auth callback reads fresh tokens from storage on each request
|
|
594
|
+
* and auto-refreshes expired access tokens via the refresh token.
|
|
595
|
+
*/
|
|
596
|
+
function getLegacyClient() {
|
|
597
|
+
return new CentiaHttpClient({
|
|
598
|
+
baseUrl: getOptions().host,
|
|
599
|
+
auth: { getAccessToken: async () => {
|
|
600
|
+
if (!await isLogin(new Gc2Service(getOptions()))) return;
|
|
601
|
+
return getTokens().accessToken || void 0;
|
|
602
|
+
} }
|
|
603
|
+
});
|
|
604
|
+
}
|
|
457
605
|
|
|
458
606
|
//#endregion
|
|
459
607
|
//#region src/Sql.ts
|
|
460
608
|
var Sql = class {
|
|
609
|
+
constructor(client) {
|
|
610
|
+
this.client = client ?? getLegacyClient();
|
|
611
|
+
}
|
|
461
612
|
async exec(request) {
|
|
462
|
-
return
|
|
613
|
+
return this.client.request({
|
|
614
|
+
path: "api/v4/sql",
|
|
615
|
+
method: "POST",
|
|
616
|
+
body: request
|
|
617
|
+
});
|
|
463
618
|
}
|
|
464
619
|
};
|
|
465
620
|
|
|
466
621
|
//#endregion
|
|
467
622
|
//#region src/Rpc.ts
|
|
468
623
|
var Rpc = class {
|
|
624
|
+
constructor(client) {
|
|
625
|
+
this.client = client ?? getLegacyClient();
|
|
626
|
+
}
|
|
469
627
|
async call(request) {
|
|
470
|
-
return
|
|
628
|
+
return this.client.request({
|
|
629
|
+
path: "api/v4/call",
|
|
630
|
+
method: "POST",
|
|
631
|
+
body: request
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/Gql.ts
|
|
638
|
+
var Gql = class {
|
|
639
|
+
constructor(schema, client) {
|
|
640
|
+
this.schema = schema;
|
|
641
|
+
this.client = client ?? getLegacyClient();
|
|
642
|
+
}
|
|
643
|
+
async request(request) {
|
|
644
|
+
return this.client.request({
|
|
645
|
+
path: `api/graphql/schema/${this.schema}`,
|
|
646
|
+
method: "POST",
|
|
647
|
+
body: request
|
|
648
|
+
});
|
|
471
649
|
}
|
|
472
650
|
};
|
|
473
651
|
|
|
474
652
|
//#endregion
|
|
475
653
|
//#region src/Meta.ts
|
|
476
654
|
var Meta = class {
|
|
655
|
+
constructor(client) {
|
|
656
|
+
this.client = client ?? getLegacyClient();
|
|
657
|
+
}
|
|
477
658
|
async query(rel) {
|
|
478
|
-
return
|
|
659
|
+
return this.client.request({
|
|
660
|
+
path: `api/v4/meta/${rel}`,
|
|
661
|
+
method: "GET"
|
|
662
|
+
});
|
|
479
663
|
}
|
|
480
664
|
};
|
|
481
665
|
|
|
482
666
|
//#endregion
|
|
483
667
|
//#region src/Status.ts
|
|
668
|
+
/**
|
|
669
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
670
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
671
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
672
|
+
*
|
|
673
|
+
*/
|
|
484
674
|
var Status = class {
|
|
485
675
|
isAuth() {
|
|
486
676
|
const tokens = getTokens();
|
|
@@ -493,6 +683,12 @@ var Status = class {
|
|
|
493
683
|
|
|
494
684
|
//#endregion
|
|
495
685
|
//#region src/Claims.ts
|
|
686
|
+
/**
|
|
687
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
688
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
689
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
690
|
+
*
|
|
691
|
+
*/
|
|
496
692
|
var Claims = class {
|
|
497
693
|
get() {
|
|
498
694
|
const tokens = getTokens().accessToken;
|
|
@@ -503,13 +699,25 @@ var Claims = class {
|
|
|
503
699
|
//#endregion
|
|
504
700
|
//#region src/Users.ts
|
|
505
701
|
var Users = class {
|
|
702
|
+
constructor(client) {
|
|
703
|
+
this.client = client ?? getLegacyClient();
|
|
704
|
+
}
|
|
506
705
|
async get(user) {
|
|
507
|
-
return
|
|
706
|
+
return this.client.request({
|
|
707
|
+
path: `api/v4/users/${user}`,
|
|
708
|
+
method: "GET"
|
|
709
|
+
});
|
|
508
710
|
}
|
|
509
711
|
};
|
|
510
712
|
|
|
511
713
|
//#endregion
|
|
512
714
|
//#region src/Ws.ts
|
|
715
|
+
/**
|
|
716
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
717
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
718
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
719
|
+
*
|
|
720
|
+
*/
|
|
513
721
|
var Ws = class {
|
|
514
722
|
constructor(options) {
|
|
515
723
|
this.options = options;
|
|
@@ -547,25 +755,49 @@ var Ws = class {
|
|
|
547
755
|
//#endregion
|
|
548
756
|
//#region src/Stats.ts
|
|
549
757
|
var Stats = class {
|
|
758
|
+
constructor(client) {
|
|
759
|
+
this.client = client ?? getLegacyClient();
|
|
760
|
+
}
|
|
550
761
|
async get() {
|
|
551
|
-
return
|
|
762
|
+
return this.client.request({
|
|
763
|
+
path: "api/v4/stats",
|
|
764
|
+
method: "GET"
|
|
765
|
+
});
|
|
552
766
|
}
|
|
553
767
|
};
|
|
554
768
|
|
|
555
769
|
//#endregion
|
|
556
770
|
//#region src/Tables.ts
|
|
557
771
|
var Tables = class {
|
|
772
|
+
constructor(client) {
|
|
773
|
+
this.client = client ?? getLegacyClient();
|
|
774
|
+
}
|
|
558
775
|
async get(schema, table) {
|
|
559
|
-
return
|
|
776
|
+
return this.client.request({
|
|
777
|
+
path: `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}`,
|
|
778
|
+
method: "GET"
|
|
779
|
+
});
|
|
560
780
|
}
|
|
561
781
|
async create(schema, table, payload) {
|
|
562
|
-
return
|
|
782
|
+
return this.client.request({
|
|
783
|
+
path: `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}`,
|
|
784
|
+
method: "POST",
|
|
785
|
+
body: payload
|
|
786
|
+
});
|
|
563
787
|
}
|
|
564
788
|
async patch(schema, table, payload) {
|
|
565
|
-
return
|
|
789
|
+
return this.client.request({
|
|
790
|
+
path: `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}`,
|
|
791
|
+
method: "PATCH",
|
|
792
|
+
body: payload
|
|
793
|
+
});
|
|
566
794
|
}
|
|
567
795
|
async delete(schema, table) {
|
|
568
|
-
return
|
|
796
|
+
return this.client.request({
|
|
797
|
+
path: `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}`,
|
|
798
|
+
method: "DELETE",
|
|
799
|
+
expectedStatus: 204
|
|
800
|
+
});
|
|
569
801
|
}
|
|
570
802
|
};
|
|
571
803
|
|
|
@@ -592,26 +824,26 @@ function extractDataFromResponse(method, res) {
|
|
|
592
824
|
if (!err || typeof err !== "object") throw new TypeError(`createApi: Invalid RPC error for method "${method}". Expected 'error' to be an object.`);
|
|
593
825
|
const code = err.code;
|
|
594
826
|
const message = err.message;
|
|
595
|
-
const data
|
|
827
|
+
const data = err.data;
|
|
596
828
|
const codeIsNum = typeof code === "number" && Number.isFinite(code);
|
|
597
829
|
const details = typeof message === "string" && message.length > 0 ? message : "Unknown error";
|
|
598
830
|
const e = /* @__PURE__ */ new Error(`createApi: RPC error for method "${method}"${codeIsNum ? ` (${code})` : ""}: ${details}`);
|
|
599
831
|
e.code = code;
|
|
600
|
-
if (data
|
|
832
|
+
if (data !== void 0) e.data = data;
|
|
601
833
|
e.method = method;
|
|
602
834
|
e.name = "JsonRpcError";
|
|
603
835
|
throw e;
|
|
604
836
|
}
|
|
605
837
|
const result = res.result;
|
|
606
838
|
if (!result || typeof result !== "object") throw new TypeError(`createApi: Invalid RPC response for method "${method}". Missing result object.`);
|
|
607
|
-
const
|
|
608
|
-
if (!Array.isArray(
|
|
609
|
-
return
|
|
839
|
+
const dataArr = result.data;
|
|
840
|
+
if (!Array.isArray(dataArr)) throw new TypeError(`createApi: Invalid RPC response for method "${method}". Expected result.data to be an array.`);
|
|
841
|
+
return dataArr;
|
|
610
842
|
}
|
|
611
|
-
async function dispatch(name, paramsLike) {
|
|
843
|
+
async function dispatch(name, paramsLike, client) {
|
|
612
844
|
if (typeof name !== "string" || name.length === 0) throw new TypeError("createApi: RPC method name must be a non-empty string.");
|
|
613
845
|
const params = validateParamsForMethod(String(name), paramsLike);
|
|
614
|
-
const rpc = new Rpc();
|
|
846
|
+
const rpc = new Rpc(client);
|
|
615
847
|
const request = {
|
|
616
848
|
jsonrpc: "2.0",
|
|
617
849
|
method: name,
|
|
@@ -621,17 +853,23 @@ async function dispatch(name, paramsLike) {
|
|
|
621
853
|
const res = await rpc.call(request);
|
|
622
854
|
return extractDataFromResponse(String(name), res);
|
|
623
855
|
}
|
|
624
|
-
function createApi() {
|
|
856
|
+
function createApi(client) {
|
|
625
857
|
return new Proxy({}, { get(_target, prop) {
|
|
626
858
|
if (typeof prop !== "string") return void 0;
|
|
627
859
|
return (...args) => {
|
|
628
|
-
return dispatch(prop, args.length === 0 ? {} : args.length === 1 ? args[0] : args);
|
|
860
|
+
return dispatch(prop, args.length === 0 ? {} : args.length === 1 ? args[0] : args, client);
|
|
629
861
|
};
|
|
630
862
|
} });
|
|
631
863
|
}
|
|
632
864
|
|
|
633
865
|
//#endregion
|
|
634
866
|
//#region src/SignUp.ts
|
|
867
|
+
/**
|
|
868
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
869
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
870
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
871
|
+
*
|
|
872
|
+
*/
|
|
635
873
|
var SignUp = class {
|
|
636
874
|
constructor(options) {
|
|
637
875
|
this.options = options;
|
|
@@ -1421,5 +1659,560 @@ function createSqlBuilder(schema) {
|
|
|
1421
1659
|
}
|
|
1422
1660
|
|
|
1423
1661
|
//#endregion
|
|
1424
|
-
|
|
1662
|
+
//#region src/provisioning/Schemas.ts
|
|
1663
|
+
var Schemas = class {
|
|
1664
|
+
constructor(client) {
|
|
1665
|
+
this.client = client;
|
|
1666
|
+
}
|
|
1667
|
+
async getSchema(schema, opts) {
|
|
1668
|
+
const path = schema ? `api/v4/schemas/${encodeURIComponent(schema)}` : "api/v4/schemas";
|
|
1669
|
+
const query = {};
|
|
1670
|
+
if (opts?.namesOnly) query.namesOnly = "true";
|
|
1671
|
+
return this.client.request({
|
|
1672
|
+
path,
|
|
1673
|
+
method: "GET",
|
|
1674
|
+
query: Object.keys(query).length > 0 ? query : void 0
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
async postSchema(body) {
|
|
1678
|
+
return { location: (await this.client.requestFull({
|
|
1679
|
+
path: "api/v4/schemas",
|
|
1680
|
+
method: "POST",
|
|
1681
|
+
body,
|
|
1682
|
+
expectedStatus: 201
|
|
1683
|
+
})).getHeader("Location") ?? "" };
|
|
1684
|
+
}
|
|
1685
|
+
async patchSchema(schema, body) {
|
|
1686
|
+
return { location: (await this.client.requestFull({
|
|
1687
|
+
path: `api/v4/schemas/${encodeURIComponent(schema)}`,
|
|
1688
|
+
method: "PATCH",
|
|
1689
|
+
body,
|
|
1690
|
+
expectedStatus: 303
|
|
1691
|
+
})).getHeader("Location") ?? "" };
|
|
1692
|
+
}
|
|
1693
|
+
async deleteSchema(schema) {
|
|
1694
|
+
await this.client.request({
|
|
1695
|
+
path: `api/v4/schemas/${encodeURIComponent(schema)}`,
|
|
1696
|
+
method: "DELETE",
|
|
1697
|
+
expectedStatus: 204
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
|
|
1702
|
+
//#endregion
|
|
1703
|
+
//#region src/provisioning/Columns.ts
|
|
1704
|
+
var Columns = class {
|
|
1705
|
+
constructor(client) {
|
|
1706
|
+
this.client = client;
|
|
1707
|
+
}
|
|
1708
|
+
basePath(schema, table) {
|
|
1709
|
+
return `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/columns`;
|
|
1710
|
+
}
|
|
1711
|
+
async getColumn(schema, table, column) {
|
|
1712
|
+
const path = column ? `${this.basePath(schema, table)}/${encodeURIComponent(column)}` : this.basePath(schema, table);
|
|
1713
|
+
return this.client.request({
|
|
1714
|
+
path,
|
|
1715
|
+
method: "GET"
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
async postColumn(schema, table, body) {
|
|
1719
|
+
return { location: (await this.client.requestFull({
|
|
1720
|
+
path: this.basePath(schema, table),
|
|
1721
|
+
method: "POST",
|
|
1722
|
+
body,
|
|
1723
|
+
expectedStatus: 201
|
|
1724
|
+
})).getHeader("Location") ?? "" };
|
|
1725
|
+
}
|
|
1726
|
+
async patchColumn(schema, table, column, body) {
|
|
1727
|
+
return { location: (await this.client.requestFull({
|
|
1728
|
+
path: `${this.basePath(schema, table)}/${encodeURIComponent(column)}`,
|
|
1729
|
+
method: "PATCH",
|
|
1730
|
+
body,
|
|
1731
|
+
expectedStatus: 303
|
|
1732
|
+
})).getHeader("Location") ?? "" };
|
|
1733
|
+
}
|
|
1734
|
+
async deleteColumn(schema, table, column) {
|
|
1735
|
+
await this.client.request({
|
|
1736
|
+
path: `${this.basePath(schema, table)}/${encodeURIComponent(column)}`,
|
|
1737
|
+
method: "DELETE",
|
|
1738
|
+
expectedStatus: 204
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
|
|
1743
|
+
//#endregion
|
|
1744
|
+
//#region src/provisioning/Constraints.ts
|
|
1745
|
+
var Constraints = class {
|
|
1746
|
+
constructor(client) {
|
|
1747
|
+
this.client = client;
|
|
1748
|
+
}
|
|
1749
|
+
basePath(schema, table) {
|
|
1750
|
+
return `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/constraints`;
|
|
1751
|
+
}
|
|
1752
|
+
async getConstraint(schema, table, constraint) {
|
|
1753
|
+
const path = constraint ? `${this.basePath(schema, table)}/${encodeURIComponent(constraint)}` : this.basePath(schema, table);
|
|
1754
|
+
return this.client.request({
|
|
1755
|
+
path,
|
|
1756
|
+
method: "GET"
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
async postConstraint(schema, table, body) {
|
|
1760
|
+
return { location: (await this.client.requestFull({
|
|
1761
|
+
path: this.basePath(schema, table),
|
|
1762
|
+
method: "POST",
|
|
1763
|
+
body,
|
|
1764
|
+
expectedStatus: 201
|
|
1765
|
+
})).getHeader("Location") ?? "" };
|
|
1766
|
+
}
|
|
1767
|
+
async deleteConstraint(schema, table, constraint) {
|
|
1768
|
+
await this.client.request({
|
|
1769
|
+
path: `${this.basePath(schema, table)}/${encodeURIComponent(constraint)}`,
|
|
1770
|
+
method: "DELETE",
|
|
1771
|
+
expectedStatus: 204
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
|
|
1776
|
+
//#endregion
|
|
1777
|
+
//#region src/provisioning/Indices.ts
|
|
1778
|
+
var Indices = class {
|
|
1779
|
+
constructor(client) {
|
|
1780
|
+
this.client = client;
|
|
1781
|
+
}
|
|
1782
|
+
basePath(schema, table) {
|
|
1783
|
+
return `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/indices`;
|
|
1784
|
+
}
|
|
1785
|
+
async getIndex(schema, table, index) {
|
|
1786
|
+
const path = index ? `${this.basePath(schema, table)}/${encodeURIComponent(index)}` : this.basePath(schema, table);
|
|
1787
|
+
return this.client.request({
|
|
1788
|
+
path,
|
|
1789
|
+
method: "GET"
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
async postIndex(schema, table, body) {
|
|
1793
|
+
return { location: (await this.client.requestFull({
|
|
1794
|
+
path: this.basePath(schema, table),
|
|
1795
|
+
method: "POST",
|
|
1796
|
+
body,
|
|
1797
|
+
expectedStatus: 201
|
|
1798
|
+
})).getHeader("Location") ?? "" };
|
|
1799
|
+
}
|
|
1800
|
+
async deleteIndex(schema, table, index) {
|
|
1801
|
+
await this.client.request({
|
|
1802
|
+
path: `${this.basePath(schema, table)}/${encodeURIComponent(index)}`,
|
|
1803
|
+
method: "DELETE",
|
|
1804
|
+
expectedStatus: 204
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
|
|
1809
|
+
//#endregion
|
|
1810
|
+
//#region src/provisioning/Sequences.ts
|
|
1811
|
+
var Sequences = class {
|
|
1812
|
+
constructor(client) {
|
|
1813
|
+
this.client = client;
|
|
1814
|
+
}
|
|
1815
|
+
basePath(schema) {
|
|
1816
|
+
return `api/v4/schemas/${encodeURIComponent(schema)}/sequences`;
|
|
1817
|
+
}
|
|
1818
|
+
async getSequence(schema, sequence) {
|
|
1819
|
+
const path = sequence ? `${this.basePath(schema)}/${encodeURIComponent(sequence)}` : this.basePath(schema);
|
|
1820
|
+
return this.client.request({
|
|
1821
|
+
path,
|
|
1822
|
+
method: "GET"
|
|
1823
|
+
});
|
|
1824
|
+
}
|
|
1825
|
+
async postSequence(schema, body) {
|
|
1826
|
+
return { location: (await this.client.requestFull({
|
|
1827
|
+
path: this.basePath(schema),
|
|
1828
|
+
method: "POST",
|
|
1829
|
+
body,
|
|
1830
|
+
expectedStatus: 201
|
|
1831
|
+
})).getHeader("Location") ?? "" };
|
|
1832
|
+
}
|
|
1833
|
+
async patchSequence(schema, sequence, body) {
|
|
1834
|
+
return { location: (await this.client.requestFull({
|
|
1835
|
+
path: `${this.basePath(schema)}/${encodeURIComponent(sequence)}`,
|
|
1836
|
+
method: "PATCH",
|
|
1837
|
+
body,
|
|
1838
|
+
expectedStatus: 303
|
|
1839
|
+
})).getHeader("Location") ?? "" };
|
|
1840
|
+
}
|
|
1841
|
+
async deleteSequence(schema, sequence) {
|
|
1842
|
+
await this.client.request({
|
|
1843
|
+
path: `${this.basePath(schema)}/${encodeURIComponent(sequence)}`,
|
|
1844
|
+
method: "DELETE",
|
|
1845
|
+
expectedStatus: 204
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
};
|
|
1849
|
+
|
|
1850
|
+
//#endregion
|
|
1851
|
+
//#region src/provisioning/Tables.ts
|
|
1852
|
+
var ProvisioningTables = class {
|
|
1853
|
+
constructor(client) {
|
|
1854
|
+
this.client = client;
|
|
1855
|
+
}
|
|
1856
|
+
basePath(schema) {
|
|
1857
|
+
return `api/v4/schemas/${encodeURIComponent(schema)}/tables`;
|
|
1858
|
+
}
|
|
1859
|
+
async getTable(schema, table) {
|
|
1860
|
+
const path = table ? `${this.basePath(schema)}/${encodeURIComponent(table)}` : this.basePath(schema);
|
|
1861
|
+
return this.client.request({
|
|
1862
|
+
path,
|
|
1863
|
+
method: "GET"
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
async postTable(schema, body) {
|
|
1867
|
+
return { location: (await this.client.requestFull({
|
|
1868
|
+
path: this.basePath(schema),
|
|
1869
|
+
method: "POST",
|
|
1870
|
+
body,
|
|
1871
|
+
expectedStatus: 201
|
|
1872
|
+
})).getHeader("Location") ?? "" };
|
|
1873
|
+
}
|
|
1874
|
+
async patchTable(schema, table, body) {
|
|
1875
|
+
return { location: (await this.client.requestFull({
|
|
1876
|
+
path: `${this.basePath(schema)}/${encodeURIComponent(table)}`,
|
|
1877
|
+
method: "PATCH",
|
|
1878
|
+
body,
|
|
1879
|
+
expectedStatus: 303
|
|
1880
|
+
})).getHeader("Location") ?? "" };
|
|
1881
|
+
}
|
|
1882
|
+
async deleteTable(schema, table) {
|
|
1883
|
+
await this.client.request({
|
|
1884
|
+
path: `${this.basePath(schema)}/${encodeURIComponent(table)}`,
|
|
1885
|
+
method: "DELETE",
|
|
1886
|
+
expectedStatus: 204
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
};
|
|
1890
|
+
|
|
1891
|
+
//#endregion
|
|
1892
|
+
//#region src/provisioning/Users.ts
|
|
1893
|
+
var ProvisioningUsers = class {
|
|
1894
|
+
constructor(client) {
|
|
1895
|
+
this.client = client;
|
|
1896
|
+
}
|
|
1897
|
+
async getUser(name) {
|
|
1898
|
+
const path = name ? `api/v4/users/${encodeURIComponent(name)}` : "api/v4/users";
|
|
1899
|
+
return this.client.request({
|
|
1900
|
+
path,
|
|
1901
|
+
method: "GET"
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
async postUser(body) {
|
|
1905
|
+
return { location: (await this.client.requestFull({
|
|
1906
|
+
path: "api/v4/users",
|
|
1907
|
+
method: "POST",
|
|
1908
|
+
body,
|
|
1909
|
+
expectedStatus: 201
|
|
1910
|
+
})).getHeader("Location") ?? "" };
|
|
1911
|
+
}
|
|
1912
|
+
async patchUser(name, body) {
|
|
1913
|
+
return { location: (await this.client.requestFull({
|
|
1914
|
+
path: `api/v4/users/${encodeURIComponent(name)}`,
|
|
1915
|
+
method: "PATCH",
|
|
1916
|
+
body,
|
|
1917
|
+
expectedStatus: 303
|
|
1918
|
+
})).getHeader("Location") ?? "" };
|
|
1919
|
+
}
|
|
1920
|
+
async deleteUser(name) {
|
|
1921
|
+
await this.client.request({
|
|
1922
|
+
path: `api/v4/users/${encodeURIComponent(name)}`,
|
|
1923
|
+
method: "DELETE",
|
|
1924
|
+
expectedStatus: 204
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1929
|
+
//#endregion
|
|
1930
|
+
//#region src/provisioning/Clients.ts
|
|
1931
|
+
var ProvisioningClients = class {
|
|
1932
|
+
constructor(client) {
|
|
1933
|
+
this.client = client;
|
|
1934
|
+
}
|
|
1935
|
+
async getClient(id) {
|
|
1936
|
+
const path = id ? `api/v4/clients/${encodeURIComponent(id)}` : "api/v4/clients";
|
|
1937
|
+
return this.client.request({
|
|
1938
|
+
path,
|
|
1939
|
+
method: "GET"
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
async postClient(body) {
|
|
1943
|
+
const res = await this.client.requestFull({
|
|
1944
|
+
path: "api/v4/clients",
|
|
1945
|
+
method: "POST",
|
|
1946
|
+
body,
|
|
1947
|
+
expectedStatus: 201
|
|
1948
|
+
});
|
|
1949
|
+
return {
|
|
1950
|
+
location: res.getHeader("Location") ?? "",
|
|
1951
|
+
secret: res.body.secret
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
async patchClient(id, body) {
|
|
1955
|
+
return { location: (await this.client.requestFull({
|
|
1956
|
+
path: `api/v4/clients/${encodeURIComponent(id)}`,
|
|
1957
|
+
method: "PATCH",
|
|
1958
|
+
body,
|
|
1959
|
+
expectedStatus: 303
|
|
1960
|
+
})).getHeader("Location") ?? "" };
|
|
1961
|
+
}
|
|
1962
|
+
async deleteClient(id) {
|
|
1963
|
+
await this.client.request({
|
|
1964
|
+
path: `api/v4/clients/${encodeURIComponent(id)}`,
|
|
1965
|
+
method: "DELETE",
|
|
1966
|
+
expectedStatus: 204
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
|
|
1971
|
+
//#endregion
|
|
1972
|
+
//#region src/provisioning/Rules.ts
|
|
1973
|
+
var Rules = class {
|
|
1974
|
+
constructor(client) {
|
|
1975
|
+
this.client = client;
|
|
1976
|
+
}
|
|
1977
|
+
async getRule(id) {
|
|
1978
|
+
const path = id != null ? `api/v4/rules/${encodeURIComponent(id)}` : "api/v4/rules";
|
|
1979
|
+
return this.client.request({
|
|
1980
|
+
path,
|
|
1981
|
+
method: "GET"
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
async postRule(body) {
|
|
1985
|
+
return this.client.request({
|
|
1986
|
+
path: "api/v4/rules",
|
|
1987
|
+
method: "POST",
|
|
1988
|
+
body,
|
|
1989
|
+
expectedStatus: 201
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
async patchRule(id, body) {
|
|
1993
|
+
return this.client.request({
|
|
1994
|
+
path: `api/v4/rules/${encodeURIComponent(id)}`,
|
|
1995
|
+
method: "PATCH",
|
|
1996
|
+
body
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
async deleteRule(id) {
|
|
2000
|
+
await this.client.request({
|
|
2001
|
+
path: `api/v4/rules/${encodeURIComponent(id)}`,
|
|
2002
|
+
method: "DELETE",
|
|
2003
|
+
expectedStatus: 204
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
|
|
2008
|
+
//#endregion
|
|
2009
|
+
//#region src/provisioning/Privileges.ts
|
|
2010
|
+
var Privileges = class {
|
|
2011
|
+
constructor(client) {
|
|
2012
|
+
this.client = client;
|
|
2013
|
+
}
|
|
2014
|
+
async getPrivileges(schema, table) {
|
|
2015
|
+
return this.client.request({
|
|
2016
|
+
path: `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/privileges`,
|
|
2017
|
+
method: "GET"
|
|
2018
|
+
});
|
|
2019
|
+
}
|
|
2020
|
+
async patchPrivileges(schema, table, body) {
|
|
2021
|
+
return this.client.request({
|
|
2022
|
+
path: `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/privileges`,
|
|
2023
|
+
method: "PATCH",
|
|
2024
|
+
body
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
};
|
|
2028
|
+
|
|
2029
|
+
//#endregion
|
|
2030
|
+
//#region src/provisioning/RpcMethods.ts
|
|
2031
|
+
var RpcMethods = class {
|
|
2032
|
+
constructor(client) {
|
|
2033
|
+
this.client = client;
|
|
2034
|
+
}
|
|
2035
|
+
async getRpc(method) {
|
|
2036
|
+
const path = method ? `api/v4/methods/${encodeURIComponent(method)}` : "api/v4/methods";
|
|
2037
|
+
return this.client.request({
|
|
2038
|
+
path,
|
|
2039
|
+
method: "GET"
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
async postRpc(body) {
|
|
2043
|
+
return { location: (await this.client.requestFull({
|
|
2044
|
+
path: "api/v4/methods",
|
|
2045
|
+
method: "POST",
|
|
2046
|
+
body,
|
|
2047
|
+
expectedStatus: 201
|
|
2048
|
+
})).getHeader("Location") ?? "" };
|
|
2049
|
+
}
|
|
2050
|
+
async patchRpc(method, body) {
|
|
2051
|
+
return { location: (await this.client.requestFull({
|
|
2052
|
+
path: `api/v4/methods/${encodeURIComponent(method)}`,
|
|
2053
|
+
method: "PATCH",
|
|
2054
|
+
body,
|
|
2055
|
+
expectedStatus: 303
|
|
2056
|
+
})).getHeader("Location") ?? "" };
|
|
2057
|
+
}
|
|
2058
|
+
async deleteRpc(method) {
|
|
2059
|
+
await this.client.request({
|
|
2060
|
+
path: `api/v4/methods/${encodeURIComponent(method)}`,
|
|
2061
|
+
method: "DELETE",
|
|
2062
|
+
expectedStatus: 204
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
async postCallDry(body) {
|
|
2066
|
+
return this.client.request({
|
|
2067
|
+
path: "api/v4/call/dry",
|
|
2068
|
+
method: "POST",
|
|
2069
|
+
body
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
};
|
|
2073
|
+
|
|
2074
|
+
//#endregion
|
|
2075
|
+
//#region src/provisioning/MetadataWrite.ts
|
|
2076
|
+
var MetadataWrite = class {
|
|
2077
|
+
constructor(client) {
|
|
2078
|
+
this.client = client;
|
|
2079
|
+
}
|
|
2080
|
+
async patchMetaData(body) {
|
|
2081
|
+
return this.client.request({
|
|
2082
|
+
path: "api/v4/meta",
|
|
2083
|
+
method: "PATCH",
|
|
2084
|
+
body
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
|
|
2089
|
+
//#endregion
|
|
2090
|
+
//#region src/provisioning/TypeScriptInterfaces.ts
|
|
2091
|
+
var TypeScriptInterfaces = class {
|
|
2092
|
+
constructor(client) {
|
|
2093
|
+
this.client = client;
|
|
2094
|
+
}
|
|
2095
|
+
async getTypeScript() {
|
|
2096
|
+
return this.client.request({
|
|
2097
|
+
path: "api/v4/interfaces",
|
|
2098
|
+
method: "GET",
|
|
2099
|
+
accept: "text/plain"
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
};
|
|
2103
|
+
|
|
2104
|
+
//#endregion
|
|
2105
|
+
//#region src/provisioning/FileImport.ts
|
|
2106
|
+
var FileImport = class {
|
|
2107
|
+
constructor(client) {
|
|
2108
|
+
this.client = client;
|
|
2109
|
+
}
|
|
2110
|
+
/**
|
|
2111
|
+
* Upload a file via multipart/form-data.
|
|
2112
|
+
* In Node.js, pass a FormData instance. In browsers, pass a native FormData.
|
|
2113
|
+
*/
|
|
2114
|
+
async postFileUpload(formData) {
|
|
2115
|
+
return this.client.request({
|
|
2116
|
+
path: "api/v4/file/upload",
|
|
2117
|
+
method: "POST",
|
|
2118
|
+
body: formData,
|
|
2119
|
+
contentType: null,
|
|
2120
|
+
expectedStatus: 201
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
async postFileProcess(body) {
|
|
2124
|
+
return this.client.request({
|
|
2125
|
+
path: "api/v4/file/process",
|
|
2126
|
+
method: "POST",
|
|
2127
|
+
body,
|
|
2128
|
+
expectedStatus: 201
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
};
|
|
2132
|
+
|
|
2133
|
+
//#endregion
|
|
2134
|
+
//#region src/provisioning/GitCommit.ts
|
|
2135
|
+
var GitCommit = class {
|
|
2136
|
+
constructor(client) {
|
|
2137
|
+
this.client = client;
|
|
2138
|
+
}
|
|
2139
|
+
async postCommit(body) {
|
|
2140
|
+
return this.client.request({
|
|
2141
|
+
path: "api/v4/commit",
|
|
2142
|
+
method: "POST",
|
|
2143
|
+
body
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
};
|
|
2147
|
+
|
|
2148
|
+
//#endregion
|
|
2149
|
+
//#region src/provisioning/SqlNoToken.ts
|
|
2150
|
+
var SqlNoToken = class {
|
|
2151
|
+
constructor(client) {
|
|
2152
|
+
this.client = client;
|
|
2153
|
+
}
|
|
2154
|
+
async postSqlNoToken(database, body) {
|
|
2155
|
+
return this.client.request({
|
|
2156
|
+
path: `api/v4/sql/database/${encodeURIComponent(database)}`,
|
|
2157
|
+
method: "POST",
|
|
2158
|
+
body
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
};
|
|
2162
|
+
|
|
2163
|
+
//#endregion
|
|
2164
|
+
//#region src/admin.ts
|
|
2165
|
+
/**
|
|
2166
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
2167
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
2168
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
2169
|
+
*/
|
|
2170
|
+
/**
|
|
2171
|
+
* Create a Centia admin client with access to provisioning operations.
|
|
2172
|
+
*
|
|
2173
|
+
* ```ts
|
|
2174
|
+
* const client = createCentiaAdminClient({
|
|
2175
|
+
* baseUrl: 'https://example.centia.io',
|
|
2176
|
+
* auth: { getAccessToken: async () => token },
|
|
2177
|
+
* });
|
|
2178
|
+
*
|
|
2179
|
+
* await client.provisioning.schemas.postSchema({ name: 'myschema' });
|
|
2180
|
+
* ```
|
|
2181
|
+
*/
|
|
2182
|
+
function createCentiaAdminClient(config) {
|
|
2183
|
+
const http = new CentiaHttpClient(config);
|
|
2184
|
+
return {
|
|
2185
|
+
http,
|
|
2186
|
+
provisioning: {
|
|
2187
|
+
schemas: new Schemas(http),
|
|
2188
|
+
tables: new ProvisioningTables(http),
|
|
2189
|
+
columns: new Columns(http),
|
|
2190
|
+
constraints: new Constraints(http),
|
|
2191
|
+
indices: new Indices(http),
|
|
2192
|
+
sequences: new Sequences(http),
|
|
2193
|
+
users: new ProvisioningUsers(http),
|
|
2194
|
+
clients: new ProvisioningClients(http),
|
|
2195
|
+
rules: new Rules(http),
|
|
2196
|
+
privileges: new Privileges(http),
|
|
2197
|
+
rpcMethods: new RpcMethods(http),
|
|
2198
|
+
metadata: new MetadataWrite(http),
|
|
2199
|
+
typeScript: new TypeScriptInterfaces(http),
|
|
2200
|
+
fileImport: new FileImport(http),
|
|
2201
|
+
gitCommit: new GitCommit(http),
|
|
2202
|
+
sqlNoToken: new SqlNoToken(http)
|
|
2203
|
+
}
|
|
2204
|
+
};
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
//#endregion
|
|
2208
|
+
//#region src/index.ts
|
|
2209
|
+
/**
|
|
2210
|
+
* @author Martin Høgh <mh@mapcentia.com>
|
|
2211
|
+
* @copyright 2013-2026 MapCentia ApS
|
|
2212
|
+
* @license https://opensource.org/license/mit The MIT License
|
|
2213
|
+
*
|
|
2214
|
+
*/
|
|
2215
|
+
|
|
2216
|
+
//#endregion
|
|
2217
|
+
export { CentiaApiError, Claims, CodeFlow, Gql, Meta, PasswordFlow, Rpc, SignUp, Sql, Stats, Status, Tables, Users, Ws, createApi, createCentiaAdminClient, createCentiaClient, createSqlBuilder, isCentiaApiError };
|
|
1425
2218
|
//# sourceMappingURL=centia-io-sdk.js.map
|