Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@braintrust/core

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@braintrust/core - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

16

dist/index.d.ts

@@ -0,1 +1,11 @@

declare const TRANSACTION_ID_FIELD = "_xact_id";
declare const OBJECT_DELETE_FIELD = "_object_delete";
declare const CREATED_FIELD = "created";
declare const IS_MERGE_FIELD = "_is_merge";
declare function mergeRowBatch<T extends {
id: string;
[IS_MERGE_FIELD]?: boolean;
}>(rows: T[]): T[];
interface Score {

@@ -11,4 +21,6 @@ name: string;

} & Extra;
type Scorer<Output, Extra> = ((args: ScorerArgs<Output, Extra>) => Promise<Score>) | ((args: ScorerArgs<Output, Extra>) => Score);
type Scorer<Output, Extra> = (args: ScorerArgs<Output, Extra>) => Score | Promise<Score>;
export type { Score, Scorer, ScorerArgs };
declare function mergeDicts(mergeInto: Record<string, unknown>, mergeFrom: Record<string, unknown>): void;
export { CREATED_FIELD, IS_MERGE_FIELD, OBJECT_DELETE_FIELD, type Score, type Scorer, type ScorerArgs, TRANSACTION_ID_FIELD, mergeDicts, mergeRowBatch };

@@ -6,2 +6,6 @@ "use strict";

var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {

@@ -19,2 +23,82 @@ if (from && typeof from === "object" || typeof from === "function") {

var src_exports = {};
__export(src_exports, {
CREATED_FIELD: () => CREATED_FIELD,
IS_MERGE_FIELD: () => IS_MERGE_FIELD,
OBJECT_DELETE_FIELD: () => OBJECT_DELETE_FIELD,
TRANSACTION_ID_FIELD: () => TRANSACTION_ID_FIELD,
mergeDicts: () => mergeDicts,
mergeRowBatch: () => mergeRowBatch
});
module.exports = __toCommonJS(src_exports);
// src/db_fields.ts
var TRANSACTION_ID_FIELD = "_xact_id";
var OBJECT_DELETE_FIELD = "_object_delete";
var CREATED_FIELD = "created";
var IS_MERGE_FIELD = "_is_merge";
// src/util.ts
function mergeDicts(mergeInto, mergeFrom) {
for (const [k, mergeFromV] of Object.entries(mergeFrom)) {
const mergeIntoV = mergeInto[k];
if (mergeIntoV instanceof Object && !Array.isArray(mergeIntoV) && mergeFrom instanceof Object && !Array.isArray(mergeFromV)) {
mergeDicts(
mergeIntoV,
mergeFromV
);
} else {
mergeInto[k] = mergeFromV;
}
}
}
// src/merge_row_batch.ts
function generateMergedRowKey(row) {
return JSON.stringify(
[
"org_id",
"project_id",
"experiment_id",
"dataset_id",
"prompt_session_id",
"log_id",
"id"
].map((k) => row[k])
);
}
function mergeRowBatch(rows) {
const out = [];
const remainingRows = [];
for (const row of rows) {
if (row.id === void 0) {
out.push(row);
} else {
remainingRows.push(row);
}
}
const rowGroups = {};
for (const row of remainingRows) {
const key = generateMergedRowKey(row);
const existingRow = rowGroups[key];
if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
mergeDicts(existingRow, row);
if (preserveNoMerge) {
delete existingRow[IS_MERGE_FIELD];
}
} else {
rowGroups[key] = row;
}
}
out.push(...Object.values(rowGroups));
return out;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
CREATED_FIELD,
IS_MERGE_FIELD,
OBJECT_DELETE_FIELD,
TRANSACTION_ID_FIELD,
mergeDicts,
mergeRowBatch
});

13

package.json
{
"name": "@braintrust/core",
"version": "0.0.6",
"version": "0.0.7",
"description": "Shared core dependencies for Braintrust packages",

@@ -12,4 +12,4 @@ "main": "./dist/index.js",

"clean": "rm -r dist/*",
"prepublishOnly": "./scripts/node_prepublish.py",
"postpublish": "./scripts/node_postpublish.py"
"prepublishOnly": "../../../scripts/node_prepublish_core.py",
"postpublish": "../../../scripts/node_postpublish_core.py"
},

@@ -45,6 +45,5 @@ "exports": {

"tsup": "^8.0.1",
"typescript": "^5.1.6",
"tsx": "^3.12.7"
},
"dependencies": {}
"tsx": "^3.14.0",
"typescript": "^5.3.3"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc