@rex0220/formula-authoring-tools 0.2.0 → 0.3.0
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/README.md +4 -1
- package/dist/cli.mjs +3878 -62
- package/dist/core.mjs +3843 -82
- package/dist/eval-worker.mjs +3785 -91
- package/dist/types/commands/calc.d.ts +2 -0
- package/dist/types/commands/save.d.ts +4 -0
- package/dist/types/commands/try-data.d.ts +54 -0
- package/dist/types/commands/try.d.ts +115 -0
- package/dist/types/core.d.ts +7 -3
- package/dist/types/sample-app.d.ts +19 -0
- package/dist/types/worker/eval-job.d.ts +32 -4
- package/dist/types/worker/eval-run.d.ts +11 -1
- package/dist/types/worker/run.d.ts +7 -3
- package/package.json +1 -1
|
@@ -35,6 +35,8 @@ export interface CalcInput {
|
|
|
35
35
|
usersOrigin: UsersOrigin | {
|
|
36
36
|
kind: "none";
|
|
37
37
|
};
|
|
38
|
+
/** APP_URL を使う式でも、接続先が無ければ既定の接続先(例の URL)で評価する(try。サンプルアプリに実在の接続は無い)。既定は名指しで止める */
|
|
39
|
+
allowDefaultBaseUrl?: boolean;
|
|
38
40
|
}
|
|
39
41
|
export interface CalcLine {
|
|
40
42
|
fieldcode: string;
|
|
@@ -25,6 +25,8 @@ export interface SaveResult {
|
|
|
25
25
|
message?: string;
|
|
26
26
|
/** status が ok でないときの誤りの種類(ConflictError、PermissionError、PathError、InputError、NormalizeError、接続の誤りの code など。想定外の失敗は Error) */
|
|
27
27
|
code?: string;
|
|
28
|
+
/** code が PluginZipError のときの、zip の誤りの種類(MCP が種類ごとの決まった文にする) */
|
|
29
|
+
zipCode?: string;
|
|
28
30
|
/** ok だが、確定の後に一時ファイルかロックを消せなかった(確定はしている。利用者に伝えて消してもらう) */
|
|
29
31
|
cleanup?: string[];
|
|
30
32
|
}
|
|
@@ -58,6 +60,8 @@ export interface SaveContext {
|
|
|
58
60
|
export declare const MAX_SAVE_INPUT_BYTES: number;
|
|
59
61
|
/** updateFields の rows の行数の上限 */
|
|
60
62
|
export declare const MAX_UPDATE_ROWS = 50;
|
|
63
|
+
/** updateFields の common で置き換えられる共通の設定のキー(封筒と pluginInfos 以外の最上位のキー。設定ファイル仕様の順。Codex のレビュー MAJOR 4) */
|
|
64
|
+
export declare const COMMON_KEYS: readonly string[];
|
|
61
65
|
/** ファイルの digest(sha256。fml_summary が返し、fml_update_fields が照合する) */
|
|
62
66
|
export declare function digestOf(text: string | Buffer): string;
|
|
63
67
|
/** 接続の誤りの状態(print-craft MCP の 15.10 の表) */
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { FieldProperty, FieldsFile } from "./fields.ts";
|
|
2
|
+
import type { KintoneRecord } from "./record.ts";
|
|
3
|
+
import type { UsersInfoTable } from "../users/index.ts";
|
|
4
|
+
export interface TryFieldDef {
|
|
5
|
+
code: string;
|
|
6
|
+
/** 型(NUMBER / TEXT / DATE … の別名も可)。SUBTABLE は fields に子 */
|
|
7
|
+
type: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
/** 選択肢(DROP_DOWN / RADIO_BUTTON / CHECK_BOX / MULTI_SELECT で必須。ほかの型には付けない) */
|
|
10
|
+
options?: string[];
|
|
11
|
+
/** 既存のテーブル(標本のテーブル1 / テーブル2 か、この一覧で先に足したテーブル)の子として足すときのテーブルのコード */
|
|
12
|
+
table?: string;
|
|
13
|
+
/** SUBTABLE の子(1 つ以上。子に table / fields は書けない) */
|
|
14
|
+
fields?: TryFieldDef[];
|
|
15
|
+
}
|
|
16
|
+
/** 架空の値のレコード(簡略形。項目コード → 値。テーブルは行(子のコード → 値)の配列) */
|
|
17
|
+
export type TryData = Record<string, unknown>;
|
|
18
|
+
export declare const TRY_MAX_EXTRA_FIELDS = 20;
|
|
19
|
+
export declare const TRY_MAX_DATA = 5;
|
|
20
|
+
export declare const TRY_MAX_TABLE_ROWS = 20;
|
|
21
|
+
export declare const TRY_MAX_OPTIONS = 50;
|
|
22
|
+
/** 文字列の値の上限(文字) */
|
|
23
|
+
export declare const TRY_MAX_VALUE_CHARS = 2000;
|
|
24
|
+
/** 型の別名(大文字小文字は区別しない)。GROUP はグループ枠なので別名にしない */
|
|
25
|
+
export declare const TYPE_ALIASES: Record<string, string>;
|
|
26
|
+
/** 足せる型(テーブルの子にできるのは SUBTABLE 以外) */
|
|
27
|
+
export declare const EXTRA_TYPES: readonly string[];
|
|
28
|
+
export declare function canonicalType(type: string): string;
|
|
29
|
+
/** 既存のコード(テーブルの外と子。kintone ではアプリの中で一意) */
|
|
30
|
+
export declare function allCodesOf(fields: FieldsFile): Set<string>;
|
|
31
|
+
/**
|
|
32
|
+
* 項目を足す(写しを返す)。戻りの added は「単価(NUMBER)」「分類(DROP_DOWN: 明細 / 小計)」「明細(SUBTABLE: 商品, 数量)」の形
|
|
33
|
+
*/
|
|
34
|
+
export declare function extendFields(fields: FieldsFile, defs: readonly TryFieldDef[]): {
|
|
35
|
+
fields: FieldsFile;
|
|
36
|
+
added: string[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* 項目定義の既定値を補う(写しを返す): 配列の型(チェック、複数選択、ユーザー・組織・グループ)の defaultValue が配列でなければ []、ほかの入力の型は ""。
|
|
40
|
+
* 設定画面の検証用レコード(authoring API の createCheckRecord)は defaultValue から作るので、手で書いた・古い fields.json に無いと検証が壊れる(e.value.join is not a function)
|
|
41
|
+
*/
|
|
42
|
+
export declare function normalizeDefaults(fields: FieldsFile): FieldsFile;
|
|
43
|
+
/** 項目の型ごとの空の値 */
|
|
44
|
+
export declare function emptyValueOf(type: string): unknown;
|
|
45
|
+
/** 空のレコードを合成する($id / $revision、全項目を空に。作成日時などは固定) */
|
|
46
|
+
export declare function emptyRecordOf(fields: FieldsFile, id: string): KintoneRecord;
|
|
47
|
+
/** 土台のレコードに無い項目(足した項目)を空で補う */
|
|
48
|
+
export declare function fillMissing(fields: FieldsFile, record: KintoneRecord): KintoneRecord;
|
|
49
|
+
/** 簡略形の値を kintone の形に(テーブル以外) */
|
|
50
|
+
export declare function convertValue(prop: FieldProperty, v: unknown, where: string, users: UsersInfoTable | null): unknown;
|
|
51
|
+
/** 簡略形のレコードを土台に当てる(写しを返す。where は data[1] など) */
|
|
52
|
+
export declare function applyData(fields: FieldsFile, base: KintoneRecord, data: TryData, where: string, users: UsersInfoTable | null): KintoneRecord;
|
|
53
|
+
/** data の一覧の形の検査(件数、JSON の大きさ) */
|
|
54
|
+
export declare function checkDataList(data: unknown): TryData[];
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* try(式の試し計算。計画 25 章。工程 8): 式ごとに同梱のサンプルアプリ(sample-app.ts。全項目タイプ × 2、テーブル 2 つ、レコード 3 件)へ 1 行だけの設定を組み、
|
|
3
|
+
* normalize(検査)→ calc(模擬)でサンプルレコードの値を返す。利用者のアプリ・レコード・接続は使わない(関数の解説や使用例の確認、式の断片の確かめに)。
|
|
4
|
+
* - 対象(as)は型(NUMBER / TEXT / DATE … TARGET_TYPES の型と、その別名)か項目コード。テーブルの中なら table(テーブルのコード)。既定は TEXT(文字列 1 行。どの値も文字列で見える)
|
|
5
|
+
* - 式は 1 回 TRY_MAX_FORMULAS まで。式ごとに独立(1 つの誤りがほかを止めない)。値(value)は対象の型に入れた後の値(kintone に保存される形。calc と同じ変換)。
|
|
6
|
+
* エンジンの生の値(raw。数値は数、日付は epoch 秒、配列は配列)が value と違うときは raw も返す(型の変換を見せる。別に 1 回評価する)
|
|
7
|
+
* - 対象は式が参照していない項目を選ぶ(数値1 を使う式なら 数値2)。自己参照になるときのために、1 行の設定は各種設定の circular_refer を ON にして組む(設定画面の検査だけの決まり)
|
|
8
|
+
* - 文脈は calc と同じ(イベント、ログインユーザー、mobile、ユーザー情報のテストデータ、policy の allowFunctions)。APP_URL はサンプルアプリの接続先(既定の例の URL)で評価する
|
|
9
|
+
* - 走査の上の制限(副作用のある関数は policy の承認、EV_SET は不可)も calc と同じ。結果を採らない sink も同じ
|
|
10
|
+
* - 架空の項目と値(try-data.ts。計画 25.3): fields で標本に項目を足す(案 2)、data で簡略形の値のレコードを作る(案 1。土台は標本の base = 3 の空のレコード)、
|
|
11
|
+
* appFields で利用者のアプリの項目定義に架空の値(案 3。標本のレコードは使わない。data が要る)
|
|
12
|
+
*/
|
|
13
|
+
import type { CalcEvent, Engine } from "../engine.ts";
|
|
14
|
+
import type { FieldsFile } from "./fields.ts";
|
|
15
|
+
import type { Finding } from "../normalize/findings.ts";
|
|
16
|
+
import type { Lang } from "../normalize/model.ts";
|
|
17
|
+
import type { Policy } from "../normalize/policy.ts";
|
|
18
|
+
import type { UsersInfoTable, UsersOrigin } from "../users/index.ts";
|
|
19
|
+
import { type TryData, type TryFieldDef } from "./try-data.ts";
|
|
20
|
+
export declare const TRY_MAX_FORMULAS = 10;
|
|
21
|
+
export declare const TRY_MAX_FORMULA_CHARS = 4000;
|
|
22
|
+
/** 既定の対象(文字列 1 行。数値も日付も配列も文字列で見える) */
|
|
23
|
+
export declare const TRY_DEFAULT_AS = "TEXT";
|
|
24
|
+
export interface TryFormula {
|
|
25
|
+
formula: string;
|
|
26
|
+
/** 対象の型(NUMBER / TEXT / DATE …)か項目コード。省略は TEXT */
|
|
27
|
+
as?: string;
|
|
28
|
+
/** テーブルの中で計算するときのテーブルのコード(テーブル1 / テーブル2) */
|
|
29
|
+
table?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface TryTarget {
|
|
32
|
+
code: string;
|
|
33
|
+
type: string;
|
|
34
|
+
table?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface TryValue {
|
|
37
|
+
/** レコード(標本は "1"〜"3"、架空の値は "d1"〜) */
|
|
38
|
+
record: string;
|
|
39
|
+
/** 対象の型に入れた後の値(kintone に保存される形)。テーブルの中なら行ごとの値の配列 */
|
|
40
|
+
value: unknown;
|
|
41
|
+
/** エンジンの生の値(value と違うときだけ。数値は数、日付は epoch 秒、配列は配列。テーブルの中なら行ごと) */
|
|
42
|
+
raw?: unknown;
|
|
43
|
+
/** 式の評価の失敗(段: 文) */
|
|
44
|
+
error?: string;
|
|
45
|
+
/** 実行時の sink が呼ばれた(結果を採らない) */
|
|
46
|
+
failed?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface TryFormulaResult {
|
|
49
|
+
/** 1 から */
|
|
50
|
+
index: number;
|
|
51
|
+
formula: string;
|
|
52
|
+
target?: TryTarget;
|
|
53
|
+
/** ok = 計算した、invalid = 検査のエラーか対象・文脈の誤り(findings に error)、failed = sink が呼ばれた */
|
|
54
|
+
status: "ok" | "invalid" | "failed";
|
|
55
|
+
/** その式の normalize の結果(エラー / 警告 / 情報)と、対象・文脈の誤り(try.target / calc.context) */
|
|
56
|
+
findings: Finding[];
|
|
57
|
+
values: TryValue[];
|
|
58
|
+
/** calc の印(ユーザー情報、イベント、再計算で変わる、kintone の文脈、副作用) */
|
|
59
|
+
marks: string[];
|
|
60
|
+
}
|
|
61
|
+
export interface TryInput {
|
|
62
|
+
engine: Engine;
|
|
63
|
+
formulas: TryFormula[];
|
|
64
|
+
/** 標本のレコードの番号(1〜3。省略は全部。data があるときの省略は無し) */
|
|
65
|
+
records?: number[];
|
|
66
|
+
/** 標本に足す項目(案 2) */
|
|
67
|
+
fields?: TryFieldDef[];
|
|
68
|
+
/** 架空の値のレコード(案 1。簡略形。標本の base の空のレコードを土台に埋める) */
|
|
69
|
+
data?: TryData[];
|
|
70
|
+
/** data の土台にする標本のレコード(1〜3。既定 3 = 空) */
|
|
71
|
+
base?: number;
|
|
72
|
+
/** 利用者のアプリの項目定義(案 3。fields.json)。標本の代わりに使う(data が要る。records は使えない) */
|
|
73
|
+
appFields?: FieldsFile;
|
|
74
|
+
evType?: string;
|
|
75
|
+
event?: CalcEvent;
|
|
76
|
+
mobile?: boolean;
|
|
77
|
+
user?: string;
|
|
78
|
+
usersInfo: UsersInfoTable | null;
|
|
79
|
+
usersOrigin: UsersOrigin | {
|
|
80
|
+
kind: "none";
|
|
81
|
+
};
|
|
82
|
+
usersLabel?: string;
|
|
83
|
+
policy?: Policy;
|
|
84
|
+
lang?: Lang;
|
|
85
|
+
}
|
|
86
|
+
export interface TryResult {
|
|
87
|
+
app: {
|
|
88
|
+
appId: number;
|
|
89
|
+
appName: string;
|
|
90
|
+
fieldCount: number;
|
|
91
|
+
/** sample = 同梱の標本、app = 利用者のアプリの項目定義(appFields) */
|
|
92
|
+
source: "sample" | "app";
|
|
93
|
+
/** 使ったレコード(標本 "1"〜"3"、架空の値 "d1"〜) */
|
|
94
|
+
records: string[];
|
|
95
|
+
/** 足した項目(「単価(NUMBER)」の形) */
|
|
96
|
+
extraFields: string[];
|
|
97
|
+
};
|
|
98
|
+
contextLine: string;
|
|
99
|
+
notice: string;
|
|
100
|
+
results: TryFormulaResult[];
|
|
101
|
+
/** 1 行の要約(ok / エラーの件数) */
|
|
102
|
+
summary: string;
|
|
103
|
+
text: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 対象の項目を決める(型か項目コード、テーブルの中かどうか)。型のときは、式が参照していない項目を優先し、短いコードの順で最初(文字列1、数値1 …。数値1 を使う式なら 数値2)。
|
|
107
|
+
* referenced は式の識別子(scanFormula)
|
|
108
|
+
*/
|
|
109
|
+
export declare function resolveTryTarget(fields: FieldsFile, targetTypes: ReadonlySet<string>, as: string | undefined, table: string | undefined, referenced?: ReadonlySet<string>): TryTarget;
|
|
110
|
+
/**
|
|
111
|
+
* 1 行だけの設定(封筒 + 既定の共通の設定 + 対象の行)。計算式ツールは有効(tool.disabled の警告を出さない)、各種設定の circular_refer は ON
|
|
112
|
+
* (自己参照の式を設定画面の検査で止めない。実行には関係ない)。各種設定の差(misc.changed)は try が自分で付けたものなので結果から除く
|
|
113
|
+
*/
|
|
114
|
+
export declare function buildTryEnvelope(engine: Engine, fields: FieldsFile, code: string, formula: string, lang: Lang): Record<string, unknown>;
|
|
115
|
+
export declare function trySettings(input: TryInput): Promise<TryResult>;
|
package/dist/types/core.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* 工程 0(2026-10-17): 読み込み(engine)、ダミー層(context)、ユーザー情報のテストデータ、zip の読み込み、安全なパス、接続。
|
|
4
4
|
* tools 0.2.0(計画 24.4。CORE_API_VERSION 2): 作業フォルダーとアプリのフォルダー(workspace)、接続のファイル(connections)、kintone/ の下の許可(permission)、
|
|
5
5
|
* ファイルの確定とロック(commit-file)、take、保存の約束(save: saveNewSettings / updateFields)、users の参照するコードの取得、JSON の誤りの文、行のキー
|
|
6
|
+
* tools 0.3.0(計画 25 章。CORE_API_VERSION は 2 のまま = 足しただけ): 同梱のサンプルアプリ(sample-app)と式の試し計算(try: trySettings。評価の仕事の kind "try")
|
|
6
7
|
*/
|
|
7
8
|
export declare const CORE_API_VERSION = 2;
|
|
8
9
|
export { createContext, type WorkContext } from "./context.ts";
|
|
@@ -27,13 +28,16 @@ export { DEFAULT_MAX_CALLS, USER_INFO_FUNCTIONS, UsersPullError, pullReferencedU
|
|
|
27
28
|
export { normalizeSettings, findCycles, stronglyConnected, type ContextNeeds, type NormalizeInput, type NormalizeResult } from "./commands/normalize.ts";
|
|
28
29
|
export { DEFAULT_EVENT, EVENT_RE, RECORDS_MAX, calcSettings, validateEvent, type CalcInput, type CalcLine, type CalcRecordResult, type CalcResult } from "./commands/calc.ts";
|
|
29
30
|
export { takeInbox, type TakeResult } from "./commands/take.ts";
|
|
30
|
-
export {
|
|
31
|
+
export { SAMPLE_APP, describeSampleApp, sampleApp, type SampleApp, type SampleRecord } from "./sample-app.ts";
|
|
32
|
+
export { TRY_DEFAULT_AS, TRY_MAX_FORMULAS, TRY_MAX_FORMULA_CHARS, buildTryEnvelope, resolveTryTarget, trySettings, type TryFormula, type TryFormulaResult, type TryInput, type TryResult, type TryTarget, type TryValue } from "./commands/try.ts";
|
|
33
|
+
export { EXTRA_TYPES, TRY_MAX_DATA, TRY_MAX_EXTRA_FIELDS, TRY_MAX_OPTIONS, TRY_MAX_TABLE_ROWS, TRY_MAX_VALUE_CHARS, TYPE_ALIASES, applyData, canonicalType, checkDataList, convertValue, emptyRecordOf, extendFields, normalizeDefaults, type TryData, type TryFieldDef } from "./commands/try-data.ts";
|
|
34
|
+
export { COMMON_KEYS, MAX_SAVE_INPUT_BYTES, MAX_UPDATE_ROWS, connectionStatusOf, digestOf, saveNewSettings, updateFields, type EvalSource, type SaveContext, type SaveResult, type SaveStatus } from "./commands/save.ts";
|
|
31
35
|
export { DEFAULT_POLICY, POLICY_FILE, PolicyError, loadPolicy, parsePolicy, type Policy } from "./normalize/policy.ts";
|
|
32
36
|
export { Findings, type Finding, type Level } from "./normalize/findings.ts";
|
|
33
37
|
export { ENVELOPE_KEYS, OUTER_KEYS, ROW_SCREEN_KEYS, ROW_SOURCE_KEYS, materialsOf, viewsOf, type FormulaSaved, type FormulaSource, type Lang } from "./normalize/model.ts";
|
|
34
38
|
export { DEFAULT_TIMEOUT_SEC, EvalError, EvalTimeoutError, MAX_TIMEOUT_SEC, runEval, type RunOptions } from "./worker/run.ts";
|
|
35
|
-
export { runEvalJob } from "./worker/eval-run.ts";
|
|
36
|
-
export type { EvalJob, EvalMessage, EvalOutcome } from "./worker/eval-job.ts";
|
|
39
|
+
export { builtinErrorName, classifyEvalError, runEvalJob } from "./worker/eval-run.ts";
|
|
40
|
+
export type { EvalErrorKind, EvalJob, EvalMessage, EvalOutcome } from "./worker/eval-job.ts";
|
|
37
41
|
export { APP_MARKER, EDIT_RE, INBOX, KINTONE_ROOT, LEGACY_WORKSPACE_FILE, SNAPSHOT_PREFIX, SNAPSHOT_RE, WorkspaceError, appDirFor, appFolderOfFile, appFoldersOf, assertAppMark, assertInsideWorkspace, assertUsableInKintone, editNameOf, ensureAppFolder, findAppDir, folderNameOf, hasLegacyConfig, legacyBlockedError, listAppFolder, markOf, modeOf, profileDirOf, readAppMark, requireProfiles, snapshotNameOf, unusedProfileDirs, type AppFolderList, type AppMark, type AppMarkState, type ModeOptions, type ProfilesContext, type WorkspaceMode } from "./workspace.ts";
|
|
38
42
|
export { CONNECTION_MAX_BYTES, ConnectionError, FALLBACK_PROFILE, PROFILE_NAME_RE, assertSameConnection, authFor, identityOf, loadConnections, pickProfile, sameIdentity, semanticDigest, snapshotOf, userApiAuthFor, type ConnectionErrorCode, type ConnectionSet, type ConnectionSnapshot, type Env, type LoadConnectionsOptions, type ProfileDef, type ProfileIdentity } from "./connections.ts";
|
|
39
43
|
export { PermissionError, assertChangeAllowed, classOfAppPath, type ChangeOp, type TargetClass } from "./permission.ts";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type FieldsFile } from "./commands/fields.ts";
|
|
2
|
+
import type { KintoneRecord } from "./commands/record.ts";
|
|
3
|
+
export interface SampleRecord {
|
|
4
|
+
/** レコード番号(1〜3。try の records で選ぶ) */
|
|
5
|
+
id: number;
|
|
6
|
+
/** 何のレコードか(典型 / 端 / 空) */
|
|
7
|
+
label: string;
|
|
8
|
+
record: KintoneRecord;
|
|
9
|
+
}
|
|
10
|
+
export interface SampleApp {
|
|
11
|
+
fields: FieldsFile;
|
|
12
|
+
records: SampleRecord[];
|
|
13
|
+
}
|
|
14
|
+
/** 埋め込んだサンプルアプリ(読むだけ。計算に使うときは sampleApp() の写しを使う) */
|
|
15
|
+
export declare const SAMPLE_APP: SampleApp;
|
|
16
|
+
/** サンプルアプリの写し(calc はレコードを書き換えるので、呼ぶたびに写す) */
|
|
17
|
+
export declare function sampleApp(): SampleApp;
|
|
18
|
+
/** サンプルアプリの説明(try --describe / fml_try の describe): 項目(1 項目 1 行。○ = 計算式を設定できる型)とレコード 3 件の形 */
|
|
19
|
+
export declare function describeSampleApp(targetTypes?: ReadonlySet<string>): string;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Worker に渡す仕事と返す結果(構造化クローンで渡せる形だけ。関数やクラスは渡さない)。
|
|
3
3
|
* normalize / calc の評価(zip のコードの実行)は Worker の中で行い、主スレッドは時間上限で terminate する(計画 7 章・11 章、Codex レビュー BLOCKER 1)。
|
|
4
4
|
* tools 0.2.0(MCP。計画 24 章): 結果に findings と calc のレコードごとの行を足した(MCP が構造のまま返す。CLI は summary / text を使う)。vendorDir(moment の置き場所)
|
|
5
|
+
* tools 0.3.0(計画 25 章): kind "try"(同梱のサンプルアプリで式の試し計算。設定ファイル・項目定義は要らない)。結果の try
|
|
5
6
|
*/
|
|
6
7
|
import type { FieldsFile } from "../commands/fields.ts";
|
|
7
8
|
import type { KintoneRecord } from "../commands/record.ts";
|
|
@@ -10,8 +11,10 @@ import type { Finding } from "../normalize/findings.ts";
|
|
|
10
11
|
import type { Policy } from "../normalize/policy.ts";
|
|
11
12
|
import type { UsersOrigin, UsersSource } from "../users/index.ts";
|
|
12
13
|
import type { CalcEvent } from "../engine.ts";
|
|
14
|
+
import type { TryFormula, TryResult } from "../commands/try.ts";
|
|
15
|
+
import type { TryData, TryFieldDef } from "../commands/try-data.ts";
|
|
13
16
|
export interface EvalJob {
|
|
14
|
-
kind: "normalize" | "calc";
|
|
17
|
+
kind: "normalize" | "calc" | "try";
|
|
15
18
|
/** 読み込み元(絶対パス。CLI が .env から決める) */
|
|
16
19
|
pluginZip?: string;
|
|
17
20
|
devPluginDir?: string;
|
|
@@ -20,9 +23,10 @@ export interface EvalJob {
|
|
|
20
23
|
vendorDir?: string;
|
|
21
24
|
/** 接続先(検証済み。APP_URL などの元。無ければ既定) */
|
|
22
25
|
baseUrl?: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
/** 設定と項目定義(normalize / calc。try では要らない) */
|
|
27
|
+
settingsText?: string;
|
|
28
|
+
settingsFile?: string;
|
|
29
|
+
fields?: FieldsFile;
|
|
26
30
|
usersSource: UsersSource;
|
|
27
31
|
usersOrigin: UsersOrigin;
|
|
28
32
|
policy: Policy;
|
|
@@ -41,8 +45,24 @@ export interface EvalJob {
|
|
|
41
45
|
mobile?: boolean;
|
|
42
46
|
user?: string;
|
|
43
47
|
};
|
|
48
|
+
/** 式の試し計算(kind "try"。サンプルアプリに 1 行だけの設定を組んで normalize + calc) */
|
|
49
|
+
try?: {
|
|
50
|
+
formulas: TryFormula[];
|
|
51
|
+
/** 標本のレコードの番号(1〜3。省略は全部。data があるときの省略は無し) */
|
|
52
|
+
records?: number[];
|
|
53
|
+
/** 標本に足す項目(案 2)、架空の値のレコード(案 1)、その土台(1〜3)、利用者のアプリの項目定義(案 3) */
|
|
54
|
+
fields?: TryFieldDef[];
|
|
55
|
+
data?: TryData[];
|
|
56
|
+
base?: number;
|
|
57
|
+
appFields?: FieldsFile;
|
|
58
|
+
evType?: string;
|
|
59
|
+
event?: CalcEvent;
|
|
60
|
+
mobile?: boolean;
|
|
61
|
+
user?: string;
|
|
62
|
+
};
|
|
44
63
|
}
|
|
45
64
|
export interface EvalOutcome {
|
|
65
|
+
/** normalize の結果(try では式ごとの結果の集計: summary は試し計算の要約、hasErrors は ok でない式があるか、findings は空(式ごとの findings は try.results)) */
|
|
46
66
|
normalize: {
|
|
47
67
|
summary: string;
|
|
48
68
|
hasErrors: boolean;
|
|
@@ -68,15 +88,23 @@ export interface EvalOutcome {
|
|
|
68
88
|
notice: string;
|
|
69
89
|
summary: string;
|
|
70
90
|
};
|
|
91
|
+
/** 式の試し計算の結果(kind "try") */
|
|
92
|
+
try?: TryResult;
|
|
71
93
|
/** エンジンの読み込みの注意 */
|
|
72
94
|
engineWarnings: string[];
|
|
73
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Worker の中の誤りの種類(信頼できる境界 = 中核の eval-run.ts が instanceof で決める。zip のコードが name を偽装しても変わらない。Codex の r2 レビュー R1):
|
|
98
|
+
* input(中核の InputError)、zip(PluginZipError。code 付き)、users(UsersDataError)、policy(PolicyError)、other(zip のコードの例外など。文は信用しない)
|
|
99
|
+
*/
|
|
100
|
+
export type EvalErrorKind = "input" | "zip" | "users" | "policy" | "other";
|
|
74
101
|
export type EvalMessage = {
|
|
75
102
|
ok: true;
|
|
76
103
|
outcome: EvalOutcome;
|
|
77
104
|
} | {
|
|
78
105
|
ok: false;
|
|
79
106
|
error: {
|
|
107
|
+
kind: EvalErrorKind;
|
|
80
108
|
name: string;
|
|
81
109
|
message: string;
|
|
82
110
|
code?: string;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
import type { EvalJob, EvalOutcome } from "./eval-job.ts";
|
|
1
|
+
import type { EvalJob, EvalMessage, EvalOutcome } from "./eval-job.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Worker の中の誤りを種類に分ける(instanceof で。中核のクラスは zip のコードから届かないので、name の偽装では input / zip にならない)。
|
|
4
|
+
* name も instanceof で決めた固定の名前(中核のクラスの名前か、JavaScript の組み込みの Error の名前。例外の name / constructor.name は使わない =
|
|
5
|
+
* zip のコードが name に値やパスを入れても出ない。Codex の r3 レビュー N1)。文は other のときは信用しない(呼ぶ側が決まった文にする)
|
|
6
|
+
*/
|
|
7
|
+
export declare function classifyEvalError(e: unknown): Extract<EvalMessage, {
|
|
8
|
+
ok: false;
|
|
9
|
+
}>["error"];
|
|
10
|
+
/** JavaScript の組み込みの Error の種類(instanceof。同じ realm で動く zip のコードの例外も、この判定は偽装できない)。それ以外は Error */
|
|
11
|
+
export declare function builtinErrorName(e: unknown): string;
|
|
2
12
|
export declare function runEvalJob(job: EvalJob): Promise<EvalOutcome>;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import type { EvalJob, EvalOutcome } from "./eval-job.ts";
|
|
1
|
+
import type { EvalErrorKind, EvalJob, EvalOutcome } from "./eval-job.ts";
|
|
2
2
|
export declare const DEFAULT_TIMEOUT_SEC = 60;
|
|
3
3
|
export declare const MAX_TIMEOUT_SEC = 600;
|
|
4
4
|
export declare class EvalTimeoutError extends Error {
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Worker の中の誤り(kind / name / code を持って主スレッドに戻す)。kind は中核が instanceof で決めた信頼できる種類(input / zip / users / policy / other)。
|
|
8
|
+
* innerName は参考の名前(other のときは zip のコードが付けた名前かもしれない)。other のときの文は値やパスを含みうる(MCP は返さない)
|
|
9
|
+
*/
|
|
7
10
|
export declare class EvalError extends Error {
|
|
8
11
|
readonly innerName: string;
|
|
9
12
|
readonly code?: string;
|
|
10
|
-
|
|
13
|
+
readonly kind: EvalErrorKind;
|
|
14
|
+
constructor(message: string, innerName: string, code?: string, kind?: EvalErrorKind);
|
|
11
15
|
}
|
|
12
16
|
export interface RunOptions {
|
|
13
17
|
timeoutSec?: number;
|
package/package.json
CHANGED