@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.
@@ -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 {
@@ -2431,6 +2594,98 @@
2431
2594
  }
2432
2595
  };
2433
2596
 
2597
+ //#endregion
2598
+ //#region src/provisioning/Functions.ts
2599
+ /**
2600
+ * Lambda-like functions: manage (CRUD), invoke (sync/async/dry-run) and read
2601
+ * the generated TypeScript interface.
2602
+ */
2603
+ var Functions = class {
2604
+ constructor(client) {
2605
+ this.client = client;
2606
+ }
2607
+ async getFunctions(name) {
2608
+ var _this = this;
2609
+ const path = name ? `api/v4/functions/${encodeURIComponent(name)}` : "api/v4/functions";
2610
+ return _this.client.request({
2611
+ path,
2612
+ method: "GET"
2613
+ });
2614
+ }
2615
+ /** Create one or more functions. Returns the Location of the created resource. */
2616
+ async postFunction(body) {
2617
+ var _this2 = this;
2618
+ var _res$getHeader;
2619
+ return { location: (_res$getHeader = (await _this2.client.requestFull({
2620
+ path: "api/v4/functions",
2621
+ method: "POST",
2622
+ body,
2623
+ expectedStatus: 201
2624
+ })).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
2625
+ }
2626
+ /** Update a function. Changing the code bumps its version. */
2627
+ async patchFunction(name, body) {
2628
+ var _this3 = this;
2629
+ var _res$getHeader2;
2630
+ return { location: (_res$getHeader2 = (await _this3.client.requestFull({
2631
+ path: `api/v4/functions/${encodeURIComponent(name)}`,
2632
+ method: "PATCH",
2633
+ body,
2634
+ expectedStatus: 303
2635
+ })).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
2636
+ }
2637
+ /** Delete a function. */
2638
+ async deleteFunction(name) {
2639
+ await this.client.request({
2640
+ path: `api/v4/functions/${encodeURIComponent(name)}`,
2641
+ method: "DELETE",
2642
+ expectedStatus: 204
2643
+ });
2644
+ }
2645
+ /** Invoke a function synchronously and return its result. */
2646
+ async invoke(name, event = {}) {
2647
+ return this.client.request({
2648
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
2649
+ method: "POST",
2650
+ body: event
2651
+ });
2652
+ }
2653
+ /** Queue a function invocation; returns immediately with 202 and an id to poll. */
2654
+ async invokeAsync(name, event = {}) {
2655
+ return this.client.request({
2656
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
2657
+ method: "POST",
2658
+ body: event,
2659
+ query: { async: "true" },
2660
+ expectedStatus: 202
2661
+ });
2662
+ }
2663
+ /** Run once to infer and store input/output type schemas (for TypeScript generation). */
2664
+ async dryRun(name, event = {}) {
2665
+ return this.client.request({
2666
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
2667
+ method: "POST",
2668
+ body: event,
2669
+ query: { dry: "true" }
2670
+ });
2671
+ }
2672
+ /** Get a stored invocation record (e.g. to poll an async invocation). */
2673
+ async getInvocation(name, id) {
2674
+ return this.client.request({
2675
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations/${encodeURIComponent(id)}`,
2676
+ method: "GET"
2677
+ });
2678
+ }
2679
+ /** Get the generated TypeScript `Functions` interface (from dry-run schemas). */
2680
+ async getInterfaces() {
2681
+ return this.client.request({
2682
+ path: "api/v4/function-interfaces",
2683
+ method: "GET",
2684
+ accept: "text/plain"
2685
+ });
2686
+ }
2687
+ };
2688
+
2434
2689
  //#endregion
2435
2690
  //#region src/provisioning/MetadataWrite.ts
2436
2691
  var MetadataWrite = class {
@@ -2564,8 +2819,10 @@
2564
2819
  users: new ProvisioningUsers(http),
2565
2820
  clients: new ProvisioningClients(http),
2566
2821
  rules: new Rules(http),
2822
+ layers: new Layers(http),
2567
2823
  privileges: new Privileges(http),
2568
2824
  rpcMethods: new RpcMethods(http),
2825
+ functions: new Functions(http),
2569
2826
  metadata: new MetadataWrite(http),
2570
2827
  typeScript: new TypeScriptInterfaces(http),
2571
2828
  fileImport: new FileImport(http),
@@ -2574,6 +2831,140 @@
2574
2831
  };
2575
2832
  }
2576
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
+
2577
2968
  //#endregion
2578
2969
  //#region src/auth/errors.ts
2579
2970
  /**
@@ -2702,6 +3093,7 @@ exports.CodeFlow = CodeFlow;
2702
3093
  exports.Gql = Gql;
2703
3094
  exports.Meta = Meta;
2704
3095
  exports.NotLoggedInError = NotLoggedInError;
3096
+ exports.Ows = Ows;
2705
3097
  exports.PasswordFlow = PasswordFlow;
2706
3098
  exports.Rpc = Rpc;
2707
3099
  exports.SessionExpiredError = SessionExpiredError;
@@ -2712,6 +3104,7 @@ exports.Stats = Stats;
2712
3104
  exports.Status = Status;
2713
3105
  exports.Tables = Tables;
2714
3106
  exports.Users = Users;
3107
+ exports.Wfs = Wfs;
2715
3108
  exports.Ws = Ws;
2716
3109
  exports.createApi = createApi;
2717
3110
  exports.createCentiaAdminClient = createCentiaAdminClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centia-io/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Centia-io TypeScript SDK",
5
5
  "author": "Martin Høgh",
6
6
  "license": "MIT",