@centia-io/sdk 0.2.1 → 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.
@@ -2357,6 +2357,169 @@
2357
2357
  }
2358
2358
  };
2359
2359
 
2360
+ //#endregion
2361
+ //#region src/provisioning/Layers.ts
2362
+ var Layers = class {
2363
+ constructor(client) {
2364
+ this.client = client;
2365
+ }
2366
+ layerPath(layer) {
2367
+ return `api/v4/layers/${encodeURIComponent(layer)}`;
2368
+ }
2369
+ classPath(layer, classId) {
2370
+ return `${this.layerPath(layer)}/classes/${encodeURIComponent(classId)}`;
2371
+ }
2372
+ async getLayer(layer, opts) {
2373
+ var _this = this;
2374
+ const path = layer ? _this.layerPath(layer) : "api/v4/layers";
2375
+ const query = {};
2376
+ if (opts === null || opts === void 0 ? void 0 : opts.namesOnly) query.namesOnly = "true";
2377
+ return _this.client.request({
2378
+ path,
2379
+ method: "GET",
2380
+ query: Object.keys(query).length > 0 ? query : void 0
2381
+ });
2382
+ }
2383
+ /** Configure existing layer(s): set properties and replace classes. */
2384
+ async postLayer(body) {
2385
+ var _this2 = this;
2386
+ var _res$getHeader;
2387
+ return { location: (_res$getHeader = (await _this2.client.requestFull({
2388
+ path: "api/v4/layers",
2389
+ method: "POST",
2390
+ body,
2391
+ expectedStatus: 201
2392
+ })).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
2393
+ }
2394
+ /** Update layer properties (key-merge on the def JSON). */
2395
+ async patchLayer(layer, body) {
2396
+ var _this3 = this;
2397
+ var _res$getHeader2;
2398
+ return { location: (_res$getHeader2 = (await _this3.client.requestFull({
2399
+ path: _this3.layerPath(layer),
2400
+ method: "PATCH",
2401
+ body,
2402
+ expectedStatus: 303
2403
+ })).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
2404
+ }
2405
+ async getLayerClass(layer, classId) {
2406
+ var _this4 = this;
2407
+ const path = classId != null ? _this4.classPath(layer, classId) : `${_this4.layerPath(layer)}/classes`;
2408
+ return _this4.client.request({
2409
+ path,
2410
+ method: "GET"
2411
+ });
2412
+ }
2413
+ async postLayerClass(layer, body) {
2414
+ var _this5 = this;
2415
+ var _res$getHeader3;
2416
+ return { location: (_res$getHeader3 = (await _this5.client.requestFull({
2417
+ path: `${_this5.layerPath(layer)}/classes`,
2418
+ method: "POST",
2419
+ body,
2420
+ expectedStatus: 201
2421
+ })).getHeader("Location")) !== null && _res$getHeader3 !== void 0 ? _res$getHeader3 : "" };
2422
+ }
2423
+ /** Update a class (key-merge). Styles/labels are managed via their own methods. */
2424
+ async patchLayerClass(layer, classId, body) {
2425
+ var _this6 = this;
2426
+ var _res$getHeader4;
2427
+ return { location: (_res$getHeader4 = (await _this6.client.requestFull({
2428
+ path: _this6.classPath(layer, classId),
2429
+ method: "PATCH",
2430
+ body,
2431
+ expectedStatus: 303
2432
+ })).getHeader("Location")) !== null && _res$getHeader4 !== void 0 ? _res$getHeader4 : "" };
2433
+ }
2434
+ /** Delete class(es). `classId` may be a comma-separated list of ids. */
2435
+ async deleteLayerClass(layer, classId) {
2436
+ var _this7 = this;
2437
+ await _this7.client.request({
2438
+ path: _this7.classPath(layer, classId),
2439
+ method: "DELETE",
2440
+ expectedStatus: 204
2441
+ });
2442
+ }
2443
+ async getStyle(layer, classId, styleId) {
2444
+ var _this8 = this;
2445
+ const base = `${_this8.classPath(layer, classId)}/styles`;
2446
+ const path = styleId != null ? `${base}/${encodeURIComponent(styleId)}` : base;
2447
+ return _this8.client.request({
2448
+ path,
2449
+ method: "GET"
2450
+ });
2451
+ }
2452
+ async postStyle(layer, classId, body) {
2453
+ var _this9 = this;
2454
+ var _res$getHeader5;
2455
+ return { location: (_res$getHeader5 = (await _this9.client.requestFull({
2456
+ path: `${_this9.classPath(layer, classId)}/styles`,
2457
+ method: "POST",
2458
+ body,
2459
+ expectedStatus: 201
2460
+ })).getHeader("Location")) !== null && _res$getHeader5 !== void 0 ? _res$getHeader5 : "" };
2461
+ }
2462
+ /** Update a style (key-merge). */
2463
+ async patchStyle(layer, classId, styleId, body) {
2464
+ var _this10 = this;
2465
+ var _res$getHeader6;
2466
+ return { location: (_res$getHeader6 = (await _this10.client.requestFull({
2467
+ path: `${_this10.classPath(layer, classId)}/styles/${encodeURIComponent(styleId)}`,
2468
+ method: "PATCH",
2469
+ body,
2470
+ expectedStatus: 303
2471
+ })).getHeader("Location")) !== null && _res$getHeader6 !== void 0 ? _res$getHeader6 : "" };
2472
+ }
2473
+ /** Delete style(s). `styleId` may be a comma-separated list of ids. */
2474
+ async deleteStyle(layer, classId, styleId) {
2475
+ var _this11 = this;
2476
+ await _this11.client.request({
2477
+ path: `${_this11.classPath(layer, classId)}/styles/${encodeURIComponent(styleId)}`,
2478
+ method: "DELETE",
2479
+ expectedStatus: 204
2480
+ });
2481
+ }
2482
+ async getLabel(layer, classId, labelId) {
2483
+ var _this12 = this;
2484
+ const base = `${_this12.classPath(layer, classId)}/labels`;
2485
+ const path = labelId != null ? `${base}/${encodeURIComponent(labelId)}` : base;
2486
+ return _this12.client.request({
2487
+ path,
2488
+ method: "GET"
2489
+ });
2490
+ }
2491
+ async postLabel(layer, classId, body) {
2492
+ var _this13 = this;
2493
+ var _res$getHeader7;
2494
+ return { location: (_res$getHeader7 = (await _this13.client.requestFull({
2495
+ path: `${_this13.classPath(layer, classId)}/labels`,
2496
+ method: "POST",
2497
+ body,
2498
+ expectedStatus: 201
2499
+ })).getHeader("Location")) !== null && _res$getHeader7 !== void 0 ? _res$getHeader7 : "" };
2500
+ }
2501
+ /** Update a label (key-merge). */
2502
+ async patchLabel(layer, classId, labelId, body) {
2503
+ var _this14 = this;
2504
+ var _res$getHeader8;
2505
+ return { location: (_res$getHeader8 = (await _this14.client.requestFull({
2506
+ path: `${_this14.classPath(layer, classId)}/labels/${encodeURIComponent(labelId)}`,
2507
+ method: "PATCH",
2508
+ body,
2509
+ expectedStatus: 303
2510
+ })).getHeader("Location")) !== null && _res$getHeader8 !== void 0 ? _res$getHeader8 : "" };
2511
+ }
2512
+ /** Delete label(s). `labelId` may be a comma-separated list of ids. */
2513
+ async deleteLabel(layer, classId, labelId) {
2514
+ var _this15 = this;
2515
+ await _this15.client.request({
2516
+ path: `${_this15.classPath(layer, classId)}/labels/${encodeURIComponent(labelId)}`,
2517
+ method: "DELETE",
2518
+ expectedStatus: 204
2519
+ });
2520
+ }
2521
+ };
2522
+
2360
2523
  //#endregion
2361
2524
  //#region src/provisioning/Privileges.ts
2362
2525
  var Privileges = class {
@@ -2656,6 +2819,7 @@
2656
2819
  users: new ProvisioningUsers(http),
2657
2820
  clients: new ProvisioningClients(http),
2658
2821
  rules: new Rules(http),
2822
+ layers: new Layers(http),
2659
2823
  privileges: new Privileges(http),
2660
2824
  rpcMethods: new RpcMethods(http),
2661
2825
  functions: new Functions(http),
@@ -2667,6 +2831,140 @@
2667
2831
  };
2668
2832
  }
2669
2833
 
2834
+ //#endregion
2835
+ //#region src/ogc/Ows.ts
2836
+ function toQuery$1(params) {
2837
+ if (!params) return void 0;
2838
+ const query = {};
2839
+ for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null) query[key] = String(value);
2840
+ return Object.keys(query).length > 0 ? query : void 0;
2841
+ }
2842
+ /**
2843
+ * OWS (WMS/WFS/UTFGRID) endpoint wrapper.
2844
+ *
2845
+ * Token-authenticated clients use `getOws`/`postOws`; anonymous and HTTP-Basic
2846
+ * clients use the `...NoToken` variants, which include the database in the path.
2847
+ *
2848
+ * Responses are streamed from the backend and returned as text (XML) or, for
2849
+ * JSON responses such as UTFGRID, as parsed JSON. Binary responses (e.g. WMS
2850
+ * GetMap images) are not supported by this wrapper — request those directly.
2851
+ */
2852
+ var Ows = class {
2853
+ constructor(client) {
2854
+ this.client = client;
2855
+ }
2856
+ /** Token-authenticated OWS GET (WMS/WFS/UTFGRID). */
2857
+ async getOws(schema, params) {
2858
+ return this.client.request({
2859
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}`,
2860
+ method: "GET",
2861
+ query: toQuery$1(params),
2862
+ accept: "*/*"
2863
+ });
2864
+ }
2865
+ /** Token-authenticated OWS POST (WFS XML). */
2866
+ async postOws(schema, xml) {
2867
+ return this.client.request({
2868
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}`,
2869
+ method: "POST",
2870
+ body: xml,
2871
+ contentType: "text/xml",
2872
+ accept: "*/*"
2873
+ });
2874
+ }
2875
+ /** Anonymous/HTTP-Basic OWS GET (WMS/WFS/UTFGRID). */
2876
+ async getOwsNoToken(schema, database, params) {
2877
+ return this.client.request({
2878
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`,
2879
+ method: "GET",
2880
+ query: toQuery$1(params),
2881
+ accept: "*/*"
2882
+ });
2883
+ }
2884
+ /** Anonymous/HTTP-Basic OWS POST (WFS XML). */
2885
+ async postOwsNoToken(schema, database, xml) {
2886
+ return this.client.request({
2887
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`,
2888
+ method: "POST",
2889
+ body: xml,
2890
+ contentType: "text/xml",
2891
+ accept: "*/*"
2892
+ });
2893
+ }
2894
+ };
2895
+
2896
+ //#endregion
2897
+ //#region src/ogc/Wfs.ts
2898
+ function wfsPath(base, options) {
2899
+ let path = base;
2900
+ if ((options === null || options === void 0 ? void 0 : options.timeSlice) != null && options.srs == null) throw new Error("timeSlice requires srs to be set");
2901
+ if ((options === null || options === void 0 ? void 0 : options.srs) != null) {
2902
+ path += `/srs/${encodeURIComponent(options.srs)}`;
2903
+ if (options.timeSlice != null) path += `/${encodeURIComponent(options.timeSlice)}`;
2904
+ }
2905
+ return path;
2906
+ }
2907
+ function toQuery(params) {
2908
+ const query = { SERVICE: "WFS" };
2909
+ for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null) query[key] = String(value);
2910
+ return query;
2911
+ }
2912
+ /**
2913
+ * WFS endpoint wrapper (GetCapabilities, DescribeFeatureType, GetFeature and
2914
+ * WFS-T transactions).
2915
+ *
2916
+ * Token-authenticated clients use `getWfs`/`postWfs`; anonymous and HTTP-Basic
2917
+ * clients (e.g. QGIS) use the `...NoToken` variants, which include the
2918
+ * database in the path. Responses are returned as XML text.
2919
+ */
2920
+ var Wfs = class {
2921
+ constructor(client) {
2922
+ this.client = client;
2923
+ }
2924
+ /** Token-authenticated WFS GET. */
2925
+ async getWfs(schema, params, options) {
2926
+ return this.client.request({
2927
+ path: wfsPath(`api/v4/wfs/schema/${encodeURIComponent(schema)}`, options),
2928
+ method: "GET",
2929
+ query: toQuery(params),
2930
+ accept: "text/xml"
2931
+ });
2932
+ }
2933
+ /** Token-authenticated WFS POST (XML-encoded GetFeature or Transaction). */
2934
+ async postWfs(schema, xml, options) {
2935
+ return this.client.request({
2936
+ path: wfsPath(`api/v4/wfs/schema/${encodeURIComponent(schema)}`, options),
2937
+ method: "POST",
2938
+ body: xml,
2939
+ contentType: "text/xml",
2940
+ accept: "text/xml"
2941
+ });
2942
+ }
2943
+ /** Anonymous/HTTP-Basic WFS GET. */
2944
+ async getWfsNoToken(schema, database, params, options) {
2945
+ var _this3 = this;
2946
+ const base = `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
2947
+ return _this3.client.request({
2948
+ path: wfsPath(base, options),
2949
+ method: "GET",
2950
+ query: toQuery(params),
2951
+ accept: "text/xml"
2952
+ });
2953
+ }
2954
+ /** Anonymous/HTTP-Basic WFS POST (XML-encoded GetFeature or Transaction). */
2955
+ async postWfsNoToken(schema, database, xml, options) {
2956
+ var _this4 = this;
2957
+ const base = `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
2958
+ return _this4.client.request({
2959
+ path: wfsPath(base, options),
2960
+ method: "POST",
2961
+ body: xml,
2962
+ contentType: "text/xml",
2963
+ accept: "text/xml"
2964
+ });
2965
+ }
2966
+ };
2967
+
2670
2968
  //#endregion
2671
2969
  //#region src/auth/errors.ts
2672
2970
  /**
@@ -2795,6 +3093,7 @@ exports.CodeFlow = CodeFlow;
2795
3093
  exports.Gql = Gql;
2796
3094
  exports.Meta = Meta;
2797
3095
  exports.NotLoggedInError = NotLoggedInError;
3096
+ exports.Ows = Ows;
2798
3097
  exports.PasswordFlow = PasswordFlow;
2799
3098
  exports.Rpc = Rpc;
2800
3099
  exports.SessionExpiredError = SessionExpiredError;
@@ -2805,6 +3104,7 @@ exports.Stats = Stats;
2805
3104
  exports.Status = Status;
2806
3105
  exports.Tables = Tables;
2807
3106
  exports.Users = Users;
3107
+ exports.Wfs = Wfs;
2808
3108
  exports.Ws = Ws;
2809
3109
  exports.createApi = createApi;
2810
3110
  exports.createCentiaAdminClient = createCentiaAdminClient;
package/node.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './dist/centia-io-sdk-node'
1
+ export * from './dist/centia-io-sdk-node'
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
- {
2
- "name": "@centia-io/sdk",
3
- "version": "0.2.1",
4
- "description": "Centia-io TypeScript SDK",
5
- "author": "Martin Høgh",
6
- "license": "MIT",
7
- "type": "module",
8
- "main": "./dist/centia-io-sdk.cjs",
9
- "module": "./dist/centia-io-sdk.js",
10
- "types": "./dist/centia-io-sdk.d.cts",
11
- "exports": {
12
- ".": {
13
- "require": "./dist/centia-io-sdk.cjs",
14
- "import": "./dist/centia-io-sdk.js"
15
- },
16
- "./node": {
17
- "import": { "types": "./dist/centia-io-sdk-node.d.ts", "default": "./dist/centia-io-sdk-node.js" },
18
- "require": { "types": "./dist/centia-io-sdk-node.d.cts", "default": "./dist/centia-io-sdk-node.cjs" }
19
- },
20
- "./package.json": "./package.json"
21
- },
22
- "files": [
23
- "dist",
24
- "node.d.ts"
25
- ],
26
- "scripts": {
27
- "build": "tsdown",
28
- "build-watch": "tsdown --watch",
29
- "test": "vitest run",
30
- "test:watch": "vitest"
31
- },
32
- "dependencies": {
33
- "configstore": "^7.0.0",
34
- "proper-lockfile": "^4.1.2"
35
- },
36
- "devDependencies": {
37
- "@types/configstore": "^6.0.2",
38
- "@types/proper-lockfile": "^4.1.4",
39
- "tsdown": "^0.17.3",
40
- "tsx": "^4.19.0",
41
- "typescript": "^5.6.3",
42
- "vitest": "^4.0.18"
43
- },
44
- "private": false,
45
- "engines": {
46
- "node": ">=18"
47
- }
48
- }
1
+ {
2
+ "name": "@centia-io/sdk",
3
+ "version": "0.2.2",
4
+ "description": "Centia-io TypeScript SDK",
5
+ "author": "Martin Høgh",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./dist/centia-io-sdk.cjs",
9
+ "module": "./dist/centia-io-sdk.js",
10
+ "types": "./dist/centia-io-sdk.d.cts",
11
+ "exports": {
12
+ ".": {
13
+ "require": "./dist/centia-io-sdk.cjs",
14
+ "import": "./dist/centia-io-sdk.js"
15
+ },
16
+ "./node": {
17
+ "import": { "types": "./dist/centia-io-sdk-node.d.ts", "default": "./dist/centia-io-sdk-node.js" },
18
+ "require": { "types": "./dist/centia-io-sdk-node.d.cts", "default": "./dist/centia-io-sdk-node.cjs" }
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "node.d.ts"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsdown",
28
+ "build-watch": "tsdown --watch",
29
+ "test": "vitest run",
30
+ "test:watch": "vitest"
31
+ },
32
+ "dependencies": {
33
+ "configstore": "^7.0.0",
34
+ "proper-lockfile": "^4.1.2"
35
+ },
36
+ "devDependencies": {
37
+ "@types/configstore": "^6.0.2",
38
+ "@types/proper-lockfile": "^4.1.4",
39
+ "tsdown": "^0.17.3",
40
+ "tsx": "^4.19.0",
41
+ "typescript": "^5.6.3",
42
+ "vitest": "^4.0.18"
43
+ },
44
+ "private": false,
45
+ "engines": {
46
+ "node": ">=18"
47
+ }
48
+ }