@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,67 @@
|
|
|
1
|
+
import { RepositoryError } from "../persistence/repository.js";
|
|
2
|
+
export class CancelRequestError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(code, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.name = "CancelRequestError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const TERMINAL = new Set([
|
|
11
|
+
"SUCCESS",
|
|
12
|
+
"FAILED",
|
|
13
|
+
"CANCELLED",
|
|
14
|
+
"UNKNOWN",
|
|
15
|
+
]);
|
|
16
|
+
export async function changeCancelRequest(input) {
|
|
17
|
+
const run = await input.repository.getRun(input.runId);
|
|
18
|
+
const current = await input.repository.getCancelRequest(input.runId);
|
|
19
|
+
if (input.release) {
|
|
20
|
+
if (current === null || current.value.state === "RELEASED")
|
|
21
|
+
return current;
|
|
22
|
+
const at = (input.now ?? (() => new Date()))().toISOString();
|
|
23
|
+
return input.repository.updateCancelRequest(input.runId, current.revision, {
|
|
24
|
+
...current.value,
|
|
25
|
+
state: "RELEASED",
|
|
26
|
+
released_at: at,
|
|
27
|
+
release_reason: input.reason,
|
|
28
|
+
release_requested_by: input.requestedBy,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (current?.value.state === "REQUESTED" ||
|
|
32
|
+
current?.value.state === "ACCEPTED")
|
|
33
|
+
return current;
|
|
34
|
+
if (TERMINAL.has(run.value.status))
|
|
35
|
+
throw new CancelRequestError("RUN_ALREADY_TERMINAL", `run '${input.runId}' is already terminal (${run.value.status})`);
|
|
36
|
+
const at = (input.now ?? (() => new Date()))().toISOString();
|
|
37
|
+
const request = {
|
|
38
|
+
run_id: input.runId,
|
|
39
|
+
state: "REQUESTED",
|
|
40
|
+
requested_by: input.requestedBy,
|
|
41
|
+
reason: input.reason,
|
|
42
|
+
requested_at: at,
|
|
43
|
+
accepted_at: null,
|
|
44
|
+
released_at: null,
|
|
45
|
+
release_reason: null,
|
|
46
|
+
release_requested_by: null,
|
|
47
|
+
};
|
|
48
|
+
if (current === null) {
|
|
49
|
+
try {
|
|
50
|
+
return await input.repository.createCancelRequest(request);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (!(error instanceof RepositoryError) ||
|
|
54
|
+
error.code !== "DUPLICATE_RECORD")
|
|
55
|
+
throw error;
|
|
56
|
+
const raced = await input.repository.getCancelRequest(input.runId);
|
|
57
|
+
if (raced === null)
|
|
58
|
+
throw error;
|
|
59
|
+
return raced;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return input.repository.updateCancelRequest(input.runId, current.revision, request);
|
|
63
|
+
}
|
|
64
|
+
export function isCancelHold(request) {
|
|
65
|
+
return (request?.value.state === "REQUESTED" || request?.value.state === "ACCEPTED");
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=cancel-request.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { NetworkDefinition } from "../domain/network-definition.js";
|
|
2
|
+
import type { NetworkRun, RunInvocation, RunInvocationStatus } from "../domain/persistence-model.js";
|
|
3
|
+
import type { CapabilitiesResult, JobInspection, ProfileDescription } from "../executor/ksql-flow-cli.js";
|
|
4
|
+
import type { NetworkLockReference } from "../persistence/network-lock.js";
|
|
5
|
+
import type { PersistenceRepository, Versioned } from "../persistence/repository.js";
|
|
6
|
+
export type EnsureRunOutcome = "NEW" | "RESUME" | "NOOP";
|
|
7
|
+
export type EnsureRunErrorCode = "NETWORK_VALIDATION_FAILED" | "BUSINESS_KEY_INVALID" | "MULTIPLE_RUNS" | "RUN_NOT_FOUND" | "RUN_ALREADY_EXISTS" | "RUN_ID_MISMATCH" | "RUN_NOT_RESUMABLE" | "RUN_ON_HOLD" | "MAX_ACTIVE_RUNS" | "PROFILE_DESCRIPTION_INVALID" | "BUNDLE_INPUT_CHANGED" | "RUN_SNAPSHOT_MISMATCH" | "BUNDLE_DIALECT_MISMATCH" | "RERUN_FROM_SUCCESS_RUN" | "RERUN_FROM_NODE_NOT_FOUND" | "RERUN_FROM_DAG_INVALID" | "RERUN_FROM_UNKNOWN_STATE" | "RERUN_FROM_NON_IDEMPOTENT" | "INPUT_FILE_MUTATED" | "INPUT_RETENTION_EXPIRED" | "ENSURE_RUN_FAILED";
|
|
8
|
+
export declare class EnsureRunError extends Error {
|
|
9
|
+
readonly code: EnsureRunErrorCode;
|
|
10
|
+
readonly blockedBy: readonly string[];
|
|
11
|
+
constructor(code: EnsureRunErrorCode, message: string, blockedBy?: readonly string[], options?: ErrorOptions);
|
|
12
|
+
}
|
|
13
|
+
export interface EnsureRunExecutor {
|
|
14
|
+
capabilities(): Promise<CapabilitiesResult>;
|
|
15
|
+
describeProfile(): Promise<ProfileDescription>;
|
|
16
|
+
inspectJob(sqlPath: string): Promise<JobInspection>;
|
|
17
|
+
}
|
|
18
|
+
export interface EnsureRunBundleStore {
|
|
19
|
+
upload(zipBytes: Uint8Array): Promise<string>;
|
|
20
|
+
download(fileKey: string): Promise<Uint8Array>;
|
|
21
|
+
}
|
|
22
|
+
export interface EnsureRunLockManager {
|
|
23
|
+
acquire(): Promise<NetworkLockReference>;
|
|
24
|
+
release(reference: NetworkLockReference, status?: string, resultCode?: string): Promise<unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface EnsureRunInput {
|
|
27
|
+
readonly networkPath: string;
|
|
28
|
+
readonly profile: string;
|
|
29
|
+
readonly scheduledFor?: string;
|
|
30
|
+
readonly businessKey?: string;
|
|
31
|
+
readonly resume?: boolean;
|
|
32
|
+
readonly resumeRunId?: string;
|
|
33
|
+
readonly rerunFrom?: string;
|
|
34
|
+
readonly requestedBy: string;
|
|
35
|
+
readonly host: string;
|
|
36
|
+
readonly invocationId?: string;
|
|
37
|
+
readonly repository: PersistenceRepository;
|
|
38
|
+
readonly lockManager: EnsureRunLockManager;
|
|
39
|
+
readonly executor: EnsureRunExecutor;
|
|
40
|
+
readonly bundleStore: EnsureRunBundleStore;
|
|
41
|
+
readonly beforeLock?: (definition: NetworkDefinition) => {
|
|
42
|
+
readonly root: string;
|
|
43
|
+
readonly retentionDays: number;
|
|
44
|
+
} | void | Promise<{
|
|
45
|
+
readonly root: string;
|
|
46
|
+
readonly retentionDays: number;
|
|
47
|
+
} | void>;
|
|
48
|
+
readonly ioRoot?: string;
|
|
49
|
+
readonly ioRetentionDays?: number;
|
|
50
|
+
readonly now?: () => Date;
|
|
51
|
+
readonly uuid?: () => string;
|
|
52
|
+
}
|
|
53
|
+
export interface EnsureRunCloseInput {
|
|
54
|
+
readonly status: Exclude<RunInvocationStatus, "RUNNING">;
|
|
55
|
+
readonly resultCode: string;
|
|
56
|
+
readonly selectedNodeIds?: readonly string[];
|
|
57
|
+
readonly preservedNodeIds?: readonly string[];
|
|
58
|
+
readonly blockedNodeIds?: readonly string[];
|
|
59
|
+
readonly reason?: string;
|
|
60
|
+
/** D-29 unrecovered drain releases only if possible and leaves Invocation untouched. */
|
|
61
|
+
readonly persistInvocation?: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface EnsureRunNoopResult {
|
|
64
|
+
readonly outcome: "NOOP";
|
|
65
|
+
readonly run: Versioned<NetworkRun>;
|
|
66
|
+
readonly invocation: null;
|
|
67
|
+
readonly blockedBy: readonly string[];
|
|
68
|
+
readonly businessKey: string;
|
|
69
|
+
}
|
|
70
|
+
export interface EnsureRunExecutionResult {
|
|
71
|
+
readonly outcome: "NEW" | "RESUME";
|
|
72
|
+
readonly run: Versioned<NetworkRun>;
|
|
73
|
+
readonly invocation: Versioned<RunInvocation>;
|
|
74
|
+
readonly blockedBy: readonly string[];
|
|
75
|
+
readonly businessKey: string;
|
|
76
|
+
readonly bundleBytes: Buffer;
|
|
77
|
+
readonly lock: NetworkLockReference;
|
|
78
|
+
close(input: EnsureRunCloseInput): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
export type EnsureRunResult = EnsureRunNoopResult | EnsureRunExecutionResult;
|
|
81
|
+
export declare function ensureRun(input: EnsureRunInput): Promise<EnsureRunResult>;
|
|
82
|
+
export declare function profileDescriptionSha256(description: ProfileDescription): string;
|
|
83
|
+
//# sourceMappingURL=ensure-run.d.ts.map
|