@centia-io/sdk 0.2.1 → 0.2.3

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 {
@@ -2530,11 +2693,14 @@
2530
2693
  this.client = client;
2531
2694
  }
2532
2695
  async patchMetaData(body) {
2533
- return this.client.request({
2696
+ var _this = this;
2697
+ var _res$getHeader;
2698
+ return { location: (_res$getHeader = (await _this.client.requestFull({
2534
2699
  path: "api/v4/meta",
2535
2700
  method: "PATCH",
2536
- body
2537
- });
2701
+ body,
2702
+ expectedStatus: 303
2703
+ })).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
2538
2704
  }
2539
2705
  };
2540
2706
 
@@ -2656,6 +2822,7 @@
2656
2822
  users: new ProvisioningUsers(http),
2657
2823
  clients: new ProvisioningClients(http),
2658
2824
  rules: new Rules(http),
2825
+ layers: new Layers(http),
2659
2826
  privileges: new Privileges(http),
2660
2827
  rpcMethods: new RpcMethods(http),
2661
2828
  functions: new Functions(http),
@@ -2667,6 +2834,140 @@
2667
2834
  };
2668
2835
  }
2669
2836
 
2837
+ //#endregion
2838
+ //#region src/ogc/Ows.ts
2839
+ function toQuery$1(params) {
2840
+ if (!params) return void 0;
2841
+ const query = {};
2842
+ for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null) query[key] = String(value);
2843
+ return Object.keys(query).length > 0 ? query : void 0;
2844
+ }
2845
+ /**
2846
+ * OWS (WMS/WFS/UTFGRID) endpoint wrapper.
2847
+ *
2848
+ * Token-authenticated clients use `getOws`/`postOws`; anonymous and HTTP-Basic
2849
+ * clients use the `...NoToken` variants, which include the database in the path.
2850
+ *
2851
+ * Responses are streamed from the backend and returned as text (XML) or, for
2852
+ * JSON responses such as UTFGRID, as parsed JSON. Binary responses (e.g. WMS
2853
+ * GetMap images) are not supported by this wrapper — request those directly.
2854
+ */
2855
+ var Ows = class {
2856
+ constructor(client) {
2857
+ this.client = client;
2858
+ }
2859
+ /** Token-authenticated OWS GET (WMS/WFS/UTFGRID). */
2860
+ async getOws(schema, params) {
2861
+ return this.client.request({
2862
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}`,
2863
+ method: "GET",
2864
+ query: toQuery$1(params),
2865
+ accept: "*/*"
2866
+ });
2867
+ }
2868
+ /** Token-authenticated OWS POST (WFS XML). */
2869
+ async postOws(schema, xml) {
2870
+ return this.client.request({
2871
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}`,
2872
+ method: "POST",
2873
+ body: xml,
2874
+ contentType: "text/xml",
2875
+ accept: "*/*"
2876
+ });
2877
+ }
2878
+ /** Anonymous/HTTP-Basic OWS GET (WMS/WFS/UTFGRID). */
2879
+ async getOwsNoToken(schema, database, params) {
2880
+ return this.client.request({
2881
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`,
2882
+ method: "GET",
2883
+ query: toQuery$1(params),
2884
+ accept: "*/*"
2885
+ });
2886
+ }
2887
+ /** Anonymous/HTTP-Basic OWS POST (WFS XML). */
2888
+ async postOwsNoToken(schema, database, xml) {
2889
+ return this.client.request({
2890
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`,
2891
+ method: "POST",
2892
+ body: xml,
2893
+ contentType: "text/xml",
2894
+ accept: "*/*"
2895
+ });
2896
+ }
2897
+ };
2898
+
2899
+ //#endregion
2900
+ //#region src/ogc/Wfs.ts
2901
+ function wfsPath(base, options) {
2902
+ let path = base;
2903
+ if ((options === null || options === void 0 ? void 0 : options.timeSlice) != null && options.srs == null) throw new Error("timeSlice requires srs to be set");
2904
+ if ((options === null || options === void 0 ? void 0 : options.srs) != null) {
2905
+ path += `/srs/${encodeURIComponent(options.srs)}`;
2906
+ if (options.timeSlice != null) path += `/${encodeURIComponent(options.timeSlice)}`;
2907
+ }
2908
+ return path;
2909
+ }
2910
+ function toQuery(params) {
2911
+ const query = { SERVICE: "WFS" };
2912
+ for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null) query[key] = String(value);
2913
+ return query;
2914
+ }
2915
+ /**
2916
+ * WFS endpoint wrapper (GetCapabilities, DescribeFeatureType, GetFeature and
2917
+ * WFS-T transactions).
2918
+ *
2919
+ * Token-authenticated clients use `getWfs`/`postWfs`; anonymous and HTTP-Basic
2920
+ * clients (e.g. QGIS) use the `...NoToken` variants, which include the
2921
+ * database in the path. Responses are returned as XML text.
2922
+ */
2923
+ var Wfs = class {
2924
+ constructor(client) {
2925
+ this.client = client;
2926
+ }
2927
+ /** Token-authenticated WFS GET. */
2928
+ async getWfs(schema, params, options) {
2929
+ return this.client.request({
2930
+ path: wfsPath(`api/v4/wfs/schema/${encodeURIComponent(schema)}`, options),
2931
+ method: "GET",
2932
+ query: toQuery(params),
2933
+ accept: "text/xml"
2934
+ });
2935
+ }
2936
+ /** Token-authenticated WFS POST (XML-encoded GetFeature or Transaction). */
2937
+ async postWfs(schema, xml, options) {
2938
+ return this.client.request({
2939
+ path: wfsPath(`api/v4/wfs/schema/${encodeURIComponent(schema)}`, options),
2940
+ method: "POST",
2941
+ body: xml,
2942
+ contentType: "text/xml",
2943
+ accept: "text/xml"
2944
+ });
2945
+ }
2946
+ /** Anonymous/HTTP-Basic WFS GET. */
2947
+ async getWfsNoToken(schema, database, params, options) {
2948
+ var _this3 = this;
2949
+ const base = `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
2950
+ return _this3.client.request({
2951
+ path: wfsPath(base, options),
2952
+ method: "GET",
2953
+ query: toQuery(params),
2954
+ accept: "text/xml"
2955
+ });
2956
+ }
2957
+ /** Anonymous/HTTP-Basic WFS POST (XML-encoded GetFeature or Transaction). */
2958
+ async postWfsNoToken(schema, database, xml, options) {
2959
+ var _this4 = this;
2960
+ const base = `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
2961
+ return _this4.client.request({
2962
+ path: wfsPath(base, options),
2963
+ method: "POST",
2964
+ body: xml,
2965
+ contentType: "text/xml",
2966
+ accept: "text/xml"
2967
+ });
2968
+ }
2969
+ };
2970
+
2670
2971
  //#endregion
2671
2972
  //#region src/auth/errors.ts
2672
2973
  /**
@@ -2795,6 +3096,7 @@ exports.CodeFlow = CodeFlow;
2795
3096
  exports.Gql = Gql;
2796
3097
  exports.Meta = Meta;
2797
3098
  exports.NotLoggedInError = NotLoggedInError;
3099
+ exports.Ows = Ows;
2798
3100
  exports.PasswordFlow = PasswordFlow;
2799
3101
  exports.Rpc = Rpc;
2800
3102
  exports.SessionExpiredError = SessionExpiredError;
@@ -2805,6 +3107,7 @@ exports.Stats = Stats;
2805
3107
  exports.Status = Status;
2806
3108
  exports.Tables = Tables;
2807
3109
  exports.Users = Users;
3110
+ exports.Wfs = Wfs;
2808
3111
  exports.Ws = Ws;
2809
3112
  exports.createApi = createApi;
2810
3113
  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.3",
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
+ }