@narrative.io/data-collaboration-sdk-ts 0.0.107 → 0.0.109

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 (69) hide show
  1. package/build/access-rules/index.d.ts +44 -0
  2. package/build/access-rules/index.js +51 -0
  3. package/build/access-rules/types.d.ts +29 -0
  4. package/build/access-rules/types.js +1 -0
  5. package/build/apps/index.d.ts +3 -3
  6. package/build/apps/index.js +4 -4
  7. package/build/apps/types.d.ts +1 -1
  8. package/build/apps/types.js +0 -1
  9. package/build/attributes/index.d.ts +9 -9
  10. package/build/attributes/index.js +8 -8
  11. package/build/attributes/types.d.ts +5 -5
  12. package/build/authentication/index.d.ts +3 -3
  13. package/build/authentication/index.js +3 -3
  14. package/build/authentication/types.d.ts +3 -3
  15. package/build/base-api.d.ts +42 -42
  16. package/build/base-api.js +51 -51
  17. package/build/company-info/index.d.ts +3 -3
  18. package/build/company-info/index.js +2 -2
  19. package/build/contracts/index.d.ts +18 -18
  20. package/build/contracts/index.js +18 -18
  21. package/build/contracts/types.d.ts +3 -3
  22. package/build/data-streams/index.d.ts +10 -10
  23. package/build/data-streams/index.js +9 -9
  24. package/build/data-streams/types.d.ts +7 -7
  25. package/build/datasets/index.d.ts +46 -30
  26. package/build/datasets/index.js +52 -32
  27. package/build/datasets/types.d.ts +15 -9
  28. package/build/forecast/index.d.ts +3 -3
  29. package/build/forecast/index.js +3 -3
  30. package/build/forecast/types.d.ts +7 -7
  31. package/build/health/index.d.ts +2 -2
  32. package/build/health/index.js +2 -2
  33. package/build/health/types.d.ts +1 -1
  34. package/build/index.d.ts +32 -31
  35. package/build/index.js +44 -24
  36. package/build/installations/index.d.ts +3 -3
  37. package/build/installations/index.js +3 -3
  38. package/build/installations/types.d.ts +1 -1
  39. package/build/mappings/index.d.ts +16 -16
  40. package/build/mappings/index.js +18 -18
  41. package/build/mappings/types.d.ts +6 -6
  42. package/build/nql/DataRulesConverter.d.ts +3 -3
  43. package/build/nql/DataRulesConverter.js +55 -31
  44. package/build/nql/NQLParser.d.ts +4 -4
  45. package/build/nql/NQLParser.js +74 -57
  46. package/build/nql/SubstraitParser.d.ts +173 -173
  47. package/build/nql/SubstraitParser.js +270 -261
  48. package/build/nql/index.d.ts +4 -4
  49. package/build/nql/index.js +3 -3
  50. package/build/nql/types.d.ts +6 -6
  51. package/build/nql/types.js +59 -29
  52. package/build/ping/index.d.ts +2 -2
  53. package/build/ping/index.js +2 -2
  54. package/build/ping/types.d.ts +1 -1
  55. package/build/products/index.d.ts +6 -6
  56. package/build/products/index.js +6 -6
  57. package/build/products/types.d.ts +4 -4
  58. package/build/resources/index.d.ts +4 -4
  59. package/build/resources/index.js +2 -2
  60. package/build/resources/types.d.ts +3 -3
  61. package/build/rosetta/types.d.ts +12 -12
  62. package/build/rosetta/types.js +69 -42
  63. package/build/rosetta-stone/index.d.ts +3 -3
  64. package/build/rosetta-stone/index.js +3 -3
  65. package/build/types.d.ts +2 -2
  66. package/build/uploads/index.d.ts +8 -8
  67. package/build/uploads/index.js +8 -8
  68. package/build/utils.js +1 -1
  69. package/package.json +3 -1
package/build/index.d.ts CHANGED
@@ -1,34 +1,35 @@
1
- import { BaseApi } from './base-api';
2
- import { DatasetApi } from './datasets';
3
- import { HealthCheckApi } from './health';
4
- import { RosettaStoneApi } from './rosetta-stone';
5
- import { type Environment, type Config, type ApiRecords, type MonetaryAmount } from './types';
6
- import type { DatasetTableSummaryAPIResponse, Dataset, DatasetTableSummary, FilePerSnapshotResponse, RetentionPolicy } from './datasets/types';
7
- import { type HealthCheckResult } from './health/types';
8
- import { type SampleRecords } from './rosetta-stone/types';
9
- import { AttributeApi } from './attributes';
10
- import { type Resource, ResourceApi, type BucketCreationRequest, type UpdateAccessTypeRequest } from './resources';
11
- import { type Attribute, type ShallowAttribute, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute } from './attributes/types';
12
- import { PingApi } from './ping';
13
- import { UploadsApi } from './uploads';
14
- import { type UploadsResponse } from './uploads/types';
15
- import { type PingStatus } from './ping/types';
16
- import { type Product, ProductsApi } from './products';
17
- import { CompanyInfoApi, type CompanyInfo } from './company-info';
18
- import { InstallationsApi, type Installation } from './installations';
19
- import { NqlApi, type Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression } from './nql';
20
- import { DataStreamsApi, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet } from './data-streams';
21
- import { ForecastApi, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState } from './forecast';
22
- import { ContractsApi, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView } from './contracts';
23
- import { getNqlObject, buildNql } from './nql/NQLParser';
24
- import { convertNqlObjectToForecastBody } from './nql/DataRulesConverter';
25
- import { AuthenticationApi, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse } from './authentication';
26
- import { AppsApi, type App } from './apps';
27
- import type { ForecastBody } from './nql/types';
28
- import { type ConversationMessageRole, isConversationMessageRole, type ConversationMessageName, isConversationMessageName, type ConversationUserMessage, isConversationUserMessage, type ConversationAssistantMessage, isConversationAssistantMessage, type ConversationSystemMessage, isConversationSystemMessage, type ConversationFunctionMessage, isConversationFunctionMessage, type ConversationMessage, isConversationMessage, type ConversationIOMessage, isConversationInputMessage, type ConversationMessages, isConversationMessages, isType, type RosettaRequestMessage, isRosettaRequestMessage, type ConversationMessageFunctionCall, isConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, isConversationAssistantMessageWithoutFunctionCall } from './rosetta/types';
29
- import { MappingsApi } from './mappings';
1
+ import { BaseApi } from "./base-api";
2
+ import { DatasetApi } from "./datasets";
3
+ import { HealthCheckApi } from "./health";
4
+ import { RosettaStoneApi } from "./rosetta-stone";
5
+ import { type Environment, type Config, type ApiRecords, type MonetaryAmount } from "./types";
6
+ import type { DatasetTableSummaryAPIResponse, Dataset, DatasetTableSummary, FilePerSnapshotResponse, RetentionPolicy } from "./datasets/types";
7
+ import { type HealthCheckResult } from "./health/types";
8
+ import { type SampleRecords } from "./rosetta-stone/types";
9
+ import { AttributeApi } from "./attributes";
10
+ import { type Resource, ResourceApi, type BucketCreationRequest, type UpdateAccessTypeRequest } from "./resources";
11
+ import { type Attribute, type ShallowAttribute, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute } from "./attributes/types";
12
+ import { PingApi } from "./ping";
13
+ import { UploadsApi } from "./uploads";
14
+ import { type UploadsResponse } from "./uploads/types";
15
+ import { type PingStatus } from "./ping/types";
16
+ import { type Product, ProductsApi } from "./products";
17
+ import { CompanyInfoApi, type CompanyInfo } from "./company-info";
18
+ import { InstallationsApi, type Installation } from "./installations";
19
+ import { NqlApi, type Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression } from "./nql";
20
+ import { DataStreamsApi, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet } from "./data-streams";
21
+ import { ForecastApi, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState } from "./forecast";
22
+ import { ContractsApi, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView } from "./contracts";
23
+ import { getNqlObject, buildNql } from "./nql/NQLParser";
24
+ import { convertNqlObjectToForecastBody } from "./nql/DataRulesConverter";
25
+ import { AuthenticationApi, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse } from "./authentication";
26
+ import { AppsApi, type App } from "./apps";
27
+ import type { ForecastBody } from "./nql/types";
28
+ import { type ConversationMessageRole, isConversationMessageRole, type ConversationMessageName, isConversationMessageName, type ConversationUserMessage, isConversationUserMessage, type ConversationAssistantMessage, isConversationAssistantMessage, type ConversationSystemMessage, isConversationSystemMessage, type ConversationFunctionMessage, isConversationFunctionMessage, type ConversationMessage, isConversationMessage, type ConversationIOMessage, isConversationInputMessage, type ConversationMessages, isConversationMessages, isType, type RosettaRequestMessage, isRosettaRequestMessage, type ConversationMessageFunctionCall, isConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, isConversationAssistantMessageWithoutFunctionCall } from "./rosetta/types";
29
+ import { MappingsApi } from "./mappings";
30
+ import { type AccessRule, AccessRulesApi } from "./access-rules/";
30
31
  declare class NarrativeApi extends BaseApi {
31
32
  }
32
- interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AppsApi {
33
+ interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AccessRulesApi, AppsApi {
33
34
  }
34
- export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, 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 DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, 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, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, type RetentionPolicy };
35
+ export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, 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 DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, 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, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, type RetentionPolicy, type AccessRule, };
package/build/index.js CHANGED
@@ -1,26 +1,46 @@
1
- import { BaseApi } from './base-api';
2
- import { DatasetApi } from './datasets';
3
- import { HealthCheckApi } from './health';
4
- import { RosettaStoneApi } from './rosetta-stone';
5
- import { applyMixins } from './utils';
6
- import { AttributeApi } from './attributes';
7
- import { ResourceApi } from './resources';
8
- import { PingApi } from './ping';
9
- import { UploadsApi } from './uploads';
10
- import { ProductsApi } from './products';
11
- import { CompanyInfoApi } from './company-info';
12
- import { InstallationsApi } from './installations';
13
- import { NqlApi } from './nql';
14
- import { DataStreamsApi } from './data-streams';
15
- import { ForecastApi } from './forecast';
16
- import { ContractsApi } from './contracts';
17
- import { getNqlObject, buildNql } from './nql/NQLParser';
18
- import { convertNqlObjectToForecastBody } from './nql/DataRulesConverter';
19
- import { AuthenticationApi } from './authentication';
20
- import { AppsApi } from './apps';
21
- import { isConversationMessageRole, isConversationMessageName, isConversationUserMessage, isConversationAssistantMessage, isConversationSystemMessage, isConversationFunctionMessage, isConversationMessage, isConversationInputMessage, isConversationMessages, isType, isRosettaRequestMessage, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithoutFunctionCall } from './rosetta/types';
22
- import { MappingsApi } from './mappings';
1
+ import { BaseApi } from "./base-api";
2
+ import { DatasetApi } from "./datasets";
3
+ import { HealthCheckApi } from "./health";
4
+ import { RosettaStoneApi } from "./rosetta-stone";
5
+ import { applyMixins } from "./utils";
6
+ import { AttributeApi } from "./attributes";
7
+ import { ResourceApi, } from "./resources";
8
+ import { PingApi } from "./ping";
9
+ import { UploadsApi } from "./uploads";
10
+ import { ProductsApi } from "./products";
11
+ import { CompanyInfoApi } from "./company-info";
12
+ import { InstallationsApi } from "./installations";
13
+ import { NqlApi, } from "./nql";
14
+ import { DataStreamsApi, } from "./data-streams";
15
+ import { ForecastApi, } from "./forecast";
16
+ import { ContractsApi, } from "./contracts";
17
+ import { getNqlObject, buildNql } from "./nql/NQLParser";
18
+ import { convertNqlObjectToForecastBody } from "./nql/DataRulesConverter";
19
+ import { AuthenticationApi, } from "./authentication";
20
+ import { AppsApi } from "./apps";
21
+ import { isConversationMessageRole, isConversationMessageName, isConversationUserMessage, isConversationAssistantMessage, isConversationSystemMessage, isConversationFunctionMessage, isConversationMessage, isConversationInputMessage, isConversationMessages, isType, isRosettaRequestMessage, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithoutFunctionCall, } from "./rosetta/types";
22
+ import { MappingsApi } from "./mappings";
23
+ import { AccessRulesApi } from "./access-rules/";
23
24
  class NarrativeApi extends BaseApi {
24
25
  }
25
- applyMixins(NarrativeApi, [BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AppsApi]);
26
- export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall };
26
+ applyMixins(NarrativeApi, [
27
+ BaseApi,
28
+ HealthCheckApi,
29
+ DatasetApi,
30
+ RosettaStoneApi,
31
+ AttributeApi,
32
+ PingApi,
33
+ CompanyInfoApi,
34
+ InstallationsApi,
35
+ UploadsApi,
36
+ ResourceApi,
37
+ NqlApi,
38
+ DataStreamsApi,
39
+ ForecastApi,
40
+ ContractsApi,
41
+ AuthenticationApi,
42
+ MappingsApi,
43
+ AppsApi,
44
+ AccessRulesApi,
45
+ ]);
46
+ export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, };
@@ -1,6 +1,6 @@
1
- import { type ApiRecords } from '../types';
2
- import { BaseApi } from '../base-api';
3
- import { type Installation } from './types';
1
+ import { type ApiRecords } from "../types";
2
+ import { BaseApi } from "../base-api";
3
+ import { type Installation } from "./types";
4
4
  /**
5
5
  * @module InstallationsApi
6
6
  * @description This module provides methods for fetching installation records.
@@ -1,5 +1,5 @@
1
- import { BaseApi } from '../base-api';
2
- const resourceName = 'installations';
1
+ import { BaseApi } from "../base-api";
2
+ const resourceName = "installations";
3
3
  /**
4
4
  * @module InstallationsApi
5
5
  * @description This module provides methods for fetching installation records.
@@ -12,7 +12,7 @@ class InstallationsApi extends BaseApi {
12
12
  * @returns {Promise<ApiRecords<Installation>>} - Promise resolving with the list of installations.
13
13
  */
14
14
  async getInstallations(appCategory) {
15
- const appCategoryQuery = appCategory !== undefined ? `?app_category=${appCategory}` : '';
15
+ const appCategoryQuery = appCategory !== undefined ? `?app_category=${appCategory}` : "";
16
16
  const url = `${resourceName}${appCategoryQuery}`;
17
17
  return await this.get(url);
18
18
  }
@@ -10,5 +10,5 @@ export interface Permission {
10
10
  acess: Access;
11
11
  resource: string;
12
12
  }
13
- type Access = 'read' | 'write' | 'admin' | 'create' | 'revise';
13
+ type Access = "read" | "write" | "admin" | "create" | "revise";
14
14
  export {};
@@ -1,7 +1,7 @@
1
- import type { Config, ApiRecords } from 'src/types';
2
- import { BaseApi } from '../base-api';
3
- import type { CreateMapping, Mapping } from './types';
4
- import { CompanyInfoApi } from '../company-info';
1
+ import type { Config, ApiRecords } from "src/types";
2
+ import { BaseApi } from "../base-api";
3
+ import type { CreateMapping, Mapping } from "./types";
4
+ import { CompanyInfoApi } from "../company-info";
5
5
  /**
6
6
  * A class for accessing the Mappings API.
7
7
  * @extends BaseApi
@@ -10,20 +10,20 @@ declare class MappingsApi extends BaseApi {
10
10
  private readonly companyInfoApi?;
11
11
  constructor(config: Config, companyInfoApi?: CompanyInfoApi | undefined);
12
12
  /**
13
- * Fetches all mappings.
14
- * @return {Promise<ApiRecords<Mapping>>} Promise object represents the API records of mappings.
15
- */
13
+ * Fetches all mappings.
14
+ * @return {Promise<ApiRecords<Mapping>>} Promise object represents the API records of mappings.
15
+ */
16
16
  getMappings(): Promise<ApiRecords<Mapping>>;
17
17
  /**
18
- * Creates a private (specific to a company) mapping between a dataset and an attribute.
19
- *
20
- * @param {CreateMapping} mapping - The mapping to be created.
21
- * @param {number} [companyId] - The ID of the company. If not provided, will be fetched from the API.
22
- * @returns {Promise<Mapping>} - A promise that resolves to the created mapping.
23
- * @public
24
- * @throws {Error} - If the company ID is undefined and cannot be fetched from the API.
25
- * @async
26
- */
18
+ * Creates a private (specific to a company) mapping between a dataset and an attribute.
19
+ *
20
+ * @param {CreateMapping} mapping - The mapping to be created.
21
+ * @param {number} [companyId] - The ID of the company. If not provided, will be fetched from the API.
22
+ * @returns {Promise<Mapping>} - A promise that resolves to the created mapping.
23
+ * @public
24
+ * @throws {Error} - If the company ID is undefined and cannot be fetched from the API.
25
+ * @async
26
+ */
27
27
  createPrivateMapping(mapping: CreateMapping, companyId?: number): Promise<Mapping>;
28
28
  /**
29
29
  * Retrieves the company ID from the API.
@@ -1,12 +1,12 @@
1
- import { BaseApi } from '../base-api';
2
- import { CompanyInfoApi } from '../company-info';
1
+ import { BaseApi } from "../base-api";
2
+ import { CompanyInfoApi } from "../company-info";
3
3
  /**
4
4
  * The name of the resource to be used in API requests.
5
5
  * @constant
6
6
  * @private
7
7
  * @type {string}
8
8
  */
9
- const resourceName = 'mappings';
9
+ const resourceName = "mappings";
10
10
  /**
11
11
  * A class for accessing the Mappings API.
12
12
  * @extends BaseApi
@@ -21,31 +21,31 @@ class MappingsApi extends BaseApi {
21
21
  apiKey: this.apiKey,
22
22
  environment: this.environment,
23
23
  verbose: this.verbose,
24
- headers: this.headers
24
+ headers: this.headers,
25
25
  });
26
26
  }
27
27
  }
28
28
  /**
29
- * Fetches all mappings.
30
- * @return {Promise<ApiRecords<Mapping>>} Promise object represents the API records of mappings.
31
- */
29
+ * Fetches all mappings.
30
+ * @return {Promise<ApiRecords<Mapping>>} Promise object represents the API records of mappings.
31
+ */
32
32
  async getMappings() {
33
33
  return await this.get(resourceName);
34
34
  }
35
35
  /**
36
- * Creates a private (specific to a company) mapping between a dataset and an attribute.
37
- *
38
- * @param {CreateMapping} mapping - The mapping to be created.
39
- * @param {number} [companyId] - The ID of the company. If not provided, will be fetched from the API.
40
- * @returns {Promise<Mapping>} - A promise that resolves to the created mapping.
41
- * @public
42
- * @throws {Error} - If the company ID is undefined and cannot be fetched from the API.
43
- * @async
44
- */
36
+ * Creates a private (specific to a company) mapping between a dataset and an attribute.
37
+ *
38
+ * @param {CreateMapping} mapping - The mapping to be created.
39
+ * @param {number} [companyId] - The ID of the company. If not provided, will be fetched from the API.
40
+ * @returns {Promise<Mapping>} - A promise that resolves to the created mapping.
41
+ * @public
42
+ * @throws {Error} - If the company ID is undefined and cannot be fetched from the API.
43
+ * @async
44
+ */
45
45
  async createPrivateMapping(mapping, companyId) {
46
- companyId = companyId ?? await this.getCompanyId();
46
+ companyId = companyId ?? (await this.getCompanyId());
47
47
  if (companyId === undefined)
48
- throw new Error('Company ID is undefined');
48
+ throw new Error("Company ID is undefined");
49
49
  const resource = `${resourceName}/companies/${companyId}`;
50
50
  return await this.post(resource, mapping);
51
51
  }
@@ -13,20 +13,20 @@ export interface Mapping {
13
13
  source: MappingSource;
14
14
  derived_from: string;
15
15
  }
16
- type MappingStatus = 'active' | 'archived' | 'pending';
17
- type MappingScope = 'global' | 'private';
18
- type MappingSource = 'system' | 'admin' | 'company';
16
+ type MappingStatus = "active" | "archived" | "pending";
17
+ type MappingScope = "global" | "private";
18
+ type MappingSource = "system" | "admin" | "company";
19
19
  interface PropertyMapping {
20
20
  path: string;
21
21
  expression: string;
22
22
  }
23
23
  interface ObjectMapping {
24
- type: 'object_mapping';
24
+ type: "object_mapping";
25
25
  property_mappings: PropertyMapping[];
26
26
  }
27
27
  interface ValueMapping {
28
- type: 'value_mapping';
28
+ type: "value_mapping";
29
29
  expression: string;
30
30
  }
31
- export type CreateMapping = Pick<Mapping, 'attribute_id' | 'dataset_id' | 'mapping'>;
31
+ export type CreateMapping = Pick<Mapping, "attribute_id" | "dataset_id" | "mapping">;
32
32
  export {};
@@ -1,6 +1,6 @@
1
- import { type ObjectAttribute } from 'src/attributes/types';
2
- import { type Attribute } from '../attributes';
3
- import type { DataRulesAttributesField, ForecastBody, Nql } from './types';
1
+ import { type ObjectAttribute } from "src/attributes/types";
2
+ import { type Attribute } from "../attributes";
3
+ import type { DataRulesAttributesField, ForecastBody, Nql } from "./types";
4
4
  /**
5
5
  * Convert an NQL object to a Forecast body.
6
6
  * @param {Nql} nqlObject - The NQL object to convert.
@@ -1,4 +1,4 @@
1
- import { AttributeApi } from '../attributes';
1
+ import { AttributeApi } from "../attributes";
2
2
  /**
3
3
  * Convert an NQL object to a Forecast body.
4
4
  * @param {Nql} nqlObject - The NQL object to convert.
@@ -11,12 +11,12 @@ export async function convertNqlObjectToForecastBody(nqlObject) {
11
11
  const forecastBody = {
12
12
  as_of: new Date().toISOString(),
13
13
  details: {
14
- type: 'marketplace',
14
+ type: "marketplace",
15
15
  pricing: price,
16
16
  data_rules: {
17
- attributes: await getAttributesFromFields(fields)
18
- }
19
- }
17
+ attributes: await getAttributesFromFields(fields),
18
+ },
19
+ },
20
20
  };
21
21
  return forecastBody;
22
22
  }
@@ -29,21 +29,27 @@ export async function convertNqlObjectToForecastBody(nqlObject) {
29
29
  async function getAttributesFromFields(fields) {
30
30
  const attributesArray = [];
31
31
  const attributesApi = new AttributeApi({
32
- environment: 'prod'
32
+ environment: "prod",
33
33
  });
34
34
  const attributes = await attributesApi.getAttributes();
35
- const uniqueAttributes = [...new Set(fields.map((field) => field.field.split('.')[0]))].filter((att) => !att.startsWith('_'));
35
+ const uniqueAttributes = [
36
+ ...new Set(fields.map((field) => field.field.split(".")[0])),
37
+ ].filter((att) => !att.startsWith("_"));
36
38
  uniqueAttributes.forEach((att) => {
37
39
  const isObjectProperty = isObject(attributes.records, att);
38
- const relevantFields = (isObjectProperty != null) ? fields.filter((field) => field.field.split('.')[0] === att && field.field !== att) : fields.filter((field) => field.field.split('.')[0] === att);
40
+ const relevantFields = isObjectProperty != null
41
+ ? fields.filter((field) => field.field.split(".")[0] === att && field.field !== att)
42
+ : fields.filter((field) => field.field.split(".")[0] === att);
39
43
  const attributeId = attributes.records.find((attribute) => attribute.name === att)?.id;
40
44
  if (attributeId === undefined) {
41
45
  throw new Error(`Attribute ${att} not found`);
42
46
  }
43
47
  attributesArray.push({
44
48
  attribute_id: attributeId,
45
- fields: relevantFields.length > 0 ? relevantFields : buildField(att, findAttributeProperties(attributes.records, att)),
46
- optional: fields.some(field => field.field.startsWith(att + '.') && field.filter === undefined)
49
+ fields: relevantFields.length > 0
50
+ ? relevantFields
51
+ : buildField(att, findAttributeProperties(attributes.records, att)),
52
+ optional: fields.some((field) => field.field.startsWith(att + ".") && field.filter === undefined),
47
53
  });
48
54
  });
49
55
  ensureAtLeastOneRequired(attributesArray);
@@ -67,8 +73,8 @@ async function getAttributesFromFields(fields) {
67
73
  * // The array is now guaranteed to have at least one object with `optional` set to `false`.
68
74
  */
69
75
  function ensureAtLeastOneRequired(dataRulesAttributes) {
70
- const exportedAttributes = dataRulesAttributes.filter(item => item.fields.filter(field => field.exported).length > 0);
71
- const hasMandatory = exportedAttributes.some(item => !item.optional);
76
+ const exportedAttributes = dataRulesAttributes.filter((item) => item.fields.filter((field) => field.exported).length > 0);
77
+ const hasMandatory = exportedAttributes.some((item) => !item.optional);
72
78
  if (!hasMandatory) {
73
79
  const randomIndex = Math.floor(Math.random() * exportedAttributes.length);
74
80
  exportedAttributes[randomIndex].optional = false;
@@ -81,22 +87,27 @@ function ensureAtLeastOneRequired(dataRulesAttributes) {
81
87
  * @throws {Error} - Throws an error if price filter conditions are not met.
82
88
  */
83
89
  function getPriceFromNql(nqlObject) {
84
- const priceFilter = nqlObject.where.filterExpressions.filter((expr) => ('left' in expr && typeof expr.left === 'object' && expr.left.field === '_price_cpm_usd') || ('right' in expr && typeof expr.right === 'object' && expr.right.field === '_price_cpm_usd'));
90
+ const priceFilter = nqlObject.where.filterExpressions.filter((expr) => ("left" in expr &&
91
+ typeof expr.left === "object" &&
92
+ expr.left.field === "_price_cpm_usd") ||
93
+ ("right" in expr &&
94
+ typeof expr.right === "object" &&
95
+ expr.right.field === "_price_cpm_usd"));
85
96
  if (priceFilter.length !== 1) {
86
- throw new Error('Expected exactly one price filter');
97
+ throw new Error("Expected exactly one price filter");
87
98
  }
88
- if (typeof priceFilter[0].right === 'number') {
99
+ if (typeof priceFilter[0].right === "number") {
89
100
  return {
90
- micro_cents_usd: priceFilter[0].right * 100000000
101
+ micro_cents_usd: priceFilter[0].right * 100000000,
91
102
  };
92
103
  }
93
- else if (typeof priceFilter[0].left === 'number') {
104
+ else if (typeof priceFilter[0].left === "number") {
94
105
  return {
95
- micro_cents_usd: priceFilter[0].left * 100000000
106
+ micro_cents_usd: priceFilter[0].left * 100000000,
96
107
  };
97
108
  }
98
109
  else {
99
- throw new Error('Expected one side of price filter to be a number');
110
+ throw new Error("Expected one side of price filter to be a number");
100
111
  }
101
112
  }
102
113
  /**
@@ -108,7 +119,10 @@ function getFieldsFromNql(nqlObject) {
108
119
  const fieldsArray = [];
109
120
  // Extract all fields from the 'select' section and mark them as exported.
110
121
  nqlObject.select.forEach((field) => {
111
- fieldsArray.push({ field: field.field.replace('"value"', 'value').replace('"type"', 'type'), exported: true });
122
+ fieldsArray.push({
123
+ field: field.field.replace('"value"', "value").replace('"type"', "type"),
124
+ exported: true,
125
+ });
112
126
  });
113
127
  // Process all filter expressions from the 'where' section.
114
128
  nqlObject.where.filterExpressions.forEach((expression) => {
@@ -122,11 +136,13 @@ function getFieldsFromNql(nqlObject) {
122
136
  * @param {DataRulesAttributesField[]} fieldsArray - The array to populate with fields.
123
137
  */
124
138
  function handleFilterExpression(expression, fieldsArray) {
125
- if ('field' in expression) {
139
+ if ("field" in expression) {
126
140
  updateFieldsArray(expression.field, fieldsArray, constructUnaryFilterExpression(expression));
127
141
  }
128
142
  else {
129
- if (typeof expression.right === 'object' && expression.right !== null && 'field' in expression.right) {
143
+ if (typeof expression.right === "object" &&
144
+ expression.right !== null &&
145
+ "field" in expression.right) {
130
146
  updateFieldsArray(expression.right, fieldsArray, constructBinaryFilterExpression(expression));
131
147
  }
132
148
  else {
@@ -143,7 +159,9 @@ function handleFilterExpression(expression, fieldsArray) {
143
159
  function updateFieldsArray(field, fieldsArray, filterExpression) {
144
160
  const existingEntry = fieldsArray.find((entry) => entry.field === field.field);
145
161
  if (existingEntry !== undefined) {
146
- if (existingEntry.filter !== undefined && typeof existingEntry.filter === 'object' && 'expressions' in existingEntry.filter) {
162
+ if (existingEntry.filter !== undefined &&
163
+ typeof existingEntry.filter === "object" &&
164
+ "expressions" in existingEntry.filter) {
147
165
  // If there are already filter expressions for this field, push the new one to the array.
148
166
  existingEntry.filter.expressions.push(filterExpression);
149
167
  }
@@ -154,7 +172,11 @@ function updateFieldsArray(field, fieldsArray, filterExpression) {
154
172
  }
155
173
  else {
156
174
  // If this field does not exist in the fieldsArray, add it with the new filter expression.
157
- fieldsArray.push({ field: field.field, exported: false, filter: { expressions: [filterExpression] } });
175
+ fieldsArray.push({
176
+ field: field.field,
177
+ exported: false,
178
+ filter: { expressions: [filterExpression] },
179
+ });
158
180
  }
159
181
  }
160
182
  /**
@@ -179,13 +201,13 @@ function constructBinaryFilterExpression(filter) {
179
201
  * @returns {string} - Returns the string representation of the expression.
180
202
  */
181
203
  function expressionToString(expr) {
182
- if (typeof expr === 'string') {
204
+ if (typeof expr === "string") {
183
205
  return `${addParentheses(expr)}`;
184
206
  }
185
- else if (typeof expr === 'number') {
207
+ else if (typeof expr === "number") {
186
208
  return expr.toString();
187
209
  }
188
- else if (typeof expr === 'boolean') {
210
+ else if (typeof expr === "boolean") {
189
211
  return expr.toString();
190
212
  }
191
213
  else {
@@ -211,7 +233,7 @@ function addParentheses(input) {
211
233
  // Regular expression that matches 'CURRENT_TIMESTAMP' or 'CURRENT_DATE' that is not followed by ()
212
234
  const regex = /(CURRENT_TIMESTAMP|CURRENT_DATE)(?!\(\))/g;
213
235
  // Replace matched string with itself followed by ()
214
- return input.replace(regex, '$1()');
236
+ return input.replace(regex, "$1()");
215
237
  }
216
238
  /**
217
239
  * Looks for an attribute with the given name and checks if it is of type 'object'.
@@ -228,12 +250,14 @@ function addParentheses(input) {
228
250
  */
229
251
  export function isObject(attributes, name) {
230
252
  // Look for the attribute with the given name.
231
- const attribute = attributes.find(attr => attr.name === name);
253
+ const attribute = attributes.find((attr) => attr.name === name);
232
254
  // If no such attribute is found, return an empty array.
233
255
  if (attribute == null) {
234
256
  return undefined;
235
257
  }
236
- return attribute.type === 'object' && 'properties' in attribute ? attribute : undefined;
258
+ return attribute.type === "object" && "properties" in attribute
259
+ ? attribute
260
+ : undefined;
237
261
  }
238
262
  /**
239
263
  * Finds an attribute with the given name, and if it is of type 'object', returns the names of its properties.
@@ -271,7 +295,7 @@ export function buildField(attribute, properties) {
271
295
  return properties.map((property) => {
272
296
  return {
273
297
  field: `${attribute}.${property}`,
274
- exported: true
298
+ exported: true,
275
299
  };
276
300
  });
277
301
  }
@@ -1,4 +1,4 @@
1
- import { type Nql, type NqlBudget, type NqlField, type NqlFilterExpression, type NqlPreSelectExpression, type NqlTable, type NqlWhere } from './types';
1
+ import { type Nql, type NqlBudget, type NqlField, type NqlFilterExpression, type NqlPreSelectExpression, type NqlTable, type NqlWhere } 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
  *
@@ -80,8 +80,8 @@ export declare function buildNql(nql: Nql | SemanticNql, strict?: NotStrict): st
80
80
  export declare function buildFrom(from: NqlTable): string;
81
81
  export declare function buildWhere(where: NqlWhere): string;
82
82
  export declare function buildField(field: NqlField | string | number | boolean): string;
83
- type ParseType = 'full' | 'semantic';
84
- type SemanticNql = Omit<Nql, 'explain' | 'limit'>;
85
- export declare function getNqlObject<T extends ParseType = 'full'>(nql: string, type?: T): T extends 'full' ? Nql : SemanticNql;
83
+ type ParseType = "full" | "semantic";
84
+ type SemanticNql = Omit<Nql, "explain" | "limit">;
85
+ export declare function getNqlObject<T extends ParseType = "full">(nql: string, type?: T): T extends "full" ? Nql : SemanticNql;
86
86
  export declare function createSemanticWhere(expressionContainer: NqlWhere): NqlWhere;
87
87
  export {};