airbyte-faros-destination 0.23.22 → 0.23.24
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/lib/converters/claude/cost_report.d.ts +19 -0
- package/lib/converters/claude/cost_report.js +57 -0
- package/lib/converters/claude/cost_report.js.map +1 -0
- package/lib/converters/claude/messages_usage_report.d.ts +27 -0
- package/lib/converters/claude/messages_usage_report.js +78 -0
- package/lib/converters/claude/messages_usage_report.js.map +1 -0
- package/lib/converters/claude/platform_common.d.ts +12 -0
- package/lib/converters/claude/platform_common.js +32 -0
- package/lib/converters/claude/platform_common.js.map +1 -0
- package/lib/converters/common/ai.d.ts +14 -0
- package/lib/converters/common/ai.js +10 -0
- package/lib/converters/common/ai.js.map +1 -0
- package/lib/converters/openai-platform/common.d.ts +2 -15
- package/lib/converters/openai-platform/common.js +12 -11
- package/lib/converters/openai-platform/common.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { ClaudePlatformConverter } from './platform_common';
|
|
4
|
+
export interface ClaudeCostReportItem {
|
|
5
|
+
_record_id: string;
|
|
6
|
+
starting_at: string;
|
|
7
|
+
ending_at: string;
|
|
8
|
+
organization_id: string;
|
|
9
|
+
workspace_id?: string | null;
|
|
10
|
+
workspace_name?: string | null;
|
|
11
|
+
description?: string | null;
|
|
12
|
+
model?: string | null;
|
|
13
|
+
amount?: string | null;
|
|
14
|
+
currency?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export declare class CostReport extends ClaudePlatformConverter {
|
|
17
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
18
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CostReport = void 0;
|
|
4
|
+
const faros_js_client_1 = require("faros-js-client");
|
|
5
|
+
const ai_1 = require("../common/ai");
|
|
6
|
+
const platform_common_1 = require("./platform_common");
|
|
7
|
+
function amountInMajorUnits(amount) {
|
|
8
|
+
if (amount == null)
|
|
9
|
+
return null;
|
|
10
|
+
const fractionalCents = Number(amount);
|
|
11
|
+
return Number.isFinite(fractionalCents) ? fractionalCents / 100 : null;
|
|
12
|
+
}
|
|
13
|
+
class CostReport extends platform_common_1.ClaudePlatformConverter {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.destinationModels = [
|
|
17
|
+
ai_1.AI_ACCOUNT_MODEL,
|
|
18
|
+
ai_1.AI_PROJECT_MODEL,
|
|
19
|
+
ai_1.AI_COST_MODEL,
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
async convert(record, ctx) {
|
|
23
|
+
const item = record.record.data;
|
|
24
|
+
const account = this.account(item.organization_id);
|
|
25
|
+
const project = this.accountEntity(item.workspace_id, account);
|
|
26
|
+
const result = [];
|
|
27
|
+
const accountRecord = this.destinationDimensionRecord(ai_1.AI_ACCOUNT_MODEL, account.uid, account);
|
|
28
|
+
if (accountRecord)
|
|
29
|
+
result.push(accountRecord);
|
|
30
|
+
if (project) {
|
|
31
|
+
const projectRecord = this.destinationDimensionRecord(ai_1.AI_PROJECT_MODEL, project.uid, {
|
|
32
|
+
...project,
|
|
33
|
+
name: item.workspace_name ?? null,
|
|
34
|
+
});
|
|
35
|
+
if (projectRecord)
|
|
36
|
+
result.push(projectRecord);
|
|
37
|
+
}
|
|
38
|
+
result.push(this.destinationRecord(ai_1.AI_COST_MODEL, {
|
|
39
|
+
uid: item._record_id,
|
|
40
|
+
source: this.source,
|
|
41
|
+
account,
|
|
42
|
+
project,
|
|
43
|
+
credential: null,
|
|
44
|
+
startedAt: faros_js_client_1.Utils.toDate(item.starting_at),
|
|
45
|
+
endedAt: faros_js_client_1.Utils.toDate(item.ending_at),
|
|
46
|
+
lineItem: item.description ?? null,
|
|
47
|
+
model: item.model ?? null,
|
|
48
|
+
amount: amountInMajorUnits(item.amount),
|
|
49
|
+
currency: item.currency ?? null,
|
|
50
|
+
quantity: null,
|
|
51
|
+
quantityUnit: null,
|
|
52
|
+
}));
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.CostReport = CostReport;
|
|
57
|
+
//# sourceMappingURL=cost_report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost_report.js","sourceRoot":"","sources":["../../../src/converters/claude/cost_report.ts"],"names":[],"mappings":";;;AACA,qDAAsC;AAEtC,qCAA+E;AAE/E,uDAA0D;AAe1D,SAAS,kBAAkB,CAAC,MAAiC;IAC3D,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACzE,CAAC;AAED,MAAa,UAAW,SAAQ,yCAAuB;IAAvD;;QACW,sBAAiB,GAAoC;YAC5D,qBAAgB;YAChB,qBAAgB;YAChB,kBAAa;SACd,CAAC;IAgDJ,CAAC;IA9CC,KAAK,CAAC,OAAO,CACX,MAAqB,EACrB,GAAkB;QAElB,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAA4B,CAAC;QACxD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACnD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC/D,MAAM,M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reamContext } from '../converter';
|
|
3
|
+
import { ClaudePlatformConverter } from './platform_common';
|
|
4
|
+
export interface ClaudeMessagesUsageItem {
|
|
5
|
+
_record_id: string;
|
|
6
|
+
starting_at: string;
|
|
7
|
+
ending_at: string;
|
|
8
|
+
organization_id: string;
|
|
9
|
+
workspace_id?: string | null;
|
|
10
|
+
workspace_name?: string | null;
|
|
11
|
+
principal_id?: string | null;
|
|
12
|
+
principal_email?: string | null;
|
|
13
|
+
api_key_id?: string | null;
|
|
14
|
+
model?: string | null;
|
|
15
|
+
service_tier?: string | null;
|
|
16
|
+
uncached_input_tokens?: number | null;
|
|
17
|
+
cache_read_input_tokens?: number | null;
|
|
18
|
+
cache_creation?: {
|
|
19
|
+
ephemeral_5m_input_tokens?: number | null;
|
|
20
|
+
ephemeral_1h_input_tokens?: number | null;
|
|
21
|
+
} | null;
|
|
22
|
+
output_tokens?: number | null;
|
|
23
|
+
}
|
|
24
|
+
export declare class MessagesUsageReport extends ClaudePlatformConverter {
|
|
25
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
26
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessagesUsageReport = void 0;
|
|
4
|
+
const faros_js_client_1 = require("faros-js-client");
|
|
5
|
+
const ai_1 = require("../common/ai");
|
|
6
|
+
const platform_common_1 = require("./platform_common");
|
|
7
|
+
function tokenSum(...values) {
|
|
8
|
+
const present = values.filter((value) => value != null);
|
|
9
|
+
return present.length ? present.reduce((sum, value) => sum + value, 0) : null;
|
|
10
|
+
}
|
|
11
|
+
class MessagesUsageReport extends platform_common_1.ClaudePlatformConverter {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.destinationModels = [
|
|
15
|
+
ai_1.AI_ACCOUNT_MODEL,
|
|
16
|
+
ai_1.AI_PROJECT_MODEL,
|
|
17
|
+
ai_1.AI_PRINCIPAL_MODEL,
|
|
18
|
+
ai_1.AI_CREDENTIAL_MODEL,
|
|
19
|
+
ai_1.AI_USAGE_MODEL,
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
async convert(record, ctx) {
|
|
23
|
+
const item = record.record.data;
|
|
24
|
+
const account = this.account(item.organization_id);
|
|
25
|
+
const project = this.accountEntity(item.workspace_id, account);
|
|
26
|
+
const principal = this.accountEntity(item.principal_id, account);
|
|
27
|
+
const credential = this.accountEntity(item.api_key_id, account);
|
|
28
|
+
const cacheWriteInputTokens = tokenSum(item.cache_creation?.ephemeral_5m_input_tokens, item.cache_creation?.ephemeral_1h_input_tokens);
|
|
29
|
+
const inputTokens = tokenSum(item.uncached_input_tokens, item.cache_read_input_tokens, cacheWriteInputTokens);
|
|
30
|
+
const result = [];
|
|
31
|
+
const accountRecord = this.destinationDimensionRecord(ai_1.AI_ACCOUNT_MODEL, account.uid, account);
|
|
32
|
+
if (accountRecord)
|
|
33
|
+
result.push(accountRecord);
|
|
34
|
+
if (project) {
|
|
35
|
+
const projectRecord = this.destinationDimensionRecord(ai_1.AI_PROJECT_MODEL, project.uid, {
|
|
36
|
+
...project,
|
|
37
|
+
name: item.workspace_name ?? null,
|
|
38
|
+
});
|
|
39
|
+
if (projectRecord)
|
|
40
|
+
result.push(projectRecord);
|
|
41
|
+
}
|
|
42
|
+
if (principal) {
|
|
43
|
+
const principalRecord = this.destinationDimensionRecord(ai_1.AI_PRINCIPAL_MODEL, principal.uid, {
|
|
44
|
+
...principal,
|
|
45
|
+
email: item.principal_email ?? null,
|
|
46
|
+
});
|
|
47
|
+
if (principalRecord)
|
|
48
|
+
result.push(principalRecord);
|
|
49
|
+
}
|
|
50
|
+
if (credential) {
|
|
51
|
+
const credentialRecord = this.destinationDimensionRecord(ai_1.AI_CREDENTIAL_MODEL, credential.uid, { ...credential });
|
|
52
|
+
if (credentialRecord)
|
|
53
|
+
result.push(credentialRecord);
|
|
54
|
+
}
|
|
55
|
+
result.push(this.destinationRecord(ai_1.AI_USAGE_MODEL, {
|
|
56
|
+
uid: item._record_id,
|
|
57
|
+
source: this.source,
|
|
58
|
+
account,
|
|
59
|
+
project,
|
|
60
|
+
principal,
|
|
61
|
+
credential,
|
|
62
|
+
startedAt: faros_js_client_1.Utils.toDate(item.starting_at),
|
|
63
|
+
endedAt: faros_js_client_1.Utils.toDate(item.ending_at),
|
|
64
|
+
model: item.model ?? null,
|
|
65
|
+
batch: item.service_tier == null ? null : item.service_tier === 'batch',
|
|
66
|
+
serviceTier: item.service_tier ?? null,
|
|
67
|
+
requests: null,
|
|
68
|
+
inputTokens,
|
|
69
|
+
cachedInputTokens: item.cache_read_input_tokens ?? null,
|
|
70
|
+
cacheWriteInputTokens,
|
|
71
|
+
uncachedInputTokens: item.uncached_input_tokens ?? null,
|
|
72
|
+
outputTokens: item.output_tokens ?? null,
|
|
73
|
+
}));
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.MessagesUsageReport = MessagesUsageReport;
|
|
78
|
+
//# sourceMappingURL=messages_usage_report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages_usage_report.js","sourceRoot":"","sources":["../../../src/converters/claude/messages_usage_report.ts"],"names":[],"mappings":";;;AACA,qDAAsC;AAEtC,qCAMsB;AAEtB,uDAA0D;AAuB1D,SAAS,QAAQ,CACf,GAAG,MAAgD;IAEnD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IACzE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,I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AAiB,EAAE,IAAI,CAAC,uBAAuB,IAAI,IAAI;YACvD,qBAAqB;YACrB,mBAAmB,EAAE,IAAI,CAAC,qBAAqB,IAAI,IAAI;YACvD,YAAY,EAAE,IAAI,CAAC,aAAa,IAAI,IAAI;SACzC,CAAC,CACH,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAzFD,kDAyFC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { AIAccountEntityKey, AIAccountKey } from '../common/ai';
|
|
3
|
+
import { Converter, DestinationModel, DestinationRecord } from '../converter';
|
|
4
|
+
export declare abstract class ClaudePlatformConverter extends Converter {
|
|
5
|
+
readonly source = "Claude";
|
|
6
|
+
private readonly seenDimensions;
|
|
7
|
+
id(record: AirbyteRecord): any;
|
|
8
|
+
protected account(organizationId: string): AIAccountKey;
|
|
9
|
+
protected accountEntity(uid: string | null | undefined, account: AIAccountKey): AIAccountEntityKey | null;
|
|
10
|
+
protected destinationRecord(model: DestinationModel, record: object): DestinationRecord;
|
|
11
|
+
protected destinationDimensionRecord(model: DestinationModel, uid: string, record: object): DestinationRecord | null;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClaudePlatformConverter = void 0;
|
|
4
|
+
const converter_1 = require("../converter");
|
|
5
|
+
class ClaudePlatformConverter extends converter_1.Converter {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.source = 'Claude';
|
|
9
|
+
this.seenDimensions = new Set();
|
|
10
|
+
}
|
|
11
|
+
id(record) {
|
|
12
|
+
return record?.record?.data?._record_id;
|
|
13
|
+
}
|
|
14
|
+
account(organizationId) {
|
|
15
|
+
return { uid: organizationId, source: this.source };
|
|
16
|
+
}
|
|
17
|
+
accountEntity(uid, account) {
|
|
18
|
+
return uid ? { uid, account } : null;
|
|
19
|
+
}
|
|
20
|
+
destinationRecord(model, record) {
|
|
21
|
+
return { model, record };
|
|
22
|
+
}
|
|
23
|
+
destinationDimensionRecord(model, uid, record) {
|
|
24
|
+
const key = `${model}:${uid}`;
|
|
25
|
+
if (this.seenDimensions.has(key))
|
|
26
|
+
return null;
|
|
27
|
+
this.seenDimensions.add(key);
|
|
28
|
+
return this.destinationRecord(model, record);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.ClaudePlatformConverter = ClaudePlatformConverter;
|
|
32
|
+
//# sourceMappingURL=platform_common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform_common.js","sourceRoot":"","sources":["../../../src/converters/claude/platform_common.ts"],"names":[],"mappings":";;;AAGA,4CAA4E;AAE5E,MAAsB,uBAAwB,SAAQ,qBAAS;IAA/D;;QACW,WAAM,GAAG,QAAQ,CAAC;QACV,mBAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IAkCtD,CAAC;IAhCC,EAAE,CAAC,MAAqB;QACtB,OAAO,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC;IAC1C,CAAC;IAES,OAAO,CAAC,cAAsB;QACtC,OAAO,EAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC;IACpD,CAAC;IAES,aAAa,CACrB,GAA8B,EAC9B,OAAqB;QAErB,OAAO,GAAG,CAAC,CAAC,CAAC,EAAC,GAAG,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC;IAES,iBAAiB,CACzB,KAAuB,EACvB,MAAc;QAEd,OAAO,EAAC,KAAK,EAAE,MAAM,EAAiC,CAAC;IACzD,CAAC;IAES,0BAA0B,CAClC,KAAuB,EACvB,GAAW,EACX,MAAc;QAEd,MAAM,GAAG,GAAG,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAC9C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF;AApCD,0DAoCC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const AI_ACCOUNT_MODEL = "ai_Account";
|
|
2
|
+
export declare const AI_PROJECT_MODEL = "ai_Project";
|
|
3
|
+
export declare const AI_PRINCIPAL_MODEL = "ai_Principal";
|
|
4
|
+
export declare const AI_CREDENTIAL_MODEL = "ai_Credential";
|
|
5
|
+
export declare const AI_USAGE_MODEL = "ai_Usage";
|
|
6
|
+
export declare const AI_COST_MODEL = "ai_Cost";
|
|
7
|
+
export interface AIAccountKey {
|
|
8
|
+
uid: string;
|
|
9
|
+
source: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AIAccountEntityKey {
|
|
12
|
+
uid: string;
|
|
13
|
+
account: AIAccountKey;
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AI_COST_MODEL = exports.AI_USAGE_MODEL = exports.AI_CREDENTIAL_MODEL = exports.AI_PRINCIPAL_MODEL = exports.AI_PROJECT_MODEL = exports.AI_ACCOUNT_MODEL = void 0;
|
|
4
|
+
exports.AI_ACCOUNT_MODEL = 'ai_Account';
|
|
5
|
+
exports.AI_PROJECT_MODEL = 'ai_Project';
|
|
6
|
+
exports.AI_PRINCIPAL_MODEL = 'ai_Principal';
|
|
7
|
+
exports.AI_CREDENTIAL_MODEL = 'ai_Credential';
|
|
8
|
+
exports.AI_USAGE_MODEL = 'ai_Usage';
|
|
9
|
+
exports.AI_COST_MODEL = 'ai_Cost';
|
|
10
|
+
//# sourceMappingURL=ai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../../src/converters/common/ai.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAChC,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAChC,QAAA,kBAAkB,GAAG,cAAc,CAAC;AACpC,QAAA,mBAAmB,GAAG,eAAe,CAAC;AACtC,QAAA,cAAc,GAAG,UAAU,CAAC;AAC5B,QAAA,aAAa,GAAG,SAAS,CAAC"}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { AI_ACCOUNT_MODEL, AI_COST_MODEL, AI_CREDENTIAL_MODEL, AI_PRINCIPAL_MODEL, AI_PROJECT_MODEL, AI_USAGE_MODEL, AIAccountEntityKey, AIAccountKey } from '../common/ai';
|
|
2
3
|
import { Converter, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
-
export
|
|
4
|
-
export declare const AI_PROJECT_MODEL = "ai_Project";
|
|
5
|
-
export declare const AI_PRINCIPAL_MODEL = "ai_Principal";
|
|
6
|
-
export declare const AI_CREDENTIAL_MODEL = "ai_Credential";
|
|
7
|
-
export declare const AI_USAGE_MODEL = "ai_Usage";
|
|
8
|
-
export declare const AI_COST_MODEL = "ai_Cost";
|
|
9
|
-
export interface AIAccountKey {
|
|
10
|
-
uid: string;
|
|
11
|
-
source: string;
|
|
12
|
-
}
|
|
13
|
-
export interface AIAccountEntityKey {
|
|
14
|
-
uid: string;
|
|
15
|
-
account: AIAccountKey;
|
|
16
|
-
}
|
|
4
|
+
export { AI_ACCOUNT_MODEL, AI_COST_MODEL, AI_CREDENTIAL_MODEL, AI_PRINCIPAL_MODEL, AI_PROJECT_MODEL, AI_USAGE_MODEL, };
|
|
17
5
|
interface AIDimensions {
|
|
18
6
|
account: AIAccountKey;
|
|
19
7
|
project: AIAccountEntityKey | null;
|
|
@@ -31,4 +19,3 @@ export declare abstract class OpenAIPlatformConverter extends Converter {
|
|
|
31
19
|
protected destinationDimensionRecord(uid: string, destinationRecord: DestinationRecord): DestinationRecord | null;
|
|
32
20
|
protected destinationDimensions({ account, project, projectName, principal, principalEmail, credential, }: AIDimensions): DestinationRecord[];
|
|
33
21
|
}
|
|
34
|
-
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpenAIPlatformConverter = exports.
|
|
3
|
+
exports.OpenAIPlatformConverter = exports.AI_USAGE_MODEL = exports.AI_PROJECT_MODEL = exports.AI_PRINCIPAL_MODEL = exports.AI_CREDENTIAL_MODEL = exports.AI_COST_MODEL = exports.AI_ACCOUNT_MODEL = void 0;
|
|
4
|
+
const ai_1 = require("../common/ai");
|
|
5
|
+
Object.defineProperty(exports, "AI_ACCOUNT_MODEL", { enumerable: true, get: function () { return ai_1.AI_ACCOUNT_MODEL; } });
|
|
6
|
+
Object.defineProperty(exports, "AI_COST_MODEL", { enumerable: true, get: function () { return ai_1.AI_COST_MODEL; } });
|
|
7
|
+
Object.defineProperty(exports, "AI_CREDENTIAL_MODEL", { enumerable: true, get: function () { return ai_1.AI_CREDENTIAL_MODEL; } });
|
|
8
|
+
Object.defineProperty(exports, "AI_PRINCIPAL_MODEL", { enumerable: true, get: function () { return ai_1.AI_PRINCIPAL_MODEL; } });
|
|
9
|
+
Object.defineProperty(exports, "AI_PROJECT_MODEL", { enumerable: true, get: function () { return ai_1.AI_PROJECT_MODEL; } });
|
|
10
|
+
Object.defineProperty(exports, "AI_USAGE_MODEL", { enumerable: true, get: function () { return ai_1.AI_USAGE_MODEL; } });
|
|
4
11
|
const converter_1 = require("../converter");
|
|
5
|
-
exports.AI_ACCOUNT_MODEL = 'ai_Account';
|
|
6
|
-
exports.AI_PROJECT_MODEL = 'ai_Project';
|
|
7
|
-
exports.AI_PRINCIPAL_MODEL = 'ai_Principal';
|
|
8
|
-
exports.AI_CREDENTIAL_MODEL = 'ai_Credential';
|
|
9
|
-
exports.AI_USAGE_MODEL = 'ai_Usage';
|
|
10
|
-
exports.AI_COST_MODEL = 'ai_Cost';
|
|
11
12
|
class OpenAIPlatformConverter extends converter_1.Converter {
|
|
12
13
|
constructor() {
|
|
13
14
|
super(...arguments);
|
|
@@ -37,14 +38,14 @@ class OpenAIPlatformConverter extends converter_1.Converter {
|
|
|
37
38
|
destinationDimensions({ account, project, projectName, principal, principalEmail, credential, }) {
|
|
38
39
|
const result = [];
|
|
39
40
|
const accountRecord = this.destinationDimensionRecord(account.uid, {
|
|
40
|
-
model:
|
|
41
|
+
model: ai_1.AI_ACCOUNT_MODEL,
|
|
41
42
|
record: account,
|
|
42
43
|
});
|
|
43
44
|
if (accountRecord)
|
|
44
45
|
result.push(accountRecord);
|
|
45
46
|
if (project) {
|
|
46
47
|
const projectRecord = this.destinationDimensionRecord(project.uid, {
|
|
47
|
-
model:
|
|
48
|
+
model: ai_1.AI_PROJECT_MODEL,
|
|
48
49
|
record: { ...project, name: projectName ?? null },
|
|
49
50
|
});
|
|
50
51
|
if (projectRecord)
|
|
@@ -52,7 +53,7 @@ class OpenAIPlatformConverter extends converter_1.Converter {
|
|
|
52
53
|
}
|
|
53
54
|
if (principal) {
|
|
54
55
|
const principalRecord = this.destinationDimensionRecord(principal.uid, {
|
|
55
|
-
model:
|
|
56
|
+
model: ai_1.AI_PRINCIPAL_MODEL,
|
|
56
57
|
record: { ...principal, email: principalEmail ?? null },
|
|
57
58
|
});
|
|
58
59
|
if (principalRecord)
|
|
@@ -60,7 +61,7 @@ class OpenAIPlatformConverter extends converter_1.Converter {
|
|
|
60
61
|
}
|
|
61
62
|
if (credential) {
|
|
62
63
|
const credentialRecord = this.destinationDimensionRecord(credential.uid, {
|
|
63
|
-
model:
|
|
64
|
+
model: ai_1.AI_CREDENTIAL_MODEL,
|
|
64
65
|
record: { ...credential },
|
|
65
66
|
});
|
|
66
67
|
if (credentialRecord)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/openai-platform/common.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/openai-platform/common.ts"],"names":[],"mappings":";;;AAEA,qCASsB;AAIpB,iGAZA,qBAAgB,OAYA;AAChB,8FAZA,kBAAa,OAYA;AACb,oGAZA,wBAAmB,OAYA;AACnB,mGAZA,uBAAkB,OAYA;AAClB,iGAZA,qBAAgB,OAYA;AAChB,+FAZA,mBAAc,OAYA;AARhB,4CAAyE;AAoBzE,MAAsB,uBAAwB,SAAQ,qBAAS;IAA/D;;QACW,WAAM,GAAG,iBAAiB,CAAC;QACnB,mBAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IAqEtD,CAAC;IAnEC,EAAE,CAAC,MAAqB;QACtB,OAAO,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC;IAC1C,CAAC;IAES,OAAO,CAAC,GAAkB;QAClC,OAAO;YACL,GAAG,EAAE,GAAG,CAAC,eAAe,EAAE,CAAC,eAAe;YAC1C,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;IAES,aAAa,CACrB,GAA8B,EAC9B,OAAqB;QAErB,OAAO,GAAG,CAAC,CAAC,CAAC,EAAC,GAAG,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC;IAES,0BAA0B,CAClC,GAAW,EACX,iBAAoC;QAEpC,MAAM,EAAC,KAAK,EAAC,GAAG,iBAAiB,CAAC;QAClC,MAAM,GAAG,GAAG,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAC9C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,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