@narrative.io/data-collaboration-sdk-ts 0.27.0 → 1.0.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.
Files changed (50) hide show
  1. package/build/access-rules/index.d.ts +1 -1
  2. package/build/access-rules/types.d.ts +1 -1
  3. package/build/access-tokens/index.d.ts +2 -2
  4. package/build/apps/index.d.ts +2 -2
  5. package/build/attributes/index.d.ts +2 -2
  6. package/build/authentication/index.d.ts +1 -1
  7. package/build/base-api.d.ts +3 -3
  8. package/build/company-info/index.d.ts +2 -2
  9. package/build/connections/index.d.ts +1 -1
  10. package/build/contracts/index.d.ts +1 -1
  11. package/build/data-planes/index.d.ts +1 -1
  12. package/build/data-streams/index.d.ts +2 -2
  13. package/build/data-streams/index.js +1 -3
  14. package/build/data-streams/types.d.ts +1 -1
  15. package/build/datasets/index.d.ts +15 -15
  16. package/build/datasets/index.js +12 -12
  17. package/build/datasets/types.d.ts +1 -1
  18. package/build/forecast/index.d.ts +1 -1
  19. package/build/forecast/types.d.ts +1 -1
  20. package/build/health/index.d.ts +1 -1
  21. package/build/index.d.ts +35 -35
  22. package/build/index.js +25 -23
  23. package/build/installations/index.d.ts +2 -2
  24. package/build/jobs/index.d.ts +2 -2
  25. package/build/jobs/types.d.ts +3 -3
  26. package/build/mappings/index.d.ts +2 -2
  27. package/build/mappings/index.js +3 -3
  28. package/build/nql/AstParser.js +10 -15
  29. package/build/nql/AstTraverse.d.ts +1 -1
  30. package/build/nql/AstTraverse.js +4 -4
  31. package/build/nql/DataRulesConverter.d.ts +2 -2
  32. package/build/nql/DataRulesConverter.js +20 -23
  33. package/build/nql/NQLParser.js +23 -31
  34. package/build/nql/NqlBuilder.d.ts +2 -2
  35. package/build/nql/NqlBuilder.js +8 -21
  36. package/build/nql/SubstraitParser.d.ts +1 -2
  37. package/build/nql/SubstraitParser.js +27 -39
  38. package/build/nql/index.d.ts +2 -2
  39. package/build/nql/types.d.ts +1 -1
  40. package/build/ping/index.d.ts +1 -1
  41. package/build/products/index.d.ts +1 -1
  42. package/build/resources/index.d.ts +3 -3
  43. package/build/rosetta-stone/index.d.ts +1 -1
  44. package/build/subscriptions/index.d.ts +2 -2
  45. package/build/subscriptions/types.d.ts +2 -2
  46. package/build/uploads/index.d.ts +1 -1
  47. package/build/uploads/index.js +1 -3
  48. package/build/utils.js +7 -11
  49. package/build/whoami/index.d.ts +1 -1
  50. package/package.json +43 -45
@@ -35,7 +35,7 @@ async function getAttributesFromFields(fields) {
35
35
  const uniqueAttributes = [
36
36
  ...new Set(fields.map((field) => stripQuotes(field.field).split(".")[0])),
37
37
  ].filter((att) => !att.startsWith("_"));
38
- uniqueAttributes.forEach((att) => {
38
+ for (const att of uniqueAttributes) {
39
39
  const isObjectProperty = isObject(attributes.records, att);
40
40
  const relevantFields = isObjectProperty != null
41
41
  ? fields.filter((field) => stripQuotes(field.field).split(".")[0] === att &&
@@ -50,9 +50,9 @@ async function getAttributesFromFields(fields) {
50
50
  fields: relevantFields.length > 0
51
51
  ? relevantFields
52
52
  : buildField(att, findAttributeProperties(attributes.records, att)),
53
- optional: fields.some((field) => field.field.startsWith(att + ".") && field.filter === undefined),
53
+ optional: fields.some((field) => field.field.startsWith(`${att}.`) && field.filter === undefined),
54
54
  });
55
- });
55
+ }
56
56
  ensureAtLeastOneRequired(attributesArray);
57
57
  return attributesArray;
58
58
  }
@@ -102,14 +102,12 @@ function getPriceFromNql(nqlObject) {
102
102
  micro_cents_usd: priceFilter[0].right * 100000000,
103
103
  };
104
104
  }
105
- else if (typeof priceFilter[0].left === "number") {
105
+ if (typeof priceFilter[0].left === "number") {
106
106
  return {
107
107
  micro_cents_usd: priceFilter[0].left * 100000000,
108
108
  };
109
109
  }
110
- else {
111
- throw new Error("Expected one side of price filter to be a number");
112
- }
110
+ throw new Error("Expected one side of price filter to be a number");
113
111
  }
114
112
  /**
115
113
  * Extract fields from an NQL object.
@@ -119,16 +117,16 @@ function getPriceFromNql(nqlObject) {
119
117
  function getFieldsFromNql(nqlObject) {
120
118
  const fieldsArray = [];
121
119
  // Extract all fields from the 'select' section and mark them as exported.
122
- nqlObject.select.forEach((field) => {
120
+ for (const field of nqlObject.select) {
123
121
  fieldsArray.push({
124
122
  field: stripQuotes(field.field),
125
123
  exported: true,
126
124
  });
127
- });
125
+ }
128
126
  // Process all filter expressions from the 'where' section.
129
- nqlObject.where.filterExpressions.forEach((expression) => {
127
+ for (const expression of nqlObject.where.filterExpressions) {
130
128
  handleFilterExpression(expression, fieldsArray);
131
- });
129
+ }
132
130
  return fieldsArray;
133
131
  }
134
132
  /**
@@ -158,7 +156,10 @@ function handleFilterExpression(expression, fieldsArray) {
158
156
  * @param {any} filterExpression - The filter expression to add to the field.
159
157
  */
160
158
  function updateFieldsArray(field, fieldsArray, filterExpression) {
161
- const existingEntry = fieldsArray.find((entry) => entry.field === stripQuotes(field.field));
159
+ const existingEntry = fieldsArray.find((entry) => entry.field ===
160
+ stripQuotes(typeof field === "object" && "field" in field
161
+ ? field.field
162
+ : field));
162
163
  if (existingEntry !== undefined) {
163
164
  if (existingEntry.filter !== undefined &&
164
165
  typeof existingEntry.filter === "object" &&
@@ -174,7 +175,9 @@ function updateFieldsArray(field, fieldsArray, filterExpression) {
174
175
  else {
175
176
  // If this field does not exist in the fieldsArray, add it with the new filter expression.
176
177
  fieldsArray.push({
177
- field: stripQuotes(field.field),
178
+ field: stripQuotes(typeof field === "object" && "field" in field
179
+ ? field.field
180
+ : field),
178
181
  exported: false,
179
182
  filter: { expressions: [filterExpression] },
180
183
  });
@@ -205,15 +208,13 @@ function expressionToString(expr) {
205
208
  if (typeof expr === "string") {
206
209
  return `${addParentheses(expr)}`;
207
210
  }
208
- else if (typeof expr === "number") {
211
+ if (typeof expr === "number") {
209
212
  return expr.toString();
210
213
  }
211
- else if (typeof expr === "boolean") {
214
+ if (typeof expr === "boolean") {
212
215
  return expr.toString();
213
216
  }
214
- else {
215
- return expr.field;
216
- }
217
+ return expr.field;
217
218
  }
218
219
  /**
219
220
  * Adds parentheses to 'CURRENT_TIMESTAMP' or 'CURRENT_DATE' in the input string
@@ -311,7 +312,6 @@ export function generateFromClause(dataRules) {
311
312
  // Handle Column Sets
312
313
  if (dataRules.column_sets !== undefined) {
313
314
  for (const columnSet of dataRules.column_sets) {
314
- // eslint-disable-next-line @typescript-eslint/naming-convention
315
315
  const { dataset_id } = columnSet;
316
316
  fromClause.push(`company_data.${dataset_id}`);
317
317
  }
@@ -322,7 +322,6 @@ export function generateFromClause(dataRules) {
322
322
  }
323
323
  // Handle JOINs
324
324
  if (dataRules.dataset_filter !== undefined) {
325
- // eslint-disable-next-line @typescript-eslint/naming-convention
326
325
  const { dataset_id, attribute } = dataRules.dataset_filter;
327
326
  const joinClause = `JOIN company_data.${dataset_id} ON company_data.${dataset_id}."${attribute.field}" = narrative.rosetta_stone."${attribute.field}"`;
328
327
  fromClause.push(joinClause);
@@ -354,12 +353,11 @@ export function dataRulesToSQL(dataRules) {
354
353
  function generateSelectClause(dataRules) {
355
354
  let selectColumns = [];
356
355
  const quoteField = (field) => field.includes(".")
357
- ? `${field.split(".")[0]}.` + '"' + field.split(".")[1] + '"'
356
+ ? `${field.split(".")[0]}."${field.split(".")[1]}"`
358
357
  : `"${field}"`;
359
358
  // Handle Column Sets
360
359
  if (dataRules.column_sets !== undefined) {
361
360
  for (const columnSet of dataRules.column_sets) {
362
- // eslint-disable-next-line @typescript-eslint/naming-convention
363
361
  const { dataset_id, fields } = columnSet;
364
362
  const qualifiedFields = fields
365
363
  .filter((f) => f.exported)
@@ -418,7 +416,6 @@ function generateWhereClause(dataRules) {
418
416
  // Handle Column Sets
419
417
  if (dataRules.column_sets !== undefined) {
420
418
  for (const columnSet of dataRules.column_sets) {
421
- // eslint-disable-next-line @typescript-eslint/naming-convention
422
419
  const { dataset_id, fields } = columnSet;
423
420
  for (const field of fields) {
424
421
  if (field.filter !== undefined) {
@@ -1,4 +1,4 @@
1
- import { NqlBooleanExpressionObj, NqlBudgetObj, NqlFieldObj, NqlFilterExpressionObj, NqlObj, NqlPreSelectExpressionObj, NqlTableObject, NqlWhereObj, NqlFilterUnaryExpressionObj, } from "./types";
1
+ import { NqlBooleanExpressionObj, NqlBudgetObj, NqlFieldObj, NqlFilterExpressionObj, NqlFilterUnaryExpressionObj, NqlObj, NqlPreSelectExpressionObj, NqlTableObject, NqlWhereObj, } from "./types";
2
2
  /**
3
3
  * Retrieves the WHERE clause from the given NQL (Nested Query Language) string and returns a parsed NqlWhereClause object.
4
4
  *
@@ -17,9 +17,7 @@ export function getWhere(nql) {
17
17
  filterExpressions,
18
18
  });
19
19
  }
20
- else {
21
- throw new Error("No WHERE clause found");
22
- }
20
+ throw new Error("No WHERE clause found");
23
21
  }
24
22
  /**
25
23
  * Retrieves the tables from the given NQL (Nested Query Language) string and returns an array of parsed NqlTable objects.
@@ -41,9 +39,7 @@ export function getFrom(nql) {
41
39
  });
42
40
  return tables;
43
41
  }
44
- else {
45
- throw new Error("No FROM clause found");
46
- }
42
+ throw new Error("No FROM clause found");
47
43
  }
48
44
  /**
49
45
  * Extracts boolean expressions from the WHERE clause string and returns an array of parsed NqlBooleanExpression objects.
@@ -54,9 +50,10 @@ export function getFrom(nql) {
54
50
  function getBooleanExpressionsFromWhere(where) {
55
51
  const booleanRegex = /\s(OR|AND)\s/gi;
56
52
  const matches = [];
57
- let boolMatch;
58
- while ((boolMatch = booleanRegex.exec(where)) !== null) {
53
+ let boolMatch = booleanRegex.exec(where);
54
+ while (boolMatch !== null) {
59
55
  matches.push(boolMatch[1].trim().toUpperCase());
56
+ boolMatch = booleanRegex.exec(where);
60
57
  }
61
58
  return NqlBooleanExpressionObj.array().parse(matches);
62
59
  }
@@ -112,7 +109,7 @@ function parseFieldFromString(fieldStr) {
112
109
  function parseString(value) {
113
110
  // Attempt to parse as a number
114
111
  const parsedNumber = Number(value);
115
- if (!isNaN(parsedNumber)) {
112
+ if (!Number.isNaN(parsedNumber)) {
116
113
  return parsedNumber;
117
114
  }
118
115
  // Attempt to parse as a boolean
@@ -231,9 +228,7 @@ export function getSelect(nql) {
231
228
  return NqlFieldObj.parse({ table: t, field: field.join(".") });
232
229
  });
233
230
  }
234
- else {
235
- throw new Error("No selected fields found");
236
- }
231
+ throw new Error("No selected fields found");
237
232
  }
238
233
  /**
239
234
  * Builds a SELECT clause for an NQL (Natural Query Language) query based on the provided fields.
@@ -243,11 +238,12 @@ export function getSelect(nql) {
243
238
  * @throws {Error} - If any of the provided fields are invalid.
244
239
  */
245
240
  export function buildSelect(fields) {
246
- fields.forEach((f) => NqlFieldObj.parse(f));
247
- return ("SELECT " +
248
- fields
249
- .map((f) => `${f.table.database}.${f.table.table}.${f.field}`)
250
- .join(", "));
241
+ for (const f of fields) {
242
+ NqlFieldObj.parse(f);
243
+ }
244
+ return `SELECT ${fields
245
+ .map((f) => `${f.table.database}.${f.table.table}.${f.field}`)
246
+ .join(", ")}`;
251
247
  }
252
248
  /**
253
249
  * Parses a string in NQL format and returns an NqlBudgetType object.
@@ -263,15 +259,13 @@ export function getLimit(nql) {
263
259
  if (match != null) {
264
260
  const [, value, currency, period] = match;
265
261
  const result = {
266
- value: parseInt(value, 10),
262
+ value: Number.parseInt(value, 10),
267
263
  currency: currency.toUpperCase(),
268
264
  period: period.toUpperCase(),
269
265
  };
270
266
  return NqlBudgetObj.parse(result);
271
267
  }
272
- else {
273
- throw new Error("Invalid budget");
274
- }
268
+ throw new Error("Invalid budget");
275
269
  }
276
270
  /**
277
271
  * Builds a LIMIT clause for an NQL (Narrative Query Language) query based on the provided budget object.
@@ -312,7 +306,7 @@ export function buildFrom(from) {
312
306
  export function buildWhere(where) {
313
307
  NqlWhereObj.parse(where);
314
308
  let str = where.filterExpressions.length > 0 ? "WHERE" : "";
315
- where.filterExpressions.forEach((f, i) => {
309
+ for (const [i, f] of where.filterExpressions.entries()) {
316
310
  if ("field" in f) {
317
311
  str += ` ${buildField(f.field)} ${f.operator}`;
318
312
  }
@@ -322,7 +316,7 @@ export function buildWhere(where) {
322
316
  if (where.booleanExpressions[i] != null) {
323
317
  str += ` ${where.booleanExpressions[i]}`;
324
318
  }
325
- });
319
+ }
326
320
  return str;
327
321
  }
328
322
  export function buildField(field) {
@@ -345,13 +339,11 @@ export function getNqlObject(nql, type) {
345
339
  if (type === undefined || type === "full") {
346
340
  return parsed;
347
341
  }
348
- else {
349
- return {
350
- where: createSemanticWhere(parsed.where),
351
- from: parsed.from,
352
- select: parsed.select,
353
- };
354
- }
342
+ return {
343
+ where: createSemanticWhere(parsed.where),
344
+ from: parsed.from,
345
+ select: parsed.select,
346
+ };
355
347
  }
356
348
  export function createSemanticWhere(expressionContainer) {
357
349
  const copy = JSON.parse(JSON.stringify(expressionContainer)); // deep copy
@@ -1,5 +1,5 @@
1
- import { type NqlBudget } from "./Ast";
2
- import { type Output, type CreateMaterializedView, type Deduplication, type Explain, type Expression, type Raw, type Select, type Statement, type Table } from "./AstParser";
1
+ import type { NqlBudget } from "./Ast";
2
+ import type { CreateMaterializedView, Deduplication, Explain, Expression, Output, Raw, Select, Statement, Table } from "./AstParser";
3
3
  export type CompiledNql = string;
4
4
  export declare function compileStatement(n: Statement): CompiledNql;
5
5
  export declare function compileCreateMaterializedView(n: CreateMaterializedView): CompiledNql;
@@ -10,7 +10,6 @@ export function compileStatement(n) {
10
10
  }
11
11
  }
12
12
  export function compileCreateMaterializedView(n) {
13
- // eslint-disable-next-line prettier/prettier
14
13
  return `CREATE MATERIALIZE VIEW ${quote(n.name)} (${compileSelect(n.select)})`;
15
14
  }
16
15
  export function compileExplain(n) {
@@ -41,7 +40,6 @@ export function compileBudget(budget) {
41
40
  default:
42
41
  unreachable(budget.period.type);
43
42
  }
44
- // eslint-disable-next-line prettier/prettier
45
43
  return `LIMIT ${budget.amount.value} ${budget.amount.currency.toUpperCase()} ${period}`;
46
44
  }
47
45
  export function compileDeduplication(d) {
@@ -49,17 +47,13 @@ export function compileDeduplication(d) {
49
47
  const expressions = d.expressions.map(compileExpression).join(", ");
50
48
  return `ROW_NUMBER() OVER (PARTITION BY ${expressions} ORDER BY 0) = 1`;
51
49
  }
52
- else {
53
- return raw(d);
54
- }
50
+ return raw(d);
55
51
  }
56
52
  export function compileFrom(tables) {
57
53
  if (isArray(tables)) {
58
54
  return compileTableRefs(tables);
59
55
  }
60
- else {
61
- return compileRawRef(tables.nql, tables.as);
62
- }
56
+ return compileRawRef(tables.nql, tables.as);
63
57
  }
64
58
  function compileTableRefs(tables) {
65
59
  function ref(table) {
@@ -67,7 +61,7 @@ function compileTableRefs(tables) {
67
61
  case "dataset":
68
62
  return aliased(`company_data.${quote(table.datasetId.toString())}`, table.as, false);
69
63
  case "rosetta_stone":
70
- return aliased(`narrative.rosetta_stone`, table.as, false);
64
+ return aliased("narrative.rosetta_stone", table.as, false);
71
65
  case "raw_table":
72
66
  return aliased(table.nql, table.as, false);
73
67
  }
@@ -117,7 +111,6 @@ function compileTableRefs(tables) {
117
111
  if (
118
112
  // Prefer explicit `join !== undefined` to the use of the `?` operator so that typescript
119
113
  // compile knows that the join is defined in the subsequent lexical scope.
120
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
121
114
  table.join !== undefined &&
122
115
  table.join.condition !== null &&
123
116
  table.join.conditionType !== "none") {
@@ -220,9 +213,7 @@ function compileAttributeRef(column, as, aliasParens) {
220
213
  if (index === 0) {
221
214
  return `${acc}${quote(segment)}`;
222
215
  }
223
- else {
224
- return `${acc}.${quote(segment)}`;
225
- }
216
+ return `${acc}.${quote(segment)}`;
226
217
  }, "");
227
218
  return aliased(`narrative.rosetta_stone.${quotedSegments}`, as, aliasParens);
228
219
  }
@@ -242,9 +233,7 @@ function compileDatasetColumnRef(datasetId, column, as, aliasParen) {
242
233
  if (index === 0) {
243
234
  return `${acc}${quote(segment)}`;
244
235
  }
245
- else {
246
- return `${acc}.${quote(segment)}`;
247
- }
236
+ return `${acc}.${quote(segment)}`;
248
237
  }, "");
249
238
  return aliased(`company_data.${quote(datasetId.toString())}.${formattedColumn}`, as, false);
250
239
  }
@@ -311,10 +300,10 @@ function compileLit(value, valueType, as) {
311
300
  break;
312
301
  }
313
302
  case "long":
314
- valueNql = `${parseInt(value)}`;
303
+ valueNql = `${Number.parseInt(value)}`;
315
304
  break;
316
305
  case "double":
317
- valueNql = `${parseFloat(value)}`;
306
+ valueNql = `${Number.parseFloat(value)}`;
318
307
  break;
319
308
  default:
320
309
  // todo(mbabic) don't really know what to do here/how complicated this needs to be
@@ -343,9 +332,7 @@ function aliased(nql, as, parens) {
343
332
  if ((parens === undefined || parens) && as !== undefined) {
344
333
  return `(${alias})`;
345
334
  }
346
- else {
347
- return alias;
348
- }
335
+ return alias;
349
336
  }
350
337
  function str(s) {
351
338
  // todo(mbabic) is this the right escaping for calcite?
@@ -267,8 +267,7 @@ interface MultiBucketExpression {
267
267
  expression: Expression;
268
268
  constrained_to_count: boolean;
269
269
  }
270
- interface Broadcast {
271
- }
270
+ type Broadcast = unknown;
272
271
  interface RoundRobin {
273
272
  exact: boolean;
274
273
  }
@@ -185,9 +185,7 @@ class SubstraitParser {
185
185
  if (ref.structField != null) {
186
186
  return this.structFieldToField(ref.structField, exprIn);
187
187
  }
188
- else {
189
- throw new Error(`Unrecognized direct reference: ${JSON.stringify(ref)}`);
190
- }
188
+ throw new Error(`Unrecognized direct reference: ${JSON.stringify(ref)}`);
191
189
  }
192
190
  /**
193
191
  * Convert a reference to a stringified representation
@@ -199,9 +197,7 @@ class SubstraitParser {
199
197
  if (ref.directReference != null) {
200
198
  return this.directReferenceToField(ref.directReference, exprIn);
201
199
  }
202
- else {
203
- throw new Error(`Unrecognized reference: ${JSON.stringify(ref)}`);
204
- }
200
+ throw new Error(`Unrecognized reference: ${JSON.stringify(ref)}`);
205
201
  }
206
202
  /**
207
203
  * Convert a Substrait function argument to a string
@@ -216,15 +212,13 @@ class SubstraitParser {
216
212
  }
217
213
  return arg.enum.specified;
218
214
  }
219
- else if (arg.type != null) {
215
+ if (arg.type != null) {
220
216
  return this.typeToField(arg.type).type;
221
217
  }
222
- else if (arg.value != null) {
218
+ if (arg.value != null) {
223
219
  return this.expressionToStr(arg.value, inp).name;
224
220
  }
225
- else {
226
- throw new Error("A FunctionArgument did not have an enum/type/value");
227
- }
221
+ throw new Error("A FunctionArgument did not have an enum/type/value");
228
222
  }
229
223
  /**
230
224
  * Converts a Substrait function reference to a string
@@ -292,7 +286,7 @@ class SubstraitParser {
292
286
  children: [],
293
287
  };
294
288
  }
295
- else if (lit.date != null) {
289
+ if (lit.date != null) {
296
290
  return {
297
291
  name: new Date((lit.date?.value ?? 0) * 8.64e7).toISOString(),
298
292
  type: "date",
@@ -300,7 +294,7 @@ class SubstraitParser {
300
294
  children: [],
301
295
  };
302
296
  }
303
- else if (lit.decimal != null) {
297
+ if (lit.decimal != null) {
304
298
  return {
305
299
  name: String(this.base64ToDecimal(lit.decimal.value ?? "", lit.decimal.precision, lit.decimal.scale)),
306
300
  type: "decimal",
@@ -308,7 +302,7 @@ class SubstraitParser {
308
302
  children: [],
309
303
  };
310
304
  }
311
- else if (lit.i32 != null) {
305
+ if (lit.i32 != null) {
312
306
  return {
313
307
  name: lit.i32?.value?.toString() ?? "unspecified",
314
308
  type: "i32",
@@ -316,7 +310,7 @@ class SubstraitParser {
316
310
  children: [],
317
311
  };
318
312
  }
319
- else if (lit.intervalDayToSecond != null) {
313
+ if (lit.intervalDayToSecond != null) {
320
314
  const val = lit.intervalDayToSecond;
321
315
  return {
322
316
  name: `${val.days}d${val.seconds}s${val.microseconds}u`,
@@ -325,7 +319,7 @@ class SubstraitParser {
325
319
  children: [],
326
320
  };
327
321
  }
328
- else if (lit.fixedChar != null) {
322
+ if (lit.fixedChar != null) {
329
323
  const val = typeof lit.fixedChar === "string"
330
324
  ? lit.fixedChar
331
325
  : lit.fixedChar.value ?? "unspecified";
@@ -336,9 +330,7 @@ class SubstraitParser {
336
330
  children: [],
337
331
  };
338
332
  }
339
- else {
340
- throw new Error(`Unrecognized literal: ${JSON.stringify(lit)}`);
341
- }
333
+ throw new Error(`Unrecognized literal: ${JSON.stringify(lit)}`);
342
334
  }
343
335
  /**
344
336
  * Convert a cast expression to a stringified representation
@@ -375,18 +367,16 @@ class SubstraitParser {
375
367
  if (expr.selection != null) {
376
368
  return this.referenceToField(expr.selection, exprIn);
377
369
  }
378
- else if (expr.scalarFunction != null) {
370
+ if (expr.scalarFunction != null) {
379
371
  return this.scalarFunctionToField(expr.scalarFunction, exprIn);
380
372
  }
381
- else if (expr.literal != null) {
373
+ if (expr.literal != null) {
382
374
  return this.literalToField(expr.literal);
383
375
  }
384
- else if (expr.cast != null) {
376
+ if (expr.cast != null) {
385
377
  return this.castToField(expr.cast, exprIn);
386
378
  }
387
- else {
388
- throw new Error(`Unrecognized expression: ${JSON.stringify(expr)}`);
389
- }
379
+ throw new Error(`Unrecognized expression: ${JSON.stringify(expr)}`);
390
380
  }
391
381
  /**
392
382
  * Convert a project relation to a print node
@@ -630,14 +620,14 @@ class SubstraitParser {
630
620
  const input = this.relToNode(agg.input);
631
621
  const props = [];
632
622
  const fields = [];
633
- agg.groupings.forEach((grouping, idx) => {
623
+ for (const [idx, grouping] of agg.groupings.entries()) {
634
624
  for (const groupingExpr of grouping.groupingExpressions) {
635
625
  const groupingField = this.expressionToStr(groupingExpr, input.schema);
636
626
  props.push({ name: `grouping[${idx}]`, value: groupingField.name });
637
627
  fields.push(groupingField);
638
628
  }
639
- });
640
- agg.measures.forEach((measure, idx) => {
629
+ }
630
+ for (const [idx, measure] of agg.measures.entries()) {
641
631
  const aggregate = this.aggregateFunctionToField(measure.measure, input.schema);
642
632
  fields.push(aggregate);
643
633
  const innerProps = [
@@ -654,7 +644,7 @@ class SubstraitParser {
654
644
  name: `measures[${idx}]`,
655
645
  value: JSON.stringify(innerProps), // TODO Is this right?
656
646
  });
657
- });
647
+ }
658
648
  const schema = this.makeSchemaField(fields);
659
649
  return this.makePrintNode("aggregate", [input], props, schema, agg.common.emit);
660
650
  }
@@ -704,27 +694,25 @@ class SubstraitParser {
704
694
  if (rel.project != null) {
705
695
  return this.projectToNode(rel.project);
706
696
  }
707
- else if (rel.read != null) {
697
+ if (rel.read != null) {
708
698
  return this.readToNode(rel.read);
709
699
  }
710
- else if (rel.fetch != null) {
700
+ if (rel.fetch != null) {
711
701
  return this.fetchToNode(rel.fetch);
712
702
  }
713
- else if (rel.sort != null) {
703
+ if (rel.sort != null) {
714
704
  return this.sortToNode(rel.sort);
715
705
  }
716
- else if (rel.aggregate != null) {
706
+ if (rel.aggregate != null) {
717
707
  return this.aggToNode(rel.aggregate);
718
708
  }
719
- else if (rel.filter != null) {
709
+ if (rel.filter != null) {
720
710
  return this.filterToNode(rel.filter);
721
711
  }
722
- else if (rel.join != null) {
712
+ if (rel.join != null) {
723
713
  return this.joinToNode(rel.join);
724
714
  }
725
- else {
726
- throw new Error(`Unrecognized relation: ${JSON.stringify(rel)}`);
727
- }
715
+ throw new Error(`Unrecognized relation: ${JSON.stringify(rel)}`);
728
716
  }
729
717
  /**
730
718
  * Converts a Substrait root relation to a print node
@@ -788,7 +776,7 @@ class SubstraitParser {
788
776
  for (let i = buffer.length - 1; i >= 0; i--) {
789
777
  value = (value << BigInt(8)) + BigInt(buffer[i]);
790
778
  }
791
- return Number(value) / Math.pow(10, scale);
779
+ return Number(value) / 10 ** scale;
792
780
  }
793
781
  deduplicate(array) {
794
782
  return Array.from(new Set(array));
@@ -1,6 +1,6 @@
1
1
  import { BaseApi } from "../base-api";
2
- import { type NqlAst } from "./Ast";
3
- import type { Nql, NqlField, NqlResult, NqlCompileResult, NqlQueryInput, NqlExpression, NqlWhere, NqlFilterBinaryExpression, NqlBooleanExpression, NqlFilterExpression, NqlFilterUnaryExpression } from "./types";
2
+ import type { NqlAst } from "./Ast";
3
+ import type { Nql, NqlBooleanExpression, NqlCompileResult, NqlExpression, NqlField, NqlFilterBinaryExpression, NqlFilterExpression, NqlFilterUnaryExpression, NqlQueryInput, NqlResult, NqlWhere } from "./types";
4
4
  /**
5
5
  * A class for accessing the NQL API.
6
6
  * @extends BaseApi
@@ -1259,7 +1259,7 @@ export interface NqlResult {
1259
1259
  company_id: number;
1260
1260
  completed_at: string;
1261
1261
  created_at: string;
1262
- failures: any[];
1262
+ failures: unknown[];
1263
1263
  idempotency_key: string;
1264
1264
  input: {
1265
1265
  nql: string;
@@ -1,5 +1,5 @@
1
1
  import { BaseApi } from "../base-api";
2
- import { type PingStatus } from "./types";
2
+ import type { PingStatus } from "./types";
3
3
  /**
4
4
  * A class for accessing the Ping API.
5
5
  * @extends BaseApi
@@ -1,5 +1,5 @@
1
1
  import { BaseApi } from "../base-api";
2
- import { type Product } from "./types";
2
+ import type { Product } from "./types";
3
3
  /**
4
4
  * A class for accessing the Products API.
5
5
  * @extends BaseApi
@@ -2,10 +2,10 @@
2
2
  * @fileoverview This module provides methods for fetching resources.
3
3
  * @author Your Name
4
4
  */
5
- import { type ApiRecords } from "../types";
6
5
  import { BaseApi } from "../base-api";
7
- import { type Resource, type BucketCreationRequest, type UpdateAccessTypeRequest } from "./types";
8
- export { type Resource, type BucketCreationRequest, type UpdateAccessTypeRequest, };
6
+ import type { ApiRecords } from "../types";
7
+ import type { BucketCreationRequest, Resource, UpdateAccessTypeRequest } from "./types";
8
+ export type { Resource, BucketCreationRequest, UpdateAccessTypeRequest };
9
9
  /**
10
10
  * @class ResourceApi
11
11
  * @extends {BaseApi}
@@ -1,6 +1,6 @@
1
1
  import type { Mapping } from "src/mappings/types";
2
2
  import { BaseApi } from "../base-api";
3
- import type { RosettaStoneResponse, SampleRecords, SampleRecord } from "./types";
3
+ import type { RosettaStoneResponse, SampleRecord, SampleRecords } from "./types";
4
4
  declare class RosettaStoneApi extends BaseApi {
5
5
  getLabelsFromSample(sample: SampleRecords): Promise<RosettaStoneResponse[]>;
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { type ApiRecords } from "../types";
2
1
  import { BaseApi } from "../base-api";
3
- import { type Subscription, type SubscriptionDetails, type DataStreamSubscriptionDetails, type MarketplaceSubscriptionDetails, type SubscriptionOutput, type SubscriptionType, type SubscriptionStatus, type SubscriptionBudget } from "./types";
2
+ import type { ApiRecords } from "../types";
3
+ import type { DataStreamSubscriptionDetails, MarketplaceSubscriptionDetails, Subscription, SubscriptionBudget, SubscriptionDetails, SubscriptionOutput, SubscriptionStatus, SubscriptionType } from "./types";
4
4
  /**
5
5
  * @module SubscriptionsApi
6
6
  * @description This module provides methods for interacing with subscriptions
@@ -1,5 +1,5 @@
1
- import { type Offer, type DataRules, type CompanyConstraint } from "src/data-streams/types";
2
- import { type DatasetConstraint } from "src/forecast/types";
1
+ import type { CompanyConstraint, DataRules, Offer } from "src/data-streams/types";
2
+ import type { DatasetConstraint } from "src/forecast/types";
3
3
  export interface Subscription {
4
4
  id: string;
5
5
  budget: SubscriptionBudget;
@@ -1,5 +1,5 @@
1
1
  import { BaseApi } from "../base-api";
2
- import { type ConfirmDatasetUpload, type UploadsResponse } from "./types";
2
+ import type { ConfirmDatasetUpload, UploadsResponse } from "./types";
3
3
  /**
4
4
  * API class for handling file uploads.
5
5
  * @extends BaseApi