@cosmicdrift/kumiko-framework 0.336.1 → 0.338.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/dist/api/api-constants.d.ts +1 -0
- package/dist/api/api-constants.js +9 -0
- package/dist/api/auth-middleware.js +45 -21
- package/dist/api/auth-routes.d.ts +1 -0
- package/dist/api/auth-routes.js +20 -0
- package/dist/api/redis-sse-broker.d.ts +1 -0
- package/dist/api/redis-sse-broker.js +4 -5
- package/dist/api/server.js +14 -4
- package/dist/api/sse-route.js +14 -1
- package/dist/bun-db/query.js +6 -4
- package/dist/compliance/sub-processors.js +10 -1
- package/dist/crypto/kek-source.js +1 -0
- package/dist/db/blind-index-cleanup.d.ts +1 -0
- package/dist/db/blind-index-cleanup.js +12 -1
- package/dist/db/event-store-executor-read.js +30 -4
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/queries/event-consumer.d.ts +2 -2
- package/dist/db/queries/event-consumer.js +5 -4
- package/dist/db/queries/event-store.js +6 -6
- package/dist/db/queries/projection-rebuild.js +4 -4
- package/dist/db/queries/seed-context.js +6 -6
- package/dist/db/tenant-db.js +16 -8
- package/dist/derivatives/derivatives-context.js +5 -2
- package/dist/engine/boot-validator/access-declarations.js +13 -7
- package/dist/engine/boot-validator/entity-handler.d.ts +1 -0
- package/dist/engine/boot-validator/entity-handler.js +26 -0
- package/dist/engine/boot-validator/index.js +2 -1
- package/dist/engine/boot-validator/pii-retention.js +11 -1
- package/dist/engine/boot-validator/projection-list-screens.d.ts +1 -1
- package/dist/engine/boot-validator/projection-list-screens.js +13 -0
- package/dist/engine/boot-validator/screens.js +12 -0
- package/dist/engine/build-config-feature-schema.js +4 -0
- package/dist/engine/config-helpers.d.ts +2 -1
- package/dist/engine/config-helpers.js +1 -0
- package/dist/engine/define-feature.js +1 -0
- package/dist/engine/extensions/escape-hatch-usage.js +3 -1
- package/dist/engine/feature-ast/extractors/hooks.js +7 -1
- package/dist/engine/feature-ast/extractors/index.d.ts +1 -1
- package/dist/engine/feature-ast/extractors/index.js +1 -1
- package/dist/engine/feature-ast/extractors/jobs-routes.js +6 -2
- package/dist/engine/feature-ast/extractors/round3.d.ts +2 -1
- package/dist/engine/feature-ast/extractors/round3.js +11 -0
- package/dist/engine/feature-ast/extractors/shared.js +1 -3
- package/dist/engine/feature-ast/index.d.ts +1 -1
- package/dist/engine/feature-ast/parse.js +3 -1
- package/dist/engine/feature-ast/patch.d.ts +3 -0
- package/dist/engine/feature-ast/patch.js +8 -11
- package/dist/engine/feature-ast/patcher.d.ts +6 -1
- package/dist/engine/feature-ast/patcher.js +3 -0
- package/dist/engine/feature-ast/pattern-change-schema.d.ts +630 -1
- package/dist/engine/feature-ast/pattern-change-schema.js +19 -2
- package/dist/engine/feature-ast/patterns.d.ts +8 -2
- package/dist/engine/feature-ast/patterns.js +1 -0
- package/dist/engine/feature-ast/render.js +9 -0
- package/dist/engine/feature-builder-state.d.ts +2 -1
- package/dist/engine/feature-builder-state.js +1 -0
- package/dist/engine/feature-config-events-jobs.d.ts +4 -1
- package/dist/engine/feature-config-events-jobs.js +25 -1
- package/dist/engine/feature-manifest.d.ts +1 -0
- package/dist/engine/feature-manifest.js +1 -0
- package/dist/engine/feature-ui-extensions.js +24 -21
- package/dist/engine/index.d.ts +1 -1
- package/dist/engine/pattern-library/library.js +2 -1
- package/dist/engine/pattern-library/static-schemas.d.ts +1 -0
- package/dist/engine/pattern-library/static-schemas.js +47 -4
- package/dist/engine/registry-facade.js +7 -0
- package/dist/engine/registry-ingest.js +7 -0
- package/dist/engine/registry-state.d.ts +2 -1
- package/dist/engine/registry-state.js +1 -0
- package/dist/engine/registry-validate.d.ts +1 -1
- package/dist/engine/registry-validate.js +39 -17
- package/dist/engine/registry.js +2 -2
- package/dist/engine/types/index.d.ts +3 -3
- package/dist/engine/types/index.js +1 -1
- package/dist/engine/types/screen.d.ts +1 -1
- package/dist/engine/types/screen.js +1 -1
- package/dist/errors/classes.d.ts +5 -0
- package/dist/errors/classes.js +15 -0
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/i18n/required-surface-keys.js +3 -5
- package/dist/jobs/job-runner.js +2 -1
- package/dist/migrations/pending-rebuilds.d.ts +2 -0
- package/dist/migrations/pending-rebuilds.js +3 -0
- package/dist/pipeline/dispatch-query.js +3 -5
- package/dist/pipeline/dispatch-shared.js +32 -5
- package/dist/pipeline/dispatch-stream.js +2 -4
- package/dist/pipeline/dispatch-write.js +2 -4
- package/dist/pipeline/event-dispatcher-delivery.d.ts +0 -1
- package/dist/pipeline/event-dispatcher-delivery.js +1 -8
- package/dist/pipeline/event-dispatcher.js +16 -25
- package/dist/pipeline/handler-access-error.d.ts +3 -0
- package/dist/pipeline/handler-access-error.js +17 -0
- package/dist/pipeline/irreversible-operation-gate.js +9 -3
- package/dist/pipeline/member-read-only-transaction.js +8 -3
- package/dist/pipeline/system-hooks.js +7 -1
- package/dist/pipeline/system-identity-switch.js +11 -8
- package/dist/search/meilisearch-adapter.js +0 -2
- package/dist/stack/push-entity-projection-tables.js +5 -3
- package/dist/stack/redis.d.ts +1 -0
- package/dist/stack/redis.js +11 -2
- package/dist/stack/table-helpers.d.ts +3 -1
- package/dist/stack/table-helpers.js +9 -7
- package/dist/stack/test-stack.js +1 -7
- package/dist/testing/handler-context.js +3 -6
- package/dist/ui-types/index.d.ts +1 -1
- package/dist/ui-types/index.js +1 -1
- package/dist/upgrade-cli.js +29 -2
- package/package.json +4 -4
- package/src/changes.json +153 -0
- package/src/scripts/codemod/collect-source-files.ts +48 -0
- package/src/scripts/codemod/migrate-cross-tenant.ts +3 -23
- package/src/scripts/codemod/migrate-db-raw.ts +6 -23
- package/src/scripts/codemod/migrate-open-to-all.ts +4 -24
- package/src/scripts/codemod/unprocessable-error-details-reason.ts +47 -3
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
// Usage:
|
|
7
7
|
// bun scripts/codemod/migrate-open-to-all.ts [--dry-run] [--test-reason "<text>"] <path...>
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import { join, resolve } from "node:path";
|
|
9
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
11
10
|
import {
|
|
12
11
|
Node,
|
|
13
12
|
type ObjectLiteralExpression,
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
type PropertyAssignment,
|
|
16
15
|
SyntaxKind,
|
|
17
16
|
} from "ts-morph";
|
|
17
|
+
import { collectSourceFiles } from "./collect-source-files.js";
|
|
18
18
|
|
|
19
19
|
const DEFAULT_TEST_REASON = "test handler callable by any signed-in test user";
|
|
20
20
|
|
|
@@ -164,28 +164,8 @@ function isMigratableFile(name: string): boolean {
|
|
|
164
164
|
return /\.(ts|tsx)$/.test(name);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
if (name === "node_modules") continue;
|
|
170
|
-
const full = join(dir, name);
|
|
171
|
-
const stat = statSync(full);
|
|
172
|
-
if (stat.isDirectory()) {
|
|
173
|
-
walkDir(full, out);
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
if (isMigratableFile(name)) out.push(full);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function collectFiles(paths: string[]): string[] {
|
|
181
|
-
const files: string[] = [];
|
|
182
|
-
for (const p of paths) {
|
|
183
|
-
const abs = resolve(p);
|
|
184
|
-
const stat = statSync(abs);
|
|
185
|
-
if (stat.isDirectory()) walkDir(abs, files);
|
|
186
|
-
else if (isMigratableFile(abs)) files.push(abs);
|
|
187
|
-
}
|
|
188
|
-
return files;
|
|
167
|
+
export function collectFiles(paths: string[]): string[] {
|
|
168
|
+
return collectSourceFiles(paths, { isMigratableFile });
|
|
189
169
|
}
|
|
190
170
|
|
|
191
171
|
// Remaining manual sites still fail boot validation, so upgrade-cli must not
|
|
@@ -51,14 +51,20 @@ function findTargetFiles(rootDir: string): string[] {
|
|
|
51
51
|
return files.sort();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
const NAMESPACE_IMPORT = "*";
|
|
55
|
+
|
|
54
56
|
type ImportedBinding = { readonly importedName: string; readonly moduleSpecifier: string };
|
|
55
57
|
|
|
56
|
-
/** Local-name -> where it's imported from, for every named value import in the file. */
|
|
58
|
+
/** Local-name -> where it's imported from, for every named or namespace value import in the file. */
|
|
57
59
|
function collectImportedNames(sourceFile: SourceFile): Map<string, ImportedBinding> {
|
|
58
60
|
const bindings = new Map<string, ImportedBinding>();
|
|
59
61
|
for (const imp of sourceFile.getImportDeclarations()) {
|
|
60
62
|
if (imp.isTypeOnly()) continue;
|
|
61
63
|
const moduleSpecifier = imp.getModuleSpecifierValue();
|
|
64
|
+
const namespaceImport = imp.getNamespaceImport();
|
|
65
|
+
if (namespaceImport) {
|
|
66
|
+
bindings.set(namespaceImport.getText(), { importedName: NAMESPACE_IMPORT, moduleSpecifier });
|
|
67
|
+
}
|
|
62
68
|
for (const spec of imp.getNamedImports()) {
|
|
63
69
|
if (spec.isTypeOnly()) continue;
|
|
64
70
|
const importedName = spec.getName();
|
|
@@ -264,6 +270,17 @@ const FAIL_UNPROCESSABLE_CALL: MigratableCall = {
|
|
|
264
270
|
process: processFailUnprocessableCall,
|
|
265
271
|
};
|
|
266
272
|
|
|
273
|
+
function isKumikoNamespaceReceiver(
|
|
274
|
+
receiver: Node,
|
|
275
|
+
importedNames: ReadonlyMap<string, ImportedBinding>,
|
|
276
|
+
): boolean {
|
|
277
|
+
if (!Node.isIdentifier(receiver)) return false;
|
|
278
|
+
const binding = importedNames.get(receiver.getText());
|
|
279
|
+
return (
|
|
280
|
+
binding?.importedName === NAMESPACE_IMPORT && KUMIKO_MODULE_RE.test(binding.moduleSpecifier)
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
267
284
|
function migrateCallSite(
|
|
268
285
|
sourceFile: SourceFile,
|
|
269
286
|
importedNames: ReadonlyMap<string, ImportedBinding>,
|
|
@@ -272,11 +289,28 @@ function migrateCallSite(
|
|
|
272
289
|
skips: SkipEntry[],
|
|
273
290
|
): boolean {
|
|
274
291
|
const callee = site.getExpression();
|
|
275
|
-
if (!Node.isIdentifier(callee)) return false;
|
|
276
|
-
const localName = callee.getText();
|
|
277
292
|
const line = site.getStartLineNumber();
|
|
278
293
|
const file = sourceFile.getFilePath();
|
|
279
294
|
|
|
295
|
+
if (!Node.isIdentifier(callee)) {
|
|
296
|
+
const unresolvedCallee = callee.getText();
|
|
297
|
+
const resolvedViaNamespace =
|
|
298
|
+
Node.isPropertyAccessExpression(callee) &&
|
|
299
|
+
callee.getName() === target.exportName &&
|
|
300
|
+
isKumikoNamespaceReceiver(callee.getExpression(), importedNames);
|
|
301
|
+
if (resolvedViaNamespace) return processCall(site, target, skips, file, line);
|
|
302
|
+
if (unresolvedCallee.endsWith(target.exportName)) {
|
|
303
|
+
skips.push({
|
|
304
|
+
file,
|
|
305
|
+
line,
|
|
306
|
+
note: `${target.exportName} is called through "${unresolvedCallee}", which is not a @cosmicdrift/kumiko-* namespace import this codemod can resolve`,
|
|
307
|
+
kind: "manual",
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
const localName = callee.getText();
|
|
313
|
+
|
|
280
314
|
const binding = importedNames.get(localName);
|
|
281
315
|
if (binding?.importedName !== target.exportName) {
|
|
282
316
|
if (localName !== target.exportName) return false;
|
|
@@ -296,6 +330,16 @@ function migrateCallSite(
|
|
|
296
330
|
return false;
|
|
297
331
|
}
|
|
298
332
|
|
|
333
|
+
return processCall(site, target, skips, file, line);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function processCall(
|
|
337
|
+
site: Node & { getArguments(): Node[] },
|
|
338
|
+
target: MigratableCall,
|
|
339
|
+
skips: SkipEntry[],
|
|
340
|
+
file: string,
|
|
341
|
+
line: number,
|
|
342
|
+
): boolean {
|
|
299
343
|
const outcome = target.process(site.getArguments(), (note, kind) =>
|
|
300
344
|
skips.push({ file, line, note, kind }),
|
|
301
345
|
);
|