@narrative.io/data-collaboration-sdk-ts 0.0.67 → 0.0.69

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.
@@ -1,6 +1,6 @@
1
1
  import { type ApiRecords } from '../types';
2
2
  import { BaseApi } from '../base-api';
3
- import { type Attribute } from './types';
3
+ import { type Attribute, type RefAttribute, type SubAttribute } from './types';
4
4
  /**
5
5
  * A class for accessing the Attribute API.
6
6
  * @extends BaseApi
@@ -34,4 +34,4 @@ declare class AttributeApi extends BaseApi {
34
34
  */
35
35
  createAttribute(data: Attribute): Promise<Attribute>;
36
36
  }
37
- export { AttributeApi, type Attribute };
37
+ export { AttributeApi, type Attribute, type RefAttribute, type SubAttribute };
package/build/index.d.ts CHANGED
@@ -8,7 +8,7 @@ import { type HealthCheckResult } from './health/types';
8
8
  import { type SampleRecords } from './rosetta-stone/types';
9
9
  import { AttributeApi } from './attributes';
10
10
  import { type Resource, ResourceApi, type BucketCreationRequest, type UpdateAccessTypeRequest } from './resources';
11
- import { type Attribute } from './attributes/types';
11
+ import { type Attribute, type RefAttribute, type SubAttribute } from './attributes/types';
12
12
  import { PingApi } from './ping';
13
13
  import { UploadsApi } from './uploads';
14
14
  import { type UploadsResponse } from './uploads/types';
@@ -29,4 +29,4 @@ declare class NarrativeApi extends BaseApi {
29
29
  }
30
30
  interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi {
31
31
  }
32
- export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, getNqlObject, buildNql, convertNqlObjectToForecastBody, type ForecastBody };
32
+ export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type RefAttribute, type SubAttribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, getNqlObject, buildNql, convertNqlObjectToForecastBody, type ForecastBody };
@@ -41,7 +41,7 @@ async function getAttributesFromFields(fields) {
41
41
  attributesArray.push({
42
42
  attribute_id: attributeId,
43
43
  fields: fields.filter((field) => field.field.split('.')[0] === att),
44
- optional: fields.some(field => field.field.startsWith(att + '.') && field.filter !== undefined)
44
+ optional: fields.some(field => field.field.startsWith(att + '.') && field.filter === undefined)
45
45
  });
46
46
  });
47
47
  ensureAtLeastOneRequired(attributesArray);
@@ -65,10 +65,11 @@ async function getAttributesFromFields(fields) {
65
65
  * // The array is now guaranteed to have at least one object with `optional` set to `false`.
66
66
  */
67
67
  function ensureAtLeastOneRequired(dataRulesAttributes) {
68
- const hasMandatory = dataRulesAttributes.some(item => !item.optional);
68
+ const exportedAttributes = dataRulesAttributes.filter(item => item.fields.filter(field => field.exported).length > 0);
69
+ const hasMandatory = exportedAttributes.some(item => !item.optional);
69
70
  if (!hasMandatory) {
70
- const randomIndex = Math.floor(Math.random() * dataRulesAttributes.length);
71
- dataRulesAttributes[randomIndex].optional = false;
71
+ const randomIndex = Math.floor(Math.random() * exportedAttributes.length);
72
+ exportedAttributes[randomIndex].optional = false;
72
73
  }
73
74
  }
74
75
  /**
@@ -174,7 +175,7 @@ function constructBinaryFilterExpression(filter) {
174
175
  */
175
176
  function expressionToString(expr) {
176
177
  if (typeof expr === 'string') {
177
- return "'expr'";
178
+ return `${expr}`;
178
179
  }
179
180
  else if (typeof expr === 'number') {
180
181
  return expr.toString();
@@ -1304,10 +1304,34 @@ export interface DataRulesAttributes {
1304
1304
  }
1305
1305
  export interface DataRulesAttributesField {
1306
1306
  field: string;
1307
- filter?: unknown;
1307
+ filter?: FilterDefinition;
1308
1308
  exported: boolean;
1309
1309
  }
1310
1310
  export interface DataRulesAttributesFieldFilter {
1311
1311
  expression: string[];
1312
1312
  }
1313
+ export type FilterDefinition = 'include_all_values_including_nulls_filter' | 'include_only_if_not_null_filter' | EnumFilter | IntervalFilter | TimestampFilter | SparkSqlConstraintFilter;
1314
+ export interface EnumFilter {
1315
+ type: InclusionType;
1316
+ list: string[];
1317
+ }
1318
+ export interface IntervalFilter {
1319
+ min?: IntervalEnd;
1320
+ max?: IntervalEnd;
1321
+ }
1322
+ export interface TimestampFilter {
1323
+ recency?: string;
1324
+ from?: IntervalEnd;
1325
+ to?: IntervalEnd;
1326
+ }
1327
+ export interface SparkSqlConstraintFilter {
1328
+ expressions: string[];
1329
+ }
1330
+ export type IntervalEndType = 'inclusive' | 'exclusive';
1331
+ export interface IntervalEnd {
1332
+ type: IntervalEndType;
1333
+ value: string;
1334
+ }
1335
+ export type SpatialPredicate = 'contains' | 'intersects';
1336
+ export type InclusionType = 'include' | 'exclude';
1313
1337
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.67",
3
+ "version": "0.0.69",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",