@bluecopa/core 0.1.68 → 0.1.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.
- package/dist/api/process/deleteProcessTrigger.d.ts +10 -0
- package/dist/api/process/getTriggersBySheet.d.ts +8 -0
- package/dist/api/process/index.d.ts +4 -0
- package/dist/api/process/registerProcessTrigger.d.ts +10 -0
- package/dist/api/process/triggerTypes.d.ts +49 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +1200 -348
- package/dist/index.es.js.map +1 -1
- package/dist/input-table-db/collectionRef.d.ts +15 -2
- package/dist/input-table-db/expandUtils.d.ts +10 -0
- package/dist/input-table-db/expandedView.d.ts +16 -0
- package/dist/input-table-db/queryBuilder.d.ts +18 -2
- package/dist/input-table-db/realtimeBinding.d.ts +16 -6
- package/dist/input-table-db/rxdb/collectionManager.d.ts +13 -1
- package/dist/input-table-db/types.d.ts +25 -1
- package/dist/utils/metric/analysisMethods.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RxCollection } from 'rxdb';
|
|
2
2
|
import { RxReplicationState } from 'rxdb/plugins/replication';
|
|
3
3
|
import { IWebsocketProvider } from '../config';
|
|
4
|
-
import { Row, WhereOp, CollectionRef, QueryBuilder, InputTableColumn, AggregateSpec, AggregateResult, GroupedAggregateResult } from './types';
|
|
4
|
+
import { Row, WhereOp, CollectionRef, QueryBuilder, InputTableColumn, AggregateSpec, AggregateResult, GroupedAggregateResult, InputTableDefinition } from './types';
|
|
5
5
|
import { DocRefImpl } from './docRef';
|
|
6
6
|
import { WhereClause } from './aggregateUtils';
|
|
7
7
|
export declare class CollectionRefImpl<TRow extends Row = Row> implements CollectionRef<TRow> {
|
|
@@ -12,14 +12,27 @@ export declare class CollectionRefImpl<TRow extends Row = Row> implements Collec
|
|
|
12
12
|
private pkColumn;
|
|
13
13
|
private replicationState;
|
|
14
14
|
private getWebsocketProvider;
|
|
15
|
-
|
|
15
|
+
private schema?;
|
|
16
|
+
private getSchemaForTable?;
|
|
17
|
+
constructor(collection: RxCollection, solutionId: string, tableName: string, primaryKeyField: string, pkColumn: InputTableColumn | undefined, replicationState: RxReplicationState<any, any>, getWebsocketProvider: () => IWebsocketProvider | undefined, schema?: InputTableDefinition, getSchemaForTable?: (tableName: string) => InputTableDefinition | null);
|
|
16
18
|
private makeQueryBuilder;
|
|
17
19
|
where(field: keyof TRow & string, op: WhereOp, value: unknown): QueryBuilder<TRow>;
|
|
18
20
|
orderBy(field: keyof TRow & string, direction?: 'asc' | 'desc'): QueryBuilder<TRow>;
|
|
19
21
|
limit(count: number): QueryBuilder<TRow>;
|
|
20
22
|
skip(count: number): QueryBuilder<TRow>;
|
|
23
|
+
expand(columnNames: string[]): QueryBuilder<TRow>;
|
|
21
24
|
doc(id: string): DocRefImpl<TRow>;
|
|
22
25
|
add(data: Partial<TRow>): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Subscribe to live changes on this collection. Auto-manages the underlying
|
|
28
|
+
* RxDB collection's pin refcount so the collection stays alive for the
|
|
29
|
+
* lifetime of the subscription.
|
|
30
|
+
*
|
|
31
|
+
* Note: `.get()`, `.count()`, and `DocRef.get()` intentionally do NOT pin
|
|
32
|
+
* the collection. They are one-shot reads where the caller is expected to
|
|
33
|
+
* tolerate the collection being LRU-evicted between calls. If you need a
|
|
34
|
+
* long-lived reference, use `.subscribe(...)`.
|
|
35
|
+
*/
|
|
23
36
|
subscribe(callback: (rows: TRow[]) => void): () => void;
|
|
24
37
|
get(): Promise<TRow[]>;
|
|
25
38
|
count(callback: (count: number) => void): () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InputTableDefinition, InputTableRelationship } from './types';
|
|
2
|
+
export declare function deriveEmbedAlias(columnName: string, allColumnNames: string[]): string;
|
|
3
|
+
export declare function resolveRelationship(columnName: string, schema: InputTableDefinition): InputTableRelationship;
|
|
4
|
+
export type ExpandDirective = {
|
|
5
|
+
alias: string;
|
|
6
|
+
referencedTable: string;
|
|
7
|
+
fkColumn: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function buildExpandSelectParam(expansions: ExpandDirective[]): string;
|
|
10
|
+
export declare function buildExpandDirectives(columnNames: string[], schema: InputTableDefinition): ExpandDirective[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { ExpandDirective } from './expandUtils';
|
|
3
|
+
import { Row } from './types';
|
|
4
|
+
export type LookupMaps = Record<string, Map<unknown, Row>>;
|
|
5
|
+
export type ReferencedStream = {
|
|
6
|
+
stream$: Observable<Row[]>;
|
|
7
|
+
pkField: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function buildLookupMap(rows: Row[], pkField: string): Map<unknown, Row>;
|
|
10
|
+
export declare function joinRowsWithLookups(primaryRows: Row[], directives: ExpandDirective[], lookups: LookupMaps): Row[];
|
|
11
|
+
export type ExpandedSubscriptionConfig = {
|
|
12
|
+
primary$: Observable<Row[]>;
|
|
13
|
+
referenced: Record<string, ReferencedStream>;
|
|
14
|
+
directives: ExpandDirective[];
|
|
15
|
+
};
|
|
16
|
+
export declare function createExpandedSubscription(config: ExpandedSubscriptionConfig, cb: (rows: Row[]) => void): () => void;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { RxCollection } from 'rxdb';
|
|
2
|
-
import {
|
|
2
|
+
import { IWebsocketProvider } from '../config';
|
|
3
|
+
import { Row, WhereOp, QueryBuilder, AggregateSpec, AggregateResult, GroupedAggregateResult, InputTableDefinition } from './types';
|
|
3
4
|
import { WhereClause } from './aggregateUtils';
|
|
5
|
+
export type ExpandContext = {
|
|
6
|
+
schema: InputTableDefinition;
|
|
7
|
+
expandColumns: string[];
|
|
8
|
+
solutionId: string;
|
|
9
|
+
tableName: string;
|
|
10
|
+
workspaceId: string;
|
|
11
|
+
getHeaders: () => Record<string, string>;
|
|
12
|
+
getSchemaForTable: (tableName: string) => InputTableDefinition | null;
|
|
13
|
+
getWebsocketProvider: () => IWebsocketProvider | undefined;
|
|
14
|
+
};
|
|
4
15
|
type OrderClause = {
|
|
5
16
|
field: string;
|
|
6
17
|
direction: 'asc' | 'desc';
|
|
@@ -9,17 +20,22 @@ type AggregateExecutor<TRow extends Row> = <TSpec extends AggregateSpec<TRow>>(w
|
|
|
9
20
|
export declare class QueryBuilderImpl<TRow extends Row = Row> implements QueryBuilder<TRow> {
|
|
10
21
|
private collection;
|
|
11
22
|
private aggregateExecutor?;
|
|
23
|
+
private expandContext?;
|
|
12
24
|
private wheres;
|
|
13
25
|
private orders;
|
|
14
26
|
private limitCount;
|
|
15
27
|
private skipCount;
|
|
16
|
-
constructor(collection: RxCollection, initialWhere?: WhereClause, initialOrder?: OrderClause, initialLimit?: number, initialSkip?: number, aggregateExecutor?: AggregateExecutor<TRow
|
|
28
|
+
constructor(collection: RxCollection, initialWhere?: WhereClause, initialOrder?: OrderClause, initialLimit?: number, initialSkip?: number, aggregateExecutor?: AggregateExecutor<TRow>, expandContext?: ExpandContext);
|
|
17
29
|
where(field: keyof TRow & string, op: WhereOp, value: unknown): QueryBuilder<TRow>;
|
|
18
30
|
orderBy(field: keyof TRow & string, direction?: 'asc' | 'desc'): QueryBuilder<TRow>;
|
|
19
31
|
limit(count: number): QueryBuilder<TRow>;
|
|
20
32
|
skip(count: number): QueryBuilder<TRow>;
|
|
33
|
+
expand(columnNames: string[]): QueryBuilder<TRow>;
|
|
21
34
|
subscribe(callback: (rows: TRow[]) => void): () => void;
|
|
35
|
+
private buildPrimaryStream;
|
|
36
|
+
private subscribeWithExpand;
|
|
22
37
|
get(): Promise<TRow[]>;
|
|
38
|
+
private getWithExpand;
|
|
23
39
|
aggregate<TSpec extends AggregateSpec<TRow>>(spec: TSpec): Promise<AggregateResult<TSpec>>;
|
|
24
40
|
aggregate<TSpec extends AggregateSpec<TRow>>(spec: TSpec, options: {
|
|
25
41
|
groupBy: [];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RxCollection } from 'rxdb';
|
|
1
2
|
import { RxReplicationState } from 'rxdb/plugins/replication';
|
|
2
3
|
import { IWebsocketProvider } from '../config';
|
|
3
4
|
export type RealtimeBindingHandle = {
|
|
@@ -6,11 +7,20 @@ export type RealtimeBindingHandle = {
|
|
|
6
7
|
/**
|
|
7
8
|
* Bind IWebsocketProvider change notifications to RxDB replication.
|
|
8
9
|
*
|
|
9
|
-
* Backend publishes events on channel:
|
|
10
|
-
*
|
|
11
|
-
* Payload: { event_name: string, event_type: "INSERT"|"UPDATE"|"DELETE", schema: string }
|
|
10
|
+
* Backend publishes events on channel:
|
|
11
|
+
* public-input-table-v2-{workspaceId}-{solutionId}-{tableName}
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* INSERT / UPDATE payloads carry no row data, so we fall back to reSync() and
|
|
14
|
+
* let the replication cursor pull the new state.
|
|
15
|
+
*
|
|
16
|
+
* DELETE payloads carry the deleted rows:
|
|
17
|
+
* { event_type: 'DELETE', deleted_rows: [{ ...row }], deleted_count: N }
|
|
18
|
+
* or, when the batch exceeds the backend's size cap:
|
|
19
|
+
* { event_type: 'DELETE', truncated: true, deleted_count: N }
|
|
20
|
+
*
|
|
21
|
+
* For DELETE we remove matching local docs directly (the pull cursor can't see
|
|
22
|
+
* deleted rows, so reSync alone would leave stale tombstones in consumers). If
|
|
23
|
+
* the payload is truncated or malformed we fall back to reSync() — worst case
|
|
24
|
+
* the deleted rows linger briefly but no data is lost.
|
|
15
25
|
*/
|
|
16
|
-
export declare function createRealtimeBinding(provider: IWebsocketProvider, replicationState: RxReplicationState<any, any>, workspaceId: string, solutionId: string, tableName: string): RealtimeBindingHandle;
|
|
26
|
+
export declare function createRealtimeBinding(provider: IWebsocketProvider, replicationState: RxReplicationState<any, any>, collection: RxCollection, primaryKeyField: string, workspaceId: string, solutionId: string, tableName: string): RealtimeBindingHandle;
|
|
@@ -12,7 +12,7 @@ export type ManagedCollection = {
|
|
|
12
12
|
workspaceId: string;
|
|
13
13
|
primaryKeyField: string;
|
|
14
14
|
lastAccessed: number;
|
|
15
|
-
/**
|
|
15
|
+
/** Lifecycle pin count — collection lives while > 0; destroyed at 0. */
|
|
16
16
|
refCount: number;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
@@ -23,6 +23,18 @@ export declare function addRef(managed: ManagedCollection): void;
|
|
|
23
23
|
* Decrement refCount for a managed collection (call when unsubscribing).
|
|
24
24
|
*/
|
|
25
25
|
export declare function releaseRef(managed: ManagedCollection): void;
|
|
26
|
+
/**
|
|
27
|
+
* Pin a collection for the lifetime of a consumer. Creates the collection on first pin,
|
|
28
|
+
* increments refCount on each subsequent call.
|
|
29
|
+
*/
|
|
30
|
+
export declare function pinCollection(solutionId: string, tableDef: InputTableDefinition, workspaceId: string, websocketProvider?: IWebsocketProvider): Promise<ManagedCollection>;
|
|
31
|
+
/**
|
|
32
|
+
* Release a pinned collection. Destroys when refCount reaches zero.
|
|
33
|
+
*/
|
|
34
|
+
export declare function unpinCollection(solutionId: string, tableName: string, workspaceId: string): Promise<void>;
|
|
35
|
+
export declare function getCollectionRefCount(solutionId: string, tableName: string, workspaceId: string): number;
|
|
36
|
+
/** Test-only — drop all tracked collections without network calls. */
|
|
37
|
+
export declare function __resetCollectionManagerForTests(): Promise<void>;
|
|
26
38
|
/**
|
|
27
39
|
* Get or create an RxDB collection for a table.
|
|
28
40
|
* Deduplicates concurrent creation requests. Handles LRU eviction with refcount protection.
|
|
@@ -11,20 +11,36 @@ export declare enum InputTableColumnType {
|
|
|
11
11
|
TIME = "time",
|
|
12
12
|
JSONB = "jsonb"
|
|
13
13
|
}
|
|
14
|
+
export declare enum InputTableOnDelete {
|
|
15
|
+
CASCADE = "cascade",
|
|
16
|
+
SET_NULL = "set_null",
|
|
17
|
+
RESTRICT = "restrict"
|
|
18
|
+
}
|
|
19
|
+
export type InputTableRelationship = {
|
|
20
|
+
column: string;
|
|
21
|
+
references_table: string;
|
|
22
|
+
references_column: string;
|
|
23
|
+
on_delete?: InputTableOnDelete;
|
|
24
|
+
};
|
|
14
25
|
export type InputTableColumn = {
|
|
15
26
|
name: string;
|
|
16
27
|
type: InputTableColumnType;
|
|
17
28
|
nullable?: boolean;
|
|
18
29
|
primary_key?: boolean;
|
|
19
30
|
auto_increment?: boolean;
|
|
31
|
+
unique?: boolean;
|
|
20
32
|
default?: string | number | boolean | null;
|
|
21
33
|
searchable?: boolean;
|
|
22
34
|
};
|
|
23
35
|
export type InputTableDefinition = {
|
|
24
36
|
name: string;
|
|
25
37
|
columns: InputTableColumn[];
|
|
38
|
+
relationships?: InputTableRelationship[];
|
|
26
39
|
};
|
|
27
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* A plain row object returned by the SDK. Rows produced by an expanded query also
|
|
42
|
+
* carry nested row objects under the embed alias for each expanded FK column.
|
|
43
|
+
*/
|
|
28
44
|
export type Row = Record<string, unknown>;
|
|
29
45
|
/** Where clause operators */
|
|
30
46
|
export type WhereOp = '==' | '!=' | '<' | '<=' | '>' | '>=' | 'in' | 'not-in';
|
|
@@ -53,6 +69,12 @@ export interface QueryBuilder<TRow extends Row = Row> {
|
|
|
53
69
|
orderBy(field: keyof TRow & string, direction?: 'asc' | 'desc'): QueryBuilder<TRow>;
|
|
54
70
|
limit(count: number): QueryBuilder<TRow>;
|
|
55
71
|
skip(count: number): QueryBuilder<TRow>;
|
|
72
|
+
/**
|
|
73
|
+
* Embed referenced rows for each listed FK column. Rows returned by `.get()` or
|
|
74
|
+
* `.subscribe()` include the referenced row under an alias derived from the column
|
|
75
|
+
* name (`customer_id` → `customer`; on collision falls back to `<col>_row`).
|
|
76
|
+
*/
|
|
77
|
+
expand(columnNames: string[]): QueryBuilder<TRow>;
|
|
56
78
|
subscribe(callback: (rows: TRow[]) => void): () => void;
|
|
57
79
|
get(): Promise<TRow[]>;
|
|
58
80
|
aggregate<TSpec extends AggregateSpec<TRow>>(spec: TSpec): Promise<AggregateResult<TSpec>>;
|
|
@@ -74,6 +96,8 @@ export interface CollectionRef<TRow extends Row = Row> {
|
|
|
74
96
|
orderBy(field: keyof TRow & string, direction?: 'asc' | 'desc'): QueryBuilder<TRow>;
|
|
75
97
|
limit(count: number): QueryBuilder<TRow>;
|
|
76
98
|
skip(count: number): QueryBuilder<TRow>;
|
|
99
|
+
/** See {@link QueryBuilder.expand}. */
|
|
100
|
+
expand(columnNames: string[]): QueryBuilder<TRow>;
|
|
77
101
|
doc(id: string): DocRef<TRow>;
|
|
78
102
|
add(data: Partial<TRow>): Promise<string>;
|
|
79
103
|
subscribe(callback: (rows: TRow[]) => void): () => void;
|
|
@@ -12,7 +12,7 @@ export type MetricToolPanelType = {
|
|
|
12
12
|
limitOptions: LimitOptions;
|
|
13
13
|
filterModel: FilterRule | [];
|
|
14
14
|
dateRange?: DateRange;
|
|
15
|
-
timeBin: TimeBin |
|
|
15
|
+
timeBin: TimeBin | '';
|
|
16
16
|
currency?: string;
|
|
17
17
|
compareTrends?: Array<{
|
|
18
18
|
id: string;
|
|
@@ -20,7 +20,7 @@ export type MetricToolPanelType = {
|
|
|
20
20
|
dateRange: DateRange;
|
|
21
21
|
}>;
|
|
22
22
|
showDimensionMappingValues?: boolean;
|
|
23
|
-
plotAsTrendsOrder?:
|
|
23
|
+
plotAsTrendsOrder?: 'asc' | 'desc' | 'none';
|
|
24
24
|
showBinSortOrderValues?: boolean;
|
|
25
25
|
};
|
|
26
26
|
export declare const getPivotGridData: (props: {
|