@shwfed/config 2.3.10 → 2.3.11

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 (50) hide show
  1. package/dist/mcp.mjs +704 -441
  2. package/dist/module.json +1 -1
  3. package/dist/preview/assets/{config-BxzDT_57.js → config-57-v4VXo.js} +1 -1
  4. package/dist/preview/assets/{config-2R4XkSGs.js → config-BZahzuEc.js} +1 -1
  5. package/dist/preview/assets/{config-KcLrpkc1.js → config-Be-2ZA2R.js} +1 -1
  6. package/dist/preview/assets/{config-ykJZssgx.js → config-BnZQO-Sp.js} +1 -1
  7. package/dist/preview/assets/{config-bxqg3yuv.js → config-Bp91DUdU.js} +1 -1
  8. package/dist/preview/assets/{config-CyScbxXy.js → config-DNokxY7M.js} +1 -1
  9. package/dist/preview/assets/{config-HdWYFZ09.js → config-_msO_f2R.js} +1 -1
  10. package/dist/preview/assets/{config-ja_GMXxV.js → config-_uPI8qV-.js} +1 -1
  11. package/dist/preview/assets/{definition.vue_vue_type_script_setup_true_lang-CWyVRSOh.js → definition.vue_vue_type_script_setup_true_lang-BtScXbs1.js} +1 -1
  12. package/dist/preview/assets/index-DDbl2Atj.js +1 -0
  13. package/dist/preview/assets/index-DGa3Oj3y.js +1075 -0
  14. package/dist/preview/assets/{index-BPKK3hGV.css → index-mbGtsgdv.css} +1 -1
  15. package/dist/preview/assets/{runtime-LBdh1D75.js → runtime-B9u14qqB.js} +1 -1
  16. package/dist/preview/assets/{runtime-B8aUJIpn.js → runtime-BBms4myv.js} +1 -1
  17. package/dist/preview/assets/{runtime-D2K1s33u.js → runtime-CfR7ZAND.js} +1 -1
  18. package/dist/preview/assets/{runtime-C9XnvD5A.js → runtime-D3EyeiyA.js} +1 -1
  19. package/dist/preview/assets/{runtime-DqZhDPHl.js → runtime-Dk9u-Ybw.js} +1 -1
  20. package/dist/preview/assets/{runtime-CpSiaWMP.js → runtime-XXqIAt53.js} +1 -1
  21. package/dist/preview/assets/{runtime-CxA8fvQP.js → runtime-cKWSGFod.js} +1 -1
  22. package/dist/preview/assets/{runtime-DAXQmtLg.js → runtime-w7V-p3t1.js} +1 -1
  23. package/dist/preview/index.html +2 -2
  24. package/dist/runtime/components/form/ai/fields-button.vue +3 -1
  25. package/dist/runtime/components/form/unit-config.vue +8 -4
  26. package/dist/runtime/components/form/utils/resolve.d.ts +48 -9
  27. package/dist/runtime/components/form/utils/resolve.js +59 -5
  28. package/dist/runtime/components/table/ai/columns-button.vue +1 -0
  29. package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/config.d.vue.ts +10 -0
  30. package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/config.vue +305 -0
  31. package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/config.vue.d.ts +10 -0
  32. package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/runtime.d.vue.ts +9 -0
  33. package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/runtime.vue +81 -0
  34. package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/runtime.vue.d.ts +9 -0
  35. package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/schema.d.ts +55 -0
  36. package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/schema.js +82 -0
  37. package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/config.d.vue.ts +10 -0
  38. package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/config.vue +310 -0
  39. package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/config.vue.d.ts +10 -0
  40. package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/runtime.d.vue.ts +9 -0
  41. package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/runtime.vue +81 -0
  42. package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/runtime.vue.d.ts +9 -0
  43. package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/schema.d.ts +66 -0
  44. package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/schema.js +71 -0
  45. package/dist/runtime/components/table/config.vue +2 -1
  46. package/dist/runtime/components/table/utils/resolve.d.ts +53 -0
  47. package/dist/runtime/components/table/utils/resolve.js +66 -1
  48. package/package.json +1 -1
  49. package/dist/preview/assets/index-D3pf2RjG.js +0 -1
  50. package/dist/preview/assets/index-OUd02U3g.js +0 -1075
@@ -0,0 +1,66 @@
1
+ import { Schema } from 'effect';
2
+ import type { ColumnDef } from '@tanstack/vue-table';
3
+ import type { Environment } from '../../../../../vendor/cel-js/lib/index.js';
4
+ import type { ColumnDefDeps, MigrateFn, MigrateSource } from '../../../utils/resolve.js';
5
+ export declare const type: "com.shwfed.table.column.switch.local";
6
+ export declare const compatibilityDate: "2026-05-20";
7
+ export declare const metadata: {
8
+ readonly name: "开关";
9
+ readonly icon: "fluent:toggle-left-20-regular";
10
+ };
11
+ export declare function schema(configure: (env: Environment) => void): Schema.Struct<{
12
+ hidden: Schema.optional<Schema.Schema<string, string, never>>;
13
+ disabled: Schema.optional<Schema.Schema<string, string, never>>;
14
+ readonly: Schema.optional<Schema.Schema<string, string, never>>;
15
+ trueLabel: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
16
+ locale: Schema.Literal<["zh"]>;
17
+ message: Schema.SchemaClass<string, string, never>;
18
+ }>], [Schema.Struct<{
19
+ locale: Schema.Literal<["ja", "en", "ko"]>;
20
+ message: Schema.SchemaClass<string, string, never>;
21
+ }>]>>;
22
+ falseLabel: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
23
+ locale: Schema.Literal<["zh"]>;
24
+ message: Schema.SchemaClass<string, string, never>;
25
+ }>], [Schema.Struct<{
26
+ locale: Schema.Literal<["ja", "en", "ko"]>;
27
+ message: Schema.SchemaClass<string, string, never>;
28
+ }>]>>;
29
+ derived: Schema.optional<Schema.Struct<{
30
+ mode: Schema.Literal<["formula", "prefill"]>;
31
+ expression: Schema.Schema<string, string, never>;
32
+ }>>;
33
+ title: Schema.TupleType<readonly [Schema.Struct<{
34
+ locale: Schema.Literal<["zh"]>;
35
+ message: Schema.SchemaClass<string, string, never>;
36
+ }>], [Schema.Struct<{
37
+ locale: Schema.Literal<["ja", "en", "ko"]>;
38
+ message: Schema.SchemaClass<string, string, never>;
39
+ }>]>;
40
+ binding: Schema.refine<string, typeof Schema.String>;
41
+ enableSorting: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
42
+ size: Schema.optional<Schema.refine<number, Schema.filter<typeof Schema.Number>>>;
43
+ grow: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
44
+ tooltip: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
45
+ locale: Schema.Literal<["zh"]>;
46
+ message: Schema.SchemaClass<string, string, never>;
47
+ }>], [Schema.Struct<{
48
+ locale: Schema.Literal<["ja", "en", "ko"]>;
49
+ message: Schema.SchemaClass<string, string, never>;
50
+ }>]>>;
51
+ id: Schema.refine<string, typeof Schema.String>;
52
+ groupId: Schema.optional<typeof Schema.UUID>;
53
+ type: Schema.Literal<["com.shwfed.table.column.switch.local"]>;
54
+ compatibilityDate: Schema.Literal<["2026-05-20"]>;
55
+ }>;
56
+ export type Value = Schema.Schema.Type<ReturnType<typeof schema>>;
57
+ /**
58
+ * Adopts values that were stored under the pre-split `com.shwfed.table.column.switch`
59
+ * type at the same `compatibilityDate`. The field shape is byte-identical to
60
+ * this entry's schema — only the discriminator changes. Migration declarations
61
+ * live exclusively on this (new) entry; the old folder was removed and is
62
+ * never touched by this rewrite.
63
+ */
64
+ export declare const migrateFrom: ReadonlyArray<MigrateSource>;
65
+ export declare const migrate: MigrateFn;
66
+ export declare function toColumnDef(value: Value, { getLocaleText }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
@@ -0,0 +1,71 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { getProperty } from "dot-prop";
3
+ import { Locale } from "../../../../../share/locale.js";
4
+ import { CelRowAccess, derivedRowField, editableColumnFields, editableHeader } from "../../../utils/shared.js";
5
+ export const type = "com.shwfed.table.column.switch.local";
6
+ export const compatibilityDate = "2026-05-20";
7
+ export const metadata = {
8
+ name: "\u5F00\u5173",
9
+ icon: "fluent:toggle-left-20-regular"
10
+ };
11
+ export function schema(configure) {
12
+ const CelBool = CelRowAccess(configure, { resultType: "bool" });
13
+ return Schema.Struct({
14
+ type: Schema.Literal(type),
15
+ compatibilityDate: Schema.Literal(compatibilityDate),
16
+ ...editableColumnFields(),
17
+ hidden: Schema.optional(CelBool.annotations({
18
+ title: "\u9690\u85CF\u6761\u4EF6",
19
+ description: "\u8FD4\u56DE `true` \u65F6\u8BE5\u884C\u7684\u5F00\u5173\u4E0D\u6E32\u67D3\uFF08\u5176\u4F59\u884C\u4E0D\u53D7\u5F71\u54CD\uFF09"
20
+ })),
21
+ disabled: Schema.optional(CelBool.annotations({
22
+ title: "\u7981\u7528\u6761\u4EF6",
23
+ description: "\u8FD4\u56DE `true` \u65F6\u5F00\u5173\u4ECD\u7136\u6E32\u67D3\u4F46\u4E0D\u53EF\u5207\u6362"
24
+ })),
25
+ readonly: Schema.optional(CelBool.annotations({
26
+ title: "\u53EA\u8BFB\u6761\u4EF6",
27
+ description: "\u8FD4\u56DE `true` \u65F6\u4EC5\u4EE5\u7EAF\u6587\u672C\u5C55\u793A\u5F53\u524D\u503C"
28
+ })),
29
+ trueLabel: Schema.optional(Locale.annotations({
30
+ title: "\u5F00\u542F\u6587\u6848",
31
+ description: "\u53EA\u8BFB\u72B6\u6001\u4E0B\uFF0C\u503C\u4E3A `true` \u65F6\u5C55\u793A\u7684\u6587\u672C\uFF1B\u7559\u7A7A\u4F7F\u7528\u9ED8\u8BA4 `\u662F`"
32
+ })),
33
+ falseLabel: Schema.optional(Locale.annotations({
34
+ title: "\u5173\u95ED\u6587\u6848",
35
+ description: "\u53EA\u8BFB\u72B6\u6001\u4E0B\uFF0C\u503C\u4E3A `false` \u65F6\u5C55\u793A\u7684\u6587\u672C\uFF1B\u7559\u7A7A\u4F7F\u7528\u9ED8\u8BA4 `\u5426`"
36
+ })),
37
+ derived: derivedRowField(configure, "bool")
38
+ }).annotations({ title: "SwitchRenderer", description: "\u5F00\u5173\u6E32\u67D3\u5668\uFF08\u53EF\u7F16\u8F91\u3001\u672C\u5730\uFF09" });
39
+ }
40
+ export const migrateFrom = [
41
+ { type: "com.shwfed.table.column.switch", compatibilityDate }
42
+ ];
43
+ export const migrate = (prev) => Effect.try({
44
+ try: () => {
45
+ if (!prev || typeof prev !== "object") {
46
+ throw new Error("\u5F00\u5173\uFF08\u672C\u5730\uFF09\u8FC1\u79FB\u5931\u8D25\uFF1A\u539F\u503C\u4E0D\u662F\u5BF9\u8C61");
47
+ }
48
+ return { ...prev, type, compatibilityDate };
49
+ },
50
+ catch: (e) => e instanceof Error ? e : new Error(String(e))
51
+ });
52
+ export function toColumnDef(value, { getLocaleText }) {
53
+ return {
54
+ header: editableHeader(getLocaleText(value.title)),
55
+ // `binding` is a dot-prop path (validated non-empty); the cell renderer
56
+ // reads through the same path it writes to. No CEL — accessor is literal.
57
+ accessorFn: (row) => {
58
+ if (!row || typeof row !== "object") return void 0;
59
+ return getProperty(row, value.binding);
60
+ },
61
+ enableSorting: value.enableSorting ?? false,
62
+ // `basic` orders by JS `<` — for booleans that yields `false < true`,
63
+ // which is the obvious grouping. Mirrors the remote switch column.
64
+ sortingFn: "basic",
65
+ size: value.size,
66
+ meta: {
67
+ grow: value.grow ?? false,
68
+ tooltip: getLocaleText(value.tooltip)
69
+ }
70
+ };
71
+ }
@@ -169,6 +169,7 @@ function configureTableQuery(env) {
169
169
  }
170
170
  const tableConfigSchema = TableConfig(configure);
171
171
  const dataSourceSchema = DataSource(configure);
172
+ const pickerEntries = computed(() => COLUMNS.filter((e) => !e.deprecated));
172
173
  const advertisedHostContext = (() => {
173
174
  const probe = new Environment({ unlistedVariablesAreDyn: false });
174
175
  const baseline = new Set(probe.getDefinitions().variables.map((v) => v.name));
@@ -1227,7 +1228,7 @@ const tableQueryValue = computed({
1227
1228
  <InputGroupCombobox>
1228
1229
  <CommandGroup>
1229
1230
  <CommandItem
1230
- v-for="entry in COLUMNS"
1231
+ v-for="entry in pickerEntries"
1231
1232
  :key="`${entry.type}@${entry.compatibilityDate}`"
1232
1233
  :value="`${entry.type}@${entry.compatibilityDate}`"
1233
1234
  @select="addColumn(entry.type, entry.compatibilityDate)"
@@ -16,6 +16,33 @@ export type ColumnDefDeps = Readonly<{
16
16
  inheritedContext: Record<string, unknown>;
17
17
  }>;
18
18
  type ToColumnDef = (value: any, deps: ColumnDefDeps) => Partial<ColumnDef<unknown, unknown>>;
19
+ /**
20
+ * Capabilities a column-migration function may need from the host. Mirrors
21
+ * the form host's `MigrationContext` so cross-host helpers can share a
22
+ * signature; extend additively rather than introducing a parallel context.
23
+ */
24
+ export type MigrationContext = Readonly<{
25
+ $cel: <T>(expression: string, context?: Record<string, unknown>) => Effect.Effect<T, unknown>;
26
+ }>;
27
+ /**
28
+ * Migrates a value of a *source* column schema to this entry's schema. Lives
29
+ * on the *target* (newer) entry. The target is picked by one of two rules:
30
+ * (a) same `type` with a strictly newer `compatibilityDate`; (b) an explicit
31
+ * `migrateFrom` declaration on the target naming this source. Failures
32
+ * surface to the host as a toast — see `table/config.vue`'s migrate handler.
33
+ */
34
+ export type MigrateFn = (prev: unknown, ctx: MigrationContext) => Effect.Effect<unknown, Error>;
35
+ /**
36
+ * Identifies a column entry by `(type, compatibilityDate)`. Used for both
37
+ * `migrateFrom` declarations and the cross-type form of `supersededBy`.
38
+ *
39
+ * Migration declarations only ever live on the *new* (target) code — old
40
+ * folders are never modified to announce that they have been superseded.
41
+ */
42
+ export type MigrateSource = Readonly<{
43
+ type: string;
44
+ compatibilityDate: string;
45
+ }>;
19
46
  export type ColumnEntry = Readonly<{
20
47
  type: string;
21
48
  compatibilityDate: string;
@@ -24,9 +51,35 @@ export type ColumnEntry = Readonly<{
24
51
  config: Component;
25
52
  runtime: Component;
26
53
  toColumnDef: ToColumnDef;
54
+ /**
55
+ * True iff this entry is shadowed by either (a) a newer-date entry sharing
56
+ * its `type`, or (b) another entry whose `migrateFrom` names this one.
57
+ */
58
+ deprecated: boolean;
59
+ /**
60
+ * Identifies the entry that supersedes this one. Same `type` for the
61
+ * date-versioned rule; a different `type` for declared cross-type
62
+ * migrations.
63
+ */
64
+ supersededBy?: MigrateSource;
65
+ migrate?: MigrateFn;
66
+ migrateFrom?: ReadonlyArray<MigrateSource>;
27
67
  }>;
28
68
  export declare const COLUMNS: ReadonlyArray<ColumnEntry>;
29
69
  export declare function allColumnSchemas(configure: (env: Environment) => void): ReadonlyArray<AnySchema>;
30
70
  export declare function findColumn(type: string, compatibilityDate: string): ColumnEntry | undefined;
71
+ /**
72
+ * Finds the registry entry that has declared `(type, compatibilityDate)` as a
73
+ * migration source on its `migrateFrom`. Use when a stored column's identity
74
+ * no longer matches any registry entry (the old folder was renamed away) —
75
+ * a present return means the value is still migratable via the target's
76
+ * `migrate`.
77
+ *
78
+ * Note: for the date-versioned rule (same `type`, newer `compatibilityDate`)
79
+ * the entry itself is in the registry and tagged `deprecated`/`supersededBy`;
80
+ * callers reach the target through `findColumn(supersededBy.type, …)`
81
+ * rather than this function.
82
+ */
83
+ export declare function findMigrationTarget(type: string, compatibilityDate: string): ColumnEntry | undefined;
31
84
  export declare function latestColumnByType(): ReadonlyArray<ColumnEntry>;
32
85
  export {};
@@ -11,6 +11,7 @@ const runtimeModules = import.meta.glob(
11
11
  "../columns/*/*/runtime.vue",
12
12
  { eager: true, import: "default", exhaustive: true }
13
13
  );
14
+ const sourceKey = (type, compatibilityDate) => `${type}@${compatibilityDate}`;
14
15
  const registry = defineRegistry({
15
16
  hostName: "shwfed-table",
16
17
  dirSegment: "columns",
@@ -21,6 +22,47 @@ const registry = defineRegistry({
21
22
  if (typeof mod.toColumnDef !== "function") {
22
23
  throw new TypeError(`[shwfed-table] column "${type}@${date}" is missing toColumnDef export`);
23
24
  }
25
+ },
26
+ // Deprecation rules mirror the form host:
27
+ // (a) date-versioned: another entry shares this entry's `type` with a
28
+ // strictly greater `compatibilityDate`;
29
+ // (b) explicit cross-type: another entry declares this one in its
30
+ // `migrateFrom`. Same source claimed twice → throw.
31
+ deriveEntryExtras: (drafts) => {
32
+ const latestByType = /* @__PURE__ */ new Map();
33
+ for (const d of drafts) {
34
+ const prev = latestByType.get(d.type);
35
+ if (!prev || d.compatibilityDate > prev) latestByType.set(d.type, d.compatibilityDate);
36
+ }
37
+ const migrationTargets2 = /* @__PURE__ */ new Map();
38
+ for (const d of drafts) {
39
+ const sources = d.module.migrateFrom;
40
+ if (!sources || sources.length === 0) continue;
41
+ for (const src of sources) {
42
+ const key = sourceKey(src.type, src.compatibilityDate);
43
+ const existing = migrationTargets2.get(key);
44
+ if (existing) {
45
+ throw new Error(
46
+ `[shwfed-table] migrateFrom collision: source "${key}" is claimed by both "${sourceKey(existing.type, existing.compatibilityDate)}" and "${sourceKey(d.type, d.compatibilityDate)}"`
47
+ );
48
+ }
49
+ migrationTargets2.set(key, { type: d.type, compatibilityDate: d.compatibilityDate });
50
+ }
51
+ }
52
+ return (draft) => {
53
+ const declared = migrationTargets2.get(sourceKey(draft.type, draft.compatibilityDate));
54
+ if (declared) {
55
+ return { deprecated: true, supersededBy: declared };
56
+ }
57
+ const latest = latestByType.get(draft.type);
58
+ if (draft.compatibilityDate < latest) {
59
+ return {
60
+ deprecated: true,
61
+ supersededBy: { type: draft.type, compatibilityDate: latest }
62
+ };
63
+ }
64
+ return { deprecated: false };
65
+ };
24
66
  }
25
67
  });
26
68
  export const COLUMNS = registry.ENTRIES.map((e) => ({
@@ -30,14 +72,37 @@ export const COLUMNS = registry.ENTRIES.map((e) => ({
30
72
  schema: e.module.schema,
31
73
  config: e.config,
32
74
  runtime: e.runtime,
33
- toColumnDef: e.module.toColumnDef
75
+ toColumnDef: e.module.toColumnDef,
76
+ deprecated: e.deprecated,
77
+ ...e.supersededBy !== void 0 ? { supersededBy: e.supersededBy } : {},
78
+ ...e.module.migrate !== void 0 ? { migrate: e.module.migrate } : {},
79
+ ...e.module.migrateFrom !== void 0 ? { migrateFrom: e.module.migrateFrom } : {}
34
80
  }));
81
+ const migrationTargets = (() => {
82
+ const map = /* @__PURE__ */ new Map();
83
+ for (const entry of COLUMNS) {
84
+ const sources = entry.migrateFrom;
85
+ if (!sources || sources.length === 0) continue;
86
+ for (const src of sources) {
87
+ map.set(sourceKey(src.type, src.compatibilityDate), {
88
+ type: entry.type,
89
+ compatibilityDate: entry.compatibilityDate
90
+ });
91
+ }
92
+ }
93
+ return map;
94
+ })();
35
95
  export function allColumnSchemas(configure) {
36
96
  return COLUMNS.map((entry) => entry.schema(configure));
37
97
  }
38
98
  export function findColumn(type, compatibilityDate) {
39
99
  return COLUMNS.find((r) => r.type === type && r.compatibilityDate === compatibilityDate);
40
100
  }
101
+ export function findMigrationTarget(type, compatibilityDate) {
102
+ const target = migrationTargets.get(sourceKey(type, compatibilityDate));
103
+ if (!target) return void 0;
104
+ return findColumn(target.type, target.compatibilityDate);
105
+ }
41
106
  export function latestColumnByType() {
42
107
  const byType = /* @__PURE__ */ new Map();
43
108
  for (const r of COLUMNS) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/config",
3
- "version": "2.3.10",
3
+ "version": "2.3.11",
4
4
  "description": "Configurable UI for SHWFED",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1 +0,0 @@
1
- import{aH as e}from"./index-OUd02U3g.js";import{aI as r,aJ as s,aK as t}from"./index-OUd02U3g.js";export{r as TableConfig,s as createTableConfig,e as default,t as getColumnTechnicalKey};