Project setProperties not working with Map

Passing a Map entity into entity.setProperties is not working as expected, however it’s enforced by TypeScript compiler. Using the entity.setProperties method with a plain object works as expectec.

Example (done in chrome console).

  1. get initial properties: await project.getProperties(); >>> {analysis_id: ‘null’}
  2. set properties with Map: await project.setProperties(new Map([[‘analysis_id’, ‘9b50c885-20d3-40a7-9c44-845313b8ba5d’]])); >>> aRa {x: Uint8Array(4), a: aR7, b: 200, c: ‘OK’, d: 4, …}
  3. get properties: await project.getProperties(); >>> {analysis_id: ‘null’}
  4. set properties with plain JS object: await project.setProperties({ ‘analysis_id’: ‘9b50c885-20d3-40a7-9c44-845313b8ba5d’ }); >>> aRa {x: Uint8Array(4), a: aR7, b: 200, c: ‘OK’, d: 4, …}
  5. get properties >>> await project.getProperties(); >>> {analysis_id: ‘9b50c885-20d3-40a7-9c44-845313b8ba5d’}

Thanks for reporting! Indeed, the signatures were wrong. We have just updated them to the following:

  /** Retrieves entity properties */
  getProperties(): Promise<{[index: string]: any}> {
    return new Promise((resolve, reject) => api.grok_EntitiesDataSource_GetProperties(grok.dapi.entities.dart, this.dart, (p: any) => resolve(p), (e: any) => reject(e)));
  }

  /** Sets entity properties */
  setProperties(props: {[index: string]: any}): Promise<any> {
    return new Promise((resolve, reject) => api.grok_EntitiesDataSource_SetProperties(grok.dapi.entities.dart, this.dart, props, (_: any) => resolve(_), (e: any) => reject(e)));
  }
1 Like