@cosmicdrift/kumiko-framework 0.320.0 → 0.321.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/package.json +4 -4
- package/src/__tests__/schema-cli.integration.test.ts +11 -0
- package/src/__tests__/upgrade-cli.test.ts +50 -3
- package/src/api/__tests__/client-ip.test.ts +25 -0
- package/src/api/__tests__/extra-routes.integration.test.ts +42 -0
- package/src/api/client-ip.ts +27 -0
- package/src/api/extra-route.ts +3 -0
- package/src/api/index.ts +2 -0
- package/src/api/server.ts +3 -1
- package/src/changes.json +48 -0
- package/src/db/queries/event-store-transfer.ts +73 -0
- package/src/engine/__tests__/steps-webhook-send.test.ts +2 -2
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/alias-reexport.ts +1 -0
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/cycle-a.ts +1 -0
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/cycle-b.ts +1 -0
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/entry.ts +3 -0
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/local-rebind.ts +3 -0
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/origin.ts +1 -0
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/star-barrel.ts +1 -0
- package/src/engine/feature-ast/__tests__/parse.test.ts +4 -4
- package/src/engine/feature-ast/__tests__/resolve-import.test.ts +138 -0
- package/src/engine/feature-ast/extractors/index.ts +4 -0
- package/src/engine/feature-ast/extractors/resolve-import.ts +187 -0
- package/src/engine/feature-ast/extractors/shared.ts +26 -19
- package/src/engine/feature-ast/parse.ts +13 -20
- package/src/engine/steps/webhook-send.ts +4 -2
- package/src/event-store/__tests__/transfer.integration.test.ts +236 -0
- package/src/event-store/index.ts +6 -0
- package/src/event-store/transfer.ts +84 -0
- package/src/pipeline/multi-stream-apply-context.ts +4 -0
- package/src/schema-cli.ts +5 -1
- package/src/upgrade-cli.ts +58 -18
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DerivativesContext } from "@cosmicdrift/kumiko-types/derivatives-types";
|
|
2
2
|
import type { MultiStreamApplyContext } from "@cosmicdrift/kumiko-types/multi-stream-apply-context-types";
|
|
3
|
+
import type { SecretsContext } from "@cosmicdrift/kumiko-types/secrets-types";
|
|
3
4
|
import type { DbRunner } from "../db/connection";
|
|
4
5
|
import type { AppendEventArgs, AppendEventFn, Registry, TenantId } from "../engine/types";
|
|
5
6
|
import { loadAggregate, loadAggregateAsOf } from "../event-store/event-store";
|
|
@@ -32,6 +33,8 @@ export type MultiStreamApplyContextDeps = {
|
|
|
32
33
|
readonly files?: FileContext;
|
|
33
34
|
// Same DerivativesContext the outer AppContext carries — mirrors `files`.
|
|
34
35
|
readonly derivatives?: DerivativesContext;
|
|
36
|
+
// Same SecretsContext the outer AppContext carries, mirrors `files`.
|
|
37
|
+
readonly secrets?: SecretsContext;
|
|
35
38
|
};
|
|
36
39
|
|
|
37
40
|
export function createMultiStreamApplyContext(
|
|
@@ -41,6 +44,7 @@ export function createMultiStreamApplyContext(
|
|
|
41
44
|
registry: deps.registry,
|
|
42
45
|
...(deps.files ? { files: deps.files } : {}),
|
|
43
46
|
...(deps.derivatives ? { derivatives: deps.derivatives } : {}),
|
|
47
|
+
...(deps.secrets ? { secrets: deps.secrets } : {}),
|
|
44
48
|
appendEvent: (async (args: AppendEventArgs) => {
|
|
45
49
|
await appendDomainEventCore(
|
|
46
50
|
{
|
package/src/schema-cli.ts
CHANGED
|
@@ -115,7 +115,11 @@ export async function runSchemaCli(
|
|
|
115
115
|
// migration, since the crashed process still records the migration as
|
|
116
116
|
// applied and the rebuild is never retried.
|
|
117
117
|
await ensureTemporalPolyfill();
|
|
118
|
-
|
|
118
|
+
// `--help`/`-h`/`help` fall through to the same "no subcommand" usage
|
|
119
|
+
// branch below (undefined) — a real request for help, not a typo that
|
|
120
|
+
// should fail loud like an unrecognized subcommand does.
|
|
121
|
+
const rawSub = argv[0];
|
|
122
|
+
const sub = rawSub === "--help" || rawSub === "-h" || rawSub === "help" ? undefined : rawSub;
|
|
119
123
|
const schemaFile = resolvePath(appCwd, "kumiko/schema.ts");
|
|
120
124
|
const migrationsDir = resolvePath(appCwd, "kumiko/migrations");
|
|
121
125
|
|
package/src/upgrade-cli.ts
CHANGED
|
@@ -100,22 +100,49 @@ function collectChangelogs(featuresDir: string): ChangelogEntry[] {
|
|
|
100
100
|
return entries;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
//
|
|
104
|
-
// changes.json
|
|
105
|
-
export function
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
|
|
103
|
+
// bundled-features is excluded: findFeaturesDirs collects it per feature
|
|
104
|
+
// (src/<feature>/changes.json), every other package has one src/changes.json.
|
|
105
|
+
export function findPackageChangelogFiles(cwd: string): string[] {
|
|
106
|
+
const isFrameworkRepo = existsSync(join(cwd, "packages/framework"));
|
|
107
|
+
if (isFrameworkRepo) {
|
|
108
|
+
const packagesDir = join(cwd, "packages");
|
|
109
|
+
return readdirSync(packagesDir, { withFileTypes: true })
|
|
110
|
+
.filter((d) => d.isDirectory() && d.name !== "bundled-features")
|
|
111
|
+
.map((d) => join(packagesDir, d.name, "src", "changes.json"))
|
|
112
|
+
.filter((p) => existsSync(p));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Consumer/app repo: walk up (same 10-level cap as the other node_modules
|
|
116
|
+
// walks) collecting every hoisted @cosmicdrift package's changes.json.
|
|
117
|
+
// Dedupe by package dir name — the nearest node_modules to cwd wins, same
|
|
118
|
+
// precedence as findCodemodScriptsRoot/readPackageVersion. realpath also
|
|
119
|
+
// dedupes a workspace symlink that resolves to an already-collected file.
|
|
120
|
+
const files: string[] = [];
|
|
121
|
+
const seenNames = new Set<string>();
|
|
122
|
+
const seenRealPaths = new Set<string>();
|
|
109
123
|
let dir = cwd;
|
|
110
124
|
for (let i = 0; i < 10; i++) {
|
|
111
|
-
const
|
|
112
|
-
if (existsSync(
|
|
125
|
+
const scopeDir = join(dir, "node_modules/@cosmicdrift");
|
|
126
|
+
if (existsSync(scopeDir)) {
|
|
127
|
+
const pkgNames = readdirSync(scopeDir, { withFileTypes: true })
|
|
128
|
+
.filter((d) => d.isDirectory() && d.name !== "kumiko-bundled-features")
|
|
129
|
+
.map((d) => d.name);
|
|
130
|
+
for (const name of pkgNames) {
|
|
131
|
+
if (seenNames.has(name)) continue;
|
|
132
|
+
const changelogPath = join(scopeDir, name, "src", "changes.json");
|
|
133
|
+
if (!existsSync(changelogPath)) continue;
|
|
134
|
+
seenNames.add(name);
|
|
135
|
+
const realPath = realpathSync(changelogPath);
|
|
136
|
+
if (seenRealPaths.has(realPath)) continue;
|
|
137
|
+
seenRealPaths.add(realPath);
|
|
138
|
+
files.push(changelogPath);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
113
141
|
const parent = join(dir, "..");
|
|
114
142
|
if (parent === dir) break;
|
|
115
143
|
dir = parent;
|
|
116
144
|
}
|
|
117
|
-
|
|
118
|
-
return null;
|
|
145
|
+
return files;
|
|
119
146
|
}
|
|
120
147
|
|
|
121
148
|
export function findFeaturesDirs(cwd: string): string[] {
|
|
@@ -129,10 +156,9 @@ export function findFeaturesDirs(cwd: string): string[] {
|
|
|
129
156
|
// Detected by presence of changes.json, not a package-name prefix — a
|
|
130
157
|
// prefix heuristic silently stops matching once packages are renamed or a
|
|
131
158
|
// differently-named package is added (fw#1605). Skipped inside the
|
|
132
|
-
// framework repo itself (packages/framework present):
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
// otherwise get double-counted as one here.
|
|
159
|
+
// framework repo itself (packages/framework present): every package's own
|
|
160
|
+
// changes.json is already collected via findPackageChangelogFiles, and
|
|
161
|
+
// would otherwise get double-counted as one here.
|
|
136
162
|
const isFrameworkRepo = existsSync(join(cwd, "packages/framework"));
|
|
137
163
|
const entDir = join(cwd, "packages");
|
|
138
164
|
if (!isFrameworkRepo && existsSync(entDir)) {
|
|
@@ -459,6 +485,16 @@ async function applyCodemods(
|
|
|
459
485
|
return 0;
|
|
460
486
|
}
|
|
461
487
|
|
|
488
|
+
const UPGRADE_USAGE = `kumiko-upgrade [--from <version>] [--dir <path>] [--json] [--verbose] [--apply [--dry-run]]
|
|
489
|
+
|
|
490
|
+
--from <version> filter baseline version (default: last applied marker, or the installed version)
|
|
491
|
+
--dir <path> target directory to check/apply against (default: cwd)
|
|
492
|
+
--json machine-readable output
|
|
493
|
+
--verbose include full migration details for each pending entry
|
|
494
|
+
--apply run codemods for pending breaking changes and write the upgrade marker
|
|
495
|
+
--dry-run with --apply, report what would run without writing anything
|
|
496
|
+
--help, -h print this usage and exit`;
|
|
497
|
+
|
|
462
498
|
// kumiko-lint-ignore complexity-budget CLI orchestration moved from bin/commands/upgrade.ts — same branching surface, shared by kumiko upgrade + published kumiko-upgrade bin
|
|
463
499
|
export async function runUpgradeCli(
|
|
464
500
|
argv: readonly string[],
|
|
@@ -466,6 +502,10 @@ export async function runUpgradeCli(
|
|
|
466
502
|
out: UpgradeCliOut,
|
|
467
503
|
options?: { readonly repoRoot?: string },
|
|
468
504
|
): Promise<number> {
|
|
505
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
506
|
+
out.log(UPGRADE_USAGE);
|
|
507
|
+
return 0;
|
|
508
|
+
}
|
|
469
509
|
// Standalone CLI entry, not booted via runProdApp/runDevApp — Temporal needs an explicit polyfill here.
|
|
470
510
|
await ensureTemporalPolyfill();
|
|
471
511
|
const repoRoot = options?.repoRoot ?? cwd;
|
|
@@ -513,8 +553,8 @@ export async function runUpgradeCli(
|
|
|
513
553
|
}
|
|
514
554
|
|
|
515
555
|
const featuresDirs = findFeaturesDirs(cwd);
|
|
516
|
-
const
|
|
517
|
-
if (featuresDirs.length === 0 &&
|
|
556
|
+
const packageChangelogFiles = findPackageChangelogFiles(cwd);
|
|
557
|
+
if (featuresDirs.length === 0 && packageChangelogFiles.length === 0) {
|
|
518
558
|
out.err("");
|
|
519
559
|
out.err(" Could not find bundled-features directory.");
|
|
520
560
|
out.err(" Run from framework/enterprise repo or an app with node_modules.");
|
|
@@ -526,8 +566,8 @@ export async function runUpgradeCli(
|
|
|
526
566
|
for (const dir of featuresDirs) {
|
|
527
567
|
allEntries.push(...collectChangelogs(dir));
|
|
528
568
|
}
|
|
529
|
-
|
|
530
|
-
allEntries.push(...readChangelogFile(
|
|
569
|
+
for (const changelogFile of packageChangelogFiles) {
|
|
570
|
+
allEntries.push(...readChangelogFile(changelogFile));
|
|
531
571
|
}
|
|
532
572
|
const pending = sortEntries(filterEntriesAfter(allEntries, currentVersion));
|
|
533
573
|
|