@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.
Files changed (130) hide show
  1. package/LICENSE +21 -0
  2. package/README.ja.md +81 -0
  3. package/README.md +117 -0
  4. package/dist/bundle/bundle-builder.d.ts +49 -0
  5. package/dist/bundle/bundle-builder.js +208 -0
  6. package/dist/bundle/index.d.ts +4 -0
  7. package/dist/bundle/index.js +4 -0
  8. package/dist/bundle/upload.d.ts +28 -0
  9. package/dist/bundle/upload.js +72 -0
  10. package/dist/bundle/zip-store.d.ts +17 -0
  11. package/dist/bundle/zip-store.js +175 -0
  12. package/dist/cli/archive-run-command.d.ts +12 -0
  13. package/dist/cli/archive-run-command.js +131 -0
  14. package/dist/cli/cancel-run-command.d.ts +9 -0
  15. package/dist/cli/cancel-run-command.js +77 -0
  16. package/dist/cli/force-unlock-network-command.d.ts +8 -0
  17. package/dist/cli/force-unlock-network-command.js +129 -0
  18. package/dist/cli/index.d.ts +3 -0
  19. package/dist/cli/index.js +132 -0
  20. package/dist/cli/plan-command.d.ts +2 -0
  21. package/dist/cli/plan-command.js +100 -0
  22. package/dist/cli/poll-requests-command.d.ts +3 -0
  23. package/dist/cli/poll-requests-command.js +74 -0
  24. package/dist/cli/record-job-unlock-command.d.ts +11 -0
  25. package/dist/cli/record-job-unlock-command.js +78 -0
  26. package/dist/cli/resolve-node-command.d.ts +13 -0
  27. package/dist/cli/resolve-node-command.js +174 -0
  28. package/dist/cli/run-network-command.d.ts +14 -0
  29. package/dist/cli/run-network-command.js +418 -0
  30. package/dist/cli/status-command.d.ts +5 -0
  31. package/dist/cli/status-command.js +137 -0
  32. package/dist/cli/validate-command.d.ts +6 -0
  33. package/dist/cli/validate-command.js +17 -0
  34. package/dist/dag/descendants.d.ts +9 -0
  35. package/dist/dag/descendants.js +67 -0
  36. package/dist/dag/topological-sort.d.ts +7 -0
  37. package/dist/dag/topological-sort.js +32 -0
  38. package/dist/domain/business-key.d.ts +15 -0
  39. package/dist/domain/business-key.js +249 -0
  40. package/dist/domain/canonical-lock-key.d.ts +17 -0
  41. package/dist/domain/canonical-lock-key.js +60 -0
  42. package/dist/domain/canonical-record-key.d.ts +18 -0
  43. package/dist/domain/canonical-record-key.js +70 -0
  44. package/dist/domain/load-network.d.ts +4 -0
  45. package/dist/domain/load-network.js +47 -0
  46. package/dist/domain/network-definition.d.ts +47 -0
  47. package/dist/domain/network-definition.js +7 -0
  48. package/dist/domain/persistence-model.d.ts +198 -0
  49. package/dist/domain/persistence-model.js +2 -0
  50. package/dist/domain/run-aggregate.d.ts +3 -0
  51. package/dist/domain/run-aggregate.js +15 -0
  52. package/dist/domain/validate-network-path.d.ts +11 -0
  53. package/dist/domain/validate-network-path.js +33 -0
  54. package/dist/domain/validate-network.d.ts +3 -0
  55. package/dist/domain/validate-network.js +180 -0
  56. package/dist/executor/attempt-executor.d.ts +43 -0
  57. package/dist/executor/attempt-executor.js +236 -0
  58. package/dist/executor/job-log-reader.d.ts +37 -0
  59. package/dist/executor/job-log-reader.js +91 -0
  60. package/dist/executor/ksql-flow-cli.d.ts +86 -0
  61. package/dist/executor/ksql-flow-cli.js +161 -0
  62. package/dist/executor/preflight.d.ts +41 -0
  63. package/dist/executor/preflight.js +150 -0
  64. package/dist/executor/result-classifier.d.ts +69 -0
  65. package/dist/executor/result-classifier.js +237 -0
  66. package/dist/executor/run-subprocess.d.ts +64 -0
  67. package/dist/executor/run-subprocess.js +175 -0
  68. package/dist/io/input-baseline.d.ts +19 -0
  69. package/dist/io/input-baseline.js +214 -0
  70. package/dist/io/io-config.d.ts +6 -0
  71. package/dist/io/io-config.js +33 -0
  72. package/dist/io/io-path.d.ts +37 -0
  73. package/dist/io/io-path.js +279 -0
  74. package/dist/orchestration/archive-run.d.ts +53 -0
  75. package/dist/orchestration/archive-run.js +323 -0
  76. package/dist/orchestration/cancel-request.d.ts +18 -0
  77. package/dist/orchestration/cancel-request.js +67 -0
  78. package/dist/orchestration/ensure-run.d.ts +83 -0
  79. package/dist/orchestration/ensure-run.js +632 -0
  80. package/dist/orchestration/job-lock-audit.d.ts +24 -0
  81. package/dist/orchestration/job-lock-audit.js +123 -0
  82. package/dist/orchestration/orphan-attempt-adjudication.d.ts +39 -0
  83. package/dist/orchestration/orphan-attempt-adjudication.js +167 -0
  84. package/dist/orchestration/reconciliation.d.ts +41 -0
  85. package/dist/orchestration/reconciliation.js +526 -0
  86. package/dist/orchestration/resolve-node.d.ts +29 -0
  87. package/dist/orchestration/resolve-node.js +105 -0
  88. package/dist/orchestration/run-activity.d.ts +13 -0
  89. package/dist/orchestration/run-activity.js +14 -0
  90. package/dist/orchestration/sequential-scheduler.d.ts +79 -0
  91. package/dist/orchestration/sequential-scheduler.js +706 -0
  92. package/dist/orchestration/status.d.ts +91 -0
  93. package/dist/orchestration/status.js +171 -0
  94. package/dist/persistence/in-memory-repository.d.ts +41 -0
  95. package/dist/persistence/in-memory-repository.js +333 -0
  96. package/dist/persistence/kintone/client.d.ts +36 -0
  97. package/dist/persistence/kintone/client.js +93 -0
  98. package/dist/persistence/kintone/design-notes.d.ts +38 -0
  99. package/dist/persistence/kintone/design-notes.js +38 -0
  100. package/dist/persistence/kintone/repository.d.ts +44 -0
  101. package/dist/persistence/kintone/repository.js +836 -0
  102. package/dist/persistence/kintone/schema.d.ts +116 -0
  103. package/dist/persistence/kintone/schema.js +115 -0
  104. package/dist/persistence/network-lock-reader.d.ts +24 -0
  105. package/dist/persistence/network-lock-reader.js +43 -0
  106. package/dist/persistence/network-lock-recovery.d.ts +66 -0
  107. package/dist/persistence/network-lock-recovery.js +392 -0
  108. package/dist/persistence/network-lock.d.ts +97 -0
  109. package/dist/persistence/network-lock.js +408 -0
  110. package/dist/persistence/repository.d.ts +101 -0
  111. package/dist/persistence/repository.js +11 -0
  112. package/dist/persistence/state-transition.d.ts +4 -0
  113. package/dist/persistence/state-transition.js +25 -0
  114. package/dist/requests/flownet-child-client.d.ts +78 -0
  115. package/dist/requests/flownet-child-client.js +243 -0
  116. package/dist/requests/kintone-request-store.d.ts +44 -0
  117. package/dist/requests/kintone-request-store.js +202 -0
  118. package/dist/requests/poll-requests-config.d.ts +26 -0
  119. package/dist/requests/poll-requests-config.js +105 -0
  120. package/dist/requests/request-model.d.ts +57 -0
  121. package/dist/requests/request-model.js +305 -0
  122. package/dist/requests/request-poller.d.ts +33 -0
  123. package/dist/requests/request-poller.js +353 -0
  124. package/dist/requests/request-result.d.ts +18 -0
  125. package/dist/requests/request-result.js +215 -0
  126. package/dist/requests/start-request.d.ts +26 -0
  127. package/dist/requests/start-request.js +83 -0
  128. package/package.json +63 -0
  129. package/schemas/.gitkeep +1 -0
  130. package/schemas/network-definition.schema.json +121 -0
@@ -0,0 +1,14 @@
1
+ import { KINTONE_DATETIME_TRUNCATION_MS } from "../persistence/kintone/design-notes.js";
2
+ export function deriveRunActivity(input) {
3
+ if (["SUCCESS", "FAILED", "CANCELLED", "UNKNOWN"].includes(input.status))
4
+ return null;
5
+ if (input.cancelState === "REQUESTED" || input.cancelState === "ACCEPTED")
6
+ return "STOPPED";
7
+ if (input.lock !== null &&
8
+ input.invocationIds.includes(input.lock.owner_invocation_id) &&
9
+ input.nowMs <=
10
+ Date.parse(input.lock.lease_expires_at) + KINTONE_DATETIME_TRUNCATION_MS)
11
+ return "LIVE";
12
+ return input.startedAt === null ? "IDLE" : "INTERRUPTED";
13
+ }
14
+ //# sourceMappingURL=run-activity.js.map
@@ -0,0 +1,79 @@
1
+ import type { NetworkRun, NetworkRunStatus, NodeAttempt, NodeStateStatus, RunInvocation, RunInvocationStatus } from "../domain/persistence-model.js";
2
+ import type { AttemptExecutionOutcome, AttemptExecutorInput } from "../executor/attempt-executor.js";
3
+ import type { JobLogReader } from "../executor/job-log-reader.js";
4
+ import type { PersistenceRepository, Versioned } from "../persistence/repository.js";
5
+ export interface SchedulerLeaseMonitor {
6
+ canStartNewNode(): boolean;
7
+ canPersistResults(): boolean;
8
+ confirmLeaseForFinalWrite(): Promise<boolean>;
9
+ requiresNetworkLeaseInterruptedFinalization(): boolean;
10
+ markControlPlaneUnreachable?(): void;
11
+ /** A heartbeat is also the fencing read before an ordinary state write. */
12
+ tick?(): Promise<boolean>;
13
+ start?(): void;
14
+ stop?(): void;
15
+ }
16
+ export interface SchedulerAttemptExecutor {
17
+ execute(input: AttemptExecutorInput): Promise<AttemptExecutionOutcome>;
18
+ }
19
+ export interface SchedulerCloseInput {
20
+ readonly status: Exclude<RunInvocationStatus, "RUNNING">;
21
+ readonly resultCode: string;
22
+ readonly selectedNodeIds: readonly string[];
23
+ readonly preservedNodeIds: readonly string[];
24
+ readonly blockedNodeIds: readonly string[];
25
+ readonly reason?: string;
26
+ readonly persistInvocation?: boolean;
27
+ }
28
+ export interface SequentialSchedulerInput {
29
+ readonly run: Versioned<NetworkRun>;
30
+ readonly invocation: Versioned<RunInvocation>;
31
+ readonly bundleBytes: Uint8Array;
32
+ readonly repository: PersistenceRepository;
33
+ readonly attemptExecutor: SchedulerAttemptExecutor;
34
+ readonly jobLogReader?: Pick<JobLogReader, "findAttemptResult">;
35
+ readonly leaseMonitor: SchedulerLeaseMonitor;
36
+ readonly profile: string;
37
+ readonly configPath: string;
38
+ readonly executionRoot?: string;
39
+ readonly ioRoot?: string;
40
+ readonly close: (input: SchedulerCloseInput) => Promise<void>;
41
+ readonly now?: () => Date;
42
+ readonly uuid?: () => string;
43
+ readonly controlPlaneDrain?: {
44
+ readonly retryDelayMs?: number;
45
+ readonly nowMs?: () => number;
46
+ readonly sleep?: (delayMs: number) => Promise<void>;
47
+ };
48
+ }
49
+ export type SchedulerNodeDisposition = "EXECUTED" | "PRESERVED" | "BLOCKED" | "DEFERRED" | "EXCLUDED";
50
+ export interface SchedulerNodeResult {
51
+ readonly nodeId: string;
52
+ readonly disposition: SchedulerNodeDisposition;
53
+ readonly status: NodeStateStatus;
54
+ readonly attemptNo: number | null;
55
+ readonly resultCode: string | null;
56
+ }
57
+ export interface SequentialSchedulerSummary {
58
+ readonly nodeResults: readonly SchedulerNodeResult[];
59
+ readonly aggregateStatus: NetworkRunStatus;
60
+ readonly invocationStatus: Exclude<RunInvocationStatus, "RUNNING">;
61
+ readonly invocationResultCode: string;
62
+ readonly selectedNodeIds: readonly string[];
63
+ readonly preservedNodeIds: readonly string[];
64
+ readonly blockedNodeIds: readonly string[];
65
+ readonly retryBrakeNodeIds: readonly string[];
66
+ readonly reconciliationRequired: boolean;
67
+ }
68
+ export declare class SchedulerLeaseInterruptedError extends Error {
69
+ readonly reconciliationRequired: boolean;
70
+ readonly code = "NETWORK_LEASE_INTERRUPTED";
71
+ constructor(reconciliationRequired: boolean, options?: ErrorOptions);
72
+ }
73
+ /** FN-10 Phase 1 scheduler: one invocation, one node at a time. */
74
+ export declare function runSequentialScheduler(input: SequentialSchedulerInput): Promise<SequentialSchedulerSummary>;
75
+ export declare function retryBrakeForNode(attempts: readonly Versioned<NodeAttempt>[], nodeId: string): {
76
+ failureKind: string;
77
+ count: number;
78
+ } | null;
79
+ //# sourceMappingURL=sequential-scheduler.d.ts.map