@conterra/ct-mapapps-typings 4.19.0-next.20241122052258 → 4.19.0-next.20241125073200

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.
@@ -120,6 +120,10 @@ interface Watchable<WatchableProperties> {
120
120
  * ```
121
121
  */
122
122
  type ExtensibleUnion<Values extends BaseType, BaseType extends number | string> = Values | ({} & BaseType);
123
+ /**
124
+ * An object that constructs instances of type T.
125
+ */
126
+ type Constructor<T, Args extends unknown[] = unknown[]> = new (...args: Args) => T;
123
127
  declare const _default: null;
124
128
 
125
- export { type DeepReadonly, type DeepWritable, type Equal, type EventCallback, type EventEmitter, type EventSource, type ExtensibleUnion, type Handle, type Primitive, type RequiredProps, type TupleKeys, type WatchCallback, type WatchEvent, type Watchable, type Writable, _default as default };
129
+ export { type Constructor, type DeepReadonly, type DeepWritable, type Equal, type EventCallback, type EventEmitter, type EventSource, type ExtensibleUnion, type Handle, type Primitive, type RequiredProps, type TupleKeys, type WatchCallback, type WatchEvent, type Watchable, type Writable, _default as default };
@@ -295,11 +295,12 @@ interface Handle {
295
295
  */
296
296
  interface Config {
297
297
  /**
298
- * Maximum length of an url before a GET request is switched to POST.
298
+ * Maximum length of an url before a GET request is switched to POST
299
+ * (if {@link ApprtRequestInit.supportsPostSwitching | supportsPostSwitching} is true for a request).
299
300
  * GET requests altered in this way will have their query parameters
300
301
  * placed into the new POST request's body (as content-type application/x-www-form-urlencoded).
301
302
  *
302
- * Switching to POST requests can be disabled by setting this property to a value `<= 0`.
303
+ * Switching to POST requests can be disabled entirely by setting this property to a value `<= 0`.
303
304
  */
304
305
  maxUrlLength: number;
305
306
  /**
@@ -398,6 +399,13 @@ interface ApprtRequestInit extends RequestInit {
398
399
  * If `"force-off"` is used, no proxy server will be used, even if a proxy rule would match.
399
400
  */
400
401
  proxyMode?: ProxyMode;
402
+ /**
403
+ * If set to `true`, GET requests with very long URLs (see {@link Config.maxUrlLength})
404
+ * will automatically switch to POST requests.
405
+ *
406
+ * Default: `false`
407
+ */
408
+ supportsPostSwitching?: boolean;
401
409
  /**
402
410
  * Convenience option to add additional query arguments to the request.
403
411
  * The transport of the given value depends on the value of `queryTransport`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conterra/ct-mapapps-typings",
3
- "version": "4.19.0-next.20241122052258",
3
+ "version": "4.19.0-next.20241125073200",
4
4
  "description": "TypeDefinitions for ct-mapapps",
5
5
  "author": "conterra",
6
6
  "license": "Apache-2.0"
@@ -1,3 +1,4 @@
1
+ import { ApprtRequestInit, ApprtRequestTarget, CustomFetch } from 'apprt-fetch';
1
2
  import { IndexableThing, AsyncStore, Metadata, GetOptions, QueryOptions, AsyncQueryResult, ResultItems } from '../api/Store.js';
2
3
  import { ComplexQueryExpression } from '../api/ComplexQueryLang.js';
3
4
  import 'apprt-core/Events';
@@ -9,10 +10,6 @@ import 'esri/geometry/Geometry';
9
10
  interface RequestOptions {
10
11
  /** custom http headers */
11
12
  headers?: Record<string, any>;
12
- /** Flag if that JSONP (javascript communication should be used), this is deprecated
13
- * @deprecated
14
- */
15
- jsonp?: boolean;
16
13
  }
17
14
  /**
18
15
  * Extra options, provided in the hook method '_filterParams'
@@ -23,6 +20,13 @@ interface MethodParameters<ItemType, IDType> {
23
20
  object?: Partial<ItemType>;
24
21
  options: Record<string, any>;
25
22
  }
23
+ interface InternalRequestOptions extends ApprtRequestInit {
24
+ url: ApprtRequestTarget;
25
+ data?: string;
26
+ query?: Record<string, any>;
27
+ content?: Record<string, any>;
28
+ headers?: Record<string, string>;
29
+ }
26
30
  /**
27
31
  * Base Store implementation for simple rest services.
28
32
  * Provides get and query methods.
@@ -60,14 +64,6 @@ declare class BaseRestStore<ItemType extends IndexableThing, IDType extends stri
60
64
  * Range parameter transporting item range definitions.
61
65
  */
62
66
  rangeParam: string;
63
- /**
64
- * Shall jsonp used for get and query
65
- */
66
- jsonp: boolean;
67
- /**
68
- * The jsonp request parameter
69
- */
70
- callbackParam: string;
71
67
  /**
72
68
  * Identifies the item array in query responses
73
69
  */
@@ -100,7 +96,7 @@ declare class BaseRestStore<ItemType extends IndexableThing, IDType extends stri
100
96
  * @param options allows overwrite of any property
101
97
  * @param fetch the fetch method to use. Provided to customize in the constructor to make tests easier.
102
98
  */
103
- constructor(options?: Partial<Pick<BaseRestStore<ItemType, IDType>, keyof BaseRestStore<ItemType, IDType>>>, fetch?: (url: string, options: Record<string, any>) => Promise<any>);
99
+ constructor(options?: Partial<Pick<BaseRestStore<ItemType, IDType>, keyof BaseRestStore<ItemType, IDType>>>, fetch?: CustomFetch);
104
100
  /**
105
101
  * Gets identity of given item.
106
102
  * @param item an item of this store.
@@ -122,18 +118,18 @@ declare class BaseRestStore<ItemType extends IndexableThing, IDType extends stri
122
118
  /**
123
119
  * Queries the store for objects.
124
120
  */
125
- query(query?: ComplexQueryExpression, options?: QueryOptions): AsyncQueryResult<ItemType>;
121
+ query(query?: ComplexQueryExpression, options?: QueryOptions & RequestOptions): AsyncQueryResult<ItemType>;
126
122
  /**
127
123
  * Hook for sub classes to add/change request parameters.
128
124
  */
129
- protected _filterParams(invokedFromMethod: string, requestParameters: Record<string, any>, originalMethodParameters: MethodParameters<ItemType, IDType>): Record<string, any>;
125
+ protected _filterParams(invokedFromMethod: string, requestParameters: InternalRequestOptions, originalMethodParameters: MethodParameters<ItemType, IDType>): InternalRequestOptions;
130
126
  /**
131
127
  * Hook for subclasses to convert ComplexQueryExpression into request parameters.
132
128
  * @param requestParameters prepared request parameters
133
129
  * @param query the complex query
134
130
  * @param options the query options
135
131
  */
136
- protected _appendQueryToRequest(requestParameters: Record<string, any>, query: ComplexQueryExpression | undefined, options: QueryOptions): void;
132
+ protected _appendQueryToRequest(requestParameters: InternalRequestOptions, query: ComplexQueryExpression | undefined, options: QueryOptions): void;
137
133
  /**
138
134
  * Converts the options.start and options.count values to request parameters.
139
135
  * By default the headers "Range" and "X-Range" are calculated and
@@ -142,14 +138,14 @@ declare class BaseRestStore<ItemType extends IndexableThing, IDType extends stri
142
138
  * @param requestParameters request parameters will be changed
143
139
  * @param options the query options, with start + count.
144
140
  */
145
- protected _appendRangeToRequest(requestParameters: Record<string, any>, options: QueryOptions): void;
141
+ protected _appendRangeToRequest(requestParameters: InternalRequestOptions, options: QueryOptions): void;
146
142
  /**
147
143
  * Converts the options.sort to request parameters.
148
144
  * By default the sort options are converted into 'sort' request parameter, like '-id,+name,+title'.
149
145
  * @param requestParameters request parameters to change.
150
146
  * @param options the query options.
151
147
  */
152
- protected _appendSortToRequest(requestParameters: Record<string, any>, options: QueryOptions): void;
148
+ protected _appendSortToRequest(requestParameters: InternalRequestOptions, options: QueryOptions): void;
153
149
  /**
154
150
  * Transforms server responses into `ResultItems<T>`.
155
151
  * The default implementation expects a server response of this format:
@@ -180,9 +176,8 @@ declare class BaseRestStore<ItemType extends IndexableThing, IDType extends stri
180
176
  * @param options the request options.
181
177
  * @returns result of the request.
182
178
  */
183
- protected _executeRequest<T>(method: string, options: Record<string, any>): Promise<T>;
179
+ protected _executeRequest<T>(method: string, options: InternalRequestOptions): Promise<T>;
184
180
  private _fetchMetadata;
185
- private _checkError;
186
181
  }
187
182
 
188
- export { BaseRestStore, type MethodParameters, type RequestOptions };
183
+ export { BaseRestStore, type InternalRequestOptions, type MethodParameters, type RequestOptions };
@@ -1,5 +1,6 @@
1
1
  import { BaseRestStore, RequestOptions } from './BaseRestStore.js';
2
2
  import { IndexableThing, AsyncWritableStore, CreateOptions } from '../api/Store.js';
3
+ import 'apprt-fetch';
3
4
  import '../api/ComplexQueryLang.js';
4
5
  import 'esri/geometry/Geometry';
5
6
  import 'apprt-core/Events';
@@ -5,6 +5,7 @@ import { ComplexQueryOptions, ASTNode } from '../ComplexQuery.js';
5
5
  import 'apprt-core/Events';
6
6
  import 'esri/geometry/Geometry';
7
7
  import './BaseRestStore.js';
8
+ import 'apprt-fetch';
8
9
 
9
10
  type Transformer = (node: ASTNode, queryOptions: ComplexQueryOptions, subResults?: string[]) => string;
10
11
  declare function toRQL(query?: ComplexQueryExpression, options?: ComplexQueryOptions): string;
@@ -4,6 +4,7 @@ import { BaseWriteableRestStore } from './BaseWriteableRestStore.js';
4
4
  import 'apprt-core/Events';
5
5
  import 'esri/geometry/Geometry';
6
6
  import './BaseRestStore.js';
7
+ import 'apprt-fetch';
7
8
 
8
9
  /**
9
10
  * SQL Store is a RestStore which uses the SQL where expressions as query language.