@api-client/core 0.12.18 → 0.13.1

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.
@@ -41725,10 +41725,10 @@
41725
41725
  "@id": "#191"
41726
41726
  },
41727
41727
  {
41728
- "@id": "#197"
41728
+ "@id": "#194"
41729
41729
  },
41730
41730
  {
41731
- "@id": "#194"
41731
+ "@id": "#197"
41732
41732
  },
41733
41733
  {
41734
41734
  "@id": "#200"
@@ -43117,7 +43117,7 @@
43117
43117
  "doc:ExternalDomainElement",
43118
43118
  "doc:DomainElement"
43119
43119
  ],
43120
- "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43120
+ "doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
43121
43121
  "core:mediaType": "application/yaml",
43122
43122
  "sourcemaps:sources": [
43123
43123
  {
@@ -43138,7 +43138,7 @@
43138
43138
  "doc:ExternalDomainElement",
43139
43139
  "doc:DomainElement"
43140
43140
  ],
43141
- "doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
43141
+ "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43142
43142
  "core:mediaType": "application/yaml",
43143
43143
  "sourcemaps:sources": [
43144
43144
  {
@@ -44421,12 +44421,12 @@
44421
44421
  {
44422
44422
  "@id": "#196/source-map/lexical/element_0",
44423
44423
  "sourcemaps:element": "amf://id#196",
44424
- "sourcemaps:value": "[(1,0)-(3,0)]"
44424
+ "sourcemaps:value": "[(1,0)-(10,0)]"
44425
44425
  },
44426
44426
  {
44427
44427
  "@id": "#199/source-map/lexical/element_0",
44428
44428
  "sourcemaps:element": "amf://id#199",
44429
- "sourcemaps:value": "[(1,0)-(10,0)]"
44429
+ "sourcemaps:value": "[(1,0)-(3,0)]"
44430
44430
  },
44431
44431
  {
44432
44432
  "@id": "#202/source-map/lexical/element_0",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.12.18",
4
+ "version": "0.13.1",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -350,6 +350,58 @@ export interface ContextListResult<T> {
350
350
  items: T[]
351
351
  }
352
352
 
353
+ /**
354
+ * Defines the type of comparison or operation to be performed on a field.
355
+ * - eq: Equal
356
+ * - neq: Not Equal
357
+ * - gt: Greater Than
358
+ * - lt: Less Than
359
+ * - gte: Greater Than or Equal
360
+ * - lte: Less Than or Equal
361
+ * - con: String contains substring / Array contains element
362
+ * - start: String starts with
363
+ * - end: String ends with
364
+ * - in: Value is one of the elements in the provided array
365
+ * - nin: Value is not one of the elements in the provided array
366
+ */
367
+ export type FilterOperator =
368
+ | 'eq' // Equal
369
+ | 'neq' // Not Equal
370
+ | 'gt' // Greater Than
371
+ | 'lt' // Less Than
372
+ | 'gte' // Greater Than or Equal
373
+ | 'lte' // Less Than or Equal
374
+ | 'con' // String contains substring / Array contains element
375
+ | 'start' // String starts with
376
+ | 'end' // String ends with
377
+ | 'in' // Value is one of the elements in the provided array
378
+ | 'nin' // Value is not one of the elements in the provided array
379
+
380
+ /**
381
+ * Represents a single filter condition applied to a field.
382
+ */
383
+ export interface AtomicFilter {
384
+ field: string
385
+ operator: FilterOperator
386
+ value?: unknown // The value to compare against the field.
387
+ // For 'in'/'nin', value should be an array.
388
+ }
389
+
390
+ /**
391
+ * Represents a group of filters combined with a logical operator.
392
+ * This allows for nesting and complex query construction.
393
+ */
394
+ export interface FilterGroup {
395
+ op: 'AND' | 'OR'
396
+ filters: (AtomicFilter | FilterGroup)[]
397
+ }
398
+
399
+ /**
400
+ * Represents a filter that can be either a single atomic condition
401
+ * or a group of conditions. This is the type to be used in ContextListOptions.
402
+ */
403
+ export type QueryFilter = AtomicFilter | FilterGroup
404
+
353
405
  /**
354
406
  * Base query options for the data store.
355
407
  */
@@ -359,25 +411,9 @@ export interface ContextListOptions {
359
411
  */
360
412
  limit?: number
361
413
  /**
362
- * Page cursor to use with the query. This is returned by the
414
+ * Page cursor to use with the query. This is returned by the API.
363
415
  */
364
416
  cursor?: string
365
- /**
366
- * Optional general purpose parent for the query.
367
- */
368
- parent?: string
369
- /**
370
- * Supported by some endpoints. When set it performs a query on the data store.
371
- */
372
- query?: string
373
- /**
374
- * Only with the `query` property. Tells the system in which fields to search for the query term.
375
- */
376
- queryField?: string[]
377
- /**
378
- * Whether to use the `descending` order.
379
- */
380
- descending?: boolean
381
417
  /**
382
418
  * The name of the field to order then results.
383
419
  */
@@ -387,11 +423,6 @@ export interface ContextListOptions {
387
423
  * It can be `asc` or `desc`.
388
424
  */
389
425
  order?: 'asc' | 'desc'
390
- /**
391
- * General purpose type property to filer the results.
392
- * This is used, for example, by the history store to list history for a specific type of requests,
393
- */
394
- type?: string
395
426
  /**
396
427
  * Used when synchronizing data in the local store with the data stored in the net-store.
397
428
  * The timestamp when the last synchronization was performed. The resulting array will contain only items that
@@ -399,14 +430,19 @@ export interface ContextListOptions {
399
430
  */
400
431
  since?: number
401
432
  /**
402
- * The list of kinds to list. This is used when querying for files.
433
+ * Optional parent identifier for hierarchical queries.
434
+ * Some specific list operations might use this directly.
403
435
  */
404
- kinds?: unknown[]
436
+ parent?: string
405
437
  /**
406
- * Some endpoints require the `oid` property to be set as a query parameter
407
- * and not as a part of the URL. It is used when the org id is optional.
438
+ * Optional organization identifier.
439
+ * Some specific list operations might use this directly if not part of the main path.
408
440
  */
409
441
  oid?: string
442
+ /**
443
+ * A structured filter object for advanced querying.
444
+ */
445
+ filter?: QueryFilter
410
446
  }
411
447
 
412
448
  export class ContextListEvent<T> extends ContextEvent<ContextListOptions, ContextListResult<T>> {
@@ -60,16 +60,12 @@ export class FilesSdk extends SdkBase {
60
60
  */
61
61
  async list(
62
62
  organization: string,
63
- kinds?: ListFileKind[],
64
63
  options: ContextListOptions = {},
65
64
  request: SdkOptions = {}
66
65
  ): Promise<ContextListResult<IFile>> {
67
66
  const { token } = request
68
67
  const opts = { ...options }
69
68
  const url = this.sdk.getUrl(RouteBuilder.files(organization))
70
- if (kinds && kinds.length) {
71
- opts.kinds = kinds
72
- }
73
69
  this.sdk.appendListOptions(url, opts)
74
70
  const result = await this.sdk.http.get(url.toString(), { token })
75
71
  this.inspectCommonStatusCodes(result)
package/src/sdk/Sdk.ts CHANGED
@@ -144,26 +144,12 @@ export abstract class Sdk {
144
144
  if (options.cursor) {
145
145
  searchParams.set('cursor', options.cursor)
146
146
  }
147
- if (Array.isArray(options.kinds)) {
148
- options.kinds.forEach((k) => url.searchParams.append('kinds', String(k)))
149
- }
150
147
  if (typeof options.limit === 'number') {
151
148
  searchParams.set('limit', String(options.limit))
152
149
  }
153
- if (options.query) {
154
- searchParams.set('query', options.query)
155
- }
156
- if (Array.isArray(options.queryField)) {
157
- options.queryField.forEach((field) => {
158
- searchParams.append('queryField', field)
159
- })
160
- }
161
150
  if (options.parent) {
162
151
  searchParams.set('parent', options.parent)
163
152
  }
164
- if (options.type) {
165
- searchParams.set('type', options.type)
166
- }
167
153
  if (options.since) {
168
154
  searchParams.set('since', String(options.since))
169
155
  }
@@ -176,8 +162,12 @@ export abstract class Sdk {
176
162
  if (options.oid) {
177
163
  searchParams.set('oid', String(options.oid))
178
164
  }
179
- if (typeof options.descending === 'boolean') {
180
- searchParams.set('descending', String(options.descending))
165
+ if (options.filter) {
166
+ const bytes = new TextEncoder().encode(JSON.stringify(options.filter))
167
+ // To be used when Uint8Array.prototype.toBase64() is available.
168
+ // const encoded = bytes.toBase64({ alphabet: 'base64url' })
169
+ const binString = Array.from(bytes, (byte) => String.fromCodePoint(byte)).join('')
170
+ searchParams.set('filter', btoa(binString))
181
171
  }
182
172
  }
183
173
  }
@@ -8,7 +8,6 @@ import {
8
8
  } from './SdkBase.js'
9
9
  import { RouteBuilder } from './RouteBuilder.js'
10
10
  import { IFile } from '../models/store/File.js'
11
- import { ListFileKind } from './FilesSdk.js'
12
11
  import { ContextListOptions, ContextListResult } from '../events/BaseEvents.js'
13
12
  import { Exception } from '../exceptions/exception.js'
14
13
 
@@ -22,16 +21,12 @@ export class SharedSdk extends SdkBase {
22
21
  */
23
22
  async list(
24
23
  organization: string,
25
- kinds?: ListFileKind[],
26
24
  options?: ContextListOptions,
27
25
  request: SdkOptions = {}
28
26
  ): Promise<ContextListResult<IFile>> {
29
27
  const { token } = request
30
28
  const url = this.sdk.getUrl(RouteBuilder.shared(organization))
31
29
  this.sdk.appendListOptions(url, options)
32
- if (Array.isArray(kinds)) {
33
- kinds.forEach((k) => url.searchParams.append('kind', k))
34
- }
35
30
  const result = await this.sdk.http.get(url.toString(), { token })
36
31
  this.inspectCommonStatusCodes(result)
37
32
  const E_PREFIX = 'Unable to list organizations. '