@scrawn/analytics 0.0.2 → 0.0.5
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/analytics.d.ts +64 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +53 -0
- package/dist/analytics.js.map +1 -0
- package/dist/data/base.d.ts +30 -0
- package/dist/data/base.d.ts.map +1 -0
- package/dist/data/base.js +49 -0
- package/dist/data/base.js.map +1 -0
- package/dist/data/fields.d.ts +32 -0
- package/dist/data/fields.d.ts.map +1 -0
- package/dist/data/fields.js +33 -0
- package/dist/data/fields.js.map +1 -0
- package/dist/data/tables.d.ts +35 -0
- package/dist/data/tables.d.ts.map +1 -0
- package/dist/data/tables.js +64 -0
- package/dist/data/tables.js.map +1 -0
- package/dist/data/types.d.ts +7 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/data/types.js +2 -0
- package/dist/data/types.js.map +1 -0
- package/dist/fieldRef.d.ts +18 -0
- package/dist/fieldRef.d.ts.map +1 -0
- package/dist/fieldRef.js +13 -0
- package/dist/fieldRef.js.map +1 -0
- package/dist/grpc/client.d.ts +18 -0
- package/dist/grpc/client.d.ts.map +1 -0
- package/dist/grpc/client.js +87 -0
- package/dist/grpc/client.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/operators.d.ts +36 -0
- package/dist/operators.d.ts.map +1 -0
- package/dist/operators.js +54 -0
- package/dist/operators.js.map +1 -0
- package/dist/query/aiToken.d.ts +7 -0
- package/dist/query/aiToken.d.ts.map +1 -0
- package/dist/query/aiToken.js +8 -0
- package/dist/query/aiToken.js.map +1 -0
- package/dist/query/base.d.ts +33 -0
- package/dist/query/base.d.ts.map +1 -0
- package/dist/query/base.js +64 -0
- package/dist/query/base.js.map +1 -0
- package/dist/query/fields.d.ts +34 -0
- package/dist/query/fields.d.ts.map +1 -0
- package/dist/query/fields.js +35 -0
- package/dist/query/fields.js.map +1 -0
- package/dist/query/payment.d.ts +7 -0
- package/dist/query/payment.d.ts.map +1 -0
- package/dist/query/payment.js +8 -0
- package/dist/query/payment.js.map +1 -0
- package/dist/query/sdkEvent.d.ts +7 -0
- package/dist/query/sdkEvent.d.ts.map +1 -0
- package/dist/query/sdkEvent.js +8 -0
- package/dist/query/sdkEvent.js.map +1 -0
- package/dist/query/types.d.ts +12 -0
- package/dist/query/types.d.ts.map +1 -0
- package/dist/query/types.js +2 -0
- package/dist/query/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Scrawn } from "@scrawn/core";
|
|
2
|
+
import { SdkEventBuilder } from "./query/sdkEvent.js";
|
|
3
|
+
import { AiTokenBuilder } from "./query/aiToken.js";
|
|
4
|
+
import { PaymentBuilder } from "./query/payment.js";
|
|
5
|
+
import { UsersBuilder, SessionsBuilder, TagsBuilder, ExpressionsBuilder, MetadataBuilder } from "./data/tables.js";
|
|
6
|
+
/**
|
|
7
|
+
* Query interface for event analytics.
|
|
8
|
+
* Each builder is pre-scoped to the correct event type.
|
|
9
|
+
*/
|
|
10
|
+
export interface EventQueries {
|
|
11
|
+
sdkEvent: SdkEventBuilder;
|
|
12
|
+
aiToken: AiTokenBuilder;
|
|
13
|
+
payment: PaymentBuilder;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Query interface for administrative data.
|
|
17
|
+
* Each builder targets a specific table.
|
|
18
|
+
*/
|
|
19
|
+
export interface DataQueries {
|
|
20
|
+
users: UsersBuilder;
|
|
21
|
+
sessions: SessionsBuilder;
|
|
22
|
+
tags: TagsBuilder;
|
|
23
|
+
expressions: ExpressionsBuilder;
|
|
24
|
+
metadata: MetadataBuilder;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Analytics client for the Scrawn platform.
|
|
28
|
+
*
|
|
29
|
+
* Provides MongoDB/drizzle-style query builders for event analytics
|
|
30
|
+
* and administrative data lookups, backed by the Scrawn gRPC API.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { Analytics, eq, gt, and, desc } from "@scrawn/analytics";
|
|
35
|
+
* import { biller } from "./scrawn/biller";
|
|
36
|
+
*
|
|
37
|
+
* const analytics = new Analytics(biller);
|
|
38
|
+
*
|
|
39
|
+
* // Query SDK events
|
|
40
|
+
* const events = await analytics.query.sdkEvent
|
|
41
|
+
* .where(and(
|
|
42
|
+
* eq(analytics.query.sdkEvent.fields.sdkCallType, "RAW"),
|
|
43
|
+
* gt(analytics.query.sdkEvent.fields.debitAmount, 100),
|
|
44
|
+
* ))
|
|
45
|
+
* .orderBy(desc(analytics.query.sdkEvent.fields.reportedTimestamp))
|
|
46
|
+
* .limit(10)
|
|
47
|
+
* .execute();
|
|
48
|
+
*
|
|
49
|
+
* // Query user data
|
|
50
|
+
* const users = await analytics.data.users
|
|
51
|
+
* .where(eq(analytics.data.users.fields.mode, "production"))
|
|
52
|
+
* .limit(10)
|
|
53
|
+
* .execute();
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare class Analytics {
|
|
57
|
+
private grpc;
|
|
58
|
+
/** Event query builders */
|
|
59
|
+
readonly query: EventQueries;
|
|
60
|
+
/** Data query builders */
|
|
61
|
+
readonly data: DataQueries;
|
|
62
|
+
constructor(biller: Scrawn<string, string>);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,kBAAkB,CAAC;IAChC,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,IAAI,CAAa;IAEzB,2BAA2B;IAC3B,SAAgB,KAAK,EAAE,YAAY,CAAC;IAEpC,0BAA0B;IAC1B,SAAgB,IAAI,EAAE,WAAW,CAAC;gBAEtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAkB3C"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { SdkEventBuilder } from "./query/sdkEvent.js";
|
|
2
|
+
import { AiTokenBuilder } from "./query/aiToken.js";
|
|
3
|
+
import { PaymentBuilder } from "./query/payment.js";
|
|
4
|
+
import { UsersBuilder, SessionsBuilder, TagsBuilder, ExpressionsBuilder, MetadataBuilder, } from "./data/tables.js";
|
|
5
|
+
/**
|
|
6
|
+
* Analytics client for the Scrawn platform.
|
|
7
|
+
*
|
|
8
|
+
* Provides MongoDB/drizzle-style query builders for event analytics
|
|
9
|
+
* and administrative data lookups, backed by the Scrawn gRPC API.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { Analytics, eq, gt, and, desc } from "@scrawn/analytics";
|
|
14
|
+
* import { biller } from "./scrawn/biller";
|
|
15
|
+
*
|
|
16
|
+
* const analytics = new Analytics(biller);
|
|
17
|
+
*
|
|
18
|
+
* // Query SDK events
|
|
19
|
+
* const events = await analytics.query.sdkEvent
|
|
20
|
+
* .where(and(
|
|
21
|
+
* eq(analytics.query.sdkEvent.fields.sdkCallType, "RAW"),
|
|
22
|
+
* gt(analytics.query.sdkEvent.fields.debitAmount, 100),
|
|
23
|
+
* ))
|
|
24
|
+
* .orderBy(desc(analytics.query.sdkEvent.fields.reportedTimestamp))
|
|
25
|
+
* .limit(10)
|
|
26
|
+
* .execute();
|
|
27
|
+
*
|
|
28
|
+
* // Query user data
|
|
29
|
+
* const users = await analytics.data.users
|
|
30
|
+
* .where(eq(analytics.data.users.fields.mode, "production"))
|
|
31
|
+
* .limit(10)
|
|
32
|
+
* .execute();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export class Analytics {
|
|
36
|
+
constructor(biller) {
|
|
37
|
+
this.grpc = biller.grpc;
|
|
38
|
+
const apiKey = biller.apikey;
|
|
39
|
+
this.query = {
|
|
40
|
+
sdkEvent: new SdkEventBuilder(this.grpc, apiKey),
|
|
41
|
+
aiToken: new AiTokenBuilder(this.grpc, apiKey),
|
|
42
|
+
payment: new PaymentBuilder(this.grpc, apiKey),
|
|
43
|
+
};
|
|
44
|
+
this.data = {
|
|
45
|
+
users: new UsersBuilder(this.grpc, apiKey),
|
|
46
|
+
sessions: new SessionsBuilder(this.grpc, apiKey),
|
|
47
|
+
tags: new TagsBuilder(this.grpc, apiKey),
|
|
48
|
+
expressions: new ExpressionsBuilder(this.grpc, apiKey),
|
|
49
|
+
metadata: new MetadataBuilder(this.grpc, apiKey),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=analytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,e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
|
+
export declare abstract class BaseDataBuilder<TFields> {
|
|
4
|
+
readonly fields: TFields;
|
|
5
|
+
readonly tableName: string;
|
|
6
|
+
protected _where?: FilterGroup;
|
|
7
|
+
protected _orderBy: OrderBy[];
|
|
8
|
+
protected _limit: number;
|
|
9
|
+
protected _offset: number;
|
|
10
|
+
constructor(fields: TFields, tableName: string);
|
|
11
|
+
where(filter: FilterCondition | FilterGroup): this;
|
|
12
|
+
orderBy(...orders: OrderBy[]): this;
|
|
13
|
+
limit(n: number): this;
|
|
14
|
+
offset(n: number): this;
|
|
15
|
+
protected buildParams(): {
|
|
16
|
+
where: FilterGroup | undefined;
|
|
17
|
+
limit: number;
|
|
18
|
+
offset: number;
|
|
19
|
+
orderBy: OrderBy[] | undefined;
|
|
20
|
+
};
|
|
21
|
+
protected unwrap(res: {
|
|
22
|
+
columnsList?: string[];
|
|
23
|
+
rowsList?: Array<{
|
|
24
|
+
valuesList?: string[];
|
|
25
|
+
}>;
|
|
26
|
+
total?: number;
|
|
27
|
+
}): DataQueryResult<TFields>;
|
|
28
|
+
abstract execute(): Promise<DataQueryResult<TFields>>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/data/base.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,8BAAsB,eAAe,CAAC,OAAO;aAOzB,MAAM,EAAE,OAAO;aACf,SAAS,EAAE,MAAM;IAPnC,SAAS,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC/B,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAM;IACnC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAO;IAC/B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAK;gBAGZ,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM;IAGnC,KAAK,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI;IASlD,OAAO,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI;IAKnC,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAKtB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAKvB,SAAS,CAAC,WAAW;;;;;;IASrB,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,KAAK,CAAC;YAAE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,eAAe,CAAC,OAAO,CAAC;IAWxI,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;CACtD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export class BaseDataBuilder {
|
|
2
|
+
constructor(fields, tableName) {
|
|
3
|
+
this.fields = fields;
|
|
4
|
+
this.tableName = tableName;
|
|
5
|
+
this._orderBy = [];
|
|
6
|
+
this._limit = 100;
|
|
7
|
+
this._offset = 0;
|
|
8
|
+
}
|
|
9
|
+
where(filter) {
|
|
10
|
+
if ("operator" in filter) {
|
|
11
|
+
this._where = { logical: "AND", conditions: [filter], groups: [] };
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
this._where = filter;
|
|
15
|
+
}
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
orderBy(...orders) {
|
|
19
|
+
this._orderBy = orders;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
limit(n) {
|
|
23
|
+
this._limit = n;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
offset(n) {
|
|
27
|
+
this._offset = n;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
buildParams() {
|
|
31
|
+
return {
|
|
32
|
+
where: this._where,
|
|
33
|
+
limit: this._limit,
|
|
34
|
+
offset: this._offset,
|
|
35
|
+
orderBy: this._orderBy.length > 0 ? this._orderBy : undefined,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
unwrap(res) {
|
|
39
|
+
const cols = res.columnsList ?? [];
|
|
40
|
+
const rows = (res.rowsList ?? []).map((r) => {
|
|
41
|
+
const vals = r.valuesList ?? [];
|
|
42
|
+
const obj = {};
|
|
43
|
+
cols.forEach((c, i) => { obj[c] = vals[i] ?? ""; });
|
|
44
|
+
return obj;
|
|
45
|
+
});
|
|
46
|
+
return { columns: cols, rows, total: res.total ?? 0 };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/data/base.ts"],"names":[],"mappings":"AAIA,MAAM,OAAgB,eAAe;IAMnC,YACkB,MAAe,EACf,SAAiB;QADjB,WAAM,GAAN,MAAM,CAAS;QACf,cAAS,GAAT,SAAS,CAAQ;QANzB,aAAQ,GAAc,EAAE,CAAC;QACzB,WAAM,GAAW,GAAG,CAAC;QACrB,YAAO,GAAW,CAAC,CAAC;IAK3B,CAAC;IAEJ,KAAK,CAAC,MAAqC;QACzC,IAAI,UAAU,IAAI,MAAM,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QACrE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,GAAG,MAAiB;QAC1B,IAAI,CAA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ldRef.js";
|
|
2
|
+
export declare const usersFields: {
|
|
3
|
+
readonly id: FieldRef<string>;
|
|
4
|
+
readonly last_billed_timestamp: FieldRef<string>;
|
|
5
|
+
readonly payment_provider_user_id: FieldRef<string>;
|
|
6
|
+
readonly mode: FieldRef<string>;
|
|
7
|
+
};
|
|
8
|
+
export declare const sessionsFields: {
|
|
9
|
+
readonly id: FieldRef<string>;
|
|
10
|
+
readonly session_id: FieldRef<string>;
|
|
11
|
+
readonly user_id: FieldRef<string>;
|
|
12
|
+
readonly processed: FieldRef<string>;
|
|
13
|
+
readonly billed_upto: FieldRef<string>;
|
|
14
|
+
readonly created_at: FieldRef<string>;
|
|
15
|
+
readonly mode: FieldRef<string>;
|
|
16
|
+
};
|
|
17
|
+
export declare const tagsFields: {
|
|
18
|
+
readonly id: FieldRef<string>;
|
|
19
|
+
readonly key: FieldRef<string>;
|
|
20
|
+
readonly amount: FieldRef<string>;
|
|
21
|
+
};
|
|
22
|
+
export declare const expressionsFields: {
|
|
23
|
+
readonly id: FieldRef<string>;
|
|
24
|
+
readonly key: FieldRef<string>;
|
|
25
|
+
readonly expr: FieldRef<string>;
|
|
26
|
+
};
|
|
27
|
+
export declare const metadataFields: {
|
|
28
|
+
readonly id: FieldRef<string>;
|
|
29
|
+
readonly payment_cron: FieldRef<string>;
|
|
30
|
+
readonly payment_webhook: FieldRef<string>;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/data/fields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;;CAQjB,CAAC;AAEX,eAAO,MAAM,UAAU;;;;CAIb,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC;AAEX,eAAO,MAAM,cAAc;;;;CAIjB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/gen-fields.ts — do not edit
|
|
2
|
+
import { FieldRef } from "../fieldRef.js";
|
|
3
|
+
export const usersFields = {
|
|
4
|
+
id: new FieldRef("id"),
|
|
5
|
+
last_billed_timestamp: new FieldRef("last_billed_timestamp"),
|
|
6
|
+
payment_provider_user_id: new FieldRef("payment_provider_user_id"),
|
|
7
|
+
mode: new FieldRef("mode"),
|
|
8
|
+
};
|
|
9
|
+
export const sessionsFields = {
|
|
10
|
+
id: new FieldRef("id"),
|
|
11
|
+
session_id: new FieldRef("session_id"),
|
|
12
|
+
user_id: new FieldRef("user_id"),
|
|
13
|
+
processed: new FieldRef("processed"),
|
|
14
|
+
billed_upto: new FieldRef("billed_upto"),
|
|
15
|
+
created_at: new FieldRef("created_at"),
|
|
16
|
+
mode: new FieldRef("mode"),
|
|
17
|
+
};
|
|
18
|
+
export const tagsFields = {
|
|
19
|
+
id: new FieldRef("id"),
|
|
20
|
+
key: new FieldRef("key"),
|
|
21
|
+
amount: new FieldRef("amount"),
|
|
22
|
+
};
|
|
23
|
+
export const expressionsFields = {
|
|
24
|
+
id: new FieldRef("id"),
|
|
25
|
+
key: new FieldRef("key"),
|
|
26
|
+
expr: new FieldRef("expr"),
|
|
27
|
+
};
|
|
28
|
+
export const metadataFields = {
|
|
29
|
+
id: new FieldRef("id"),
|
|
30
|
+
payment_cron: new FieldRef("payment_cron"),
|
|
31
|
+
payment_webhook: new FieldRef("payment_webhook"),
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/data/fields.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,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0,0 +1,35 @@
|
|
|
1
|
+
import { BaseDataBuilder } from "./base.js";
|
|
2
|
+
import type { GrpcClient } from "@scrawn/core";
|
|
3
|
+
import type { DataQueryResult } from "./types.js";
|
|
4
|
+
import { usersFields, sessionsFields, tagsFields, expressionsFields, metadataFields } from "./fields.js";
|
|
5
|
+
export declare class UsersBuilder extends BaseDataBuilder<typeof usersFields> {
|
|
6
|
+
private grpc;
|
|
7
|
+
private apiKey;
|
|
8
|
+
constructor(grpc: GrpcClient, apiKey: string);
|
|
9
|
+
execute(): Promise<DataQueryResult<typeof usersFields>>;
|
|
10
|
+
}
|
|
11
|
+
export declare class SessionsBuilder extends BaseDataBuilder<typeof sessionsFields> {
|
|
12
|
+
private grpc;
|
|
13
|
+
private apiKey;
|
|
14
|
+
constructor(grpc: GrpcClient, apiKey: string);
|
|
15
|
+
execute(): Promise<DataQueryResult<typeof sessionsFields>>;
|
|
16
|
+
}
|
|
17
|
+
export declare class TagsBuilder extends BaseDataBuilder<typeof tagsFields> {
|
|
18
|
+
private grpc;
|
|
19
|
+
private apiKey;
|
|
20
|
+
constructor(grpc: GrpcClient, apiKey: string);
|
|
21
|
+
execute(): Promise<DataQueryResult<typeof tagsFields>>;
|
|
22
|
+
}
|
|
23
|
+
export declare class ExpressionsBuilder extends BaseDataBuilder<typeof expressionsFields> {
|
|
24
|
+
private grpc;
|
|
25
|
+
private apiKey;
|
|
26
|
+
constructor(grpc: GrpcClient, apiKey: string);
|
|
27
|
+
execute(): Promise<DataQueryResult<typeof expressionsFields>>;
|
|
28
|
+
}
|
|
29
|
+
export declare class MetadataBuilder extends BaseDataBuilder<typeof metadataFields> {
|
|
30
|
+
private grpc;
|
|
31
|
+
private apiKey;
|
|
32
|
+
constructor(grpc: GrpcClient, apiKey: string);
|
|
33
|
+
execute(): Promise<DataQueryResult<typeof metadataFields>>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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AC;CAKpE;AAED,qBAAa,eAAgB,SAAQ,eAAe,CAAC,OAAO,cAAc,CAAC;IAC7D,OAAO,CAAC,IAAI;IAAc,OAAO,CAAC,MAAM;gBAAhC,IAAI,EAAE,UAAU,EAAU,MAAM,EAAE,MAAM;IAGtD,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,OAAO,cAAc,CAAC,CAAC;CAKjE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { BaseDataBuilder } from "./base.js";
|
|
2
|
+
import { callDataQuery } from "../grpc/client.js";
|
|
3
|
+
import { usersFields, sessionsFields, tagsFields, expressionsFields, metadataFields, } from "./fields.js";
|
|
4
|
+
export class UsersBuilder extends BaseDataBuilder {
|
|
5
|
+
constructor(grpc, apiKey) {
|
|
6
|
+
super(usersFields, "users");
|
|
7
|
+
this.grpc = grpc;
|
|
8
|
+
this.apiKey = apiKey;
|
|
9
|
+
}
|
|
10
|
+
async execute() {
|
|
11
|
+
const params = this.buildParams();
|
|
12
|
+
const res = await callDataQuery(this.grpc, this.apiKey, "users", params);
|
|
13
|
+
return this.unwrap(res);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class SessionsBuilder extends BaseDataBuilder {
|
|
17
|
+
constructor(grpc, apiKey) {
|
|
18
|
+
super(sessionsFields, "sessions");
|
|
19
|
+
this.grpc = grpc;
|
|
20
|
+
this.apiKey = apiKey;
|
|
21
|
+
}
|
|
22
|
+
async execute() {
|
|
23
|
+
const params = this.buildParams();
|
|
24
|
+
const res = await callDataQuery(this.grpc, this.apiKey, "sessions", params);
|
|
25
|
+
return this.unwrap(res);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class TagsBuilder extends BaseDataBuilder {
|
|
29
|
+
constructor(grpc, apiKey) {
|
|
30
|
+
super(tagsFields, "tags");
|
|
31
|
+
this.grpc = grpc;
|
|
32
|
+
this.apiKey = apiKey;
|
|
33
|
+
}
|
|
34
|
+
async execute() {
|
|
35
|
+
const params = this.buildParams();
|
|
36
|
+
const res = await callDataQuery(this.grpc, this.apiKey, "tags", params);
|
|
37
|
+
return this.unwrap(res);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export class ExpressionsBuilder extends BaseDataBuilder {
|
|
41
|
+
constructor(grpc, apiKey) {
|
|
42
|
+
super(expressionsFields, "expressions");
|
|
43
|
+
this.grpc = grpc;
|
|
44
|
+
this.apiKey = apiKey;
|
|
45
|
+
}
|
|
46
|
+
async execute() {
|
|
47
|
+
const params = this.buildParams();
|
|
48
|
+
const res = await callDataQuery(this.grpc, this.apiKey, "expressions", params);
|
|
49
|
+
return this.unwrap(res);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class MetadataBuilder extends BaseDataBuilder {
|
|
53
|
+
constructor(grpc, apiKey) {
|
|
54
|
+
super(metadataFields, "metadata");
|
|
55
|
+
this.grpc = grpc;
|
|
56
|
+
this.apiKey = apiKey;
|
|
57
|
+
}
|
|
58
|
+
async execute() {
|
|
59
|
+
const params = this.buildParams();
|
|
60
|
+
const res = await callDataQuery(this.grpc, this.apiKey, "metadata", params);
|
|
61
|
+
return this.unwrap(res);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../src/data/tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIlD,OAAO,EACL,WAAW,EACX,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,YAAa,SAAQ,eAAmC;IACnE,YAAoB,IAAgB,EAAU,MAAc;QAC1D,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QADV,SAAI,GAAJ,IAAI,CAAY;QAAU,WAA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AAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/data/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldRef — typed field reference for query builders.
|
|
3
|
+
* Carries the field name along with its TypeScript type for operator type safety.
|
|
4
|
+
*/
|
|
5
|
+
export declare class FieldRef<T> {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
constructor(name: string);
|
|
8
|
+
toString(): string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Extracts a row type from a fields object.
|
|
12
|
+
* Given { id: FieldRef<string>, mode: FieldRef<string> },
|
|
13
|
+
* yields { id: string, mode: string }.
|
|
14
|
+
*/
|
|
15
|
+
export type InferRow<TFields> = {
|
|
16
|
+
[K in keyof TFields]: TFields[K] extends FieldRef<infer V> ? V : never;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=fieldRef.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldRef.d.ts","sourceRoot":"","sources":["../src/fieldRef.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,QAAQ,CAAC,CAAC;aACO,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;IAExC,QAAQ,IAAI,MAAM;CAGnB;AAED;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,OAAO,IAAI;KAC7B,CAAC,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CACvE,CAAC"}
|
package/dist/fieldRef.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldRef — typed field reference for query builders.
|
|
3
|
+
* Carries the field name along with its TypeScript type for operator type safety.
|
|
4
|
+
*/
|
|
5
|
+
export class FieldRef {
|
|
6
|
+
constructor(name) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
}
|
|
9
|
+
toString() {
|
|
10
|
+
return this.name;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=fieldRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldRef.js","sourceRoot":"","sources":["../src/fieldRef.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACnB,YAA4B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAE5C,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GrpcClient } from "@scrawn/core";
|
|
2
|
+
import { QueryEventsResponse } from "@scrawn/core";
|
|
3
|
+
import { QueryResponse } from "@scrawn/core";
|
|
4
|
+
import type { FilterGroup, Aggregation as AggType, OrderBy as OrderByType } from "../operators.ts";
|
|
5
|
+
export declare function callEventQuery(grpc: GrpcClient, apiKey: string, params: {
|
|
6
|
+
where?: FilterGroup;
|
|
7
|
+
aggregation?: AggType;
|
|
8
|
+
groupBy?: string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
offset?: number;
|
|
11
|
+
}): Promise<QueryEventsResponse.AsObject>;
|
|
12
|
+
export declare function callDataQuery(grpc: GrpcClient, apiKey: string, tableName: string, params: {
|
|
13
|
+
where?: FilterGroup;
|
|
14
|
+
limit?: number;
|
|
15
|
+
offset?: number;
|
|
16
|
+
orderBy?: OrderByType[];
|
|
17
|
+
}): Promise<QueryResponse.AsObject>;
|
|
18
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/grpc/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAGL,mBAAmB,EAKpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAGL,aAAa,EAId,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,WAAW,EACX,WAAW,IAAI,OAAO,EACtB,OAAO,IAAI,WAAW,EACvB,MAAM,iBAAiB,CAAC;AAsCzB,wBAAsB,cAAc,CAClC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,WAAW,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACxG,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAuBvC;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;CAAE,GACxF,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAqBjC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { QueryServiceClient, QueryEventsRequest, FilterGroup as QFilterGroup, FilterCondition as QFilterCondition, Aggregation, GroupBy, } from "@scrawn/core";
|
|
2
|
+
import { DataQueryServiceClient, QueryRequest, FilterGroup as DFilterGroup, FilterCondition as DFilterCondition, OrderBy as DOrderBy, } from "@scrawn/core";
|
|
3
|
+
function opQuery(op) {
|
|
4
|
+
switch (op) {
|
|
5
|
+
case "EQ": return 1;
|
|
6
|
+
case "GT": return 2;
|
|
7
|
+
case "GTE": return 3;
|
|
8
|
+
case "LT": return 4;
|
|
9
|
+
case "LTE": return 5;
|
|
10
|
+
case "NEQ": return 6;
|
|
11
|
+
default: return 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function buildQueryGroup(group) {
|
|
15
|
+
const fg = new QFilterGroup();
|
|
16
|
+
fg.setLogical(group.logical === "AND" ? 1 : 2);
|
|
17
|
+
fg.setConditionsList(group.conditions.map((c) => {
|
|
18
|
+
const fc = new QFilterCondition();
|
|
19
|
+
fc.setField(c.field);
|
|
20
|
+
fc.setOperator(opQuery(c.operator));
|
|
21
|
+
fc.setValue(c.value);
|
|
22
|
+
return fc;
|
|
23
|
+
}));
|
|
24
|
+
fg.setGroupsList(group.groups.map(buildQueryGroup));
|
|
25
|
+
return fg;
|
|
26
|
+
}
|
|
27
|
+
function buildDataGroup(group) {
|
|
28
|
+
const fg = new DFilterGroup();
|
|
29
|
+
fg.setLogical(group.logical === "AND" ? 1 : 2);
|
|
30
|
+
fg.setConditionsList(group.conditions.map((c) => {
|
|
31
|
+
const fc = new DFilterCondition();
|
|
32
|
+
fc.setField(c.field);
|
|
33
|
+
fc.setOperator(opQuery(c.operator));
|
|
34
|
+
fc.setValue(c.value);
|
|
35
|
+
return fc;
|
|
36
|
+
}));
|
|
37
|
+
fg.setGroupsList(group.groups.map(buildDataGroup));
|
|
38
|
+
return fg;
|
|
39
|
+
}
|
|
40
|
+
export async function callEventQuery(grpc, apiKey, params) {
|
|
41
|
+
const req = new QueryEventsRequest();
|
|
42
|
+
if (params.where)
|
|
43
|
+
req.setWhere(buildQueryGroup(params.where));
|
|
44
|
+
if (params.aggregation) {
|
|
45
|
+
const a = new Aggregation();
|
|
46
|
+
a.setType(params.aggregation.type === "SUM" ? 1 : 2);
|
|
47
|
+
if (params.aggregation.field)
|
|
48
|
+
a.setField(params.aggregation.field);
|
|
49
|
+
req.setAggregation(a);
|
|
50
|
+
}
|
|
51
|
+
if (params.groupBy) {
|
|
52
|
+
const gb = new GroupBy();
|
|
53
|
+
gb.setField(params.groupBy);
|
|
54
|
+
req.setGroupBy(gb);
|
|
55
|
+
}
|
|
56
|
+
req.setLimit(params.limit ?? 100);
|
|
57
|
+
req.setOffset(params.offset ?? 0);
|
|
58
|
+
const res = await grpc
|
|
59
|
+
.newCall(QueryServiceClient, "queryEvents")
|
|
60
|
+
.addMetadata("authorization", `Bearer ${apiKey}`)
|
|
61
|
+
.addPayload(req)
|
|
62
|
+
.request();
|
|
63
|
+
return res.toObject();
|
|
64
|
+
}
|
|
65
|
+
export async function callDataQuery(grpc, apiKey, tableName, params) {
|
|
66
|
+
const req = new QueryRequest();
|
|
67
|
+
req.setTable(tableName);
|
|
68
|
+
if (params.where)
|
|
69
|
+
req.setWhere(buildDataGroup(params.where));
|
|
70
|
+
if (params.orderBy && params.orderBy.length > 0) {
|
|
71
|
+
req.setOrderByList(params.orderBy.map((o) => {
|
|
72
|
+
const ob = new DOrderBy();
|
|
73
|
+
ob.setField(o.field);
|
|
74
|
+
ob.setDescending(o.descending);
|
|
75
|
+
return ob;
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
req.setLimit(params.limit ?? 100);
|
|
79
|
+
req.setOffset(params.offset ?? 0);
|
|
80
|
+
const res = await grpc
|
|
81
|
+
.newCall(DataQueryServiceClient, "query")
|
|
82
|
+
.addMetadata("authorization", `Bearer ${apiKey}`)
|
|
83
|
+
.addPayload(req)
|
|
84
|
+
.request();
|
|
85
|
+
return res.toObject();
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/grpc/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAElB,WAAW,IAAI,YAAY,EAC3B,eAAe,IAAI,gBAAgB,EACnC,WAAW,EACX,OAAO,GACR,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,sBAAsB,EACtB,YAAY,EAEZ,WAAW,IAAI,Y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,QAAQ,EAAE,CAAC;YAC1B,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACrB,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;YAC/B,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC,CAAC;IACN,CAAC;IACD,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;IAClC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IAElC,MAAM,GAAG,GAAG,MAAM,IAAI;SACnB,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC;SACxC,WAAW,CAAC,eAAe,EAAE,UAAU,MAAM,EAAE,CAAC;SAChD,UAAU,CAAC,GAAG,CAAC;SACf,OAAO,EAAiB,CAAC;IAC5B,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Analytics } from "./analytics.js";
|
|
2
|
+
export type { EventQueries, DataQueries } from "./analytics.js";
|
|
3
|
+
export { FieldRef } from "./fieldRef.js";
|
|
4
|
+
export type { InferRow } from "./fieldRef.js";
|
|
5
|
+
export { eq, neq, gt, gte, lt, lte, contains, and, or, asc, desc, sum, count, } from "./operators.js";
|
|
6
|
+
export type { FilterCondition, FilterGroup, OrderBy, Aggregation, QueryOperator, } from "./operators.js";
|
|
7
|
+
export type { EventRow, AggregationRow, EventListResult, EventAggResult } from "./query/types.js";
|
|
8
|
+
export type { DataQueryResult } from "./data/types.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EACL,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,QAAQ,EACnC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,GAC/B,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,eAAe,EACf,WAAW,EACX,OAAO,EACP,WAAW,EACX,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClG,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EACL,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,QAAQ,EACnC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,GAC/B,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FieldRef } from "./fieldRef.js";
|
|
2
|
+
export type QueryOperator = "EQ" | "GT" | "GTE" | "LT" | "LTE" | "NEQ" | "CONTAINS";
|
|
3
|
+
export interface FilterCondition {
|
|
4
|
+
field: string;
|
|
5
|
+
operator: QueryOperator;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FilterGroup {
|
|
9
|
+
logical: "AND" | "OR";
|
|
10
|
+
conditions: FilterCondition[];
|
|
11
|
+
groups: FilterGroup[];
|
|
12
|
+
}
|
|
13
|
+
export interface OrderBy {
|
|
14
|
+
field: string;
|
|
15
|
+
descending: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface Aggregation {
|
|
18
|
+
type: "SUM" | "COUNT";
|
|
19
|
+
field?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function eq<T>(field: FieldRef<T>, value: T): FilterCondition;
|
|
22
|
+
export declare function neq<T>(field: FieldRef<T>, value: T): FilterCondition;
|
|
23
|
+
export declare function gt<T>(field: FieldRef<T>, value: T): FilterCondition;
|
|
24
|
+
export declare function gte<T>(field: FieldRef<T>, value: T): FilterCondition;
|
|
25
|
+
export declare function lt<T>(field: FieldRef<T>, value: T): FilterCondition;
|
|
26
|
+
export declare function lte<T>(field: FieldRef<T>, value: T): FilterCondition;
|
|
27
|
+
export declare function contains<T>(field: FieldRef<T>, value: T): FilterCondition;
|
|
28
|
+
type FilterInput = FilterCondition | FilterGroup;
|
|
29
|
+
export declare function and(...filters: FilterInput[]): FilterGroup;
|
|
30
|
+
export declare function or(...filters: FilterInput[]): FilterGroup;
|
|
31
|
+
export declare function asc(field: FieldRef<unknown>): OrderBy;
|
|
32
|
+
export declare function desc(field: FieldRef<unknown>): OrderBy;
|
|
33
|
+
export declare function sum(field: FieldRef<number>): Aggregation;
|
|
34
|
+
export declare function count(): Aggregation;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../src/operators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,G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,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,eAAe,CAEzE;AAID,KAAK,WAAW,GAAG,eAAe,GAAG,WAAW,CAAC;AAEjD,wBAAgB,GAAG,CAAC,GAAG,OAAO,EAAE,WAAW,EAAE,GAAG,WAAW,CAM1D;AAED,wBAAgB,EAAE,CAAC,GAAG,OAAO,EAAE,WAAW,EAAE,GAAG,WAAW,CAMzD;AAID,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,OAAO,CAErD;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,OAAO,CAEtD;AAID,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,WAAW,CAExD;AAED,wBAAgB,KAAK,IAAI,WAAW,CAEnC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// ---- comparison operators ----
|
|
2
|
+
function condition(field, operator, value) {
|
|
3
|
+
return { field: field.name, operator, value: String(value) };
|
|
4
|
+
}
|
|
5
|
+
export function eq(field, value) {
|
|
6
|
+
return condition(field, "EQ", value);
|
|
7
|
+
}
|
|
8
|
+
export function neq(field, value) {
|
|
9
|
+
return condition(field, "NEQ", value);
|
|
10
|
+
}
|
|
11
|
+
export function gt(field, value) {
|
|
12
|
+
return condition(field, "GT", value);
|
|
13
|
+
}
|
|
14
|
+
export function gte(field, value) {
|
|
15
|
+
return condition(field, "GTE", value);
|
|
16
|
+
}
|
|
17
|
+
export function lt(field, value) {
|
|
18
|
+
return condition(field, "LT", value);
|
|
19
|
+
}
|
|
20
|
+
export function lte(field, value) {
|
|
21
|
+
return condition(field, "LTE", value);
|
|
22
|
+
}
|
|
23
|
+
export function contains(field, value) {
|
|
24
|
+
return condition(field, "CONTAINS", value);
|
|
25
|
+
}
|
|
26
|
+
export function and(...filters) {
|
|
27
|
+
return {
|
|
28
|
+
logical: "AND",
|
|
29
|
+
conditions: filters.filter((f) => "field" in f),
|
|
30
|
+
groups: filters.filter((f) => "logical" in f),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function or(...filters) {
|
|
34
|
+
return {
|
|
35
|
+
logical: "OR",
|
|
36
|
+
conditions: filters.filter((f) => "field" in f),
|
|
37
|
+
groups: filters.filter((f) => "logical" in f),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// ---- sorting ----
|
|
41
|
+
export function asc(field) {
|
|
42
|
+
return { field: field.name, descending: false };
|
|
43
|
+
}
|
|
44
|
+
export function desc(field) {
|
|
45
|
+
return { field: field.name, descending: true };
|
|
46
|
+
}
|
|
47
|
+
// ---- aggregation ----
|
|
48
|
+
export function sum(field) {
|
|
49
|
+
return { type: "SUM", field: field.name };
|
|
50
|
+
}
|
|
51
|
+
export function count() {
|
|
52
|
+
return { type: "COUNT" };
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=operators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../src/operators.ts"],"names":[],"mappings":"AA0BA,iCAAiC;AAEjC,SAAS,SAAS,CAAI,KAAkB,EAAE,QAAuB,EAAE,KAAQ;IACzE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,EAAE,CAAI,KAAkB,EAAE,KAAQ;IAChD,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,GAAG,CAAI,KAAkB,EAAE,KAAQ;IACjD,OAAO,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,EAAE,CAAI,KAAkB,EAAE,KAAQ;IAChD,OAAO,SAAS,CAA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,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,KAAwB;IAC3C,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AACjD,CAAC;AAED,wBAAwB;AAExB,MAAM,UAAU,GAAG,CAAC,KAAuB;IACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseEventBuilder } from "./base.js";
|
|
2
|
+
import type { GrpcClient } from "@scrawn/core";
|
|
3
|
+
import { aiTokenFields } from "./fields.js";
|
|
4
|
+
export declare class AiTokenBuilder extends BaseEventBuilder<typeof aiTokenFields> {
|
|
5
|
+
constructor(grpc: GrpcClient, apiKey: string);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=aiToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiToken.d.ts","sourceRoot":"","sources":["../../src/query/aiToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,qBAAa,cAAe,SAAQ,gBAAgB,CAAC,OAAO,aAAa,CAAC;gBAC5D,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM;CAG7C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseEventBuilder } from "./base.js";
|
|
2
|
+
import { aiTokenFields } from "./fields.js";
|
|
3
|
+
export class AiTokenBuilder extends BaseEventBuilder {
|
|
4
|
+
constructor(grpc, apiKey) {
|
|
5
|
+
super(aiTokenFields, "AI_TOKEN_USAGE", grpc, apiKey);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=aiToken.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiToken.js","sourceRoot":"","sources":["../../src/query/aiToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,cAAe,SAAQ,gBAAsC;IACxE,YAAY,IAAgB,EAAE,MAAc;QAC1C,KAAK,CAAC,aAAa,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { FieldRef } from "../fieldRef.js";
|
|
2
|
+
import type { FilterCondition, FilterGroup, Aggregation, OrderBy } from "../operators.js";
|
|
3
|
+
import type { GrpcClient } from "@scrawn/core";
|
|
4
|
+
import type { EventListResult, EventAggResult } from "./types.js";
|
|
5
|
+
export declare abstract class BaseEventBuilder<TFields, TAgg extends boolean = false> {
|
|
6
|
+
readonly fields: TFields;
|
|
7
|
+
private grpc;
|
|
8
|
+
private apiKey;
|
|
9
|
+
protected _where?: FilterGroup;
|
|
10
|
+
protected _aggregation?: Aggregation;
|
|
11
|
+
protected _groupBy?: string;
|
|
12
|
+
protected _limit: number;
|
|
13
|
+
protected _offset: number;
|
|
14
|
+
protected _orderBy: OrderBy[];
|
|
15
|
+
private _eventTypeFilter;
|
|
16
|
+
constructor(fields: TFields, eventType: string, grpc: GrpcClient, apiKey: string);
|
|
17
|
+
where(filter: FilterCondition | FilterGroup): this;
|
|
18
|
+
orderBy(...orders: OrderBy[]): this;
|
|
19
|
+
limit(n: number): this;
|
|
20
|
+
offset(n: number): this;
|
|
21
|
+
aggregate(agg: Aggregation): BaseEventBuilder<TFields, true>;
|
|
22
|
+
groupBy(field: FieldRef<unknown>): this;
|
|
23
|
+
protected buildParams(): {
|
|
24
|
+
where: FilterGroup;
|
|
25
|
+
aggregation: Aggregation | undefined;
|
|
26
|
+
groupBy: string | undefined;
|
|
27
|
+
limit: number;
|
|
28
|
+
offset: number;
|
|
29
|
+
orderBy: OrderBy[] | undefined;
|
|
30
|
+
};
|
|
31
|
+
execute(): Promise<TAgg extends true ? EventAggResult : EventListResult>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/query/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,WAAW,EACX,OAAO,EACR,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAElE,8BAAsB,gBAAgB,CAAC,OAAO,EAAE,IAAI,SAAS,OAAO,GAAG,KAAK;aAUxD,MAAM,EAAE,OAAO;IAE/B,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,MAAM;IAZhB,SAAS,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC/B,SAAS,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC;IACrC,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAO;IAC/B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAK;IAC9B,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAM;IACnC,OAAO,CAAC,gBAAgB,CAAkB;gBAGxB,MAAM,EAAE,OAAO,EAC/B,SAAS,EAAE,MAAM,EACT,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM;IAKxB,KAAK,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI;IAalD,OAAO,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI;IAKnC,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAKtB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAKvB,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC;IAK5D,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI;IAKvC,SAAS,CAAC,WAAW;;;;;;;;IAWf,OAAO,IAAI,OAAO,CAAC,IAAI,SAAS,IAAI,GAAG,cAAc,GAAG,eAAe,CAAC;CAM/E"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { and } from "../operators.js";
|
|
2
|
+
import { callEventQuery } from "../grpc/client.js";
|
|
3
|
+
export class BaseEventBuilder {
|
|
4
|
+
constructor(fields, eventType, grpc, apiKey) {
|
|
5
|
+
this.fields = fields;
|
|
6
|
+
this.grpc = grpc;
|
|
7
|
+
this.apiKey = apiKey;
|
|
8
|
+
this._limit = 100;
|
|
9
|
+
this._offset = 0;
|
|
10
|
+
this._orderBy = [];
|
|
11
|
+
this._eventTypeFilter = { field: "eventType", operator: "EQ", value: eventType };
|
|
12
|
+
}
|
|
13
|
+
where(filter) {
|
|
14
|
+
if ("operator" in filter) {
|
|
15
|
+
this._where = and(this._eventTypeFilter, filter);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this._where = {
|
|
19
|
+
logical: filter.logical,
|
|
20
|
+
conditions: [this._eventTypeFilter, ...filter.conditions],
|
|
21
|
+
groups: filter.groups,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
orderBy(...orders) {
|
|
27
|
+
this._orderBy = orders;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
limit(n) {
|
|
31
|
+
this._limit = n;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
offset(n) {
|
|
35
|
+
this._offset = n;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
aggregate(agg) {
|
|
39
|
+
this._aggregation = agg;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
groupBy(field) {
|
|
43
|
+
this._groupBy = field.name;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
buildParams() {
|
|
47
|
+
return {
|
|
48
|
+
where: this._where ?? and(this._eventTypeFilter),
|
|
49
|
+
aggregation: this._aggregation,
|
|
50
|
+
groupBy: this._groupBy,
|
|
51
|
+
limit: this._limit,
|
|
52
|
+
offset: this._offset,
|
|
53
|
+
orderBy: this._orderBy.length > 0 ? this._orderBy : undefined,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async execute() {
|
|
57
|
+
const params = this.buildParams();
|
|
58
|
+
const res = await callEventQuery(this.grpc, this.apiKey, params);
|
|
59
|
+
if (this._aggregation)
|
|
60
|
+
return { rows: res.aggRowsList ?? [], total: res.total ?? 0 };
|
|
61
|
+
return { rows: res.rowsList ?? [], total: res.total ?? 0 };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/query/base.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,MAAM,OAAgB,gBAAgB;IASpC,YACkB,MAAe,EAC/B,SAAiB,EACT,IAAgB,EAChB,MAAc;QAHN,WAAM,GAAN,MAAM,CAAS;QAEvB,SAAI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ACnB,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAChD,WAAW,EAAE,IAAI,CAAC,YAAY;YAC9B,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;SAC9D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjE,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,WAAW,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC,EAAkE,CAAC;QACrJ,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC,EAAoE,CAAC;IAC/H,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FieldRef } from "../fieldRef.js";
|
|
2
|
+
export declare const sdkEventFields: {
|
|
3
|
+
readonly eventId: FieldRef<string>;
|
|
4
|
+
readonly eventType: FieldRef<string>;
|
|
5
|
+
readonly userId: FieldRef<string>;
|
|
6
|
+
readonly reportedTimestamp: FieldRef<string>;
|
|
7
|
+
readonly ingestedTimestamp: FieldRef<string>;
|
|
8
|
+
readonly apiKeyId: FieldRef<string>;
|
|
9
|
+
readonly sdkCallType: FieldRef<string>;
|
|
10
|
+
readonly debitAmount: FieldRef<number>;
|
|
11
|
+
};
|
|
12
|
+
export declare const aiTokenFields: {
|
|
13
|
+
readonly eventId: FieldRef<string>;
|
|
14
|
+
readonly eventType: FieldRef<string>;
|
|
15
|
+
readonly userId: FieldRef<string>;
|
|
16
|
+
readonly reportedTimestamp: FieldRef<string>;
|
|
17
|
+
readonly ingestedTimestamp: FieldRef<string>;
|
|
18
|
+
readonly apiKeyId: FieldRef<string>;
|
|
19
|
+
readonly model: FieldRef<string>;
|
|
20
|
+
readonly inputTokens: FieldRef<number>;
|
|
21
|
+
readonly outputTokens: FieldRef<number>;
|
|
22
|
+
readonly inputDebitAmount: FieldRef<number>;
|
|
23
|
+
readonly outputDebitAmount: FieldRef<number>;
|
|
24
|
+
};
|
|
25
|
+
export declare const paymentFields: {
|
|
26
|
+
readonly eventId: FieldRef<string>;
|
|
27
|
+
readonly eventType: FieldRef<string>;
|
|
28
|
+
readonly userId: FieldRef<string>;
|
|
29
|
+
readonly reportedTimestamp: FieldRef<string>;
|
|
30
|
+
readonly ingestedTimestamp: FieldRef<string>;
|
|
31
|
+
readonly apiKeyId: FieldRef<string>;
|
|
32
|
+
readonly creditAmount: FieldRef<number>;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/query/fields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,eAAO,MAAM,cAAc;;;;;;;;;CASjB,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;;;;;;;;CAYhB,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;;;;CAQhB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/gen-fields.ts — do not edit
|
|
2
|
+
import { FieldRef } from "../fieldRef.js";
|
|
3
|
+
export const sdkEventFields = {
|
|
4
|
+
eventId: new FieldRef("eventId"),
|
|
5
|
+
eventType: new FieldRef("eventType"),
|
|
6
|
+
userId: new FieldRef("userId"),
|
|
7
|
+
reportedTimestamp: new FieldRef("reportedTimestamp"),
|
|
8
|
+
ingestedTimestamp: new FieldRef("ingestedTimestamp"),
|
|
9
|
+
apiKeyId: new FieldRef("apiKeyId"),
|
|
10
|
+
sdkCallType: new FieldRef("sdkCallType"),
|
|
11
|
+
debitAmount: new FieldRef("debitAmount"),
|
|
12
|
+
};
|
|
13
|
+
export const aiTokenFields = {
|
|
14
|
+
eventId: new FieldRef("eventId"),
|
|
15
|
+
eventType: new FieldRef("eventType"),
|
|
16
|
+
userId: new FieldRef("userId"),
|
|
17
|
+
reportedTimestamp: new FieldRef("reportedTimestamp"),
|
|
18
|
+
ingestedTimestamp: new FieldRef("ingestedTimestamp"),
|
|
19
|
+
apiKeyId: new FieldRef("apiKeyId"),
|
|
20
|
+
model: new FieldRef("model"),
|
|
21
|
+
inputTokens: new FieldRef("inputTokens"),
|
|
22
|
+
outputTokens: new FieldRef("outputTokens"),
|
|
23
|
+
inputDebitAmount: new FieldRef("inputDebitAmount"),
|
|
24
|
+
outputDebitAmount: new FieldRef("outputDebitAmount"),
|
|
25
|
+
};
|
|
26
|
+
export const paymentFields = {
|
|
27
|
+
eventId: new FieldRef("eventId"),
|
|
28
|
+
eventType: new FieldRef("eventType"),
|
|
29
|
+
userId: new FieldRef("userId"),
|
|
30
|
+
reportedTimestamp: new FieldRef("reportedTimestamp"),
|
|
31
|
+
ingestedTimestamp: new FieldRef("ingestedTimestamp"),
|
|
32
|
+
apiKeyId: new FieldRef("apiKeyId"),
|
|
33
|
+
creditAmount: new FieldRef("creditAmount"),
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/query/fields.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,QAAQ,EAA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W,CAAC;IAC5C,MAAM,EAAE,IAAI,QAAQ,CAAS,QAAQ,CAAC;IACtC,iBAAiB,EAAE,IAAI,QAAQ,CAAS,mBAAmB,CAAC;IAC5D,iBAAiB,EAAE,IAAI,QAAQ,CAAS,mBAAmB,CAAC;IAC5D,QAAQ,EAAE,IAAI,QAAQ,CAAS,UAAU,CAAC;IAC1C,YAAY,EAAE,IAAI,QAAQ,CAAS,cAAc,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseEventBuilder } from "./base.js";
|
|
2
|
+
import type { GrpcClient } from "@scrawn/core";
|
|
3
|
+
import { paymentFields } from "./fields.js";
|
|
4
|
+
export declare class PaymentBuilder extends BaseEventBuilder<typeof paymentFields> {
|
|
5
|
+
constructor(grpc: GrpcClient, apiKey: string);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=payment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../src/query/payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,qBAAa,cAAe,SAAQ,gBAAgB,CAAC,OAAO,aAAa,CAAC;gBAC5D,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM;CAG7C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseEventBuilder } from "./base.js";
|
|
2
|
+
import { paymentFields } from "./fields.js";
|
|
3
|
+
export class PaymentBuilder extends BaseEventBuilder {
|
|
4
|
+
constructor(grpc, apiKey) {
|
|
5
|
+
super(paymentFields, "PAYMENT", grpc, apiKey);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=payment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../../src/query/payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,cAAe,SAAQ,gBAAsC;IACxE,YAAY,IAAgB,EAAE,MAAc;QAC1C,KAAK,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseEventBuilder } from "./base.js";
|
|
2
|
+
import type { GrpcClient } from "@scrawn/core";
|
|
3
|
+
import { sdkEventFields } from "./fields.js";
|
|
4
|
+
export declare class SdkEventBuilder extends BaseEventBuilder<typeof sdkEventFields> {
|
|
5
|
+
constructor(grpc: GrpcClient, apiKey: string);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=sdkEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkEvent.d.ts","sourceRoot":"","sources":["../../src/query/sdkEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,qBAAa,eAAgB,SAAQ,gBAAgB,CAAC,OAAO,cAAc,CAAC;gBAC9D,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM;CAG7C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseEventBuilder } from "./base.js";
|
|
2
|
+
import { sdkEventFields } from "./fields.js";
|
|
3
|
+
export class SdkEventBuilder extends BaseEventBuilder {
|
|
4
|
+
constructor(grpc, apiKey) {
|
|
5
|
+
super(sdkEventFields, "SDK_CALL", grpc, apiKey);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=sdkEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkEvent.js","sourceRoot":"","sources":["../../src/query/sdkEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,OAAO,eAAgB,SAAQ,gBAAuC;IAC1E,YAAY,IAAgB,EAAE,MAAc;QAC1C,KAAK,CAAC,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { QueryEventsResponse } from "@scrawn/core";
|
|
2
|
+
export type EventRow = QueryEventsResponse.AsObject["rowsList"][number];
|
|
3
|
+
export type AggregationRow = QueryEventsResponse.AsObject["aggRowsList"][number];
|
|
4
|
+
export interface EventListResult {
|
|
5
|
+
rows: EventRow[];
|
|
6
|
+
total: number;
|
|
7
|
+
}
|
|
8
|
+
export interface EventAggResult {
|
|
9
|
+
rows: AggregationRow[];
|
|
10
|
+
total: number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/query/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,MAAM,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AACxE,MAAM,MAAM,cAAc,GAAG,mBAAmB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/query/types.ts"],"names":[],"mappings":""}
|