@transai/connector-runner-ai-agent 0.53.11 → 0.54.0

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 (41) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/index.cjs +413 -413
  3. package/index.cjs.map +2 -2
  4. package/libs/connector-runtime-sdk/src/lib/sdk/sender.sdk.interface.d.ts +1 -0
  5. package/libs/cube-query-executor/src/index.d.ts +1 -0
  6. package/libs/cube-query-executor/src/lib/retry.d.ts +1 -0
  7. package/libs/cube-query-executor/src/lib/temporarily-unavailable.error.d.ts +3 -0
  8. package/libs/httpclient/src/lib/cache/redis-cache.service.d.ts +4 -0
  9. package/libs/kafka-base-service/src/lib/abstract-rdkafka-service.d.ts +14 -1
  10. package/libs/kafka-base-service/src/lib/rdkafka-bulk-listener.service.d.ts +16 -3
  11. package/libs/kafka-base-service/src/lib/rdkafka-logs.service.d.ts +8 -2
  12. package/libs/kafka-base-service/src/lib/types.d.ts +22 -0
  13. package/libs/types/src/index.d.ts +2 -0
  14. package/libs/types/src/lib/backoff.d.ts +6 -0
  15. package/libs/types/src/lib/ingestion.constants.d.ts +36 -0
  16. package/libs/types/src/lib/management-api/connector-orchestrator-config.interface.d.ts +1 -0
  17. package/libs/types/src/lib/management-api/dataset/collection.interface.d.ts +12 -0
  18. package/libs/types/src/lib/management-api/dataset/dataset-record.interface.d.ts +1 -0
  19. package/libs/types/src/lib/management-api/dataset/dataset-validation.d.ts +20 -0
  20. package/libs/types/src/lib/management-api/dataset/dataset.interface.d.ts +13 -7
  21. package/libs/types/src/lib/management-api/dataset/datasets.interface.d.ts +13 -7
  22. package/libs/types/src/lib/management-api/dataset/dimension.interface.d.ts +2 -0
  23. package/libs/types/src/lib/management-api/dataset/dimensions.interface.d.ts +1 -0
  24. package/libs/types/src/lib/management-api/dataset/measure.interface.d.ts +2 -0
  25. package/libs/types/src/lib/management-api/dataset/measures.interface.d.ts +1 -0
  26. package/libs/types/src/lib/management-api/dataset/segment.interface.d.ts +8 -7
  27. package/libs/types/src/lib/management-api/dataset/segments.interface.d.ts +7 -7
  28. package/libs/types/src/lib/management-api/dataset/typed-dataset.d.ts +25 -0
  29. package/libs/types/src/lib/management-api/document-dataset/index.d.ts +1 -0
  30. package/libs/types/src/lib/management-api/document-dataset/mapping.d.ts +37 -0
  31. package/libs/types/src/lib/management-api/expression/index.d.ts +1 -0
  32. package/libs/types/src/lib/management-api/expression/jsonata-expression.d.ts +2 -0
  33. package/libs/types/src/lib/management-api/index.d.ts +3 -0
  34. package/libs/types/src/lib/management-api/metrics/index.d.ts +0 -1
  35. package/libs/types/src/lib/management-api/template-implementation-overrides.interface.d.ts +26 -14
  36. package/libs/types/src/lib/management-api/template-implementation.interface.d.ts +52 -28
  37. package/libs/types/src/lib/management-api/template.interface.d.ts +13 -7
  38. package/libs/types/src/lib/management-api/tenant.interface.d.ts +1 -0
  39. package/libs/types/src/lib/message.types.d.ts +10 -0
  40. package/package.json +1 -1
  41. package/libs/types/src/lib/management-api/metrics/expression.d.ts +0 -3
package/index.cjs.map CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/index.cjs.map
3
- size: 43273992 bytes
4
- sha256: 1485c3e98dea2fa589c2cfc9f4e8cbf3619c0c2616e748cee8e2ded63168ea96
3
+ size: 43300325 bytes
4
+ sha256: a7b26cc94741b90f5228d0d551f922cbcd4975b0c379aa53a40467414eeb9132
@@ -13,6 +13,7 @@ export type SenderMetadata = {
13
13
  export interface Context {
14
14
  timestamp?: Date;
15
15
  ttl?: number;
16
+ level?: 'priority' | 'normal' | 'bulk';
16
17
  extraPayload?: {
17
18
  [key: string]: string;
18
19
  };
@@ -2,4 +2,5 @@ export * from './lib/bad-request.error';
2
2
  export * from './lib/create-cube-api';
3
3
  export * from './lib/cube-query-executor';
4
4
  export * from './lib/retry';
5
+ export * from './lib/temporarily-unavailable.error';
5
6
  export * from './lib/types';
@@ -10,4 +10,5 @@ export declare const executeOptionsSchema: z.ZodObject<{
10
10
  }, z.core.$strip>;
11
11
  export type ExecuteOptions = z.infer<typeof executeOptionsSchema>;
12
12
  export declare function isRetryableQueryError(error: unknown): boolean;
13
+ export declare function isTemporaryQueryError(error: unknown): boolean;
13
14
  export declare function waitForRetry(delayMs: number): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { BadRequestError } from './bad-request.error';
2
+ export declare class TemporarilyUnavailableError extends BadRequestError {
3
+ }
@@ -5,6 +5,10 @@ export interface OptionsInterface {
5
5
  }
6
6
  export declare class RedisCacheService implements CacheServiceInterface {
7
7
  #private;
8
+ /**
9
+ * A url gets its own client, which this service connects; a client passed in is the caller's to connect.
10
+ * Either way a Redis failure is logged and the cache acts empty, so callers fall back to the uncached call.
11
+ */
8
12
  constructor(redisClient: RedisClientType | string, options?: OptionsInterface);
9
13
  get<T>(key: string): Promise<T | undefined>;
10
14
  set<T>(key: string, value: T): Promise<void>;
@@ -2,6 +2,12 @@ import { KafkaJS } from '@confluentinc/kafka-javascript';
2
2
  import { Logger } from '@transai/logger';
3
3
  import { BaseConnectorConfig, KafkaCompressionCodec } from '@xip-online-data/types';
4
4
  import { MessageMonitorInterface } from './message-monitor.interface';
5
+ import { IEnsureTopicsResult, ITopicSpec } from './types';
6
+ export interface IConsumerMembership {
7
+ groupInstanceId?: string;
8
+ sessionTimeoutMs?: number;
9
+ cooperativeSticky?: boolean;
10
+ }
5
11
  export declare abstract class AbstractRdKafkaService {
6
12
  #private;
7
13
  protected readonly baseYamlConfig: BaseConnectorConfig;
@@ -21,9 +27,16 @@ export declare abstract class AbstractRdKafkaService {
21
27
  protected messageMonitor: MessageMonitorInterface | undefined;
22
28
  abstract init(): Promise<void>;
23
29
  protected readonly logger: Logger;
24
- constructor(baseYamlConfig: BaseConnectorConfig, connectorTopic?: string | undefined);
30
+ constructor(baseYamlConfig: BaseConnectorConfig, connectorTopic?: string | undefined, registerSignalHandlers?: boolean, membership?: IConsumerMembership);
31
+ private static withMembership;
32
+ stop(): Promise<void>;
25
33
  exitProcess: (type: string) => Promise<void>;
26
34
  private getCorrespondingMonitor;
35
+ /**
36
+ * Creates the missing topics and never alters an existing one; a topic whose
37
+ * partition count differs from the request is reported, not changed.
38
+ */
39
+ ensureTopics(topics: Array<ITopicSpec>, replicationFactor: number): Promise<IEnsureTopicsResult>;
27
40
  protected connectConsumer: () => Promise<void>;
28
41
  protected getRegularTopics: () => Array<string>;
29
42
  protected getRegexTopics: () => Promise<Array<string>>;
@@ -1,9 +1,22 @@
1
1
  import { BaseConnectorConfig, XodBaseMessageType } from '@xip-online-data/types';
2
- import { AbstractRdKafkaService } from './abstract-rdkafka-service';
2
+ import { AbstractRdKafkaService, IConsumerMembership } from './abstract-rdkafka-service';
3
+ import { IBatchContext, IRawKafkaMessage } from './types';
4
+ export interface IBulkListenerOptions extends IConsumerMembership {
5
+ registerSignalHandlers?: boolean;
6
+ }
7
+ export type BulkCallback = (messages: Array<XodBaseMessageType>, context?: IBatchContext) => Promise<void>;
8
+ export interface IRawBatchHandler {
9
+ onRawBatch(messages: Array<IRawKafkaMessage>, context: IBatchContext): Promise<void>;
10
+ }
11
+ /**
12
+ * An `IRawBatchHandler` commits on success only: a batch is retried with backoff until the handler succeeds. An
13
+ * outage longer than `max.poll.interval.ms` causes a rebalance and reprocessing. The handler owns parsing, so a
14
+ * poison message cannot throw before the retry loop.
15
+ */
3
16
  export declare class RdKafkaBulkListenerService extends AbstractRdKafkaService {
4
17
  #private;
5
- private readonly callbackFunction;
6
18
  private readonly bulkApplicable;
7
- constructor(baseYamlConfig: BaseConnectorConfig, callbackFunction: (messages: Array<XodBaseMessageType>) => Promise<void>, bulkApplicable?: (messages: Array<XodBaseMessageType>) => boolean);
19
+ constructor(baseYamlConfig: BaseConnectorConfig, callback: BulkCallback | IRawBatchHandler, bulkApplicable?: (messages: Array<XodBaseMessageType>) => boolean, options?: IBulkListenerOptions);
8
20
  init: () => Promise<void>;
21
+ stop(): Promise<void>;
9
22
  }
@@ -1,5 +1,10 @@
1
1
  import { XodBaseMessageType, XodResponseType } from '@xip-online-data/types';
2
2
  import { AbstractRdKafkaService } from './abstract-rdkafka-service';
3
+ export interface IRawProducerMessage {
4
+ key: Buffer | null;
5
+ value: Buffer | null;
6
+ headers?: Record<string, string>;
7
+ }
3
8
  export declare class RdKafkaLogsService extends AbstractRdKafkaService {
4
9
  #private;
5
10
  protected initialized: boolean;
@@ -7,6 +12,7 @@ export declare class RdKafkaLogsService extends AbstractRdKafkaService {
7
12
  init: () => Promise<void>;
8
13
  private warnOnMultiPartitionTopics;
9
14
  private consume;
10
- send(messages: Array<XodBaseMessageType>, topic: string): Promise<boolean>;
11
- sendIndividual(messages: Array<XodBaseMessageType>, topic: string): Promise<boolean>;
15
+ send(messages: Array<XodBaseMessageType>, topic: string, key?: string): Promise<boolean>;
16
+ sendRaw(topic: string, messages: Array<IRawProducerMessage>): Promise<void>;
17
+ sendIndividual(messages: Array<XodBaseMessageType>, topic: string, key?: string): Promise<boolean>;
12
18
  }
@@ -3,3 +3,25 @@ export interface KafkaCallbackWrapper {
3
3
  callback: (message: XodBaseMessageType) => Promise<KafkaCallbackResponse>;
4
4
  identifier: string;
5
5
  }
6
+ export interface IRawKafkaMessage {
7
+ topic: string;
8
+ partition: number;
9
+ offset: string;
10
+ key: Buffer | null;
11
+ value: Buffer | null;
12
+ }
13
+ export interface IBatchContext {
14
+ isActive(): boolean;
15
+ }
16
+ export interface ITopicSpec {
17
+ name: string;
18
+ partitions: number;
19
+ }
20
+ export interface IEnsureTopicsResult {
21
+ created: Array<string>;
22
+ partitionMismatches: Array<{
23
+ name: string;
24
+ existing: number;
25
+ requested: number;
26
+ }>;
27
+ }
@@ -1,6 +1,8 @@
1
1
  export * from './lib/types';
2
+ export * from './lib/backoff';
2
3
  export * from './lib/response.types';
3
4
  export * from './lib/message.types';
5
+ export * from './lib/ingestion.constants';
4
6
  export * from './lib/cube-query-config.types';
5
7
  export * from './lib/file-action.types';
6
8
  export * from './lib/management-api';
@@ -0,0 +1,6 @@
1
+ export interface IBackoff {
2
+ baseMs: number;
3
+ maxMs: number;
4
+ }
5
+ /** Exponential backoff: `baseMs` doubled per retry (0-based), capped at `maxMs`. */
6
+ export declare const backoffMs: (retries: number, backoff: IBackoff) => number;
@@ -0,0 +1,36 @@
1
+ export declare const INGRESS_MAX_RECORDS = 200;
2
+ export declare const INGRESS_MAX_BODY_BYTES = 1048576;
3
+ /** The ingestion service owns this table; management-api fetches its active rows over HTTP to point Cube at the typed tables. */
4
+ export declare const DATASET_TABLES: {
5
+ readonly name: "document_dataset_tables";
6
+ readonly columns: {
7
+ readonly tenantIdentifier: "tenant_identifier";
8
+ readonly datasetKey: "dataset_key";
9
+ readonly mappingHash: "mapping_hash";
10
+ readonly schemaName: "schema_name";
11
+ readonly tableName: "table_name";
12
+ readonly collection: "collection";
13
+ readonly mapping: "mapping";
14
+ readonly state: "state";
15
+ readonly activatedAt: "activated_at";
16
+ readonly retiredAt: "retired_at";
17
+ readonly createdAt: "created_at";
18
+ readonly updatedAt: "updated_at";
19
+ };
20
+ readonly states: {
21
+ readonly building: "building";
22
+ readonly active: "active";
23
+ readonly retired: "retired";
24
+ };
25
+ };
26
+ /** The table version of a typed dataset that the ingestion service serves now. */
27
+ export interface IActiveDatasetTable {
28
+ tenantIdentifier: string;
29
+ datasetKey: string;
30
+ mappingHash: string;
31
+ schemaName: string;
32
+ tableName: string;
33
+ columns: Array<string>;
34
+ /** ISO 8601 */
35
+ activatedAt: string;
36
+ }
@@ -7,6 +7,7 @@ export interface ConnectorOrchestratorConfigInterface {
7
7
  }
8
8
  export interface ConnectorOrchestratorConfigWithKafkaInterface extends ConnectorOrchestratorConfigInterface {
9
9
  kafkaBrokers?: Array<string>;
10
+ ingestionApiUrl?: string;
10
11
  }
11
12
  export interface ConnectorOrchestratorFullConfigurationInterface {
12
13
  config: ConnectorOrchestratorConfigWithKafkaInterface;
@@ -3,8 +3,20 @@ import { FiltersInterface } from './filters.interface';
3
3
  export declare const CollectionSchema: z.ZodObject<{
4
4
  collection: z.ZodString;
5
5
  filters: z.ZodOptional<z.ZodType<FiltersInterface, unknown, z.core.$ZodTypeInternals<FiltersInterface, unknown>>>;
6
+ projection: z.ZodOptional<z.ZodObject<{
7
+ expr: z.ZodOptional<z.ZodString>;
8
+ key: z.ZodOptional<z.ZodString>;
9
+ }, z.core.$strip>>;
6
10
  }, z.core.$strip>;
7
11
  export interface CollectionInterface {
8
12
  collection: string;
9
13
  filters?: FiltersInterface;
14
+ /**
15
+ * Makes a documents dataset typed. Without `expr` every document is one row, and without `key` the row key is the
16
+ * document key, so `{}` is a typed dataset that uses both defaults.
17
+ */
18
+ projection?: {
19
+ expr?: string;
20
+ key?: string;
21
+ };
10
22
  }
@@ -4,6 +4,7 @@ import { MetaInterface } from './meta.interface';
4
4
  export interface DatasetRecordInterface extends DatasetInterface {
5
5
  id: string;
6
6
  tenantId: string;
7
+ updatedAt: Date;
7
8
  }
8
9
  export interface DatasetRecordFiltersInterface {
9
10
  name: string;
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { DatasetTypeEnum } from '../type-enums';
3
+ import { CollectionInterface } from './collection.interface';
4
+ import { DimensionsInterface } from './dimensions.interface';
5
+ import { MeasuresInterface } from './measures.interface';
6
+ import { RelationsInterface } from './relations.interface';
7
+ import { SegmentsInterface } from './segments.interface';
8
+ interface DatasetValidationInput {
9
+ type?: DatasetTypeEnum;
10
+ parent?: string;
11
+ sql?: string;
12
+ collection?: CollectionInterface;
13
+ dimensions?: DimensionsInterface;
14
+ segments?: SegmentsInterface;
15
+ relations?: RelationsInterface;
16
+ measures?: MeasuresInterface;
17
+ }
18
+ /** The rules across fields of a dataset that its schema alone cannot express; used by `DatasetSchema`. */
19
+ export declare const validateDataset: (val: DatasetValidationInput, ctx: z.RefinementCtx) => void;
20
+ export {};
@@ -19,6 +19,10 @@ export declare const DatasetSchema: z.ZodObject<{
19
19
  collection: z.ZodOptional<z.ZodObject<{
20
20
  collection: z.ZodString;
21
21
  filters: z.ZodOptional<z.ZodType<import("./filters.interface").FiltersInterface, unknown, z.core.$ZodTypeInternals<import("./filters.interface").FiltersInterface, unknown>>>;
22
+ projection: z.ZodOptional<z.ZodObject<{
23
+ expr: z.ZodOptional<z.ZodString>;
24
+ key: z.ZodOptional<z.ZodString>;
25
+ }, z.core.$strip>>;
22
26
  }, z.core.$strip>>;
23
27
  dimensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
24
28
  name: z.ZodString;
@@ -43,6 +47,7 @@ export declare const DatasetSchema: z.ZodObject<{
43
47
  }, z.core.$strip>>;
44
48
  field: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
45
49
  sql: z.ZodOptional<z.ZodString>;
50
+ expr: z.ZodOptional<z.ZodString>;
46
51
  public: z.ZodOptional<z.ZodBoolean>;
47
52
  primaryKey: z.ZodOptional<z.ZodBoolean>;
48
53
  subQuery: z.ZodOptional<z.ZodBoolean>;
@@ -52,17 +57,17 @@ export declare const DatasetSchema: z.ZodObject<{
52
57
  interval: z.ZodString;
53
58
  }, z.core.$strip>>>;
54
59
  }, z.core.$strip>, z.ZodLiteral<false>]>>>;
55
- segments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
56
- sql: z.ZodOptional<z.ZodString>;
57
- dimension: z.ZodOptional<z.ZodString>;
58
- operator: z.ZodOptional<z.ZodEnum<typeof import("../type-enums").FilterOperatorsEnum>>;
59
- value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
60
- }, z.core.$strip>, z.ZodObject<{
60
+ segments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
61
+ expr: z.ZodOptional<z.ZodString>;
61
62
  name: z.ZodOptional<z.ZodString>;
62
63
  description: z.ZodOptional<z.ZodString>;
63
64
  public: z.ZodOptional<z.ZodBoolean>;
64
65
  override: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<DatasetStatusEnum.manual>]>>;
65
- }, z.core.$strip>>, z.ZodLiteral<false>]>>>;
66
+ sql: z.ZodOptional<z.ZodString>;
67
+ dimension: z.ZodOptional<z.ZodString>;
68
+ operator: z.ZodOptional<z.ZodEnum<typeof import("../type-enums").FilterOperatorsEnum>>;
69
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
70
+ }, z.core.$strip>, z.ZodLiteral<false>]>>>;
66
71
  relations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
67
72
  type: z.ZodEnum<typeof import("../type-enums").RelationTypesEnum>;
68
73
  dimension: z.ZodOptional<z.ZodString>;
@@ -79,6 +84,7 @@ export declare const DatasetSchema: z.ZodObject<{
79
84
  index: z.ZodOptional<z.ZodString>;
80
85
  upperIndex: z.ZodOptional<z.ZodString>;
81
86
  sql: z.ZodOptional<z.ZodString>;
87
+ expr: z.ZodOptional<z.ZodString>;
82
88
  dimension: z.ZodOptional<z.ZodString>;
83
89
  public: z.ZodOptional<z.ZodBoolean>;
84
90
  override: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<DatasetStatusEnum.manual>]>>;
@@ -12,6 +12,10 @@ export declare const DatasetsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodO
12
12
  collection: z.ZodOptional<z.ZodObject<{
13
13
  collection: z.ZodString;
14
14
  filters: z.ZodOptional<z.ZodType<import("./filters.interface").FiltersInterface, unknown, z.core.$ZodTypeInternals<import("./filters.interface").FiltersInterface, unknown>>>;
15
+ projection: z.ZodOptional<z.ZodObject<{
16
+ expr: z.ZodOptional<z.ZodString>;
17
+ key: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strip>>;
15
19
  }, z.core.$strip>>;
16
20
  dimensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
17
21
  name: z.ZodString;
@@ -36,6 +40,7 @@ export declare const DatasetsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodO
36
40
  }, z.core.$strip>>;
37
41
  field: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
38
42
  sql: z.ZodOptional<z.ZodString>;
43
+ expr: z.ZodOptional<z.ZodString>;
39
44
  public: z.ZodOptional<z.ZodBoolean>;
40
45
  primaryKey: z.ZodOptional<z.ZodBoolean>;
41
46
  subQuery: z.ZodOptional<z.ZodBoolean>;
@@ -45,17 +50,17 @@ export declare const DatasetsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodO
45
50
  interval: z.ZodString;
46
51
  }, z.core.$strip>>>;
47
52
  }, z.core.$strip>, z.ZodLiteral<false>]>>>;
48
- segments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
49
- sql: z.ZodOptional<z.ZodString>;
50
- dimension: z.ZodOptional<z.ZodString>;
51
- operator: z.ZodOptional<z.ZodEnum<typeof import("..").FilterOperatorsEnum>>;
52
- value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
53
- }, z.core.$strip>, z.ZodObject<{
53
+ segments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
54
+ expr: z.ZodOptional<z.ZodString>;
54
55
  name: z.ZodOptional<z.ZodString>;
55
56
  description: z.ZodOptional<z.ZodString>;
56
57
  public: z.ZodOptional<z.ZodBoolean>;
57
58
  override: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<import("..").DatasetStatusEnum.manual>]>>;
58
- }, z.core.$strip>>, z.ZodLiteral<false>]>>>;
59
+ sql: z.ZodOptional<z.ZodString>;
60
+ dimension: z.ZodOptional<z.ZodString>;
61
+ operator: z.ZodOptional<z.ZodEnum<typeof import("..").FilterOperatorsEnum>>;
62
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
63
+ }, z.core.$strip>, z.ZodLiteral<false>]>>>;
59
64
  relations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
60
65
  type: z.ZodEnum<typeof import("..").RelationTypesEnum>;
61
66
  dimension: z.ZodOptional<z.ZodString>;
@@ -72,6 +77,7 @@ export declare const DatasetsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodO
72
77
  index: z.ZodOptional<z.ZodString>;
73
78
  upperIndex: z.ZodOptional<z.ZodString>;
74
79
  sql: z.ZodOptional<z.ZodString>;
80
+ expr: z.ZodOptional<z.ZodString>;
75
81
  dimension: z.ZodOptional<z.ZodString>;
76
82
  public: z.ZodOptional<z.ZodBoolean>;
77
83
  override: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<import("..").DatasetStatusEnum.manual>]>>;
@@ -25,6 +25,7 @@ export declare const DimensionSchema: z.ZodObject<{
25
25
  }, z.core.$strip>>;
26
26
  field: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
27
27
  sql: z.ZodOptional<z.ZodString>;
28
+ expr: z.ZodOptional<z.ZodString>;
28
29
  public: z.ZodOptional<z.ZodBoolean>;
29
30
  primaryKey: z.ZodOptional<z.ZodBoolean>;
30
31
  subQuery: z.ZodOptional<z.ZodBoolean>;
@@ -45,6 +46,7 @@ export interface DimensionInterface {
45
46
  switch?: SwitchInterface;
46
47
  field?: string | Array<string>;
47
48
  sql?: string;
49
+ expr?: string;
48
50
  public?: boolean;
49
51
  primaryKey?: boolean;
50
52
  subQuery?: boolean;
@@ -23,6 +23,7 @@ export declare const DimensionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<reado
23
23
  }, z.core.$strip>>;
24
24
  field: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
25
25
  sql: z.ZodOptional<z.ZodString>;
26
+ expr: z.ZodOptional<z.ZodString>;
26
27
  public: z.ZodOptional<z.ZodBoolean>;
27
28
  primaryKey: z.ZodOptional<z.ZodBoolean>;
28
29
  subQuery: z.ZodOptional<z.ZodBoolean>;
@@ -9,6 +9,7 @@ export declare const MeasureSchema: z.ZodObject<{
9
9
  index: z.ZodOptional<z.ZodString>;
10
10
  upperIndex: z.ZodOptional<z.ZodString>;
11
11
  sql: z.ZodOptional<z.ZodString>;
12
+ expr: z.ZodOptional<z.ZodString>;
12
13
  dimension: z.ZodOptional<z.ZodString>;
13
14
  public: z.ZodOptional<z.ZodBoolean>;
14
15
  override: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<DatasetStatusEnum.manual>]>>;
@@ -22,6 +23,7 @@ export interface MeasureInterface {
22
23
  index?: string;
23
24
  upperIndex?: string;
24
25
  sql?: string;
26
+ expr?: string;
25
27
  dimension?: string;
26
28
  public?: boolean;
27
29
  override?: boolean | DatasetStatusEnum.manual;
@@ -8,6 +8,7 @@ export declare const MeasuresSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonl
8
8
  index: z.ZodOptional<z.ZodString>;
9
9
  upperIndex: z.ZodOptional<z.ZodString>;
10
10
  sql: z.ZodOptional<z.ZodString>;
11
+ expr: z.ZodOptional<z.ZodString>;
11
12
  dimension: z.ZodOptional<z.ZodString>;
12
13
  public: z.ZodOptional<z.ZodBoolean>;
13
14
  override: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<import("..").DatasetStatusEnum.manual>]>>;
@@ -1,20 +1,21 @@
1
1
  import { z } from 'zod';
2
2
  import { DatasetStatusEnum } from '../type-enums';
3
3
  import { FilterInterface } from './filter.interface';
4
- export declare const SegmentSchema: z.ZodIntersection<z.ZodObject<{
5
- sql: z.ZodOptional<z.ZodString>;
6
- dimension: z.ZodOptional<z.ZodString>;
7
- operator: z.ZodOptional<z.ZodEnum<typeof import("../type-enums").FilterOperatorsEnum>>;
8
- value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
9
- }, z.core.$strip>, z.ZodObject<{
4
+ export declare const SegmentSchema: z.ZodObject<{
5
+ expr: z.ZodOptional<z.ZodString>;
10
6
  name: z.ZodOptional<z.ZodString>;
11
7
  description: z.ZodOptional<z.ZodString>;
12
8
  public: z.ZodOptional<z.ZodBoolean>;
13
9
  override: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<DatasetStatusEnum.manual>]>>;
14
- }, z.core.$strip>>;
10
+ sql: z.ZodOptional<z.ZodString>;
11
+ dimension: z.ZodOptional<z.ZodString>;
12
+ operator: z.ZodOptional<z.ZodEnum<typeof import("../type-enums").FilterOperatorsEnum>>;
13
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
14
+ }, z.core.$strip>;
15
15
  export interface SegmentInterface extends FilterInterface {
16
16
  name?: string;
17
17
  description?: string;
18
18
  public?: boolean;
19
19
  override?: boolean | DatasetStatusEnum.manual;
20
+ expr?: string;
20
21
  }
@@ -1,16 +1,16 @@
1
1
  import { z } from 'zod';
2
2
  import { SegmentInterface } from './segment.interface';
3
- export declare const SegmentsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
4
- sql: z.ZodOptional<z.ZodString>;
5
- dimension: z.ZodOptional<z.ZodString>;
6
- operator: z.ZodOptional<z.ZodEnum<typeof import("..").FilterOperatorsEnum>>;
7
- value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
8
- }, z.core.$strip>, z.ZodObject<{
3
+ export declare const SegmentsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
4
+ expr: z.ZodOptional<z.ZodString>;
9
5
  name: z.ZodOptional<z.ZodString>;
10
6
  description: z.ZodOptional<z.ZodString>;
11
7
  public: z.ZodOptional<z.ZodBoolean>;
12
8
  override: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<import("..").DatasetStatusEnum.manual>]>>;
13
- }, z.core.$strip>>, z.ZodLiteral<false>]>>;
9
+ sql: z.ZodOptional<z.ZodString>;
10
+ dimension: z.ZodOptional<z.ZodString>;
11
+ operator: z.ZodOptional<z.ZodEnum<typeof import("..").FilterOperatorsEnum>>;
12
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
13
+ }, z.core.$strip>, z.ZodLiteral<false>]>>;
14
14
  export interface SegmentsInterface {
15
15
  [key: string]: SegmentInterface | false;
16
16
  }
@@ -0,0 +1,25 @@
1
+ import { DatasetTypeEnum, DimensionTypesEnum, MeasureTypesEnum } from '../type-enums';
2
+ import { CollectionInterface } from './collection.interface';
3
+ export declare const TYPED_SAFE_KEY_PATTERN: RegExp;
4
+ export declare const MAX_IDENTIFIER_BYTES = 63;
5
+ export declare const tenantSchemaName: (identifier: string) => string;
6
+ export declare const isSafeTenantSchemaIdentifier: (identifier: string) => boolean;
7
+ export declare const TYPED_SEGMENT_COLUMN_PREFIX = "segment__";
8
+ export declare const TYPED_MEASURE_COLUMN_PREFIX = "measure__";
9
+ export declare const TYPED_DEFAULT_COLUMNS: Readonly<Record<string, string>>;
10
+ export declare const TYPED_DEFAULT_DIMENSIONS: ReadonlyArray<string>;
11
+ export declare const isTypedDataset: (dataset: {
12
+ type?: DatasetTypeEnum;
13
+ collection?: Partial<CollectionInterface>;
14
+ }) => boolean;
15
+ export declare const isReservedTypedKey: (key: string) => boolean;
16
+ export declare const isValidTypedKey: (key: string) => boolean;
17
+ export declare const isTextMeasureType: (type: MeasureTypesEnum) => boolean;
18
+ /** The Postgres column type of a typed dimension; segments are always `boolean`. */
19
+ export declare const typedDimensionColumnType: (type: DimensionTypesEnum) => string;
20
+ export declare const typedMeasureColumnType: (type: MeasureTypesEnum) => string;
21
+ /** Single source of truth for whether a typed dimension gets a table column. */
22
+ export declare const hasTypedColumn: (dimension: {
23
+ expr?: string;
24
+ field?: string | Array<string>;
25
+ }) => boolean;
@@ -0,0 +1 @@
1
+ export * from './mapping';
@@ -0,0 +1,37 @@
1
+ import { DimensionTypesEnum, MeasureTypesEnum } from '../type-enums';
2
+ export interface DocumentDatasetMappingDimension {
3
+ expr: string;
4
+ type: DimensionTypesEnum;
5
+ index: boolean;
6
+ }
7
+ export interface DocumentDatasetMappingDimensions {
8
+ [key: string]: DocumentDatasetMappingDimension;
9
+ }
10
+ export interface DocumentDatasetMappingSource {
11
+ expr?: string;
12
+ key?: string;
13
+ }
14
+ export interface DocumentDatasetMappingSegments {
15
+ [key: string]: {
16
+ expr: string;
17
+ };
18
+ }
19
+ export interface DocumentDatasetMappingMeasures {
20
+ [key: string]: {
21
+ expr: string;
22
+ type: MeasureTypesEnum;
23
+ };
24
+ }
25
+ export interface DocumentDatasetMappingConfig {
26
+ tenantIdentifier: string;
27
+ datasetKey: string;
28
+ collection: string;
29
+ schemaName: string;
30
+ tableName: string;
31
+ source: DocumentDatasetMappingSource;
32
+ dimensions: DocumentDatasetMappingDimensions;
33
+ segments: DocumentDatasetMappingSegments;
34
+ measures: DocumentDatasetMappingMeasures;
35
+ mappingHash: string;
36
+ updatedAt: string;
37
+ }
@@ -0,0 +1 @@
1
+ export * from './jsonata-expression';
@@ -0,0 +1,2 @@
1
+ import { z } from 'zod';
2
+ export declare const JsonataExpressionSchema: z.ZodString;
@@ -19,12 +19,15 @@ export * from './dataset/datasets.interface';
19
19
  export * from './dataset/dataset.interface';
20
20
  export * from './dataset/dataset-record.interface';
21
21
  export * from './dataset/collection.interface';
22
+ export * from './dataset/typed-dataset';
22
23
  export * from './dataset/filters.interface';
23
24
  export * from './dataset/filter.interface';
24
25
  export * from './connector/connector.interface';
25
26
  export * from './connector/connectors.interface';
26
27
  export * from './webhook';
28
+ export * from './expression';
27
29
  export * from './metrics';
30
+ export * from './document-dataset';
28
31
  export * from './query.interface';
29
32
  export * from './template.interface';
30
33
  export * from './template-implementation.interface';
@@ -1,5 +1,4 @@
1
1
  export * from './dimensions';
2
- export * from './expression';
3
2
  export * from './measures';
4
3
  export * from './key';
5
4
  export * from './metrics';