@centia-io/sdk 0.2.0 → 0.2.2
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/README.md +69 -0
- package/dist/centia-io-sdk.cjs +393 -0
- package/dist/centia-io-sdk.d.cts +349 -2
- package/dist/centia-io-sdk.d.cts.map +1 -1
- package/dist/centia-io-sdk.d.ts +349 -2
- package/dist/centia-io-sdk.d.ts.map +1 -1
- package/dist/centia-io-sdk.js +392 -1
- package/dist/centia-io-sdk.js.map +1 -1
- package/dist/centia-io-sdk.umd.js +393 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -363,6 +363,75 @@ Notes:
|
|
|
363
363
|
- `createApi<T>()` relies on naming conventions: the property name is the JSON‑RPC `method` name.
|
|
364
364
|
- Each call returns `result.data` from the RPC response (array of rows).
|
|
365
365
|
|
|
366
|
+
## Layer styling (admin client)
|
|
367
|
+
|
|
368
|
+
Layer configuration (properties, classes, styles and labels — MapServer-backed cartography) is managed through the admin client:
|
|
369
|
+
|
|
370
|
+
```ts
|
|
371
|
+
import { createCentiaAdminClient } from '@centia-io/sdk'
|
|
372
|
+
|
|
373
|
+
const client = createCentiaAdminClient({
|
|
374
|
+
baseUrl: 'https://example.centia.io',
|
|
375
|
+
auth: { getAccessToken: async () => token },
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
const layers = client.provisioning.layers
|
|
379
|
+
|
|
380
|
+
// List layer keys
|
|
381
|
+
const names = await layers.getLayer(undefined, { namesOnly: true })
|
|
382
|
+
|
|
383
|
+
// Read a full layer definition (properties + classes with styles/labels)
|
|
384
|
+
const layer = await layers.getLayer('my_schema.my_table.the_geom')
|
|
385
|
+
|
|
386
|
+
// Update layer properties (key-merge)
|
|
387
|
+
await layers.patchLayer('my_schema.my_table.the_geom', {
|
|
388
|
+
name: 'my_schema.my_table.the_geom',
|
|
389
|
+
properties: { opacity: '80', geotype: 'POLYGON' },
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
// Classes, styles and labels have their own CRUD methods
|
|
393
|
+
const { location } = await layers.postLayerClass('my_schema.my_table.the_geom', {
|
|
394
|
+
name: 'Roads',
|
|
395
|
+
expression: "[type]='road'",
|
|
396
|
+
})
|
|
397
|
+
await layers.postStyle('my_schema.my_table.the_geom', 'a1b2c3d4', { color: '#008000', width: '2' })
|
|
398
|
+
await layers.postLabel('my_schema.my_table.the_geom', 'a1b2c3d4', { text: '[name]', on: true })
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## OGC services (OWS / WFS)
|
|
402
|
+
|
|
403
|
+
`Ows` and `Wfs` wrap the OGC endpoints and take a `CentiaHttpClient`:
|
|
404
|
+
|
|
405
|
+
```ts
|
|
406
|
+
import { createCentiaClient, Ows, Wfs } from '@centia-io/sdk'
|
|
407
|
+
|
|
408
|
+
const http = createCentiaClient({
|
|
409
|
+
baseUrl: 'https://example.centia.io',
|
|
410
|
+
auth: { getAccessToken: async () => token },
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
// Token-authenticated WFS
|
|
414
|
+
const wfs = new Wfs(http)
|
|
415
|
+
const capabilities = await wfs.getWfs('my_schema', { REQUEST: 'GetCapabilities' })
|
|
416
|
+
const gml = await wfs.getWfs(
|
|
417
|
+
'my_schema',
|
|
418
|
+
{ REQUEST: 'GetFeature', TYPENAME: 'my_table', MAXFEATURES: 100 },
|
|
419
|
+
{ srs: 25832 }, // optional output SRID (and optional timeSlice for versioned layers)
|
|
420
|
+
)
|
|
421
|
+
|
|
422
|
+
// WFS-T transactions are posted as XML
|
|
423
|
+
await wfs.postWfs('my_schema', '<wfs:Transaction>…</wfs:Transaction>')
|
|
424
|
+
|
|
425
|
+
// Generic OWS (WMS/WFS/UTFGRID)
|
|
426
|
+
const ows = new Ows(http)
|
|
427
|
+
const wmsCaps = await ows.getOws('my_schema', { SERVICE: 'WMS', REQUEST: 'GetCapabilities' })
|
|
428
|
+
|
|
429
|
+
// Anonymous / HTTP-Basic access uses the ...NoToken variants with the database in the path
|
|
430
|
+
const anonCaps = await wfs.getWfsNoToken('my_schema', 'my_database', { REQUEST: 'GetCapabilities' })
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
Responses are returned as XML text (or parsed JSON for JSON formats such as UTFGRID). Binary responses like WMS `GetMap` images are not supported by these wrappers.
|
|
434
|
+
|
|
366
435
|
## Error handling
|
|
367
436
|
|
|
368
437
|
- Network/HTTP errors: thrown as `Error` with the status/body text when available.
|
package/dist/centia-io-sdk.cjs
CHANGED
|
@@ -2352,6 +2352,169 @@ var Rules = class {
|
|
|
2352
2352
|
}
|
|
2353
2353
|
};
|
|
2354
2354
|
|
|
2355
|
+
//#endregion
|
|
2356
|
+
//#region src/provisioning/Layers.ts
|
|
2357
|
+
var Layers = class {
|
|
2358
|
+
constructor(client) {
|
|
2359
|
+
this.client = client;
|
|
2360
|
+
}
|
|
2361
|
+
layerPath(layer) {
|
|
2362
|
+
return `api/v4/layers/${encodeURIComponent(layer)}`;
|
|
2363
|
+
}
|
|
2364
|
+
classPath(layer, classId) {
|
|
2365
|
+
return `${this.layerPath(layer)}/classes/${encodeURIComponent(classId)}`;
|
|
2366
|
+
}
|
|
2367
|
+
async getLayer(layer, opts) {
|
|
2368
|
+
var _this = this;
|
|
2369
|
+
const path = layer ? _this.layerPath(layer) : "api/v4/layers";
|
|
2370
|
+
const query = {};
|
|
2371
|
+
if (opts === null || opts === void 0 ? void 0 : opts.namesOnly) query.namesOnly = "true";
|
|
2372
|
+
return _this.client.request({
|
|
2373
|
+
path,
|
|
2374
|
+
method: "GET",
|
|
2375
|
+
query: Object.keys(query).length > 0 ? query : void 0
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
/** Configure existing layer(s): set properties and replace classes. */
|
|
2379
|
+
async postLayer(body) {
|
|
2380
|
+
var _this2 = this;
|
|
2381
|
+
var _res$getHeader;
|
|
2382
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2383
|
+
path: "api/v4/layers",
|
|
2384
|
+
method: "POST",
|
|
2385
|
+
body,
|
|
2386
|
+
expectedStatus: 201
|
|
2387
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2388
|
+
}
|
|
2389
|
+
/** Update layer properties (key-merge on the def JSON). */
|
|
2390
|
+
async patchLayer(layer, body) {
|
|
2391
|
+
var _this3 = this;
|
|
2392
|
+
var _res$getHeader2;
|
|
2393
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2394
|
+
path: _this3.layerPath(layer),
|
|
2395
|
+
method: "PATCH",
|
|
2396
|
+
body,
|
|
2397
|
+
expectedStatus: 303
|
|
2398
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2399
|
+
}
|
|
2400
|
+
async getLayerClass(layer, classId) {
|
|
2401
|
+
var _this4 = this;
|
|
2402
|
+
const path = classId != null ? _this4.classPath(layer, classId) : `${_this4.layerPath(layer)}/classes`;
|
|
2403
|
+
return _this4.client.request({
|
|
2404
|
+
path,
|
|
2405
|
+
method: "GET"
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2408
|
+
async postLayerClass(layer, body) {
|
|
2409
|
+
var _this5 = this;
|
|
2410
|
+
var _res$getHeader3;
|
|
2411
|
+
return { location: (_res$getHeader3 = (await _this5.client.requestFull({
|
|
2412
|
+
path: `${_this5.layerPath(layer)}/classes`,
|
|
2413
|
+
method: "POST",
|
|
2414
|
+
body,
|
|
2415
|
+
expectedStatus: 201
|
|
2416
|
+
})).getHeader("Location")) !== null && _res$getHeader3 !== void 0 ? _res$getHeader3 : "" };
|
|
2417
|
+
}
|
|
2418
|
+
/** Update a class (key-merge). Styles/labels are managed via their own methods. */
|
|
2419
|
+
async patchLayerClass(layer, classId, body) {
|
|
2420
|
+
var _this6 = this;
|
|
2421
|
+
var _res$getHeader4;
|
|
2422
|
+
return { location: (_res$getHeader4 = (await _this6.client.requestFull({
|
|
2423
|
+
path: _this6.classPath(layer, classId),
|
|
2424
|
+
method: "PATCH",
|
|
2425
|
+
body,
|
|
2426
|
+
expectedStatus: 303
|
|
2427
|
+
})).getHeader("Location")) !== null && _res$getHeader4 !== void 0 ? _res$getHeader4 : "" };
|
|
2428
|
+
}
|
|
2429
|
+
/** Delete class(es). `classId` may be a comma-separated list of ids. */
|
|
2430
|
+
async deleteLayerClass(layer, classId) {
|
|
2431
|
+
var _this7 = this;
|
|
2432
|
+
await _this7.client.request({
|
|
2433
|
+
path: _this7.classPath(layer, classId),
|
|
2434
|
+
method: "DELETE",
|
|
2435
|
+
expectedStatus: 204
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
async getStyle(layer, classId, styleId) {
|
|
2439
|
+
var _this8 = this;
|
|
2440
|
+
const base = `${_this8.classPath(layer, classId)}/styles`;
|
|
2441
|
+
const path = styleId != null ? `${base}/${encodeURIComponent(styleId)}` : base;
|
|
2442
|
+
return _this8.client.request({
|
|
2443
|
+
path,
|
|
2444
|
+
method: "GET"
|
|
2445
|
+
});
|
|
2446
|
+
}
|
|
2447
|
+
async postStyle(layer, classId, body) {
|
|
2448
|
+
var _this9 = this;
|
|
2449
|
+
var _res$getHeader5;
|
|
2450
|
+
return { location: (_res$getHeader5 = (await _this9.client.requestFull({
|
|
2451
|
+
path: `${_this9.classPath(layer, classId)}/styles`,
|
|
2452
|
+
method: "POST",
|
|
2453
|
+
body,
|
|
2454
|
+
expectedStatus: 201
|
|
2455
|
+
})).getHeader("Location")) !== null && _res$getHeader5 !== void 0 ? _res$getHeader5 : "" };
|
|
2456
|
+
}
|
|
2457
|
+
/** Update a style (key-merge). */
|
|
2458
|
+
async patchStyle(layer, classId, styleId, body) {
|
|
2459
|
+
var _this10 = this;
|
|
2460
|
+
var _res$getHeader6;
|
|
2461
|
+
return { location: (_res$getHeader6 = (await _this10.client.requestFull({
|
|
2462
|
+
path: `${_this10.classPath(layer, classId)}/styles/${encodeURIComponent(styleId)}`,
|
|
2463
|
+
method: "PATCH",
|
|
2464
|
+
body,
|
|
2465
|
+
expectedStatus: 303
|
|
2466
|
+
})).getHeader("Location")) !== null && _res$getHeader6 !== void 0 ? _res$getHeader6 : "" };
|
|
2467
|
+
}
|
|
2468
|
+
/** Delete style(s). `styleId` may be a comma-separated list of ids. */
|
|
2469
|
+
async deleteStyle(layer, classId, styleId) {
|
|
2470
|
+
var _this11 = this;
|
|
2471
|
+
await _this11.client.request({
|
|
2472
|
+
path: `${_this11.classPath(layer, classId)}/styles/${encodeURIComponent(styleId)}`,
|
|
2473
|
+
method: "DELETE",
|
|
2474
|
+
expectedStatus: 204
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
async getLabel(layer, classId, labelId) {
|
|
2478
|
+
var _this12 = this;
|
|
2479
|
+
const base = `${_this12.classPath(layer, classId)}/labels`;
|
|
2480
|
+
const path = labelId != null ? `${base}/${encodeURIComponent(labelId)}` : base;
|
|
2481
|
+
return _this12.client.request({
|
|
2482
|
+
path,
|
|
2483
|
+
method: "GET"
|
|
2484
|
+
});
|
|
2485
|
+
}
|
|
2486
|
+
async postLabel(layer, classId, body) {
|
|
2487
|
+
var _this13 = this;
|
|
2488
|
+
var _res$getHeader7;
|
|
2489
|
+
return { location: (_res$getHeader7 = (await _this13.client.requestFull({
|
|
2490
|
+
path: `${_this13.classPath(layer, classId)}/labels`,
|
|
2491
|
+
method: "POST",
|
|
2492
|
+
body,
|
|
2493
|
+
expectedStatus: 201
|
|
2494
|
+
})).getHeader("Location")) !== null && _res$getHeader7 !== void 0 ? _res$getHeader7 : "" };
|
|
2495
|
+
}
|
|
2496
|
+
/** Update a label (key-merge). */
|
|
2497
|
+
async patchLabel(layer, classId, labelId, body) {
|
|
2498
|
+
var _this14 = this;
|
|
2499
|
+
var _res$getHeader8;
|
|
2500
|
+
return { location: (_res$getHeader8 = (await _this14.client.requestFull({
|
|
2501
|
+
path: `${_this14.classPath(layer, classId)}/labels/${encodeURIComponent(labelId)}`,
|
|
2502
|
+
method: "PATCH",
|
|
2503
|
+
body,
|
|
2504
|
+
expectedStatus: 303
|
|
2505
|
+
})).getHeader("Location")) !== null && _res$getHeader8 !== void 0 ? _res$getHeader8 : "" };
|
|
2506
|
+
}
|
|
2507
|
+
/** Delete label(s). `labelId` may be a comma-separated list of ids. */
|
|
2508
|
+
async deleteLabel(layer, classId, labelId) {
|
|
2509
|
+
var _this15 = this;
|
|
2510
|
+
await _this15.client.request({
|
|
2511
|
+
path: `${_this15.classPath(layer, classId)}/labels/${encodeURIComponent(labelId)}`,
|
|
2512
|
+
method: "DELETE",
|
|
2513
|
+
expectedStatus: 204
|
|
2514
|
+
});
|
|
2515
|
+
}
|
|
2516
|
+
};
|
|
2517
|
+
|
|
2355
2518
|
//#endregion
|
|
2356
2519
|
//#region src/provisioning/Privileges.ts
|
|
2357
2520
|
var Privileges = class {
|
|
@@ -2426,6 +2589,98 @@ var RpcMethods = class {
|
|
|
2426
2589
|
}
|
|
2427
2590
|
};
|
|
2428
2591
|
|
|
2592
|
+
//#endregion
|
|
2593
|
+
//#region src/provisioning/Functions.ts
|
|
2594
|
+
/**
|
|
2595
|
+
* Lambda-like functions: manage (CRUD), invoke (sync/async/dry-run) and read
|
|
2596
|
+
* the generated TypeScript interface.
|
|
2597
|
+
*/
|
|
2598
|
+
var Functions = class {
|
|
2599
|
+
constructor(client) {
|
|
2600
|
+
this.client = client;
|
|
2601
|
+
}
|
|
2602
|
+
async getFunctions(name) {
|
|
2603
|
+
var _this = this;
|
|
2604
|
+
const path = name ? `api/v4/functions/${encodeURIComponent(name)}` : "api/v4/functions";
|
|
2605
|
+
return _this.client.request({
|
|
2606
|
+
path,
|
|
2607
|
+
method: "GET"
|
|
2608
|
+
});
|
|
2609
|
+
}
|
|
2610
|
+
/** Create one or more functions. Returns the Location of the created resource. */
|
|
2611
|
+
async postFunction(body) {
|
|
2612
|
+
var _this2 = this;
|
|
2613
|
+
var _res$getHeader;
|
|
2614
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2615
|
+
path: "api/v4/functions",
|
|
2616
|
+
method: "POST",
|
|
2617
|
+
body,
|
|
2618
|
+
expectedStatus: 201
|
|
2619
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2620
|
+
}
|
|
2621
|
+
/** Update a function. Changing the code bumps its version. */
|
|
2622
|
+
async patchFunction(name, body) {
|
|
2623
|
+
var _this3 = this;
|
|
2624
|
+
var _res$getHeader2;
|
|
2625
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2626
|
+
path: `api/v4/functions/${encodeURIComponent(name)}`,
|
|
2627
|
+
method: "PATCH",
|
|
2628
|
+
body,
|
|
2629
|
+
expectedStatus: 303
|
|
2630
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2631
|
+
}
|
|
2632
|
+
/** Delete a function. */
|
|
2633
|
+
async deleteFunction(name) {
|
|
2634
|
+
await this.client.request({
|
|
2635
|
+
path: `api/v4/functions/${encodeURIComponent(name)}`,
|
|
2636
|
+
method: "DELETE",
|
|
2637
|
+
expectedStatus: 204
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
/** Invoke a function synchronously and return its result. */
|
|
2641
|
+
async invoke(name, event = {}) {
|
|
2642
|
+
return this.client.request({
|
|
2643
|
+
path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
|
|
2644
|
+
method: "POST",
|
|
2645
|
+
body: event
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
/** Queue a function invocation; returns immediately with 202 and an id to poll. */
|
|
2649
|
+
async invokeAsync(name, event = {}) {
|
|
2650
|
+
return this.client.request({
|
|
2651
|
+
path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
|
|
2652
|
+
method: "POST",
|
|
2653
|
+
body: event,
|
|
2654
|
+
query: { async: "true" },
|
|
2655
|
+
expectedStatus: 202
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
/** Run once to infer and store input/output type schemas (for TypeScript generation). */
|
|
2659
|
+
async dryRun(name, event = {}) {
|
|
2660
|
+
return this.client.request({
|
|
2661
|
+
path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
|
|
2662
|
+
method: "POST",
|
|
2663
|
+
body: event,
|
|
2664
|
+
query: { dry: "true" }
|
|
2665
|
+
});
|
|
2666
|
+
}
|
|
2667
|
+
/** Get a stored invocation record (e.g. to poll an async invocation). */
|
|
2668
|
+
async getInvocation(name, id) {
|
|
2669
|
+
return this.client.request({
|
|
2670
|
+
path: `api/v4/functions/${encodeURIComponent(name)}/invocations/${encodeURIComponent(id)}`,
|
|
2671
|
+
method: "GET"
|
|
2672
|
+
});
|
|
2673
|
+
}
|
|
2674
|
+
/** Get the generated TypeScript `Functions` interface (from dry-run schemas). */
|
|
2675
|
+
async getInterfaces() {
|
|
2676
|
+
return this.client.request({
|
|
2677
|
+
path: "api/v4/function-interfaces",
|
|
2678
|
+
method: "GET",
|
|
2679
|
+
accept: "text/plain"
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
};
|
|
2683
|
+
|
|
2429
2684
|
//#endregion
|
|
2430
2685
|
//#region src/provisioning/MetadataWrite.ts
|
|
2431
2686
|
var MetadataWrite = class {
|
|
@@ -2559,8 +2814,10 @@ function createCentiaAdminClient(config) {
|
|
|
2559
2814
|
users: new ProvisioningUsers(http),
|
|
2560
2815
|
clients: new ProvisioningClients(http),
|
|
2561
2816
|
rules: new Rules(http),
|
|
2817
|
+
layers: new Layers(http),
|
|
2562
2818
|
privileges: new Privileges(http),
|
|
2563
2819
|
rpcMethods: new RpcMethods(http),
|
|
2820
|
+
functions: new Functions(http),
|
|
2564
2821
|
metadata: new MetadataWrite(http),
|
|
2565
2822
|
typeScript: new TypeScriptInterfaces(http),
|
|
2566
2823
|
fileImport: new FileImport(http),
|
|
@@ -2569,6 +2826,140 @@ function createCentiaAdminClient(config) {
|
|
|
2569
2826
|
};
|
|
2570
2827
|
}
|
|
2571
2828
|
|
|
2829
|
+
//#endregion
|
|
2830
|
+
//#region src/ogc/Ows.ts
|
|
2831
|
+
function toQuery$1(params) {
|
|
2832
|
+
if (!params) return void 0;
|
|
2833
|
+
const query = {};
|
|
2834
|
+
for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null) query[key] = String(value);
|
|
2835
|
+
return Object.keys(query).length > 0 ? query : void 0;
|
|
2836
|
+
}
|
|
2837
|
+
/**
|
|
2838
|
+
* OWS (WMS/WFS/UTFGRID) endpoint wrapper.
|
|
2839
|
+
*
|
|
2840
|
+
* Token-authenticated clients use `getOws`/`postOws`; anonymous and HTTP-Basic
|
|
2841
|
+
* clients use the `...NoToken` variants, which include the database in the path.
|
|
2842
|
+
*
|
|
2843
|
+
* Responses are streamed from the backend and returned as text (XML) or, for
|
|
2844
|
+
* JSON responses such as UTFGRID, as parsed JSON. Binary responses (e.g. WMS
|
|
2845
|
+
* GetMap images) are not supported by this wrapper — request those directly.
|
|
2846
|
+
*/
|
|
2847
|
+
var Ows = class {
|
|
2848
|
+
constructor(client) {
|
|
2849
|
+
this.client = client;
|
|
2850
|
+
}
|
|
2851
|
+
/** Token-authenticated OWS GET (WMS/WFS/UTFGRID). */
|
|
2852
|
+
async getOws(schema, params) {
|
|
2853
|
+
return this.client.request({
|
|
2854
|
+
path: `api/v4/ows/schema/${encodeURIComponent(schema)}`,
|
|
2855
|
+
method: "GET",
|
|
2856
|
+
query: toQuery$1(params),
|
|
2857
|
+
accept: "*/*"
|
|
2858
|
+
});
|
|
2859
|
+
}
|
|
2860
|
+
/** Token-authenticated OWS POST (WFS XML). */
|
|
2861
|
+
async postOws(schema, xml) {
|
|
2862
|
+
return this.client.request({
|
|
2863
|
+
path: `api/v4/ows/schema/${encodeURIComponent(schema)}`,
|
|
2864
|
+
method: "POST",
|
|
2865
|
+
body: xml,
|
|
2866
|
+
contentType: "text/xml",
|
|
2867
|
+
accept: "*/*"
|
|
2868
|
+
});
|
|
2869
|
+
}
|
|
2870
|
+
/** Anonymous/HTTP-Basic OWS GET (WMS/WFS/UTFGRID). */
|
|
2871
|
+
async getOwsNoToken(schema, database, params) {
|
|
2872
|
+
return this.client.request({
|
|
2873
|
+
path: `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`,
|
|
2874
|
+
method: "GET",
|
|
2875
|
+
query: toQuery$1(params),
|
|
2876
|
+
accept: "*/*"
|
|
2877
|
+
});
|
|
2878
|
+
}
|
|
2879
|
+
/** Anonymous/HTTP-Basic OWS POST (WFS XML). */
|
|
2880
|
+
async postOwsNoToken(schema, database, xml) {
|
|
2881
|
+
return this.client.request({
|
|
2882
|
+
path: `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`,
|
|
2883
|
+
method: "POST",
|
|
2884
|
+
body: xml,
|
|
2885
|
+
contentType: "text/xml",
|
|
2886
|
+
accept: "*/*"
|
|
2887
|
+
});
|
|
2888
|
+
}
|
|
2889
|
+
};
|
|
2890
|
+
|
|
2891
|
+
//#endregion
|
|
2892
|
+
//#region src/ogc/Wfs.ts
|
|
2893
|
+
function wfsPath(base, options) {
|
|
2894
|
+
let path = base;
|
|
2895
|
+
if ((options === null || options === void 0 ? void 0 : options.timeSlice) != null && options.srs == null) throw new Error("timeSlice requires srs to be set");
|
|
2896
|
+
if ((options === null || options === void 0 ? void 0 : options.srs) != null) {
|
|
2897
|
+
path += `/srs/${encodeURIComponent(options.srs)}`;
|
|
2898
|
+
if (options.timeSlice != null) path += `/${encodeURIComponent(options.timeSlice)}`;
|
|
2899
|
+
}
|
|
2900
|
+
return path;
|
|
2901
|
+
}
|
|
2902
|
+
function toQuery(params) {
|
|
2903
|
+
const query = { SERVICE: "WFS" };
|
|
2904
|
+
for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null) query[key] = String(value);
|
|
2905
|
+
return query;
|
|
2906
|
+
}
|
|
2907
|
+
/**
|
|
2908
|
+
* WFS endpoint wrapper (GetCapabilities, DescribeFeatureType, GetFeature and
|
|
2909
|
+
* WFS-T transactions).
|
|
2910
|
+
*
|
|
2911
|
+
* Token-authenticated clients use `getWfs`/`postWfs`; anonymous and HTTP-Basic
|
|
2912
|
+
* clients (e.g. QGIS) use the `...NoToken` variants, which include the
|
|
2913
|
+
* database in the path. Responses are returned as XML text.
|
|
2914
|
+
*/
|
|
2915
|
+
var Wfs = class {
|
|
2916
|
+
constructor(client) {
|
|
2917
|
+
this.client = client;
|
|
2918
|
+
}
|
|
2919
|
+
/** Token-authenticated WFS GET. */
|
|
2920
|
+
async getWfs(schema, params, options) {
|
|
2921
|
+
return this.client.request({
|
|
2922
|
+
path: wfsPath(`api/v4/wfs/schema/${encodeURIComponent(schema)}`, options),
|
|
2923
|
+
method: "GET",
|
|
2924
|
+
query: toQuery(params),
|
|
2925
|
+
accept: "text/xml"
|
|
2926
|
+
});
|
|
2927
|
+
}
|
|
2928
|
+
/** Token-authenticated WFS POST (XML-encoded GetFeature or Transaction). */
|
|
2929
|
+
async postWfs(schema, xml, options) {
|
|
2930
|
+
return this.client.request({
|
|
2931
|
+
path: wfsPath(`api/v4/wfs/schema/${encodeURIComponent(schema)}`, options),
|
|
2932
|
+
method: "POST",
|
|
2933
|
+
body: xml,
|
|
2934
|
+
contentType: "text/xml",
|
|
2935
|
+
accept: "text/xml"
|
|
2936
|
+
});
|
|
2937
|
+
}
|
|
2938
|
+
/** Anonymous/HTTP-Basic WFS GET. */
|
|
2939
|
+
async getWfsNoToken(schema, database, params, options) {
|
|
2940
|
+
var _this3 = this;
|
|
2941
|
+
const base = `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
|
|
2942
|
+
return _this3.client.request({
|
|
2943
|
+
path: wfsPath(base, options),
|
|
2944
|
+
method: "GET",
|
|
2945
|
+
query: toQuery(params),
|
|
2946
|
+
accept: "text/xml"
|
|
2947
|
+
});
|
|
2948
|
+
}
|
|
2949
|
+
/** Anonymous/HTTP-Basic WFS POST (XML-encoded GetFeature or Transaction). */
|
|
2950
|
+
async postWfsNoToken(schema, database, xml, options) {
|
|
2951
|
+
var _this4 = this;
|
|
2952
|
+
const base = `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
|
|
2953
|
+
return _this4.client.request({
|
|
2954
|
+
path: wfsPath(base, options),
|
|
2955
|
+
method: "POST",
|
|
2956
|
+
body: xml,
|
|
2957
|
+
contentType: "text/xml",
|
|
2958
|
+
accept: "text/xml"
|
|
2959
|
+
});
|
|
2960
|
+
}
|
|
2961
|
+
};
|
|
2962
|
+
|
|
2572
2963
|
//#endregion
|
|
2573
2964
|
//#region src/auth/errors.ts
|
|
2574
2965
|
/**
|
|
@@ -2697,6 +3088,7 @@ exports.CodeFlow = CodeFlow;
|
|
|
2697
3088
|
exports.Gql = Gql;
|
|
2698
3089
|
exports.Meta = Meta;
|
|
2699
3090
|
exports.NotLoggedInError = NotLoggedInError;
|
|
3091
|
+
exports.Ows = Ows;
|
|
2700
3092
|
exports.PasswordFlow = PasswordFlow;
|
|
2701
3093
|
exports.Rpc = Rpc;
|
|
2702
3094
|
exports.SessionExpiredError = SessionExpiredError;
|
|
@@ -2707,6 +3099,7 @@ exports.Stats = Stats;
|
|
|
2707
3099
|
exports.Status = Status;
|
|
2708
3100
|
exports.Tables = Tables;
|
|
2709
3101
|
exports.Users = Users;
|
|
3102
|
+
exports.Wfs = Wfs;
|
|
2710
3103
|
exports.Ws = Ws;
|
|
2711
3104
|
exports.createApi = createApi;
|
|
2712
3105
|
exports.createCentiaAdminClient = createCentiaAdminClient;
|