Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './src/ai/stream';
export * from './src/auth/tokensPair';
export * from './src/base/businessOperation/businessOperation';
export * from './src/billing/planProlongrationPayload';
Expand Down
1 change: 1 addition & 0 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./src/ai/stream"), exports);
__exportStar(require("./src/auth/tokensPair"), exports);
__exportStar(require("./src/base/businessOperation/businessOperation"), exports);
__exportStar(require("./src/billing/planProlongrationPayload"), exports);
Expand Down
34 changes: 34 additions & 0 deletions build/src/ai/stream.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Stream part that carries generated text.
*/
export type AiStreamTextDeltaPart = {
/**
* Discriminant of a text-carrying part.
*/
type: 'text-delta';
/**
* Text generated for this part.
*/
delta: string;
};
/**
* Stream part that carries a generation failure.
*/
export type AiStreamErrorPart = {
/**
* Discriminant of a failure-carrying part.
*/
type: 'error';
/**
* Description of the failure.
*/
errorText: string;
};
/**
* Discriminated union of parts an AI stream consists of.
*/
export type AiStreamPart = AiStreamTextDeltaPart | AiStreamErrorPart;
/**
* Asynchronous sequence of parts forming an AI-generated answer.
*/
export type AiStream = AsyncIterable<AiStreamPart>;
2 changes: 2 additions & 0 deletions build/src/ai/stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './src/ai/stream';

export * from './src/auth/tokensPair';

export * from './src/base/businessOperation/businessOperation';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hawk.so/types",
"version": "0.6.5",
"version": "0.7.0",
"description": "TypeScript definitions for Hawk",
"types": "build/index.d.ts",
"main": "build/index.js",
Expand Down
39 changes: 39 additions & 0 deletions src/ai/stream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Stream part that carries generated text.
*/
export type AiStreamTextDeltaPart = {
/**
* Discriminant of a text-carrying part.
*/
type: 'text-delta';

/**
* Text generated for this part.
*/
delta: string;
};
Comment on lines +4 to +14

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These stay type because they're members of a discriminated union that gets exhaustively matched on .type – an interface can be reopened and merged into by any importer, so a variant's shape would no longer be fixed by its declaration, while interface still fits standalone, extendable shapes elsewhere in the package.


/**
* Stream part that carries a generation failure.
*/
export type AiStreamErrorPart = {
/**
* Discriminant of a failure-carrying part.
*/
type: 'error';

/**
* Description of the failure.
*/
errorText: string;
};

/**
* Discriminated union of parts an AI stream consists of.
*/
export type AiStreamPart = AiStreamTextDeltaPart | AiStreamErrorPart;

/**
* Asynchronous sequence of parts forming an AI-generated answer.
*/
export type AiStream = AsyncIterable<AiStreamPart>;
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"target": "es2018", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', 'ES2022', 'ES2023', 'ES2024', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
Expand Down
Loading