From 319026b5c5078ca0b6907d1c4935c99b15e60b51 Mon Sep 17 00:00:00 2001 From: Ben Bahrman Date: Wed, 18 Sep 2024 10:14:33 -0500 Subject: [PATCH 1/4] Assign type of any to asMap and asMappedResults to allow for assignment to meaningful specific type --- N/query.d.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/N/query.d.ts b/N/query.d.ts index b3bbdba9..675bcfc7 100644 --- a/N/query.d.ts +++ b/N/query.d.ts @@ -112,8 +112,8 @@ interface CreateColumnOptions { /** * An alias for this column. An alias is an alternate name for a column, and the alias is used in mapped results. - * In general, the alias is an optional property. - * + * In general, the alias is an optional property. + * * To use mapped results, you must specify an alias in the following situations: * 1. You must specify an alias for a column when the column uses a formula. * 2. You must specify an alias when two columns in a joined query use the same field ID. @@ -149,8 +149,8 @@ interface CreateColumnWithFormulaOptions { /** * An alias for this column. An alias is an alternate name for a column, and the alias is used in mapped results. - * In general, the alias is an optional property. - * + * In general, the alias is an optional property. + * * To use mapped results, you must specify an alias in the following situations: * 1. You must specify an alias for a column when the column uses a formula. * 2. You must specify an alias when two columns in a joined query use the same field ID. @@ -207,7 +207,7 @@ export interface RunSuiteQLOptions { query: string; params?: Array; - + customScriptId?: string; } @@ -602,7 +602,6 @@ export interface Condition { readonly component: Component; } -export type QueryResultMap = { [fieldId: string]: string | boolean | number | null } /** * Set of results returned by the query. */ @@ -637,8 +636,7 @@ export interface ResultSet { * A mapped result is a JavaScript object with key-value pairs. * In this object, the key is either the field ID or the alias that was used for the corresponding query.Column object. */ - asMappedResults(): Array; - asMappedResults(): Array; + asMappedResults(): Array; } /** Corresponds to a single row of the ResultSet. */ @@ -661,8 +659,7 @@ export interface Result { * A mapped result is a JavaScript object with key-value pairs. * In this object, the key is either the field ID or the alias that was used for the corresponding query.Column object. */ - asMap(): QueryResultMap; - asMap(): QueryResultMap + asMap(): any; } /** @@ -752,7 +749,7 @@ interface Period { readonly code: string; /** * The type of the period. This property uses values from the query.PeriodType enum. - * If you create a period using query.createPeriod(options) and do not specify a value for the options.type + * If you create a period using query.createPeriod(options) and do not specify a value for the options.type * parameter, the default value of this property is query.PeriodType.START. */ readonly type: string; @@ -1259,7 +1256,7 @@ export enum FieldContext { CONVERTED = "CONVERTED", /** Displays consolidated currency amounts in the base currency. */ CURRENCY_CONSOLIDATED = "CURRENCY_CONSOLIDATED", - /** + /** * Displays user-friendly field values. * For example, for the entity field on Transaction records, using the DISPLAY enum value displays the name of the entity instead of its ID. */ From eed0d5e45f5e2093fd941af4c3cb1d892cef6c87 Mon Sep 17 00:00:00 2001 From: Ben Bahrman Date: Thu, 19 Sep 2024 12:48:17 -0500 Subject: [PATCH 2/4] Updating to generic type per feedback --- N/query.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/N/query.d.ts b/N/query.d.ts index 675bcfc7..a601a088 100644 --- a/N/query.d.ts +++ b/N/query.d.ts @@ -602,6 +602,10 @@ export interface Condition { readonly component: Component; } +export type LowercaseKeys = { + [K in keyof T as Lowercase]: T[K]; +}; + /** * Set of results returned by the query. */ @@ -636,7 +640,7 @@ export interface ResultSet { * A mapped result is a JavaScript object with key-value pairs. * In this object, the key is either the field ID or the alias that was used for the corresponding query.Column object. */ - asMappedResults(): Array; + asMappedResults>(): LowercaseKeys[]; } /** Corresponds to a single row of the ResultSet. */ @@ -659,7 +663,7 @@ export interface Result { * A mapped result is a JavaScript object with key-value pairs. * In this object, the key is either the field ID or the alias that was used for the corresponding query.Column object. */ - asMap(): any; + asMap>(): LowercaseKeys; } /** From f374f77dd62a177c952c56129b88e5d392394e16 Mon Sep 17 00:00:00 2001 From: Ben Bahrman Date: Thu, 19 Sep 2024 18:07:19 +0000 Subject: [PATCH 3/4] Removed errant whitepace changes --- N/query.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/N/query.d.ts b/N/query.d.ts index a601a088..7a6e1d4a 100644 --- a/N/query.d.ts +++ b/N/query.d.ts @@ -112,8 +112,8 @@ interface CreateColumnOptions { /** * An alias for this column. An alias is an alternate name for a column, and the alias is used in mapped results. - * In general, the alias is an optional property. - * + * In general, the alias is an optional property. + * * To use mapped results, you must specify an alias in the following situations: * 1. You must specify an alias for a column when the column uses a formula. * 2. You must specify an alias when two columns in a joined query use the same field ID. @@ -149,8 +149,8 @@ interface CreateColumnWithFormulaOptions { /** * An alias for this column. An alias is an alternate name for a column, and the alias is used in mapped results. - * In general, the alias is an optional property. - * + * In general, the alias is an optional property. + * * To use mapped results, you must specify an alias in the following situations: * 1. You must specify an alias for a column when the column uses a formula. * 2. You must specify an alias when two columns in a joined query use the same field ID. @@ -207,7 +207,7 @@ export interface RunSuiteQLOptions { query: string; params?: Array; - + customScriptId?: string; } @@ -753,7 +753,7 @@ interface Period { readonly code: string; /** * The type of the period. This property uses values from the query.PeriodType enum. - * If you create a period using query.createPeriod(options) and do not specify a value for the options.type + * If you create a period using query.createPeriod(options) and do not specify a value for the options.type * parameter, the default value of this property is query.PeriodType.START. */ readonly type: string; @@ -1260,7 +1260,7 @@ export enum FieldContext { CONVERTED = "CONVERTED", /** Displays consolidated currency amounts in the base currency. */ CURRENCY_CONSOLIDATED = "CURRENCY_CONSOLIDATED", - /** + /** * Displays user-friendly field values. * For example, for the entity field on Transaction records, using the DISPLAY enum value displays the name of the entity instead of its ID. */ From 4477c9aade1e5e85b2334d64219a9a58321526d2 Mon Sep 17 00:00:00 2001 From: Ben Bahrman Date: Tue, 22 Oct 2024 07:14:30 -0500 Subject: [PATCH 4/4] Updating naming of QueryResultMap back to actual name --- N/query.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/N/query.d.ts b/N/query.d.ts index a601a088..34a06e5e 100644 --- a/N/query.d.ts +++ b/N/query.d.ts @@ -602,8 +602,8 @@ export interface Condition { readonly component: Component; } -export type LowercaseKeys = { - [K in keyof T as Lowercase]: T[K]; +export type QueryMapResult = { + [K in keyof T as Lowercase]: string|number|null; }; /** @@ -640,7 +640,7 @@ export interface ResultSet { * A mapped result is a JavaScript object with key-value pairs. * In this object, the key is either the field ID or the alias that was used for the corresponding query.Column object. */ - asMappedResults>(): LowercaseKeys[]; + asMappedResults>(): QueryMapResult; } /** Corresponds to a single row of the ResultSet. */ @@ -663,7 +663,7 @@ export interface Result { * A mapped result is a JavaScript object with key-value pairs. * In this object, the key is either the field ID or the alias that was used for the corresponding query.Column object. */ - asMap>(): LowercaseKeys; + asMap(): QueryResultMap } /**