@cosmicdrift/kumiko-framework 0.350.0 → 0.352.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 (45) hide show
  1. package/dist/bun-db/query.js +3 -3
  2. package/dist/db/dialect.d.ts +1 -1
  3. package/dist/db/dialect.js +4 -3
  4. package/dist/db/located-timestamp.js +1 -1
  5. package/dist/db/queries/seed-context.d.ts +17 -0
  6. package/dist/db/queries/seed-context.js +26 -0
  7. package/dist/db/table-builder.d.ts +5 -5
  8. package/dist/engine/boot-validator/entity-handler.d.ts +1 -0
  9. package/dist/engine/boot-validator/entity-handler.js +17 -0
  10. package/dist/engine/boot-validator/index.js +2 -1
  11. package/dist/engine/boot-validator/query-output-columns.js +3 -3
  12. package/dist/engine/boot-validator/query-refs.js +11 -7
  13. package/dist/engine/boot-validator/screens.js +89 -9
  14. package/dist/engine/build-app-schema.js +3 -0
  15. package/dist/engine/steps/_duration-utils.js +1 -1
  16. package/dist/engine/types/index.d.ts +1 -1
  17. package/dist/es-ops/context.js +15 -1
  18. package/dist/es-ops/index.d.ts +1 -1
  19. package/dist/es-ops/types.d.ts +20 -0
  20. package/dist/event-store/event-store.d.ts +1 -0
  21. package/dist/event-store/event-store.js +4 -17
  22. package/dist/event-store/index.d.ts +1 -0
  23. package/dist/event-store/index.js +1 -0
  24. package/dist/event-store/tenant-db-append.d.ts +8 -0
  25. package/dist/event-store/tenant-db-append.js +16 -0
  26. package/dist/i18n/required-surface-keys.js +7 -1
  27. package/dist/pipeline/dispatch-batch.js +5 -1
  28. package/dist/pipeline/dispatch-write.js +36 -82
  29. package/dist/pipeline/event-dispatcher-delivery.d.ts +1 -0
  30. package/dist/pipeline/event-dispatcher-delivery.js +3 -10
  31. package/dist/pipeline/pre-handler-gates.d.ts +9 -0
  32. package/dist/pipeline/pre-handler-gates.js +104 -0
  33. package/dist/pipeline/pre-transaction-reservations.d.ts +12 -3
  34. package/dist/pipeline/pre-transaction-reservations.js +34 -21
  35. package/dist/rate-limit/resolver.js +3 -6
  36. package/dist/time/legacy-date.d.ts +1 -1
  37. package/dist/time/legacy-date.js +1 -1
  38. package/dist/time/polyfill.d.ts +1 -0
  39. package/dist/time/polyfill.js +14 -33
  40. package/dist/time/tz-context.d.ts +1 -1
  41. package/dist/time/tz-context.js +8 -11
  42. package/dist/ui-types/index.d.ts +1 -1
  43. package/dist/upgrade-cli.js +39 -35
  44. package/package.json +4 -4
  45. package/src/changes.json +27 -0
@@ -9,7 +9,7 @@ export type { BooleanFieldDef, DateFieldDef, EmbeddedDerivedCellDef, EntityDefin
9
9
  export type { AccessRule, OpenToAllAccessRule, OpenToAllDeclaration, OpenToAllPersonalData, RoleAccessPersonalData, RoleAccessRule, } from "../engine/types/handlers.js";
10
10
  export { isOpenToAllGranted, isUiAccessGranted } from "../engine/types/handlers.js";
11
11
  export type { IconKey, NavDefinition, NavIconKey } from "../engine/types/nav.js";
12
- export type { ActionFormFooterAction, ActionFormRedirect, ActionFormScreenDefinition, ConfigEditScreenDefinition, CustomScreenDefinition, CustomScreenRoute, DashboardChartKind, DashboardChartPanel, DashboardChartTone, DashboardCustomPanel, DashboardDateParam, DashboardFeedPanel, DashboardFilterDefinition, DashboardI18nText, DashboardListPanel, DashboardMoneyParam, DashboardPanelDefinition, DashboardPanelEmptyState, DashboardPanelQueryOptions, DashboardPanelSpan, DashboardPanelVisibility, DashboardProgressListPanel, DashboardScopeDefinition, DashboardScreenDefinition, DashboardScreenPanel, DashboardStatGroupPanel, DashboardStatPanel, DashboardText, DashboardTextParam, DashboardTimeRangeDefinition, DashboardValueFormat, EditExtensionSection, EditFieldSpec, EditFieldsSection, EditLayout, EditRelatedListSection, EditSectionSpec, EditWriteFormSection, EntityEditScreenDefinition, EntityListExpandableRow, EntityListFacetConfig, EntityListFacetExtraOption, EntityListScreenDefinition, FieldCondition, FieldIconKey, FieldRenderer, FormWidth, ListBadgeTone, ListColumnDisplay, ListColumnSpec, ListFacetSpec, ListSortSpec, MetricNavigate, MetricSpec, PlatformComponent, ProjectionDetailScreenDefinition, ProjectionListScreenDefinition, RecordHeaderSubtitlePart, RelatedListGroupBy, RelatedListRowTone, RelatedListToolbarAction, RowAction, RowActionDisplay, RowActionDrawer, RowActionMode, RowActionNavigate, RowActionWriteHandler, RowFieldExtractor, ScreenDefinition, ScreenFilter, ScreenFilterOp, ScreenSlots, SecretMintConfirmStep, SecretMintScreenDefinition, SecretReveal, SecretRevealField, SecretsEditScreenDefinition, SecretsEditSection, ToolbarAction, } from "../engine/types/screen.js";
12
+ export type { ActionFormFooterAction, ActionFormRedirect, ActionFormScreenDefinition, ConfigEditScreenDefinition, CustomScreenDefinition, CustomScreenRoute, DashboardChartKind, DashboardChartMarkerKind, DashboardChartPanel, DashboardChartRangeOption, DashboardChartRanges, DashboardChartTone, DashboardCustomPanel, DashboardDateParam, DashboardFeedPanel, DashboardFilterDefinition, DashboardI18nText, DashboardListPanel, DashboardMoneyParam, DashboardPanelDefinition, DashboardPanelEmptyState, DashboardPanelGate, DashboardPanelQueryOptions, DashboardPanelSpan, DashboardPanelVisibility, DashboardProgressListPanel, DashboardScopeDefinition, DashboardScreenDefinition, DashboardScreenPanel, DashboardStatGroupPanel, DashboardStatPanel, DashboardText, DashboardTextParam, DashboardTimeRangeDefinition, DashboardValueFormat, EditExtensionSection, EditFieldSpec, EditFieldsSection, EditLayout, EditRelatedListSection, EditSectionSpec, EditWriteFormSection, EntityEditScreenDefinition, EntityListExpandableRow, EntityListFacetConfig, EntityListFacetExtraOption, EntityListScreenDefinition, FieldCondition, FieldIconKey, FieldRenderer, FormWidth, ListBadgeTone, ListColumnDisplay, ListColumnSpec, ListFacetSpec, ListSortSpec, MetricNavigate, MetricSpec, PlatformComponent, ProjectionDetailScreenDefinition, ProjectionListScreenDefinition, RecordHeaderSubtitlePart, RelatedListGroupBy, RelatedListRowTone, RelatedListToolbarAction, RowAction, RowActionDisplay, RowActionDrawer, RowActionMode, RowActionNavigate, RowActionWriteHandler, RowFieldExtractor, ScreenDefinition, ScreenFilter, ScreenFilterOp, ScreenSlots, SecretMintConfirmStep, SecretMintScreenDefinition, SecretReveal, SecretRevealField, SecretsEditScreenDefinition, SecretsEditSection, ToolbarAction, } from "../engine/types/screen.js";
13
13
  export { metricField, relatedListGroupHeaderLabel, relatedListGroupKey, } from "../engine/types/screen.js";
14
14
  export type { TargetRef } from "../engine/types/target-ref.js";
15
15
  export type { TreeAction, TreeNode, TreeNodeState } from "../engine/types/tree-node.js";
@@ -6,45 +6,42 @@ import { compareVersions, filterEntriesAfter, parseFeatureChangelog, sortEntries
6
6
  import { ensureTemporalPolyfill } from "./time/index.js";
7
7
  const SEMVER_RE = /^\d+\.\d+\.\d+$/;
8
8
  const CODEMOD_SUBDIR = "scripts/codemod";
9
- function readPackageVersion(cwd, pkgName, repoLocalPath) {
10
- // Walk up from cwd to find node_modules/@cosmicdrift/<pkgName>/package.json
11
- // (handles bun workspace hoisting where packages live in parent node_modules)
12
- let dir = cwd;
13
- for (let i = 0; i < 10; i++) {
14
- const nmPath = join(dir, `node_modules/@cosmicdrift/${pkgName}/package.json`);
15
- if (existsSync(nmPath)) {
16
- try {
17
- const pkg = JSON.parse(readFileSync(nmPath, "utf-8"));
18
- return pkg.version ?? null;
19
- }
20
- catch {
21
- return null;
22
- }
23
- }
24
- const parent = join(dir, "..");
25
- if (parent === dir)
26
- break;
27
- dir = parent;
28
- }
29
- // Fallback: repo-local package root
30
- const repoPath = join(cwd, repoLocalPath);
31
- if (existsSync(repoPath)) {
32
- try {
33
- const pkg = JSON.parse(readFileSync(repoPath, "utf-8"));
34
- return pkg.version ?? null;
35
- }
36
- catch {
9
+ function readPackageJsonVersion(packageJsonPath) {
10
+ if (!existsSync(packageJsonPath))
11
+ return null;
12
+ try {
13
+ const pkg = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
14
+ if (typeof pkg !== "object" || pkg === null || !("version" in pkg))
37
15
  return null;
38
- }
16
+ return typeof pkg.version === "string" ? pkg.version : null;
39
17
  }
40
- return null;
18
+ catch {
19
+ return null;
20
+ }
21
+ }
22
+ // bun.lock pins transitive packages too, so a repo that only depends on
23
+ // kumiko-cli/-guards still records the bundled-features version it resolved.
24
+ function readLockfileVersion(root, pkgName) {
25
+ const lockPath = join(root, "bun.lock");
26
+ if (!existsSync(lockPath))
27
+ return null;
28
+ const pinned = new RegExp(`"@cosmicdrift/${pkgName}": \\["@cosmicdrift/${pkgName}@(\\d+\\.\\d+\\.\\d+)"`).exec(readFileSync(lockPath, "utf-8"));
29
+ return pinned?.[1] ?? null;
30
+ }
31
+ // Only the repo's own install, package dir and lockfile count. Walking up
32
+ // from a worktree nested in a parent workspace read that workspace's version,
33
+ // and the isolated linker keeps transitive packages out of node_modules.
34
+ function readPackageVersion(root, pkgName, repoLocalPath) {
35
+ return (readPackageJsonVersion(join(root, `node_modules/@cosmicdrift/${pkgName}/package.json`)) ??
36
+ readPackageJsonVersion(join(root, repoLocalPath)) ??
37
+ readLockfileVersion(root, pkgName));
41
38
  }
42
39
  // Changelog entries come from @cosmicdrift/kumiko-bundled-features (see
43
40
  // findFeaturesDirs); comparing against the framework version instead
44
41
  // compares unrelated packages once the two stop being versioned in lockstep.
45
- function readCurrentVersion(cwd) {
46
- return (readPackageVersion(cwd, "kumiko-bundled-features", "packages/bundled-features/package.json") ??
47
- readPackageVersion(cwd, "kumiko-framework", "packages/framework/package.json"));
42
+ function readCurrentVersion(root) {
43
+ return (readPackageVersion(root, "kumiko-bundled-features", "packages/bundled-features/package.json") ??
44
+ readPackageVersion(root, "kumiko-framework", "packages/framework/package.json"));
48
45
  }
49
46
  function readChangelogFile(filePath) {
50
47
  if (!existsSync(filePath))
@@ -677,11 +674,18 @@ export async function runUpgradeCli(argv, cwd, out, options) {
677
674
  for (const changelogFile of packageChangelogFiles) {
678
675
  allEntries.push(...readChangelogFile(changelogFile));
679
676
  }
680
- const pending = sortEntries(filterEntriesAfter(allEntries, currentVersion));
677
+ // Installed version of the target the marker belongs to (cwd unless --dir).
678
+ const targetInstalledVersion = dirFlag ? readCurrentVersion(targetDir) : installedVersion;
679
+ // Changelogs can be found in a parent workspace's newer install. A change
680
+ // the repo has not installed yet is not pending for it.
681
+ const installedEntries = targetInstalledVersion === null
682
+ ? allEntries
683
+ : allEntries.filter((entry) => compareVersions(entry.version, targetInstalledVersion) <= 0);
684
+ const pending = sortEntries(filterEntriesAfter(installedEntries, currentVersion));
681
685
  if (getFlag(args, "apply")) {
682
686
  // Marker must reflect what is actually installed under the target (or
683
687
  // cwd), not the filter baseline above — otherwise CI stays green forever.
684
- const markerVersion = dirFlag ? readCurrentVersion(targetDir) : installedVersion;
688
+ const markerVersion = targetInstalledVersion;
685
689
  const dryRun = getFlag(args, "dry-run");
686
690
  if (markerVersion === null && !dryRun) {
687
691
  out.err("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-framework",
3
- "version": "0.350.0",
3
+ "version": "0.352.0",
4
4
  "description": "Framework core — engine, pipeline, API, DB, and every other bit that makes Kumiko go.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -206,8 +206,8 @@
206
206
  "./package.json": "./package.json"
207
207
  },
208
208
  "dependencies": {
209
- "@cosmicdrift/kumiko-http": "0.350.0",
210
- "@cosmicdrift/kumiko-types": "0.350.0",
209
+ "@cosmicdrift/kumiko-http": "0.352.0",
210
+ "@cosmicdrift/kumiko-types": "0.352.0",
211
211
  "bullmq": "^5.76.7",
212
212
  "bun-types": "^1.3.13",
213
213
  "hono": "^4.13.1",
@@ -223,7 +223,7 @@
223
223
  "zod": "^4.4.3"
224
224
  },
225
225
  "devDependencies": {
226
- "@cosmicdrift/kumiko-dispatcher-live": "0.350.0",
226
+ "@cosmicdrift/kumiko-dispatcher-live": "0.352.0",
227
227
  "bun-types": "^1.3.13",
228
228
  "pino-pretty": "^13.1.3"
229
229
  },
package/src/changes.json CHANGED
@@ -1,4 +1,31 @@
1
1
  [
2
+ {
3
+ "version": "0.352.0",
4
+ "type": "improvement",
5
+ "title": "appendEventInTenantDb and getStreamVersionInTenantDb append and read stream versions through a TenantDb, optionally running inline projections",
6
+ "detail": "`appendEventInTenantDb` appends an event on a TenantDb's own connection or transaction\nFramework-side code that holds a `TenantDb` (for example inside `runInOwnTransaction`) could not append to the event store without a raw runner. `appendEventInTenantDb(tenantDb, event, { registry })` and `getStreamVersionInTenantDb(tenantDb, aggregateId)` from `@cosmicdrift/kumiko-framework/event-store` do it: the tenant is always the TenantDb's own, the append goes through `append()` (PII encryption, origin stamping), and with `registry` the inline projections run on the same runner."
7
+ },
8
+ {
9
+ "version": "0.352.0",
10
+ "type": "fix",
11
+ "title": "Rate-limited, denied or invalid callers no longer consume cap usage or trigger soft-warn, because pre-handler gates run before reserveBeforeTransaction"
12
+ },
13
+ {
14
+ "version": "0.352.0",
15
+ "type": "improvement",
16
+ "title": "reserveBeforeTransaction may return a ReservationHandle whose confirmInTransaction settles the reservation inside the handler transaction"
17
+ },
18
+ {
19
+ "version": "0.352.0",
20
+ "type": "improvement",
21
+ "title": "Seeds can find template rows with ctx.findTemplateResources",
22
+ "detail": "Seeds can replace a raw SELECT … FROM read_template_resources with ctx.findTemplateResources, which binds every filter value as a parameter."
23
+ },
24
+ {
25
+ "version": "0.352.0",
26
+ "type": "improvement",
27
+ "title": "Boot validation and the client schema cover select optionsAvailabilityQuery on entity and screen fields"
28
+ },
2
29
  {
3
30
  "version": "0.349.0",
4
31
  "type": "improvement",