@rex0220/ksql-flownet 1.0.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/LICENSE +21 -0
- package/README.ja.md +81 -0
- package/README.md +117 -0
- package/dist/bundle/bundle-builder.d.ts +49 -0
- package/dist/bundle/bundle-builder.js +208 -0
- package/dist/bundle/index.d.ts +4 -0
- package/dist/bundle/index.js +4 -0
- package/dist/bundle/upload.d.ts +28 -0
- package/dist/bundle/upload.js +72 -0
- package/dist/bundle/zip-store.d.ts +17 -0
- package/dist/bundle/zip-store.js +175 -0
- package/dist/cli/archive-run-command.d.ts +12 -0
- package/dist/cli/archive-run-command.js +131 -0
- package/dist/cli/cancel-run-command.d.ts +9 -0
- package/dist/cli/cancel-run-command.js +77 -0
- package/dist/cli/force-unlock-network-command.d.ts +8 -0
- package/dist/cli/force-unlock-network-command.js +129 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +132 -0
- package/dist/cli/plan-command.d.ts +2 -0
- package/dist/cli/plan-command.js +100 -0
- package/dist/cli/poll-requests-command.d.ts +3 -0
- package/dist/cli/poll-requests-command.js +74 -0
- package/dist/cli/record-job-unlock-command.d.ts +11 -0
- package/dist/cli/record-job-unlock-command.js +78 -0
- package/dist/cli/resolve-node-command.d.ts +13 -0
- package/dist/cli/resolve-node-command.js +174 -0
- package/dist/cli/run-network-command.d.ts +14 -0
- package/dist/cli/run-network-command.js +418 -0
- package/dist/cli/status-command.d.ts +5 -0
- package/dist/cli/status-command.js +137 -0
- package/dist/cli/validate-command.d.ts +6 -0
- package/dist/cli/validate-command.js +17 -0
- package/dist/dag/descendants.d.ts +9 -0
- package/dist/dag/descendants.js +67 -0
- package/dist/dag/topological-sort.d.ts +7 -0
- package/dist/dag/topological-sort.js +32 -0
- package/dist/domain/business-key.d.ts +15 -0
- package/dist/domain/business-key.js +249 -0
- package/dist/domain/canonical-lock-key.d.ts +17 -0
- package/dist/domain/canonical-lock-key.js +60 -0
- package/dist/domain/canonical-record-key.d.ts +18 -0
- package/dist/domain/canonical-record-key.js +70 -0
- package/dist/domain/load-network.d.ts +4 -0
- package/dist/domain/load-network.js +47 -0
- package/dist/domain/network-definition.d.ts +47 -0
- package/dist/domain/network-definition.js +7 -0
- package/dist/domain/persistence-model.d.ts +198 -0
- package/dist/domain/persistence-model.js +2 -0
- package/dist/domain/run-aggregate.d.ts +3 -0
- package/dist/domain/run-aggregate.js +15 -0
- package/dist/domain/validate-network-path.d.ts +11 -0
- package/dist/domain/validate-network-path.js +33 -0
- package/dist/domain/validate-network.d.ts +3 -0
- package/dist/domain/validate-network.js +180 -0
- package/dist/executor/attempt-executor.d.ts +43 -0
- package/dist/executor/attempt-executor.js +236 -0
- package/dist/executor/job-log-reader.d.ts +37 -0
- package/dist/executor/job-log-reader.js +91 -0
- package/dist/executor/ksql-flow-cli.d.ts +86 -0
- package/dist/executor/ksql-flow-cli.js +161 -0
- package/dist/executor/preflight.d.ts +41 -0
- package/dist/executor/preflight.js +150 -0
- package/dist/executor/result-classifier.d.ts +69 -0
- package/dist/executor/result-classifier.js +237 -0
- package/dist/executor/run-subprocess.d.ts +64 -0
- package/dist/executor/run-subprocess.js +175 -0
- package/dist/io/input-baseline.d.ts +19 -0
- package/dist/io/input-baseline.js +214 -0
- package/dist/io/io-config.d.ts +6 -0
- package/dist/io/io-config.js +33 -0
- package/dist/io/io-path.d.ts +37 -0
- package/dist/io/io-path.js +279 -0
- package/dist/orchestration/archive-run.d.ts +53 -0
- package/dist/orchestration/archive-run.js +323 -0
- package/dist/orchestration/cancel-request.d.ts +18 -0
- package/dist/orchestration/cancel-request.js +67 -0
- package/dist/orchestration/ensure-run.d.ts +83 -0
- package/dist/orchestration/ensure-run.js +632 -0
- package/dist/orchestration/job-lock-audit.d.ts +24 -0
- package/dist/orchestration/job-lock-audit.js +123 -0
- package/dist/orchestration/orphan-attempt-adjudication.d.ts +39 -0
- package/dist/orchestration/orphan-attempt-adjudication.js +167 -0
- package/dist/orchestration/reconciliation.d.ts +41 -0
- package/dist/orchestration/reconciliation.js +526 -0
- package/dist/orchestration/resolve-node.d.ts +29 -0
- package/dist/orchestration/resolve-node.js +105 -0
- package/dist/orchestration/run-activity.d.ts +13 -0
- package/dist/orchestration/run-activity.js +14 -0
- package/dist/orchestration/sequential-scheduler.d.ts +79 -0
- package/dist/orchestration/sequential-scheduler.js +706 -0
- package/dist/orchestration/status.d.ts +91 -0
- package/dist/orchestration/status.js +171 -0
- package/dist/persistence/in-memory-repository.d.ts +41 -0
- package/dist/persistence/in-memory-repository.js +333 -0
- package/dist/persistence/kintone/client.d.ts +36 -0
- package/dist/persistence/kintone/client.js +93 -0
- package/dist/persistence/kintone/design-notes.d.ts +38 -0
- package/dist/persistence/kintone/design-notes.js +38 -0
- package/dist/persistence/kintone/repository.d.ts +44 -0
- package/dist/persistence/kintone/repository.js +836 -0
- package/dist/persistence/kintone/schema.d.ts +116 -0
- package/dist/persistence/kintone/schema.js +115 -0
- package/dist/persistence/network-lock-reader.d.ts +24 -0
- package/dist/persistence/network-lock-reader.js +43 -0
- package/dist/persistence/network-lock-recovery.d.ts +66 -0
- package/dist/persistence/network-lock-recovery.js +392 -0
- package/dist/persistence/network-lock.d.ts +97 -0
- package/dist/persistence/network-lock.js +408 -0
- package/dist/persistence/repository.d.ts +101 -0
- package/dist/persistence/repository.js +11 -0
- package/dist/persistence/state-transition.d.ts +4 -0
- package/dist/persistence/state-transition.js +25 -0
- package/dist/requests/flownet-child-client.d.ts +78 -0
- package/dist/requests/flownet-child-client.js +243 -0
- package/dist/requests/kintone-request-store.d.ts +44 -0
- package/dist/requests/kintone-request-store.js +202 -0
- package/dist/requests/poll-requests-config.d.ts +26 -0
- package/dist/requests/poll-requests-config.js +105 -0
- package/dist/requests/request-model.d.ts +57 -0
- package/dist/requests/request-model.js +305 -0
- package/dist/requests/request-poller.d.ts +33 -0
- package/dist/requests/request-poller.js +353 -0
- package/dist/requests/request-result.d.ts +18 -0
- package/dist/requests/request-result.js +215 -0
- package/dist/requests/start-request.d.ts +26 -0
- package/dist/requests/start-request.js +83 -0
- package/package.json +63 -0
- package/schemas/.gitkeep +1 -0
- package/schemas/network-definition.schema.json +121 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export class KintoneApiError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
apiCode;
|
|
4
|
+
responseBody;
|
|
5
|
+
constructor(status, apiCode, responseBody) {
|
|
6
|
+
super(`kintone API returned ${status}${apiCode ? ` ${apiCode}` : ""}`);
|
|
7
|
+
this.name = "KintoneApiError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.apiCode = apiCode;
|
|
10
|
+
this.responseBody = responseBody;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class KintoneTransportError extends Error {
|
|
14
|
+
causeDetail;
|
|
15
|
+
constructor(causeDetail) {
|
|
16
|
+
super("kintone request outcome is unknown");
|
|
17
|
+
this.name = "KintoneTransportError";
|
|
18
|
+
this.causeDetail = causeDetail;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class KintoneClient {
|
|
22
|
+
baseUrl;
|
|
23
|
+
appId;
|
|
24
|
+
apiToken;
|
|
25
|
+
fetchImpl;
|
|
26
|
+
constructor(config) {
|
|
27
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
28
|
+
this.appId = config.appId;
|
|
29
|
+
this.apiToken = config.apiToken;
|
|
30
|
+
this.fetchImpl = config.fetch ?? fetch;
|
|
31
|
+
}
|
|
32
|
+
async getRecords(query) {
|
|
33
|
+
const url = new URL(`${this.baseUrl}/k/v1/records.json`);
|
|
34
|
+
url.searchParams.set("app", String(this.appId));
|
|
35
|
+
url.searchParams.set("query", query);
|
|
36
|
+
const body = await this.request("GET", url);
|
|
37
|
+
return body.records;
|
|
38
|
+
}
|
|
39
|
+
async postRecord(record) {
|
|
40
|
+
const body = await this.request("POST", `${this.baseUrl}/k/v1/record.json`, {
|
|
41
|
+
app: this.appId,
|
|
42
|
+
record,
|
|
43
|
+
});
|
|
44
|
+
const result = body;
|
|
45
|
+
return { id: result.id, revision: Number(result.revision) };
|
|
46
|
+
}
|
|
47
|
+
async putRecord(recordKey, revision, record) {
|
|
48
|
+
const body = await this.request("PUT", `${this.baseUrl}/k/v1/record.json`, {
|
|
49
|
+
app: this.appId,
|
|
50
|
+
updateKey: { field: "record_key", value: recordKey },
|
|
51
|
+
revision,
|
|
52
|
+
record,
|
|
53
|
+
});
|
|
54
|
+
return Number(body.revision);
|
|
55
|
+
}
|
|
56
|
+
async putRecordById(id, revision, record) {
|
|
57
|
+
const body = await this.request("PUT", `${this.baseUrl}/k/v1/record.json`, {
|
|
58
|
+
app: this.appId,
|
|
59
|
+
id,
|
|
60
|
+
revision,
|
|
61
|
+
record,
|
|
62
|
+
});
|
|
63
|
+
return Number(body.revision);
|
|
64
|
+
}
|
|
65
|
+
async request(method, url, body) {
|
|
66
|
+
let response;
|
|
67
|
+
try {
|
|
68
|
+
response = await this.fetchImpl(url, {
|
|
69
|
+
method,
|
|
70
|
+
headers: {
|
|
71
|
+
"X-Cybozu-API-Token": this.apiToken,
|
|
72
|
+
...(body === undefined ? {} : { "Content-Type": "application/json" }),
|
|
73
|
+
},
|
|
74
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
throw new KintoneTransportError(error);
|
|
79
|
+
}
|
|
80
|
+
const responseBody = await response.json().catch(() => null);
|
|
81
|
+
if (!response.ok) {
|
|
82
|
+
const code = typeof responseBody === "object" &&
|
|
83
|
+
responseBody !== null &&
|
|
84
|
+
"code" in responseBody &&
|
|
85
|
+
typeof responseBody.code === "string"
|
|
86
|
+
? responseBody.code
|
|
87
|
+
: null;
|
|
88
|
+
throw new KintoneApiError(response.status, code, responseBody);
|
|
89
|
+
}
|
|
90
|
+
return responseBody;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable timestamp precision note (FN-04 / FDR review material):
|
|
3
|
+
*
|
|
4
|
+
* kintone DATETIME fields persist minute precision. This affects ordering and
|
|
5
|
+
* elapsed-time evidence for execution_started_at, runner_execution_started_at,
|
|
6
|
+
* started_at, finished_at, updated_at, and resolved_at. Domain values remain
|
|
7
|
+
* ISO-8601 strings and are not redesigned in FN-04. Callers must not use the
|
|
8
|
+
* persisted DATETIME value to prove sub-minute ordering; precise runner/event
|
|
9
|
+
* evidence must remain in its owning durable execution log until a later FDR
|
|
10
|
+
* decision defines a canonical precision-preserving field.
|
|
11
|
+
*/
|
|
12
|
+
export declare const KINTONE_DATETIME_PRECISION: "minute";
|
|
13
|
+
export declare const KINTONE_DATETIME_TRUNCATION_MS = 60000;
|
|
14
|
+
/**
|
|
15
|
+
* Deployment prerequisite (M3): apply
|
|
16
|
+
* spikes/a-app-layout/console/add-state-revision-before.console.js to the
|
|
17
|
+
* selected app layout before integration tests. NODE_ATTEMPT writes formally
|
|
18
|
+
* include state_revision_before and therefore fail against the old schema.
|
|
19
|
+
*/
|
|
20
|
+
export declare const STATE_REVISION_BEFORE_DEPLOYMENT_REQUIRED: true;
|
|
21
|
+
/**
|
|
22
|
+
* updateKey concurrency observation (M3 device measurement, 2026-08-30): two
|
|
23
|
+
* PUTs using the same revision do not have a deterministic loser response.
|
|
24
|
+
* kintone returned either 409 GAIA_CO02 or 400 GAIA_DA02 across repeated
|
|
25
|
+
* races. GAIA_DA02 is therefore adjudicated by re-reading the record: a newer
|
|
26
|
+
* revision or a missing target is a revision conflict, while inconclusive or
|
|
27
|
+
* failed reads remain fail-closed remote errors.
|
|
28
|
+
*/
|
|
29
|
+
export declare const UPDATE_KEY_DA02_REQUIRES_REREAD: true;
|
|
30
|
+
/**
|
|
31
|
+
* Network Run uniqueness (M3): the R1 canonical record_key derived from
|
|
32
|
+
* profile, network_id, and business_key is permanent across terminal and
|
|
33
|
+
* non-terminal Runs. A duplicate-prohibited INSERT on that key is the final
|
|
34
|
+
* adjudication. Network-lock serialization only narrows the race window as the
|
|
35
|
+
* first defense; the unique constraint remains the final defense.
|
|
36
|
+
*/
|
|
37
|
+
export declare const RUN_R1_INSERT_IS_FINAL_UNIQUENESS_ADJUDICATION: true;
|
|
38
|
+
//# sourceMappingURL=design-notes.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable timestamp precision note (FN-04 / FDR review material):
|
|
3
|
+
*
|
|
4
|
+
* kintone DATETIME fields persist minute precision. This affects ordering and
|
|
5
|
+
* elapsed-time evidence for execution_started_at, runner_execution_started_at,
|
|
6
|
+
* started_at, finished_at, updated_at, and resolved_at. Domain values remain
|
|
7
|
+
* ISO-8601 strings and are not redesigned in FN-04. Callers must not use the
|
|
8
|
+
* persisted DATETIME value to prove sub-minute ordering; precise runner/event
|
|
9
|
+
* evidence must remain in its owning durable execution log until a later FDR
|
|
10
|
+
* decision defines a canonical precision-preserving field.
|
|
11
|
+
*/
|
|
12
|
+
export const KINTONE_DATETIME_PRECISION = "minute";
|
|
13
|
+
export const KINTONE_DATETIME_TRUNCATION_MS = 60_000;
|
|
14
|
+
/**
|
|
15
|
+
* Deployment prerequisite (M3): apply
|
|
16
|
+
* spikes/a-app-layout/console/add-state-revision-before.console.js to the
|
|
17
|
+
* selected app layout before integration tests. NODE_ATTEMPT writes formally
|
|
18
|
+
* include state_revision_before and therefore fail against the old schema.
|
|
19
|
+
*/
|
|
20
|
+
export const STATE_REVISION_BEFORE_DEPLOYMENT_REQUIRED = true;
|
|
21
|
+
/**
|
|
22
|
+
* updateKey concurrency observation (M3 device measurement, 2026-08-30): two
|
|
23
|
+
* PUTs using the same revision do not have a deterministic loser response.
|
|
24
|
+
* kintone returned either 409 GAIA_CO02 or 400 GAIA_DA02 across repeated
|
|
25
|
+
* races. GAIA_DA02 is therefore adjudicated by re-reading the record: a newer
|
|
26
|
+
* revision or a missing target is a revision conflict, while inconclusive or
|
|
27
|
+
* failed reads remain fail-closed remote errors.
|
|
28
|
+
*/
|
|
29
|
+
export const UPDATE_KEY_DA02_REQUIRES_REREAD = true;
|
|
30
|
+
/**
|
|
31
|
+
* Network Run uniqueness (M3): the R1 canonical record_key derived from
|
|
32
|
+
* profile, network_id, and business_key is permanent across terminal and
|
|
33
|
+
* non-terminal Runs. A duplicate-prohibited INSERT on that key is the final
|
|
34
|
+
* adjudication. Network-lock serialization only narrows the race window as the
|
|
35
|
+
* first defense; the unique constraint remains the final defense.
|
|
36
|
+
*/
|
|
37
|
+
export const RUN_R1_INSERT_IS_FINAL_UNIQUENESS_ADJUDICATION = true;
|
|
38
|
+
//# sourceMappingURL=design-notes.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AttemptResolution, CancelRequest, NetworkRun, NodeAttempt, NodeState, OperationAudit, RunInvocation } from "../../domain/persistence-model.js";
|
|
2
|
+
import type { AttemptExecutionStart, AttemptInputBaselineWrite, AttemptFinalization, CreateAttemptInput, Inconsistency, InvocationFinalization, NodeStateWrite, PersistenceRepository, RunAggregateUpdate, Versioned } from "../repository.js";
|
|
3
|
+
export interface KintoneRepositoryConfig {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
stateAppId: number;
|
|
6
|
+
stateApiToken: string;
|
|
7
|
+
auditAppId: number;
|
|
8
|
+
auditApiToken: string;
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
}
|
|
11
|
+
export declare class KintonePersistenceRepository implements PersistenceRepository {
|
|
12
|
+
private readonly state;
|
|
13
|
+
private readonly audit;
|
|
14
|
+
constructor(config: KintoneRepositoryConfig);
|
|
15
|
+
createRun(run: NetworkRun): Promise<Versioned<NetworkRun>>;
|
|
16
|
+
getCancelRequest(runId: string): Promise<Versioned<CancelRequest> | null>;
|
|
17
|
+
createCancelRequest(request: CancelRequest): Promise<Versioned<CancelRequest>>;
|
|
18
|
+
updateCancelRequest(runId: string, expectedRevision: number, request: CancelRequest): Promise<Versioned<CancelRequest>>;
|
|
19
|
+
getRunByBusinessKey(profile: string, networkId: string, businessKey: string): Promise<Versioned<NetworkRun> | null>;
|
|
20
|
+
getRun(runId: string): Promise<Versioned<NetworkRun>>;
|
|
21
|
+
listRuns(profile: string, networkId: string): Promise<Versioned<NetworkRun>[]>;
|
|
22
|
+
updateRunAggregate(runId: string, expectedRevision: number, update: RunAggregateUpdate): Promise<Versioned<NetworkRun>>;
|
|
23
|
+
archiveRun(runId: string, expectedRevision: number, at: string): Promise<Versioned<NetworkRun>>;
|
|
24
|
+
private requiredRunById;
|
|
25
|
+
createInvocation(value: RunInvocation): Promise<Versioned<RunInvocation>>;
|
|
26
|
+
getInvocations(runId: string): Promise<Versioned<RunInvocation>[]>;
|
|
27
|
+
finalizeInvocation(invocationId: string, expectedRevision: number, finalization: InvocationFinalization): Promise<Versioned<RunInvocation>>;
|
|
28
|
+
getNodeStates(runId: string): Promise<Versioned<NodeState>[]>;
|
|
29
|
+
getAttempts(runId: string): Promise<Versioned<NodeAttempt>[]>;
|
|
30
|
+
getResolutions(runId: string): Promise<Versioned<AttemptResolution>[]>;
|
|
31
|
+
upsertNodeState(write: NodeStateWrite): Promise<Versioned<NodeState>>;
|
|
32
|
+
createAttempt(input: CreateAttemptInput): Promise<Versioned<NodeAttempt>>;
|
|
33
|
+
setAttemptExecutionStarted(attemptId: string, expectedRevision: number, start: AttemptExecutionStart): Promise<Versioned<NodeAttempt>>;
|
|
34
|
+
setAttemptInputBaseline(attemptId: string, expectedRevision: number, write: AttemptInputBaselineWrite): Promise<Versioned<NodeAttempt>>;
|
|
35
|
+
finalizeAttempt(attemptId: string, expectedRevision: number, finalization: AttemptFinalization): Promise<Versioned<NodeAttempt>>;
|
|
36
|
+
appendResolution(value: AttemptResolution): Promise<Versioned<AttemptResolution>>;
|
|
37
|
+
appendOperationAudit(value: OperationAudit): Promise<Versioned<OperationAudit>>;
|
|
38
|
+
getOperationAuditByEventId(eventId: string): Promise<Versioned<OperationAudit> | null>;
|
|
39
|
+
listInconsistencies(runId: string): Promise<Inconsistency[]>;
|
|
40
|
+
private createWithAdjudication;
|
|
41
|
+
private requiredByRecordKey;
|
|
42
|
+
private put;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=repository.d.ts.map
|