@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.
@@ -2351,6 +2351,169 @@ var Rules = class {
2351
2351
  }
2352
2352
  };
2353
2353
 
2354
+ //#endregion
2355
+ //#region src/provisioning/Layers.ts
2356
+ var Layers = class {
2357
+ constructor(client) {
2358
+ this.client = client;
2359
+ }
2360
+ layerPath(layer) {
2361
+ return `api/v4/layers/${encodeURIComponent(layer)}`;
2362
+ }
2363
+ classPath(layer, classId) {
2364
+ return `${this.layerPath(layer)}/classes/${encodeURIComponent(classId)}`;
2365
+ }
2366
+ async getLayer(layer, opts) {
2367
+ var _this = this;
2368
+ const path = layer ? _this.layerPath(layer) : "api/v4/layers";
2369
+ const query = {};
2370
+ if (opts === null || opts === void 0 ? void 0 : opts.namesOnly) query.namesOnly = "true";
2371
+ return _this.client.request({
2372
+ path,
2373
+ method: "GET",
2374
+ query: Object.keys(query).length > 0 ? query : void 0
2375
+ });
2376
+ }
2377
+ /** Configure existing layer(s): set properties and replace classes. */
2378
+ async postLayer(body) {
2379
+ var _this2 = this;
2380
+ var _res$getHeader;
2381
+ return { location: (_res$getHeader = (await _this2.client.requestFull({
2382
+ path: "api/v4/layers",
2383
+ method: "POST",
2384
+ body,
2385
+ expectedStatus: 201
2386
+ })).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
2387
+ }
2388
+ /** Update layer properties (key-merge on the def JSON). */
2389
+ async patchLayer(layer, body) {
2390
+ var _this3 = this;
2391
+ var _res$getHeader2;
2392
+ return { location: (_res$getHeader2 = (await _this3.client.requestFull({
2393
+ path: _this3.layerPath(layer),
2394
+ method: "PATCH",
2395
+ body,
2396
+ expectedStatus: 303
2397
+ })).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
2398
+ }
2399
+ async getLayerClass(layer, classId) {
2400
+ var _this4 = this;
2401
+ const path = classId != null ? _this4.classPath(layer, classId) : `${_this4.layerPath(layer)}/classes`;
2402
+ return _this4.client.request({
2403
+ path,
2404
+ method: "GET"
2405
+ });
2406
+ }
2407
+ async postLayerClass(layer, body) {
2408
+ var _this5 = this;
2409
+ var _res$getHeader3;
2410
+ return { location: (_res$getHeader3 = (await _this5.client.requestFull({
2411
+ path: `${_this5.layerPath(layer)}/classes`,
2412
+ method: "POST",
2413
+ body,
2414
+ expectedStatus: 201
2415
+ })).getHeader("Location")) !== null && _res$getHeader3 !== void 0 ? _res$getHeader3 : "" };
2416
+ }
2417
+ /** Update a class (key-merge). Styles/labels are managed via their own methods. */
2418
+ async patchLayerClass(layer, classId, body) {
2419
+ var _this6 = this;
2420
+ var _res$getHeader4;
2421
+ return { location: (_res$getHeader4 = (await _this6.client.requestFull({
2422
+ path: _this6.classPath(layer, classId),
2423
+ method: "PATCH",
2424
+ body,
2425
+ expectedStatus: 303
2426
+ })).getHeader("Location")) !== null && _res$getHeader4 !== void 0 ? _res$getHeader4 : "" };
2427
+ }
2428
+ /** Delete class(es). `classId` may be a comma-separated list of ids. */
2429
+ async deleteLayerClass(layer, classId) {
2430
+ var _this7 = this;
2431
+ await _this7.client.request({
2432
+ path: _this7.classPath(layer, classId),
2433
+ method: "DELETE",
2434
+ expectedStatus: 204
2435
+ });
2436
+ }
2437
+ async getStyle(layer, classId, styleId) {
2438
+ var _this8 = this;
2439
+ const base = `${_this8.classPath(layer, classId)}/styles`;
2440
+ const path = styleId != null ? `${base}/${encodeURIComponent(styleId)}` : base;
2441
+ return _this8.client.request({
2442
+ path,
2443
+ method: "GET"
2444
+ });
2445
+ }
2446
+ async postStyle(layer, classId, body) {
2447
+ var _this9 = this;
2448
+ var _res$getHeader5;
2449
+ return { location: (_res$getHeader5 = (await _this9.client.requestFull({
2450
+ path: `${_this9.classPath(layer, classId)}/styles`,
2451
+ method: "POST",
2452
+ body,
2453
+ expectedStatus: 201
2454
+ })).getHeader("Location")) !== null && _res$getHeader5 !== void 0 ? _res$getHeader5 : "" };
2455
+ }
2456
+ /** Update a style (key-merge). */
2457
+ async patchStyle(layer, classId, styleId, body) {
2458
+ var _this10 = this;
2459
+ var _res$getHeader6;
2460
+ return { location: (_res$getHeader6 = (await _this10.client.requestFull({
2461
+ path: `${_this10.classPath(layer, classId)}/styles/${encodeURIComponent(styleId)}`,
2462
+ method: "PATCH",
2463
+ body,
2464
+ expectedStatus: 303
2465
+ })).getHeader("Location")) !== null && _res$getHeader6 !== void 0 ? _res$getHeader6 : "" };
2466
+ }
2467
+ /** Delete style(s). `styleId` may be a comma-separated list of ids. */
2468
+ async deleteStyle(layer, classId, styleId) {
2469
+ var _this11 = this;
2470
+ await _this11.client.request({
2471
+ path: `${_this11.classPath(layer, classId)}/styles/${encodeURIComponent(styleId)}`,
2472
+ method: "DELETE",
2473
+ expectedStatus: 204
2474
+ });
2475
+ }
2476
+ async getLabel(layer, classId, labelId) {
2477
+ var _this12 = this;
2478
+ const base = `${_this12.classPath(layer, classId)}/labels`;
2479
+ const path = labelId != null ? `${base}/${encodeURIComponent(labelId)}` : base;
2480
+ return _this12.client.request({
2481
+ path,
2482
+ method: "GET"
2483
+ });
2484
+ }
2485
+ async postLabel(layer, classId, body) {
2486
+ var _this13 = this;
2487
+ var _res$getHeader7;
2488
+ return { location: (_res$getHeader7 = (await _this13.client.requestFull({
2489
+ path: `${_this13.classPath(layer, classId)}/labels`,
2490
+ method: "POST",
2491
+ body,
2492
+ expectedStatus: 201
2493
+ })).getHeader("Location")) !== null && _res$getHeader7 !== void 0 ? _res$getHeader7 : "" };
2494
+ }
2495
+ /** Update a label (key-merge). */
2496
+ async patchLabel(layer, classId, labelId, body) {
2497
+ var _this14 = this;
2498
+ var _res$getHeader8;
2499
+ return { location: (_res$getHeader8 = (await _this14.client.requestFull({
2500
+ path: `${_this14.classPath(layer, classId)}/labels/${encodeURIComponent(labelId)}`,
2501
+ method: "PATCH",
2502
+ body,
2503
+ expectedStatus: 303
2504
+ })).getHeader("Location")) !== null && _res$getHeader8 !== void 0 ? _res$getHeader8 : "" };
2505
+ }
2506
+ /** Delete label(s). `labelId` may be a comma-separated list of ids. */
2507
+ async deleteLabel(layer, classId, labelId) {
2508
+ var _this15 = this;
2509
+ await _this15.client.request({
2510
+ path: `${_this15.classPath(layer, classId)}/labels/${encodeURIComponent(labelId)}`,
2511
+ method: "DELETE",
2512
+ expectedStatus: 204
2513
+ });
2514
+ }
2515
+ };
2516
+
2354
2517
  //#endregion
2355
2518
  //#region src/provisioning/Privileges.ts
2356
2519
  var Privileges = class {
@@ -2425,6 +2588,98 @@ var RpcMethods = class {
2425
2588
  }
2426
2589
  };
2427
2590
 
2591
+ //#endregion
2592
+ //#region src/provisioning/Functions.ts
2593
+ /**
2594
+ * Lambda-like functions: manage (CRUD), invoke (sync/async/dry-run) and read
2595
+ * the generated TypeScript interface.
2596
+ */
2597
+ var Functions = class {
2598
+ constructor(client) {
2599
+ this.client = client;
2600
+ }
2601
+ async getFunctions(name) {
2602
+ var _this = this;
2603
+ const path = name ? `api/v4/functions/${encodeURIComponent(name)}` : "api/v4/functions";
2604
+ return _this.client.request({
2605
+ path,
2606
+ method: "GET"
2607
+ });
2608
+ }
2609
+ /** Create one or more functions. Returns the Location of the created resource. */
2610
+ async postFunction(body) {
2611
+ var _this2 = this;
2612
+ var _res$getHeader;
2613
+ return { location: (_res$getHeader = (await _this2.client.requestFull({
2614
+ path: "api/v4/functions",
2615
+ method: "POST",
2616
+ body,
2617
+ expectedStatus: 201
2618
+ })).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
2619
+ }
2620
+ /** Update a function. Changing the code bumps its version. */
2621
+ async patchFunction(name, body) {
2622
+ var _this3 = this;
2623
+ var _res$getHeader2;
2624
+ return { location: (_res$getHeader2 = (await _this3.client.requestFull({
2625
+ path: `api/v4/functions/${encodeURIComponent(name)}`,
2626
+ method: "PATCH",
2627
+ body,
2628
+ expectedStatus: 303
2629
+ })).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
2630
+ }
2631
+ /** Delete a function. */
2632
+ async deleteFunction(name) {
2633
+ await this.client.request({
2634
+ path: `api/v4/functions/${encodeURIComponent(name)}`,
2635
+ method: "DELETE",
2636
+ expectedStatus: 204
2637
+ });
2638
+ }
2639
+ /** Invoke a function synchronously and return its result. */
2640
+ async invoke(name, event = {}) {
2641
+ return this.client.request({
2642
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
2643
+ method: "POST",
2644
+ body: event
2645
+ });
2646
+ }
2647
+ /** Queue a function invocation; returns immediately with 202 and an id to poll. */
2648
+ async invokeAsync(name, event = {}) {
2649
+ return this.client.request({
2650
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
2651
+ method: "POST",
2652
+ body: event,
2653
+ query: { async: "true" },
2654
+ expectedStatus: 202
2655
+ });
2656
+ }
2657
+ /** Run once to infer and store input/output type schemas (for TypeScript generation). */
2658
+ async dryRun(name, event = {}) {
2659
+ return this.client.request({
2660
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
2661
+ method: "POST",
2662
+ body: event,
2663
+ query: { dry: "true" }
2664
+ });
2665
+ }
2666
+ /** Get a stored invocation record (e.g. to poll an async invocation). */
2667
+ async getInvocation(name, id) {
2668
+ return this.client.request({
2669
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations/${encodeURIComponent(id)}`,
2670
+ method: "GET"
2671
+ });
2672
+ }
2673
+ /** Get the generated TypeScript `Functions` interface (from dry-run schemas). */
2674
+ async getInterfaces() {
2675
+ return this.client.request({
2676
+ path: "api/v4/function-interfaces",
2677
+ method: "GET",
2678
+ accept: "text/plain"
2679
+ });
2680
+ }
2681
+ };
2682
+
2428
2683
  //#endregion
2429
2684
  //#region src/provisioning/MetadataWrite.ts
2430
2685
  var MetadataWrite = class {
@@ -2558,8 +2813,10 @@ function createCentiaAdminClient(config) {
2558
2813
  users: new ProvisioningUsers(http),
2559
2814
  clients: new ProvisioningClients(http),
2560
2815
  rules: new Rules(http),
2816
+ layers: new Layers(http),
2561
2817
  privileges: new Privileges(http),
2562
2818
  rpcMethods: new RpcMethods(http),
2819
+ functions: new Functions(http),
2563
2820
  metadata: new MetadataWrite(http),
2564
2821
  typeScript: new TypeScriptInterfaces(http),
2565
2822
  fileImport: new FileImport(http),
@@ -2568,6 +2825,140 @@ function createCentiaAdminClient(config) {
2568
2825
  };
2569
2826
  }
2570
2827
 
2828
+ //#endregion
2829
+ //#region src/ogc/Ows.ts
2830
+ function toQuery$1(params) {
2831
+ if (!params) return void 0;
2832
+ const query = {};
2833
+ for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null) query[key] = String(value);
2834
+ return Object.keys(query).length > 0 ? query : void 0;
2835
+ }
2836
+ /**
2837
+ * OWS (WMS/WFS/UTFGRID) endpoint wrapper.
2838
+ *
2839
+ * Token-authenticated clients use `getOws`/`postOws`; anonymous and HTTP-Basic
2840
+ * clients use the `...NoToken` variants, which include the database in the path.
2841
+ *
2842
+ * Responses are streamed from the backend and returned as text (XML) or, for
2843
+ * JSON responses such as UTFGRID, as parsed JSON. Binary responses (e.g. WMS
2844
+ * GetMap images) are not supported by this wrapper — request those directly.
2845
+ */
2846
+ var Ows = class {
2847
+ constructor(client) {
2848
+ this.client = client;
2849
+ }
2850
+ /** Token-authenticated OWS GET (WMS/WFS/UTFGRID). */
2851
+ async getOws(schema, params) {
2852
+ return this.client.request({
2853
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}`,
2854
+ method: "GET",
2855
+ query: toQuery$1(params),
2856
+ accept: "*/*"
2857
+ });
2858
+ }
2859
+ /** Token-authenticated OWS POST (WFS XML). */
2860
+ async postOws(schema, xml) {
2861
+ return this.client.request({
2862
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}`,
2863
+ method: "POST",
2864
+ body: xml,
2865
+ contentType: "text/xml",
2866
+ accept: "*/*"
2867
+ });
2868
+ }
2869
+ /** Anonymous/HTTP-Basic OWS GET (WMS/WFS/UTFGRID). */
2870
+ async getOwsNoToken(schema, database, params) {
2871
+ return this.client.request({
2872
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`,
2873
+ method: "GET",
2874
+ query: toQuery$1(params),
2875
+ accept: "*/*"
2876
+ });
2877
+ }
2878
+ /** Anonymous/HTTP-Basic OWS POST (WFS XML). */
2879
+ async postOwsNoToken(schema, database, xml) {
2880
+ return this.client.request({
2881
+ path: `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`,
2882
+ method: "POST",
2883
+ body: xml,
2884
+ contentType: "text/xml",
2885
+ accept: "*/*"
2886
+ });
2887
+ }
2888
+ };
2889
+
2890
+ //#endregion
2891
+ //#region src/ogc/Wfs.ts
2892
+ function wfsPath(base, options) {
2893
+ let path = base;
2894
+ if ((options === null || options === void 0 ? void 0 : options.timeSlice) != null && options.srs == null) throw new Error("timeSlice requires srs to be set");
2895
+ if ((options === null || options === void 0 ? void 0 : options.srs) != null) {
2896
+ path += `/srs/${encodeURIComponent(options.srs)}`;
2897
+ if (options.timeSlice != null) path += `/${encodeURIComponent(options.timeSlice)}`;
2898
+ }
2899
+ return path;
2900
+ }
2901
+ function toQuery(params) {
2902
+ const query = { SERVICE: "WFS" };
2903
+ for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null) query[key] = String(value);
2904
+ return query;
2905
+ }
2906
+ /**
2907
+ * WFS endpoint wrapper (GetCapabilities, DescribeFeatureType, GetFeature and
2908
+ * WFS-T transactions).
2909
+ *
2910
+ * Token-authenticated clients use `getWfs`/`postWfs`; anonymous and HTTP-Basic
2911
+ * clients (e.g. QGIS) use the `...NoToken` variants, which include the
2912
+ * database in the path. Responses are returned as XML text.
2913
+ */
2914
+ var Wfs = class {
2915
+ constructor(client) {
2916
+ this.client = client;
2917
+ }
2918
+ /** Token-authenticated WFS GET. */
2919
+ async getWfs(schema, params, options) {
2920
+ return this.client.request({
2921
+ path: wfsPath(`api/v4/wfs/schema/${encodeURIComponent(schema)}`, options),
2922
+ method: "GET",
2923
+ query: toQuery(params),
2924
+ accept: "text/xml"
2925
+ });
2926
+ }
2927
+ /** Token-authenticated WFS POST (XML-encoded GetFeature or Transaction). */
2928
+ async postWfs(schema, xml, options) {
2929
+ return this.client.request({
2930
+ path: wfsPath(`api/v4/wfs/schema/${encodeURIComponent(schema)}`, options),
2931
+ method: "POST",
2932
+ body: xml,
2933
+ contentType: "text/xml",
2934
+ accept: "text/xml"
2935
+ });
2936
+ }
2937
+ /** Anonymous/HTTP-Basic WFS GET. */
2938
+ async getWfsNoToken(schema, database, params, options) {
2939
+ var _this3 = this;
2940
+ const base = `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
2941
+ return _this3.client.request({
2942
+ path: wfsPath(base, options),
2943
+ method: "GET",
2944
+ query: toQuery(params),
2945
+ accept: "text/xml"
2946
+ });
2947
+ }
2948
+ /** Anonymous/HTTP-Basic WFS POST (XML-encoded GetFeature or Transaction). */
2949
+ async postWfsNoToken(schema, database, xml, options) {
2950
+ var _this4 = this;
2951
+ const base = `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
2952
+ return _this4.client.request({
2953
+ path: wfsPath(base, options),
2954
+ method: "POST",
2955
+ body: xml,
2956
+ contentType: "text/xml",
2957
+ accept: "text/xml"
2958
+ });
2959
+ }
2960
+ };
2961
+
2571
2962
  //#endregion
2572
2963
  //#region src/auth/errors.ts
2573
2964
  /**
@@ -2690,5 +3081,5 @@ function isExpired(jwt, skewSeconds) {
2690
3081
  */
2691
3082
 
2692
3083
  //#endregion
2693
- export { CentiaApiError, Claims, CodeFlow, Gql, Meta, NotLoggedInError, PasswordFlow, Rpc, SessionExpiredError, SignUp, Sql, SqlNoToken, Stats, Status, Tables, Users, Ws, createApi, createCentiaAdminClient, createCentiaClient, createSqlBuilder, createTokenProvider, isCentiaApiError };
3084
+ export { CentiaApiError, Claims, CodeFlow, Gql, Meta, NotLoggedInError, Ows, PasswordFlow, Rpc, SessionExpiredError, SignUp, Sql, SqlNoToken, Stats, Status, Tables, Users, Wfs, Ws, createApi, createCentiaAdminClient, createCentiaClient, createSqlBuilder, createTokenProvider, isCentiaApiError };
2694
3085
  //# sourceMappingURL=centia-io-sdk.js.map