@elaraai/e3-types 1.0.104 → 1.0.105
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/api.d.ts +410 -6
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/api.js +185 -7
- package/dist/src/api.js.map +1 -1
- package/dist/src/function-call.d.ts +206 -0
- package/dist/src/function-call.d.ts.map +1 -0
- package/dist/src/function-call.js +117 -0
- package/dist/src/function-call.js.map +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/names.d.ts +2 -2
- package/dist/src/names.d.ts.map +1 -1
- package/dist/src/release.d.ts +1 -1
- package/dist/src/release.js +1 -1
- package/package.json +2 -2
- package/src/api.ts +204 -7
- package/src/function-call.ts +137 -0
- package/src/index.ts +32 -0
- package/src/names.ts +2 -2
- package/src/release.ts +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A kept function call, as a repository's call store keeps it
|
|
8
|
+
* (east-workspace#1554).
|
|
9
|
+
*
|
|
10
|
+
* A call of a named function through a workspace is filed when it starts,
|
|
11
|
+
* runs where its backend runs calls, and is kept once it ends, until the
|
|
12
|
+
* lifetime its end gives it; so is a one-shot started as a call, its caller's
|
|
13
|
+
* program run as an anonymous function. The store keeps what readers are
|
|
14
|
+
* shown, the call as the API answers it ({@link FunctionCallType}). Beside it,
|
|
15
|
+
* it keeps what the call's run needs and no reader is shown: the function
|
|
16
|
+
* object it runs, the runner it runs on, whether it runs verbose, its
|
|
17
|
+
* deadline, and a request to cancel it.
|
|
18
|
+
*
|
|
19
|
+
* It is stored state (`WIRE_MIGRATION.md`): a change to its type ships a
|
|
20
|
+
* repository upgrade step.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import {
|
|
24
|
+
BooleanType, DateTimeType, IntegerType, OptionType, StringType, StructType, decodeBeast2For, encodeBeast2For, type ValueTypeOf,
|
|
25
|
+
} from '@elaraai/east';
|
|
26
|
+
import { FunctionCallType } from './api.js';
|
|
27
|
+
import { RunnerType } from './runner.js';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A request to cancel a running call: who asked, and when.
|
|
31
|
+
*
|
|
32
|
+
* @property by - Who asked, as the host's auth names them; `none` without an
|
|
33
|
+
* identity
|
|
34
|
+
* @property at - When they asked
|
|
35
|
+
*/
|
|
36
|
+
export const FunctionCallCancelType = StructType({
|
|
37
|
+
by: OptionType(StringType),
|
|
38
|
+
at: DateTimeType,
|
|
39
|
+
});
|
|
40
|
+
export type FunctionCallCancelType = typeof FunctionCallCancelType;
|
|
41
|
+
|
|
42
|
+
/** A request to cancel a running call. */
|
|
43
|
+
export type FunctionCallCancel = ValueTypeOf<typeof FunctionCallCancelType>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* How long a call is kept once it ends, by how it ended, in milliseconds: the
|
|
47
|
+
* lifetimes the host that filed it gives, which whatever records its end
|
|
48
|
+
* applies.
|
|
49
|
+
*
|
|
50
|
+
* @property succeeded - A call that succeeded, or was cancelled
|
|
51
|
+
* @property failed - A call that failed, was refused (`invalid`), returned too
|
|
52
|
+
* large a value, timed out, or was lost
|
|
53
|
+
*/
|
|
54
|
+
export const FunctionCallKeepType = StructType({
|
|
55
|
+
succeeded: IntegerType,
|
|
56
|
+
failed: IntegerType,
|
|
57
|
+
});
|
|
58
|
+
export type FunctionCallKeepType = typeof FunctionCallKeepType;
|
|
59
|
+
|
|
60
|
+
/** How long a call is kept once it ends. */
|
|
61
|
+
export type FunctionCallKeep = ValueTypeOf<typeof FunctionCallKeepType>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A kept call, as its store keeps it.
|
|
65
|
+
*
|
|
66
|
+
* @property call - The call as readers are shown it
|
|
67
|
+
* @property workspace - The workspace it was called through
|
|
68
|
+
* @property functionObject - The hash of the function object it runs: the one
|
|
69
|
+
* the deployed package named when it started, whatever is deployed since;
|
|
70
|
+
* for a one-shot call, the anonymous one its start stored, naming the
|
|
71
|
+
* caller's program, its types and its runner, and no inputs
|
|
72
|
+
* @property runner - The runner it runs on: the function's own, or one the
|
|
73
|
+
* call named and its caller's grant allowed; a one-shot call's own
|
|
74
|
+
* @property verbose - Whether a stock runner runs it with `-v`
|
|
75
|
+
* @property deadline - When its timeout ends: a call still recorded running
|
|
76
|
+
* once its deadline and a grace have passed is lost
|
|
77
|
+
* @property cancel - A request to cancel it, once one is made
|
|
78
|
+
* @property keep - How long it is kept once it ends, by how it ended
|
|
79
|
+
*/
|
|
80
|
+
export const FunctionCallJobType = StructType({
|
|
81
|
+
call: FunctionCallType,
|
|
82
|
+
workspace: StringType,
|
|
83
|
+
functionObject: StringType,
|
|
84
|
+
runner: RunnerType,
|
|
85
|
+
verbose: BooleanType,
|
|
86
|
+
deadline: DateTimeType,
|
|
87
|
+
cancel: OptionType(FunctionCallCancelType),
|
|
88
|
+
keep: FunctionCallKeepType,
|
|
89
|
+
});
|
|
90
|
+
export type FunctionCallJobType = typeof FunctionCallJobType;
|
|
91
|
+
|
|
92
|
+
/** A kept call, as its store keeps it. */
|
|
93
|
+
export type FunctionCallJob = ValueTypeOf<typeof FunctionCallJobType>;
|
|
94
|
+
|
|
95
|
+
const encodeJob = encodeBeast2For(FunctionCallJobType);
|
|
96
|
+
const decodeJob = decodeBeast2For(FunctionCallJobType);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Encode a kept call as its store keeps it, in beast2.
|
|
100
|
+
*
|
|
101
|
+
* @param job - The call
|
|
102
|
+
* @returns Its bytes
|
|
103
|
+
*/
|
|
104
|
+
export function encodeFunctionCallJob(job: FunctionCallJob): Uint8Array {
|
|
105
|
+
return encodeJob(job);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Decode a kept call from its store's bytes.
|
|
110
|
+
*
|
|
111
|
+
* @param bytes - The call's bytes, as {@link encodeFunctionCallJob} wrote them
|
|
112
|
+
* @returns The call
|
|
113
|
+
* @throws {Error} When the bytes are not a kept call of this release's form
|
|
114
|
+
*/
|
|
115
|
+
export function decodeFunctionCallJob(bytes: Uint8Array): FunctionCallJob {
|
|
116
|
+
return decodeJob(bytes);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* What a kept call names, which gc keeps while the call is kept: the function
|
|
121
|
+
* object it runs, and with it the program the object names; each value
|
|
122
|
+
* argument's object; the version of each dataset argument and each input it
|
|
123
|
+
* read; and its value once it succeeded. A one-shot call's function object is
|
|
124
|
+
* its own, which no package names, so the call alone keeps it, and its
|
|
125
|
+
* program, for as long as it runs and is kept.
|
|
126
|
+
*
|
|
127
|
+
* @param job - The call
|
|
128
|
+
* @returns The hashes it names: its function object's, then its arguments' in
|
|
129
|
+
* order, then its inputs', then its value's
|
|
130
|
+
*/
|
|
131
|
+
export function functionCallRoots(job: FunctionCallJob): string[] {
|
|
132
|
+
const { call } = job;
|
|
133
|
+
const roots = [job.functionObject, ...call.args.map((arg) => (arg.type === 'value' ? arg.value : arg.value.hash))];
|
|
134
|
+
for (const input of call.inputs) roots.push(input.hash);
|
|
135
|
+
if (call.state.type === 'succeeded') roots.push(call.state.value.value);
|
|
136
|
+
return roots;
|
|
137
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -112,6 +112,19 @@ export {
|
|
|
112
112
|
decodeFunctionObject,
|
|
113
113
|
} from './function.js';
|
|
114
114
|
|
|
115
|
+
// Kept function calls, as a repository's call store keeps them
|
|
116
|
+
export {
|
|
117
|
+
FunctionCallCancelType,
|
|
118
|
+
type FunctionCallCancel,
|
|
119
|
+
FunctionCallKeepType,
|
|
120
|
+
type FunctionCallKeep,
|
|
121
|
+
FunctionCallJobType,
|
|
122
|
+
type FunctionCallJob,
|
|
123
|
+
encodeFunctionCallJob,
|
|
124
|
+
decodeFunctionCallJob,
|
|
125
|
+
functionCallRoots,
|
|
126
|
+
} from './function-call.js';
|
|
127
|
+
|
|
115
128
|
// Record objects
|
|
116
129
|
export {
|
|
117
130
|
RecordCommitType,
|
|
@@ -443,6 +456,17 @@ export {
|
|
|
443
456
|
SplitCallProgressType,
|
|
444
457
|
SplitCallStatusType,
|
|
445
458
|
SplitCallPlanType,
|
|
459
|
+
// Function calls, kept for a lifetime
|
|
460
|
+
FunctionCallStateType,
|
|
461
|
+
FunctionCallArgType,
|
|
462
|
+
FunctionCallSummaryType,
|
|
463
|
+
FunctionCallType,
|
|
464
|
+
FunctionCallStatusType,
|
|
465
|
+
FunctionCallAnswerType,
|
|
466
|
+
FunctionCallPageType,
|
|
467
|
+
FUNCTION_CALLS_PAGE_DEFAULT,
|
|
468
|
+
FUNCTION_CALLS_PAGE_MAX,
|
|
469
|
+
SplitCallReportType,
|
|
446
470
|
MutationCallRequestType,
|
|
447
471
|
MutationResultType,
|
|
448
472
|
RecordMigrationAppliedType,
|
|
@@ -519,6 +543,14 @@ export {
|
|
|
519
543
|
type SplitCallProgress,
|
|
520
544
|
type SplitCallStatus,
|
|
521
545
|
type SplitCallPlan,
|
|
546
|
+
type FunctionCallState,
|
|
547
|
+
type FunctionCallArg,
|
|
548
|
+
type FunctionCallSummary,
|
|
549
|
+
type FunctionCall,
|
|
550
|
+
type FunctionCallStatus,
|
|
551
|
+
type FunctionCallAnswer,
|
|
552
|
+
type FunctionCallPage,
|
|
553
|
+
type SplitCallReport,
|
|
522
554
|
type MutationCallRequest,
|
|
523
555
|
type MutationResult,
|
|
524
556
|
type RecordMigrationApplied,
|
package/src/names.ts
CHANGED
|
@@ -18,8 +18,8 @@ export type NamedKind = 'repository' | 'workspace' | 'package' | 'package versio
|
|
|
18
18
|
export type HashKind = 'object hash' | 'task hash' | 'inputs hash';
|
|
19
19
|
|
|
20
20
|
/** What an id e3 makes a path or a key of names: an execution attempt, a
|
|
21
|
-
* dataflow run,
|
|
22
|
-
export type IdKind = 'execution id' | 'run id' | 'gc run id';
|
|
21
|
+
* dataflow run, a gc run in steps, or a kept function call. */
|
|
22
|
+
export type IdKind = 'execution id' | 'run id' | 'gc run id' | 'call id';
|
|
23
23
|
|
|
24
24
|
/** What a hash or an id e3 makes a path or a key of names: not a name, so
|
|
25
25
|
* checked for its form rather than by {@link nameProblem}. */
|
package/src/release.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/** The release of e3 this build is. */
|
|
20
|
-
export const E3_RELEASE = '1.0.
|
|
20
|
+
export const E3_RELEASE = '1.0.105';
|
|
21
21
|
|
|
22
22
|
/** A semantic version: its core, a pre-release, and build metadata. */
|
|
23
23
|
const RELEASE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|