@rex0220/formula-authoring-tools 0.1.0 → 0.2.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 -2
- package/dist/cli.mjs +33 -11
- package/dist/core.mjs +1361 -35
- package/dist/eval-worker.mjs +21 -8
- package/dist/types/commands/save.d.ts +82 -0
- package/dist/types/commands/take.d.ts +18 -0
- package/dist/types/commit-file.d.ts +38 -0
- package/dist/types/connections.d.ts +106 -0
- package/dist/types/core.d.ts +19 -11
- package/dist/types/engine.d.ts +4 -0
- package/dist/types/permission-error.d.ts +3 -0
- package/dist/types/permission.d.ts +10 -0
- package/dist/types/worker/eval-job.d.ts +18 -0
- package/dist/types/worker/run.d.ts +4 -0
- package/dist/types/workspace.d.ts +126 -0
- package/package.json +2 -1
package/dist/eval-worker.mjs
CHANGED
|
@@ -93,7 +93,7 @@ function devMeta() {
|
|
|
93
93
|
return { toolsVersion: pkg.version, pluginId: FORMULA_PLUGIN_ID, minPluginVersion: MIN_PLUGIN_VERSION, supportedApiVersions: [...SUPPORTED_API_VERSIONS], commit: gitCommit(AUTHORING_ROOT), builtAt: "", mode: "dev" };
|
|
94
94
|
}
|
|
95
95
|
function toolsMeta() {
|
|
96
|
-
if (true) return JSON.parse('{"toolsVersion":"0.
|
|
96
|
+
if (true) return JSON.parse('{"toolsVersion":"0.2.0","pluginId":"dhgihghfgfmibkdldkeibboabfnmdpke","minPluginVersion":101,"supportedApiVersions":[1],"commit":"1e50847","builtAt":"2026-10-18T02:11:59.644Z","mode":"build"}');
|
|
97
97
|
return devMeta();
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -362,6 +362,9 @@ function defaultUsersInfo() {
|
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
// src/engine.ts
|
|
365
|
+
function momentFileOf(opt) {
|
|
366
|
+
return opt.vendorDir ? path3.join(opt.vendorDir, path3.basename(MOMENT_FILE)) : MOMENT_FILE;
|
|
367
|
+
}
|
|
365
368
|
var DEFAULT_CONTEXT_BASE_URL = "https://example.cybozu.com";
|
|
366
369
|
var SENTINEL_USER = { id: "0", code: "__sentinel__", name: "", email: "", timezone: "Asia/Tokyo", language: "ja", isGuest: false };
|
|
367
370
|
var loaded = null;
|
|
@@ -461,15 +464,16 @@ async function loadOnce(opt) {
|
|
|
461
464
|
}
|
|
462
465
|
if (!src.api) throw new PluginZipError(`計算式プラグインの zip に ${API_ENTRY} が無い(Ver.${MIN_PLUGIN_VERSION} 以降の zip が要る): ${src.from}`, "no-api", known);
|
|
463
466
|
if (!src.decimal) warnings.push(`zip に ${DECIMAL_ENTRY} が無い(べき乗の小数の指数がエラーになる)`);
|
|
464
|
-
|
|
467
|
+
const momentFile = momentFileOf(opt);
|
|
468
|
+
if (!existsSync(momentFile)) throw new Error(`moment が無い: ${momentFile}(tools の npm install 時に取る。手で取るなら npm run vendor)`);
|
|
465
469
|
try {
|
|
466
|
-
return await startEngine({ ...src, api: src.api }, known, warnings, stamp);
|
|
470
|
+
return await startEngine({ ...src, api: src.api }, known, warnings, stamp, momentFile);
|
|
467
471
|
} catch (e) {
|
|
468
472
|
poisoned = { code: e instanceof PluginZipError ? e.code : "unexpected", info: e instanceof PluginZipError ? e.info : known };
|
|
469
473
|
throw e;
|
|
470
474
|
}
|
|
471
475
|
}
|
|
472
|
-
async function startEngine(src, known, warnings, stamp) {
|
|
476
|
+
async function startEngine(src, known, warnings, stamp, momentFile) {
|
|
473
477
|
const g = globalThis;
|
|
474
478
|
const { Window } = await import("happy-dom");
|
|
475
479
|
const ctx = {
|
|
@@ -545,7 +549,7 @@ async function startEngine(src, known, warnings, stamp) {
|
|
|
545
549
|
throw new PluginZipError(`計算式プラグインの zip のコード(${entry})を実行できない: ${e instanceof Error ? e.message : String(e)}`, "engine-unreadable", known);
|
|
546
550
|
}
|
|
547
551
|
};
|
|
548
|
-
runScript(readFileSync3(
|
|
552
|
+
runScript(readFileSync3(momentFile, "utf8"), momentFile);
|
|
549
553
|
runScript(src.momentTimezone, `${src.from}!${MOMENT_TZ_ENTRY}`, MOMENT_TZ_ENTRY);
|
|
550
554
|
runScript(src.bignumber, `${src.from}!${BIGNUMBER_ENTRY}`, BIGNUMBER_ENTRY);
|
|
551
555
|
if (src.decimal) runScript(src.decimal, `${src.from}!${DECIMAL_ENTRY}`, DECIMAL_ENTRY);
|
|
@@ -1259,7 +1263,7 @@ function calcSettings(input) {
|
|
|
1259
1263
|
|
|
1260
1264
|
// src/worker/eval-run.ts
|
|
1261
1265
|
async function runEvalJob(job) {
|
|
1262
|
-
const engine = await loadEngine({ pluginZip: job.pluginZip, devPluginDir: job.devPluginDir, mode: job.mode });
|
|
1266
|
+
const engine = await loadEngine({ pluginZip: job.pluginZip, devPluginDir: job.devPluginDir, mode: job.mode, vendorDir: job.vendorDir });
|
|
1263
1267
|
if (job.baseUrl) engine.setContext({ baseUrl: job.baseUrl });
|
|
1264
1268
|
const usersInfo = buildUsersInfo(job.usersSource);
|
|
1265
1269
|
const usersLabel = job.usersOrigin.kind === "file" ? job.usersOrigin.file : "既定のテストデータ(架空)";
|
|
@@ -1276,7 +1280,16 @@ async function runEvalJob(job) {
|
|
|
1276
1280
|
usersOrigin: job.usersOrigin
|
|
1277
1281
|
});
|
|
1278
1282
|
const outcome = {
|
|
1279
|
-
normalize: {
|
|
1283
|
+
normalize: {
|
|
1284
|
+
summary: res.summary,
|
|
1285
|
+
hasErrors: res.findings.hasErrors,
|
|
1286
|
+
warnings: res.findings.count("warning"),
|
|
1287
|
+
findings: [...res.findings.items],
|
|
1288
|
+
output: res.output,
|
|
1289
|
+
checkDiffs: res.checkDiffs,
|
|
1290
|
+
appId: res.appId,
|
|
1291
|
+
size: res.size
|
|
1292
|
+
},
|
|
1280
1293
|
engineWarnings: [...engine.warnings]
|
|
1281
1294
|
};
|
|
1282
1295
|
if (job.kind === "calc" && job.calc && !res.findings.hasErrors) {
|
|
@@ -1294,7 +1307,7 @@ async function runEvalJob(job) {
|
|
|
1294
1307
|
usersInfo,
|
|
1295
1308
|
usersOrigin: job.usersOrigin
|
|
1296
1309
|
});
|
|
1297
|
-
outcome.calc = { text: r.text, failed: r.records.some((x) => x.errors.length > 0 || x.failed) };
|
|
1310
|
+
outcome.calc = { text: r.text, failed: r.records.some((x) => x.errors.length > 0 || x.failed), records: r.records, contextLine: r.contextLine, notice: r.notice, summary: r.summary };
|
|
1298
1311
|
}
|
|
1299
1312
|
return outcome;
|
|
1300
1313
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type Lang } from "../normalize/model.ts";
|
|
2
|
+
import type { Policy } from "../normalize/policy.ts";
|
|
3
|
+
import type { Finding } from "../normalize/findings.ts";
|
|
4
|
+
import { type WorkspaceMode } from "../workspace.ts";
|
|
5
|
+
import { ConnectionError } from "../connections.ts";
|
|
6
|
+
import { type UsersOrigin, type UsersSource } from "../users/index.ts";
|
|
7
|
+
import { type FieldChange } from "./diff.ts";
|
|
8
|
+
import { type RunOptions } from "../worker/run.ts";
|
|
9
|
+
export type SaveStatus = "ok" | "invalid" | "conflict" | "denied" | "failed";
|
|
10
|
+
export interface SaveResult {
|
|
11
|
+
status: SaveStatus;
|
|
12
|
+
/** 作業フォルダーからの相対パス(区切りは /) */
|
|
13
|
+
path: string;
|
|
14
|
+
/** 確定したファイルの digest(sha256。ok のとき) */
|
|
15
|
+
digest?: string;
|
|
16
|
+
findings: Finding[];
|
|
17
|
+
/** normalize の要約(検査まで進んだとき) */
|
|
18
|
+
summary?: string;
|
|
19
|
+
/** updateFields: 前の内容と確定した内容の差(項目ごと。affectsRecords = 既存レコードの値に影響する) */
|
|
20
|
+
diff?: {
|
|
21
|
+
fields: FieldChange[];
|
|
22
|
+
common: string[];
|
|
23
|
+
};
|
|
24
|
+
/** status が ok でないときの理由(決まった文) */
|
|
25
|
+
message?: string;
|
|
26
|
+
/** status が ok でないときの誤りの種類(ConflictError、PermissionError、PathError、InputError、NormalizeError、接続の誤りの code など。想定外の失敗は Error) */
|
|
27
|
+
code?: string;
|
|
28
|
+
/** ok だが、確定の後に一時ファイルかロックを消せなかった(確定はしている。利用者に伝えて消してもらう) */
|
|
29
|
+
cleanup?: string[];
|
|
30
|
+
}
|
|
31
|
+
/** 評価(normalize)の読み込み元(Worker に渡す。中核は環境変数を読まない) */
|
|
32
|
+
export interface EvalSource {
|
|
33
|
+
pluginZip?: string;
|
|
34
|
+
devPluginDir?: string;
|
|
35
|
+
mode?: "build" | "dev";
|
|
36
|
+
/** moment の置き場所(MCP は束ねた本体の隣の vendor/) */
|
|
37
|
+
vendorDir?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface SaveContext {
|
|
40
|
+
/** 作業フォルダーの実際のパス */
|
|
41
|
+
root: string;
|
|
42
|
+
/** 動く形(kintone/ の下を読む・変えてよいか。workspace.ts の modeOf) */
|
|
43
|
+
mode: WorkspaceMode;
|
|
44
|
+
policy: Policy;
|
|
45
|
+
source: EvalSource;
|
|
46
|
+
/** Worker の動かし方(時間上限、入口、出力の受け取り先) */
|
|
47
|
+
run?: RunOptions;
|
|
48
|
+
/** 評価の文脈の接続先(検証済み。APP_URL などの元) */
|
|
49
|
+
baseUrl?: string;
|
|
50
|
+
/** ユーザー情報のテストデータ(無ければ既定の架空の 10 人) */
|
|
51
|
+
usersSource?: UsersSource;
|
|
52
|
+
usersOrigin?: UsersOrigin;
|
|
53
|
+
lang?: Lang;
|
|
54
|
+
/** 試験用: 確定の直後(片付けの前)に呼ぶ。MCP は渡さない */
|
|
55
|
+
afterPlace?: () => void;
|
|
56
|
+
}
|
|
57
|
+
/** 入力(content / rows / common)の上限(バイト) */
|
|
58
|
+
export declare const MAX_SAVE_INPUT_BYTES: number;
|
|
59
|
+
/** updateFields の rows の行数の上限 */
|
|
60
|
+
export declare const MAX_UPDATE_ROWS = 50;
|
|
61
|
+
/** ファイルの digest(sha256。fml_summary が返し、fml_update_fields が照合する) */
|
|
62
|
+
export declare function digestOf(text: string | Buffer): string;
|
|
63
|
+
/** 接続の誤りの状態(print-craft MCP の 15.10 の表) */
|
|
64
|
+
export declare function connectionStatusOf(e: ConnectionError): Exclude<SaveStatus, "ok">;
|
|
65
|
+
/** 新しい設定を保存する(expectedAbsent: true が要る。同じ名前のファイルがあれば conflict) */
|
|
66
|
+
export declare function saveNewSettings(ctx: SaveContext, opt: {
|
|
67
|
+
path: string;
|
|
68
|
+
content: string;
|
|
69
|
+
fields?: string;
|
|
70
|
+
expectedAbsent: true;
|
|
71
|
+
}): Promise<SaveResult>;
|
|
72
|
+
/**
|
|
73
|
+
* 既存の設定の項目の行を差し替える(rows は fieldcode の行の JSON の配列の文字列。common は共通の設定の JSON の文字列)。
|
|
74
|
+
* expectedDigest は fml_summary(summary)が返した値。差し替えた後の設定を normalize し、エラーが無ければ確定する
|
|
75
|
+
*/
|
|
76
|
+
export declare function updateFields(ctx: SaveContext, opt: {
|
|
77
|
+
path: string;
|
|
78
|
+
expectedDigest: string;
|
|
79
|
+
rows: string;
|
|
80
|
+
common?: string;
|
|
81
|
+
fields?: string;
|
|
82
|
+
}): Promise<SaveResult>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type WorkspaceMode } from "../workspace.ts";
|
|
2
|
+
export interface TakeResult {
|
|
3
|
+
/** leftInInbox: 行き先には置いたが inbox の元を消せなかった(消してよい。次の take でも「同じもの」として消す) */
|
|
4
|
+
moved: Array<{
|
|
5
|
+
file: string;
|
|
6
|
+
to: string;
|
|
7
|
+
same: boolean;
|
|
8
|
+
leftInInbox?: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
/** reason は決まった文(ファイルの中身・絶対パス・秘密の値を入れない。Codex の実装レビュー BLOCKER 1) */
|
|
11
|
+
skipped: Array<{
|
|
12
|
+
file: string;
|
|
13
|
+
reason: string;
|
|
14
|
+
}>;
|
|
15
|
+
/** 置いたが一時ファイルを消せなかった、など(移したことは変わらない) */
|
|
16
|
+
warnings: string[];
|
|
17
|
+
}
|
|
18
|
+
export declare function takeInbox(cwdIn: string, mode: WorkspaceMode, profile?: string): TakeResult;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const LOCK_STALE_MS = 60000;
|
|
2
|
+
/** 確定先に同じ名前のファイルが既にある(確かめた後に作られた場合を含む) */
|
|
3
|
+
export declare class FileExistsError extends Error {
|
|
4
|
+
}
|
|
5
|
+
/** 同じファイルへの別の書き込みがロックを持っている */
|
|
6
|
+
export declare class LockBusyError extends Error {
|
|
7
|
+
}
|
|
8
|
+
/** EPERM / EBUSY なら短く待ってやり直す(tries 回まで)。それ以外の失敗はそのまま投げる */
|
|
9
|
+
export declare function withRetry<T>(fn: () => T, tries?: number): T;
|
|
10
|
+
/** 片付けを 1 つずつ試し、失敗の文を返す(一方の失敗で他方を飛ばさない。EPERM / EBUSY は短く待ってやり直す) */
|
|
11
|
+
export declare function cleanupAll(steps: Array<() => void>, tries?: number): string[];
|
|
12
|
+
/** 確定先と同じフォルダーの一時ファイルの名前 */
|
|
13
|
+
export declare function tempPathFor(target: string): string;
|
|
14
|
+
/** 一時ファイルを新しい名前で確定する(同じ名前があれば FileExistsError。上書きしない)。link は試験用(ハードリンクが使えない場合を作る) */
|
|
15
|
+
export declare function placeNew(tmp: string, target: string, link?: (from: string, to: string) => void): void;
|
|
16
|
+
export interface WriteNewResult {
|
|
17
|
+
/** 確定の後の片付けの失敗(確定はしている) */
|
|
18
|
+
cleanup: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 新しいファイルとして書く。recheck は一時ファイルを書く前と確定の直前に呼ぶ(書ける場所・許可を確かめ直す。投げれば確定しない)。
|
|
22
|
+
* 同じ名前があれば FileExistsError(確かめた後に作られた場合も)。失敗したら一時ファイルを消す
|
|
23
|
+
*/
|
|
24
|
+
export declare function writeNewFile(target: string, text: string, recheck?: () => void): WriteNewResult;
|
|
25
|
+
export interface Lock {
|
|
26
|
+
/** まだ自分のロックか(確定の直前に確かめる) */
|
|
27
|
+
owned(): boolean;
|
|
28
|
+
/** 自分のロックなら外す(他の保存が取り直したロックは消さない)。外したら true */
|
|
29
|
+
release(): boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function lockPathFor(target: string): string;
|
|
32
|
+
/** 試験用: 古いロックを付け替える直前・戻す直前に呼ぶ(その間に替わる場合を作る) */
|
|
33
|
+
export interface LockTestHooks {
|
|
34
|
+
beforeClaim?: () => void;
|
|
35
|
+
beforeRestore?: () => void;
|
|
36
|
+
}
|
|
37
|
+
/** 確定先のロックを取る。取れなければ LockBusyError */
|
|
38
|
+
export declare function acquireLock(target: string, staleMs?: number, hooks?: LockTestHooks): Lock;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type Stats } from "node:fs";
|
|
2
|
+
import type { KintoneAuth } from "./env.ts";
|
|
3
|
+
export declare const CONNECTION_MAX_BYTES: number;
|
|
4
|
+
/** 接続のファイルを読むときの fs の呼び出し(試験だけが差し替える。読み込みの途中の書き換えを再現するため。中核の入口 core.ts からは出さない) */
|
|
5
|
+
interface FsOps {
|
|
6
|
+
openSync: (p: string, flags: string) => number;
|
|
7
|
+
fstatSync: (fd: number) => Stats;
|
|
8
|
+
readSync: (fd: number, buf: Buffer, offset: number, length: number, position: number) => number;
|
|
9
|
+
closeSync: (fd: number) => void;
|
|
10
|
+
statSync: (p: string) => Stats;
|
|
11
|
+
}
|
|
12
|
+
/** 試験用: fs の呼び出しを差し替える(undefined で元に戻す) */
|
|
13
|
+
export declare function setFsOpsForTest(ops?: Partial<FsOps>): void;
|
|
14
|
+
/** profile の名前(kintone/<profile>/ のフォルダーの名前になる) */
|
|
15
|
+
export declare const PROFILE_NAME_RE: RegExp;
|
|
16
|
+
/** kSQL と同じ: 引数も defaultProfile も無ければ dev(15.1 の 8) */
|
|
17
|
+
export declare const FALLBACK_PROFILE = "dev";
|
|
18
|
+
/** 誤りの種類(15.10。status は呼ぶ側が決める: inside-workspace は denied、unknown-profile と guest-mismatch は invalid、印と connection-changed は conflict、ほかは failed) */
|
|
19
|
+
export type ConnectionErrorCode = "not-configured" | "unreadable" | "inside-workspace" | "legacy-config-present" | "unknown-profile" | "no-default-profile" | "profile-invalid" | "no-token" | "env-missing" | "no-userpass" | "no-user-api-auth" | "guest-mismatch" | "app-marker-missing" | "app-marker-invalid" | "app-identity-conflict" | "connection-changed";
|
|
20
|
+
export declare class ConnectionError extends Error {
|
|
21
|
+
readonly code: ConnectionErrorCode;
|
|
22
|
+
constructor(message: string, code: ConnectionErrorCode);
|
|
23
|
+
}
|
|
24
|
+
export type Env = Readonly<Record<string, string | undefined>>;
|
|
25
|
+
/** profile の秘密でない識別(アプリのフォルダーの印と、確定の前の比較に使う) */
|
|
26
|
+
export interface ProfileIdentity {
|
|
27
|
+
profile: string;
|
|
28
|
+
baseUrl: string;
|
|
29
|
+
host: string;
|
|
30
|
+
/** ゲストスペースの番号(通常のスペースは null) */
|
|
31
|
+
guestSpaceId: number | null;
|
|
32
|
+
}
|
|
33
|
+
export interface ProfileDef extends ProfileIdentity {
|
|
34
|
+
/** auto を解決した後の認証の種類 */
|
|
35
|
+
auth: "token" | "userpass";
|
|
36
|
+
/** tokenMap のアプリの番号(値は持たない) */
|
|
37
|
+
tokenApps: number[];
|
|
38
|
+
/** アプリごとに、トークンが使えるか(env: の変数があるか。変数の名前は持たない) */
|
|
39
|
+
tokenReady: Record<number, boolean>;
|
|
40
|
+
/** ログイン名とパスワードがそろっているか(userpass のとき) */
|
|
41
|
+
userpassReady: boolean;
|
|
42
|
+
/** User API の cybozu.com 共通の API トークンがあるか(userApiToken。env: なら変数があるか。値は持たない) */
|
|
43
|
+
userApiTokenReady: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface ConnectionSet {
|
|
46
|
+
/** 接続のファイルの名前(パスは持たない。応答に出してよいのはこれだけ) */
|
|
47
|
+
fileName: string;
|
|
48
|
+
/** 中身の sha256 */
|
|
49
|
+
digest: string;
|
|
50
|
+
/** ファイルに書いた defaultProfile(無ければ undefined) */
|
|
51
|
+
defaultProfile?: string;
|
|
52
|
+
/** 使える profile */
|
|
53
|
+
profiles: ReadonlyMap<string, ProfileDef>;
|
|
54
|
+
/** 使えない profile と理由(決まった文。値を含まない) */
|
|
55
|
+
invalid: ReadonlyArray<{
|
|
56
|
+
name: string;
|
|
57
|
+
reason: string;
|
|
58
|
+
}>;
|
|
59
|
+
/** 警告(ほかの利用者が読める、など。パスを含まない) */
|
|
60
|
+
warnings: readonly string[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 接続のスナップショット(15.6): 呼び出しの初めに選んだ profile の秘密でない値。kintone の API・保存先・アプリのフォルダーの印・preview の接続先に同じものを使い、
|
|
64
|
+
* 確定の直前に読み直した profile の意味の digest(semanticDigest)と比べる。ファイル全体の digest は使わない(ほかの profile だけの書き換えでは止めない)
|
|
65
|
+
*/
|
|
66
|
+
export interface ConnectionSnapshot extends ProfileIdentity {
|
|
67
|
+
auth: "token" | "userpass";
|
|
68
|
+
/** 読んだ接続のファイルの名前(文に出してよいのはこれだけ) */
|
|
69
|
+
fileName: string;
|
|
70
|
+
}
|
|
71
|
+
export interface LoadConnectionsOptions {
|
|
72
|
+
/** そのプロセスが知っている作業フォルダー(この中の接続のファイルは使わない) */
|
|
73
|
+
workspaceRoots: readonly string[];
|
|
74
|
+
/** env: と passwordEnv を引く環境変数(中核は process.env を読まない) */
|
|
75
|
+
env: Env;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 接続のファイルを読む(15.2、15.3)。file は絶対パス(設定の値の ~ の展開と引用符を外すのは呼ぶ側)。
|
|
79
|
+
* 読めない・作業フォルダーの中は ConnectionError。profile ごとの誤りは invalid に入れる(ほかの profile は使える)
|
|
80
|
+
*/
|
|
81
|
+
export declare function loadConnections(file: string | undefined, opt: LoadConnectionsOptions): ConnectionSet;
|
|
82
|
+
/** profile を選ぶ(15.2: 引数 → defaultProfile → "dev") */
|
|
83
|
+
export declare function pickProfile(set: ConnectionSet, name?: string): ProfileDef;
|
|
84
|
+
/** 選んだ profile のスナップショット(15.6) */
|
|
85
|
+
export declare function snapshotOf(set: ConnectionSet, def: ProfileDef): ConnectionSnapshot;
|
|
86
|
+
/**
|
|
87
|
+
* 選んだ profile の意味の digest(15.6): profile、接続先、ゲストスペース、認証の種類、対象のアプリと、資格情報の指紋(解決したログイン名とパスワード、
|
|
88
|
+
* または対象のアプリのトークンの HMAC。鍵はプロセスごとの乱数)。直接書いた値・ログイン名・env: の参照先の値の入れ替えも違う digest になる(r3 MAJOR 1)。
|
|
89
|
+
* この digest も指紋も外に出さない(このプロセスの中で比べるだけ)
|
|
90
|
+
*/
|
|
91
|
+
export declare function semanticDigest(set: ConnectionSet, def: ProfileDef, appId?: number): string;
|
|
92
|
+
/** 確定の直前に、読み直した接続で同じ profile の意味の digest が同じか(違えば connection-changed) */
|
|
93
|
+
export declare function assertSameConnection(before: {
|
|
94
|
+
set: ConnectionSet;
|
|
95
|
+
def: ProfileDef;
|
|
96
|
+
}, reload: () => ConnectionSet, appId?: number): void;
|
|
97
|
+
/** アプリ N の認証(15.2)。対象のアプリのトークンだけを解決する */
|
|
98
|
+
export declare function authFor(set: ConnectionSet, profile: ProfileDef, appId: number): KintoneAuth;
|
|
99
|
+
/**
|
|
100
|
+
* User API(users --pull)の認証(計算式の tools の拡張): profile の userApiToken(cybozu.com 共通管理の API トークン。Bearer)があればそれ、
|
|
101
|
+
* 無ければログイン名とパスワード(2 要素認証のないアカウント)。アプリの API トークン(tokenMap)では User API を呼べないので使わない
|
|
102
|
+
*/
|
|
103
|
+
export declare function userApiAuthFor(set: ConnectionSet, profile: ProfileDef): KintoneAuth;
|
|
104
|
+
export declare function identityOf(def: ProfileDef): ProfileIdentity;
|
|
105
|
+
export declare function sameIdentity(a: ProfileIdentity, b: ProfileIdentity): boolean;
|
|
106
|
+
export {};
|
package/dist/types/core.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 中核の入口(@rex0220/formula-authoring-tools/core
|
|
3
|
-
* 工程 0(2026-10-17): 読み込み(engine)、ダミー層(context)、ユーザー情報のテストデータ、zip
|
|
2
|
+
* 中核の入口(@rex0220/formula-authoring-tools/core。formula MCP が使う)。cli.ts と dev-paths.ts は含めない(環境変数と process.cwd を読むのは CLI だけ)。
|
|
3
|
+
* 工程 0(2026-10-17): 読み込み(engine)、ダミー層(context)、ユーザー情報のテストデータ、zip の読み込み、安全なパス、接続。
|
|
4
|
+
* tools 0.2.0(計画 24.4。CORE_API_VERSION 2): 作業フォルダーとアプリのフォルダー(workspace)、接続のファイル(connections)、kintone/ の下の許可(permission)、
|
|
5
|
+
* ファイルの確定とロック(commit-file)、take、保存の約束(save: saveNewSettings / updateFields)、users の参照するコードの取得、JSON の誤りの文、行のキー
|
|
4
6
|
*/
|
|
5
|
-
export declare const CORE_API_VERSION =
|
|
7
|
+
export declare const CORE_API_VERSION = 2;
|
|
6
8
|
export { createContext, type WorkContext } from "./context.ts";
|
|
7
|
-
export { PathError, WRITE_ROOTS, isInside, realResolve, resolveRead, resolveWrite } from "./safe-path.ts";
|
|
8
|
-
export { FORMULA_PLUGIN_ID, MIN_PLUGIN_VERSION, SUPPORTED_API_VERSIONS, REQUIRED_API, isSupportedPluginVersion, schemaRevisionOf, toolsMeta, type ToolsMeta } from "./meta.ts";
|
|
9
|
-
export { DEFAULT_CONTEXT_BASE_URL, SENTINEL_USER, loadEngine, resolvePluginSources, type CalcEvent, type Engine, type EngineContext, type EngineSource, type FormulaAuthoringApi, type FormulaInstance, type LoadEngineOptions, type LoginUser, type SinkCall } from "./engine.ts";
|
|
9
|
+
export { PathError, WRITE_ROOTS, isInside, realResolve, resolveRead, resolveWrite, resolveWriteDir, safeFileName } from "./safe-path.ts";
|
|
10
|
+
export { FORMULA_PLUGIN_ID, FORMULA_CONFIG_PLUGIN_ID, MIN_PLUGIN_VERSION, SUPPORTED_API_VERSIONS, REQUIRED_API, isSupportedPluginVersion, schemaRevisionOf, toolsMeta, type ToolsMeta } from "./meta.ts";
|
|
11
|
+
export { DEFAULT_CONTEXT_BASE_URL, SENTINEL_USER, loadEngine, momentFileOf, resolvePluginSources, type CalcEvent, type Engine, type EngineContext, type EngineSource, type FormulaAuthoringApi, type FormulaInstance, type LoadEngineOptions, type LoginUser, type SinkCall } from "./engine.ts";
|
|
10
12
|
export { PluginZipError, pluginIdOf, readPluginZip, type PluginSources, type PluginZipErrorCode, type PluginZipErrorInfo } from "./plugin-zip.ts";
|
|
11
13
|
export { DEFAULT_USERS, UsersDataError, buildUsersInfo, defaultUsersInfo, summarizeUsers, validateUsersSource, type UsersInfoTable, type UsersOrigin, type UsersSource } from "./users/index.ts";
|
|
12
|
-
export { AuthError, baseUrlFromEnv, describeAuth, kintoneConfigPath, loadAuth, pluginZipPath, unquote, type KintoneAuth, type LoadAuthOptions } from "./env.ts";
|
|
14
|
+
export { AuthError, baseUrlFromEnv, describeAuth, kintoneConfigPath, loadAuth, loadUserApiAuth, pluginZipPath, unquote, type KintoneAuth, type LoadAuthOptions } from "./env.ts";
|
|
13
15
|
export { KintoneUrlError, isKintoneBaseUrl, normalizeKintoneBaseUrl } from "./kintone-url.ts";
|
|
14
16
|
export { InputError, MAX_INPUT_BYTES, PLUGIN_NAME, formatDate, jsonDiff, readFieldsFile, readJsonLimited, readTextLimited, relativeSettingsPath } from "./input.ts";
|
|
17
|
+
export { jsonErrorText, jsonErrorWhere } from "./json-error.ts";
|
|
15
18
|
export { ALLOWED_APIS, ALLOWED_USER_APIS, NotAllowedError, RECEIVE_LIMITS, RestError, createRestClient, type AllowedApi, type AllowedUserApi, type FetchLike, type RestClient } from "./kintone-rest.ts";
|
|
16
19
|
export { scanFormula, scanFormulas, type ScanResult } from "./scan.ts";
|
|
17
20
|
export { contextTargetsOf, fetchFields, listFields, referenceTablesOf, summarizeFields, type FieldProperty, type FieldsFile, type FieldsOptions, type LayoutRow } from "./commands/fields.ts";
|
|
@@ -20,13 +23,18 @@ export { LIST_LIMIT, QUERY_MAX, QueryError, SHAPE_TEXT_MAX, listQueryOf, listRec
|
|
|
20
23
|
export { defaultPullName, pullSettings, type PullOptions, type PullResult } from "./commands/pull.ts";
|
|
21
24
|
export { bodyOf, rowsOf, summarizeSettings, type Envelope, type SourceRow } from "./commands/summary.ts";
|
|
22
25
|
export { diffSettings, type DiffResult, type FieldChange } from "./commands/diff.ts";
|
|
23
|
-
export { DEFAULT_MAX_CALLS, UsersPullError, pullUsers, usersFileNameOf, type PullUsersOptions } from "./commands/users.ts";
|
|
24
|
-
export { normalizeSettings, findCycles, type NormalizeInput, type NormalizeResult } from "./commands/normalize.ts";
|
|
26
|
+
export { DEFAULT_MAX_CALLS, USER_INFO_FUNCTIONS, UsersPullError, pullReferencedUsers, pullUsers, referencedCodesOf, scanUserInfoCalls, usersFileNameOf, type PullUsersOptions, type ReferencedCodes } from "./commands/users.ts";
|
|
27
|
+
export { normalizeSettings, findCycles, stronglyConnected, type ContextNeeds, type NormalizeInput, type NormalizeResult } from "./commands/normalize.ts";
|
|
25
28
|
export { DEFAULT_EVENT, EVENT_RE, RECORDS_MAX, calcSettings, validateEvent, type CalcInput, type CalcLine, type CalcRecordResult, type CalcResult } from "./commands/calc.ts";
|
|
29
|
+
export { takeInbox, type TakeResult } from "./commands/take.ts";
|
|
30
|
+
export { MAX_SAVE_INPUT_BYTES, MAX_UPDATE_ROWS, connectionStatusOf, digestOf, saveNewSettings, updateFields, type EvalSource, type SaveContext, type SaveResult, type SaveStatus } from "./commands/save.ts";
|
|
26
31
|
export { DEFAULT_POLICY, POLICY_FILE, PolicyError, loadPolicy, parsePolicy, type Policy } from "./normalize/policy.ts";
|
|
27
32
|
export { Findings, type Finding, type Level } from "./normalize/findings.ts";
|
|
28
|
-
export { materialsOf, viewsOf, type FormulaSaved, type FormulaSource, type Lang } from "./normalize/model.ts";
|
|
33
|
+
export { ENVELOPE_KEYS, OUTER_KEYS, ROW_SCREEN_KEYS, ROW_SOURCE_KEYS, materialsOf, viewsOf, type FormulaSaved, type FormulaSource, type Lang } from "./normalize/model.ts";
|
|
29
34
|
export { DEFAULT_TIMEOUT_SEC, EvalError, EvalTimeoutError, MAX_TIMEOUT_SEC, runEval, type RunOptions } from "./worker/run.ts";
|
|
30
35
|
export { runEvalJob } from "./worker/eval-run.ts";
|
|
31
36
|
export type { EvalJob, EvalMessage, EvalOutcome } from "./worker/eval-job.ts";
|
|
32
|
-
export {
|
|
37
|
+
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
|
+
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
|
+
export { PermissionError, assertChangeAllowed, classOfAppPath, type ChangeOp, type TargetClass } from "./permission.ts";
|
|
40
|
+
export { FileExistsError, LOCK_STALE_MS, LockBusyError, acquireLock, cleanupAll, lockPathFor, placeNew, tempPathFor, withRetry, writeNewFile, type Lock, type WriteNewResult } from "./commit-file.ts";
|
package/dist/types/engine.d.ts
CHANGED
|
@@ -99,7 +99,11 @@ export interface LoadEngineOptions {
|
|
|
99
99
|
/** 開発中(mode dev)の読み込み元(隣の formula の prod/)。CLI は FORMULA_ALLOW_DEV_PLUGIN=1 のときだけ dev-paths.ts の formulaProdDir で決めて渡す */
|
|
100
100
|
devPluginDir?: string;
|
|
101
101
|
mode?: "build" | "dev";
|
|
102
|
+
/** moment(vendor/)の置き場所。省略すれば tools の vendor/(paths.ts)。MCP は束ねた本体の隣の vendor/ を渡す(tools 0.2.0) */
|
|
103
|
+
vendorDir?: string;
|
|
102
104
|
}
|
|
105
|
+
/** moment のファイル(vendorDir があればその中。無ければ tools の vendor/) */
|
|
106
|
+
export declare function momentFileOf(opt: LoadEngineOptions): string;
|
|
103
107
|
export declare const DEFAULT_CONTEXT_BASE_URL = "https://example.cybozu.com";
|
|
104
108
|
/** 指定が無いときにコンストラクターへ返す番兵(式が使えば走査で止める。calc の表には「ログインユーザー: 指定なし」) */
|
|
105
109
|
export declare const SENTINEL_USER: LoginUser;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PermissionError } from "./permission-error.ts";
|
|
2
|
+
import { type WorkspaceMode } from "./workspace.ts";
|
|
3
|
+
export { PermissionError };
|
|
4
|
+
export type ChangeOp = "settings" | "snapshot" | "fields" | "record";
|
|
5
|
+
/** アプリのフォルダーの中の場所(print-craft の docs/permission-table.md の P4〜P9 から out/ を除いたもの) */
|
|
6
|
+
export type TargetClass = "snapshot" | "edit" | "newsettings" | "fields" | "record" | "other";
|
|
7
|
+
/** アプリのフォルダーからの相対パスで場所を分ける。. で始まる名前(印など)はどの操作でも書けない other */
|
|
8
|
+
export declare function classOfAppPath(relInFolder: string): TargetClass;
|
|
9
|
+
/** kintone/ の下をこの操作で変えてよいか。だめなら PermissionError(denied)か ConnectionError(印・接続の変化は conflict。移行で止まっているのは failed) */
|
|
10
|
+
export declare function assertChangeAllowed(root: string, file: string, op: ChangeOp, mode: WorkspaceMode): void;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Worker に渡す仕事と返す結果(構造化クローンで渡せる形だけ。関数やクラスは渡さない)。
|
|
3
3
|
* normalize / calc の評価(zip のコードの実行)は Worker の中で行い、主スレッドは時間上限で terminate する(計画 7 章・11 章、Codex レビュー BLOCKER 1)。
|
|
4
|
+
* tools 0.2.0(MCP。計画 24 章): 結果に findings と calc のレコードごとの行を足した(MCP が構造のまま返す。CLI は summary / text を使う)。vendorDir(moment の置き場所)
|
|
4
5
|
*/
|
|
5
6
|
import type { FieldsFile } from "../commands/fields.ts";
|
|
6
7
|
import type { KintoneRecord } from "../commands/record.ts";
|
|
8
|
+
import type { CalcRecordResult } from "../commands/calc.ts";
|
|
9
|
+
import type { Finding } from "../normalize/findings.ts";
|
|
7
10
|
import type { Policy } from "../normalize/policy.ts";
|
|
8
11
|
import type { UsersOrigin, UsersSource } from "../users/index.ts";
|
|
9
12
|
import type { CalcEvent } from "../engine.ts";
|
|
@@ -13,6 +16,8 @@ export interface EvalJob {
|
|
|
13
16
|
pluginZip?: string;
|
|
14
17
|
devPluginDir?: string;
|
|
15
18
|
mode?: "build" | "dev";
|
|
19
|
+
/** moment(vendor/)の置き場所(省略すれば tools の vendor/。MCP は束ねた本体の隣) */
|
|
20
|
+
vendorDir?: string;
|
|
16
21
|
/** 接続先(検証済み。APP_URL などの元。無ければ既定) */
|
|
17
22
|
baseUrl?: string;
|
|
18
23
|
settingsText: string;
|
|
@@ -42,13 +47,26 @@ export interface EvalOutcome {
|
|
|
42
47
|
summary: string;
|
|
43
48
|
hasErrors: boolean;
|
|
44
49
|
warnings: number;
|
|
50
|
+
/** 検査の結果(エラー / 警告 / 情報。MCP が返す) */
|
|
51
|
+
findings: Finding[];
|
|
45
52
|
output?: Record<string, unknown>;
|
|
46
53
|
checkDiffs?: string[];
|
|
54
|
+
/** 封筒の appId と、保存値の大きさの見積もり */
|
|
55
|
+
appId?: number;
|
|
56
|
+
size?: {
|
|
57
|
+
bytes: number;
|
|
58
|
+
keys: number;
|
|
59
|
+
};
|
|
47
60
|
};
|
|
48
61
|
calc?: {
|
|
49
62
|
text: string;
|
|
50
63
|
/** エラーか sink のあるレコードがある */
|
|
51
64
|
failed: boolean;
|
|
65
|
+
/** レコードごとの結果(項目ごとの前後の値。MCP が返す) */
|
|
66
|
+
records: CalcRecordResult[];
|
|
67
|
+
contextLine: string;
|
|
68
|
+
notice: string;
|
|
69
|
+
summary: string;
|
|
52
70
|
};
|
|
53
71
|
/** エンジンの読み込みの注意 */
|
|
54
72
|
engineWarnings: string[];
|
|
@@ -13,5 +13,9 @@ export interface RunOptions {
|
|
|
13
13
|
timeoutSec?: number;
|
|
14
14
|
/** 主スレッドで動かす(テスト) */
|
|
15
15
|
inline?: boolean;
|
|
16
|
+
/** Worker の入口(絶対パス)。省略すれば自分の隣の eval-worker.mjs / eval-worker.ts */
|
|
17
|
+
workerFile?: string;
|
|
18
|
+
/** Worker の標準出力・標準エラーの受け取り先(渡すと親の標準出力・標準エラーに流さない) */
|
|
19
|
+
captureOutput?: (chunk: string, stream: "stdout" | "stderr") => void;
|
|
16
20
|
}
|
|
17
21
|
export declare function runEval(job: EvalJob, opt?: RunOptions): Promise<EvalOutcome>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ConnectionError, type ConnectionSet, type Env, type ProfileDef } from "./connections.ts";
|
|
2
|
+
export declare const KINTONE_ROOT = "kintone";
|
|
3
|
+
export declare const INBOX = "inbox";
|
|
4
|
+
/** 1.x の作業フォルダーの環境の定義(2.0.0 から読まない。あれば移行を求めて止まる) */
|
|
5
|
+
export declare const LEGACY_WORKSPACE_FILE = "environments.json";
|
|
6
|
+
/** アプリのフォルダーの印(15.5) */
|
|
7
|
+
export declare const APP_MARKER = ".formula-app.json";
|
|
8
|
+
/** 設定画面のダウンロードのファイル名の接頭辞(kit の exportFileName。計算式プラグインの src/config/main.ts の exportPrefix) */
|
|
9
|
+
export declare const SNAPSHOT_PREFIX = "rex0220-formula";
|
|
10
|
+
export declare const SNAPSHOT_RE: RegExp;
|
|
11
|
+
export declare const EDIT_RE: RegExp;
|
|
12
|
+
export declare class WorkspaceError extends Error {
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 動く形(15.4、15.11。r3 MAJOR 7): single(1 接続の形。CLI だけ)、profiles(接続のファイルがある)、not-configured(MCP で接続のファイルが無い)、
|
|
16
|
+
* legacy-blocked(接続のファイルが無く environments.json がある)。どの形でも settings/ などのローカルの操作は動く。kintone/** を読む・書くのは profiles だけ
|
|
17
|
+
*/
|
|
18
|
+
export type WorkspaceMode = {
|
|
19
|
+
kind: "single";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "profiles";
|
|
22
|
+
connections: ProfilesContext;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "not-configured";
|
|
25
|
+
} | {
|
|
26
|
+
kind: "legacy-blocked";
|
|
27
|
+
};
|
|
28
|
+
/** profile の形の文脈: 呼び出しの初めに読んだ接続(秘密を含む。外に出さない)と、確定の前に読み直す関数 */
|
|
29
|
+
export interface ProfilesContext {
|
|
30
|
+
set: ConnectionSet;
|
|
31
|
+
reload: () => ConnectionSet;
|
|
32
|
+
}
|
|
33
|
+
export interface ModeOptions {
|
|
34
|
+
/** 接続のファイルの絶対パス(設定されていなければ undefined、設定されていて空なら "") */
|
|
35
|
+
configFile: string | undefined;
|
|
36
|
+
/** そのプロセスが知っている作業フォルダー(この中の接続のファイルは使わない) */
|
|
37
|
+
workspaceRoots: readonly string[];
|
|
38
|
+
/** env: と passwordEnv を引く環境変数 */
|
|
39
|
+
env: Env;
|
|
40
|
+
/** 接続のファイルが無いときの形: CLI は single(.env の 1 接続)、MCP は not-configured */
|
|
41
|
+
surface: "cli" | "mcp";
|
|
42
|
+
}
|
|
43
|
+
/** 1.x の environments.json があるか(リンク切れの symlink も「ある」) */
|
|
44
|
+
export declare function hasLegacyConfig(cwd: string): boolean;
|
|
45
|
+
/** 移行で止まっているときの誤り(kintone を使う操作と kintone/** の操作が投げる) */
|
|
46
|
+
export declare function legacyBlockedError(): ConnectionError;
|
|
47
|
+
/**
|
|
48
|
+
* 動く形を決める(15.4 の表)。接続のファイルが設定されていれば読む(空・読めない・形が違うのは誤り。1 接続の形に戻らない)。
|
|
49
|
+
* 設定されていなければ、environments.json があれば legacy-blocked、無ければ CLI は single、MCP は not-configured
|
|
50
|
+
*/
|
|
51
|
+
export declare function modeOf(cwd: string, opt: ModeOptions): WorkspaceMode;
|
|
52
|
+
/** kintone を使う操作・アプリのフォルダーの操作の前に: profile の形でなければ止める(未設定・移行で止まっている・1 接続の形の理由で) */
|
|
53
|
+
export declare function requireProfiles(mode: WorkspaceMode, what: string): ProfilesContext;
|
|
54
|
+
/** アプリのフォルダーの名前(番号-アプリ名。名前が使えなければ番号だけ) */
|
|
55
|
+
export declare function folderNameOf(appId: number, appName: string): string;
|
|
56
|
+
export declare function profileDirOf(cwd: string, profile: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* フォルダー・ファイルの実体(symlink を解いたもの)が作業フォルダーの中か。外なら一覧を作らず・読まずに PathError。リンク切れ・ループも PathError
|
|
59
|
+
* (kintone/<profile> や inbox が外への symlink のとき、外のファイルの名前を出さない。B1 の Codex レビュー BLOCKER 1)
|
|
60
|
+
*/
|
|
61
|
+
export declare function assertInsideWorkspace(cwd: string, p: string): void;
|
|
62
|
+
/** 今あるアプリのフォルダー(番号で探す。無ければ null。同じ番号が 2 つあれば止まる)。kintone/ と profile のフォルダーの実体が作業フォルダーの中のときだけ一覧する */
|
|
63
|
+
export declare function findAppDir(cwd: string, profile: string, appId: number): string | null;
|
|
64
|
+
/** アプリのフォルダー(あればそれ、無ければ 番号-アプリ名 で作る場所。作るのは ensureAppFolder) */
|
|
65
|
+
export declare function appDirFor(cwd: string, profile: string, appId: number, appName: string): string;
|
|
66
|
+
/** ファイルが kintone/<profile>/<番号>-…/ の中(records/ などの下を含む)なら、そのフォルダーと profile と番号 */
|
|
67
|
+
export declare function appFolderOfFile(cwd: string, file: string): {
|
|
68
|
+
dir: string;
|
|
69
|
+
profile: string;
|
|
70
|
+
appId: number;
|
|
71
|
+
} | null;
|
|
72
|
+
/** ダウンロードと同じ名前(kit の exportFileName と同じ。日時はこの PC の時刻) */
|
|
73
|
+
export declare function snapshotNameOf(appId: number, now?: Date): string;
|
|
74
|
+
export declare function editNameOf(snapshotFile: string): string;
|
|
75
|
+
export interface AppMark {
|
|
76
|
+
schemaVersion: 1;
|
|
77
|
+
profile: string;
|
|
78
|
+
origin: string;
|
|
79
|
+
guestSpaceId: number | null;
|
|
80
|
+
appId: number;
|
|
81
|
+
}
|
|
82
|
+
export declare function markOf(def: ProfileDef, appId: number): AppMark;
|
|
83
|
+
export type AppMarkState = {
|
|
84
|
+
state: "missing";
|
|
85
|
+
} | {
|
|
86
|
+
state: "invalid";
|
|
87
|
+
} | {
|
|
88
|
+
state: "ok";
|
|
89
|
+
mark: AppMark;
|
|
90
|
+
};
|
|
91
|
+
/** 印を読む(無い・壊れている・読めた) */
|
|
92
|
+
export declare function readAppMark(dir: string): AppMarkState;
|
|
93
|
+
/** アプリのフォルダーの印が、今の接続のこのアプリのものか(無い・壊れている・違うは ConnectionError。conflict) */
|
|
94
|
+
export declare function assertAppMark(dir: string, def: ProfileDef, appId: number): void;
|
|
95
|
+
/**
|
|
96
|
+
* アプリのフォルダーを使う(fields / pull / take だけが呼ぶ。15.5)。あれば印を確かめる。無ければ、同じ親の一時フォルダー(. で始まる名前)に印を置いてから
|
|
97
|
+
* 最後の名前に付け替える(途中で止まっても印の無いフォルダーを残さない。r3 MINOR 1)。付け替えの先が既にあれば(同時に作った)、その印を確かめて使う。
|
|
98
|
+
* dir は appDirFor の値(書ける場所と許可は呼ぶ側が先に確かめる)
|
|
99
|
+
*/
|
|
100
|
+
export declare function ensureAppFolder(dir: string, def: ProfileDef, appId: number): void;
|
|
101
|
+
/**
|
|
102
|
+
* kintone/** の中のファイル・フォルダーを通常の操作で読む・一覧する前に(15.5、r3 MAJOR 3): profile の形で、フォルダーの profile が接続のファイルにあり、
|
|
103
|
+
* 印が今の接続のこのアプリのものか。kintone/ の外なら何もしない。profile が無い = denied(PermissionError)、印 = conflict(ConnectionError)
|
|
104
|
+
*/
|
|
105
|
+
export declare function assertUsableInKintone(cwd: string, file: string, mode: WorkspaceMode): void;
|
|
106
|
+
export interface AppFolderList {
|
|
107
|
+
dir: string;
|
|
108
|
+
hasFields: boolean;
|
|
109
|
+
/** ダウンロードと pull(新しい順) */
|
|
110
|
+
snapshots: string[];
|
|
111
|
+
/** 直したもの(新しい順) */
|
|
112
|
+
edits: string[];
|
|
113
|
+
/** AI が作った設定など、その他の json(. で始まる印などは出さない) */
|
|
114
|
+
others: string[];
|
|
115
|
+
records: string[];
|
|
116
|
+
}
|
|
117
|
+
/** アプリのフォルダーの一覧。cwd を渡すと、フォルダーと records の実体が作業フォルダーの中か確かめてから一覧する */
|
|
118
|
+
export declare function listAppFolder(dir: string, cwd?: string): AppFolderList;
|
|
119
|
+
/** profile のフォルダーの中のアプリのフォルダーと印の状態(診断と files の一覧。中身は返さない。15.5) */
|
|
120
|
+
export declare function appFoldersOf(cwd: string, def: ProfileDef): Array<{
|
|
121
|
+
name: string;
|
|
122
|
+
appId: number | null;
|
|
123
|
+
mark: "ok" | "missing" | "invalid" | "conflict";
|
|
124
|
+
}>;
|
|
125
|
+
/** kintone/ の下の profile のフォルダーのうち、接続のファイルに無いもの(使われていないフォルダー。診断で名前だけ示す) */
|
|
126
|
+
export declare function unusedProfileDirs(cwd: string, set: ConnectionSet): string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rex0220/formula-authoring-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "rex0220 計算式プラグイン(kintone)の設定を AI で作るための CLI。利用者のプラグインの zip から authoring API と計算式エンジンを読んで Node で動く",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"prepack": "node scripts/vendor.mjs && node scripts/build.mjs",
|
|
35
35
|
"gen-docs": "node scripts/gen-docs.mjs"
|
|
36
36
|
},
|
|
37
|
+
"publishConfig": { "access": "public" },
|
|
37
38
|
"homepage": "https://github.com/rex0220/formula-authoring#readme",
|
|
38
39
|
"repository": {
|
|
39
40
|
"type": "git",
|