@elaraai/east 0.0.1-beta.37 → 0.0.1-beta.38
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/src/example.d.ts +64 -0
- package/dist/src/example.d.ts.map +1 -0
- package/dist/src/example.js +13 -0
- package/dist/src/example.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import type { CallableFunctionExpr } from "./expr/function.js";
|
|
6
|
+
import type { CallableAsyncFunctionExpr } from "./expr/asyncfunction.js";
|
|
7
|
+
import type { SubtypeExprOrValue } from "./expr/types.js";
|
|
8
|
+
import { type EastType } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Defines an East example — an East function expression with metadata.
|
|
11
|
+
*
|
|
12
|
+
* The `fn` field is an `East.function()` — the exact same thing users write.
|
|
13
|
+
* Tests call it with `inputs` and assert the result equals `returns`.
|
|
14
|
+
* The index generator serializes `fn.toString()` for agent context.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { East, ArrayType, IntegerType } from "@elaraai/east";
|
|
19
|
+
* import { example } from "@elaraai/east";
|
|
20
|
+
*
|
|
21
|
+
* export const pushToArray = example({
|
|
22
|
+
* keywords: ["array", "push", "pushLast", "mutation"],
|
|
23
|
+
* description: "Push items to an array using pushLast",
|
|
24
|
+
* fn: East.function([], ArrayType(IntegerType), ($) => {
|
|
25
|
+
* const a = $.let([], ArrayType(IntegerType));
|
|
26
|
+
* $(a.pushLast(1n));
|
|
27
|
+
* $(a.pushLast(2n));
|
|
28
|
+
* return a;
|
|
29
|
+
* }),
|
|
30
|
+
* inputs: [],
|
|
31
|
+
* returns: [1n, 2n],
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* export const filterArray = example({
|
|
35
|
+
* keywords: ["array", "filter"],
|
|
36
|
+
* description: "Filter array elements greater than a threshold",
|
|
37
|
+
* fn: East.function([ArrayType(IntegerType), IntegerType], ArrayType(IntegerType), ($, items, threshold) => {
|
|
38
|
+
* return items.filter(($, x) => x.greater(threshold));
|
|
39
|
+
* }),
|
|
40
|
+
* inputs: [[1n, 5n, 3n, 8n, 2n], 3n],
|
|
41
|
+
* returns: [5n, 8n],
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export interface ExampleDef<I extends EastType[] = EastType[], O = any> {
|
|
46
|
+
/** Searchable keywords: API names, type names, concepts */
|
|
47
|
+
keywords: string[];
|
|
48
|
+
/** Human-readable description of what this example demonstrates */
|
|
49
|
+
description: string;
|
|
50
|
+
/** The East function expression — an East.function() or East.asyncFunction() call */
|
|
51
|
+
fn: CallableFunctionExpr<I, O> | CallableAsyncFunctionExpr<I, O>;
|
|
52
|
+
/** Default input values for testing */
|
|
53
|
+
inputs: {
|
|
54
|
+
[K in keyof I]: SubtypeExprOrValue<I[K]>;
|
|
55
|
+
};
|
|
56
|
+
/** Expected return value when called with inputs */
|
|
57
|
+
returns?: SubtypeExprOrValue<O>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates an example definition. Identity function that provides
|
|
61
|
+
* type checking and marks the export for index generation.
|
|
62
|
+
*/
|
|
63
|
+
export declare function example<const I extends any[], O>(def: ExampleDef<I, O>): ExampleDef<I, O>;
|
|
64
|
+
//# sourceMappingURL=example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/example.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,QAAQ,EAAE,GAAG,QAAQ,EAAE,EAAE,CAAC,GAAG,GAAG;IAClE,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,EAAE,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,yBAAyB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjE,uCAAuC;IACvC,MAAM,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAAE,CAAC;IACrD,oDAAoD;IACpD,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,EAC5C,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GACtB,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAElB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import {} from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Creates an example definition. Identity function that provides
|
|
8
|
+
* type checking and marks the export for index generation.
|
|
9
|
+
*/
|
|
10
|
+
export function example(def) {
|
|
11
|
+
return def;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/example.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAiB,MAAM,YAAY,CAAC;AAmD3C;;;GAGG;AACH,MAAM,UAAU,OAAO,CACnB,GAAqB;IAErB,OAAO,GAAG,CAAC;AACf,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
|
package/dist/src/index.js
CHANGED
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
|