Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/tego/src/plugin-presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export class PluginPresets extends Plugin {
'error-handler',
'event-source',
'file',
'web',
'workflow',
'message',
'pdf',
'ui-schema',
'user',
'web',
'worker-thread',
'env-secrets',
];
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"oxlint --fix"
]
},
"dependencies": {
"ts-morph": "^26.0.0"
},
Comment on lines +39 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

ts-morph is heavy – confirm it’s really needed at runtime

ts-morph (~13 MB install, many transitive deps) has been added to the main dependencies block, which means:

  1. It ships to production containers/functions even if used only in build-time tooling.
  2. It increases cold-start size for serverless environments.

If the new schema-initializer code imports ts-morph only during code-gen/build (e.g. inside a CLI), move it to devDependencies:

-  "dependencies": {
-    "ts-morph": "^26.0.0"
-  },
+  "devDependencies": {
+    "ts-morph": "^26.0.0",
+    ...
+  },

Keep it here only when the browser / Node runtime dynamically requires it at execution time.


🏁 Script executed:

#!/bin/bash
# Find ts-morph entry in package.json
rg -n '"ts-morph"' -n package.json

# Search for any imports or requires of ts-morph in the codebase
rg -n "from ['\"]ts-morph['\"]|require\(['\"]ts-morph['\"]\)" .

Length of output: 139


Move ts-morph into devDependencies

We searched the repo and found no import or require of ts-morph in runtime code, so it isn’t used in production. To avoid bloating your production bundle/container, please relocate it to devDependencies.

• File: package.json (line 40)

   "dependencies": {
-    "ts-morph": "^26.0.0"
   },
+  "devDependencies": {
+    "ts-morph": "^26.0.0",
+    …other dev deps…
+  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"dependencies": {
"ts-morph": "^26.0.0"
},
"dependencies": {
},
"devDependencies": {
"ts-morph": "^26.0.0",
…other dev deps…
},
🤖 Prompt for AI Agents
In package.json around lines 39 to 41, the dependency "ts-morph" is currently
listed under "dependencies" but is not used in production runtime code. Move
"ts-morph" from the "dependencies" section to the "devDependencies" section to
prevent it from being included in the production bundle or container.

"devDependencies": {
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1",
Expand Down
1 change: 0 additions & 1 deletion packages/client/src/built-in/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ export class BuiltInPlugin extends Plugin {
},
});
await this.app.pm.add(SchemaComponentPlugin, { name: 'schema-component' });
await this.app.pm.add(SchemaInitializerPlugin, { name: 'schema-initializer' });
await this.app.pm.add(SchemaSettingsPlugin, { name: 'schema-settings' });
await this.app.pm.add(PluginBlockSchemaComponent, { name: 'block-schema-component' });
await this.app.pm.add(AntdSchemaComponentPlugin, { name: 'antd-schema-component' });
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/schema-component/antd/action/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './hooks/useGetAriaLabelOfModal';
export * from './hooks/useGetAriaLabelOfPopover';
export * from './Action.Designer';
export * from './Action.Area';
export { linkageAction } from './utils';
1 change: 1 addition & 0 deletions packages/client/src/schema-component/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './dnd-context';
export * from './sortable-item';
export { parseVariables } from './utils';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { CollectionFieldProvider } from '../../../data-source';
import { useRecord } from '../../../record-provider';
import { useCompile, useComponent } from '../../../schema-component';
import { Option } from '../../../schema-settings/VariableInput/type';
import { VariableInputOption } from '../../../schema-settings/VariableInput/type';
import { formatVariableScop } from '../../../schema-settings/VariableInput/utils/formatVariableScop';
import { getShouldChange, VariableInput } from '../../../schema-settings/VariableInput/VariableInput';
import { useLocalVariables, useVariables } from '../../../variables';
Expand Down Expand Up @@ -112,7 +112,7 @@ export const AssignedField = (props: AssignedFieldProps) => {
);

const returnScope = useCallback(
(scope: Option[]) => {
(scope: VariableInputOption[]) => {
const currentForm = scope.find((item) => item.value === '$nForm');
const fields = getCollectionFields(name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { FlagProvider, useFlag } from '../flag-provider';
import { useLocalVariables, useVariables } from '../variables';
import { isVariable } from '../variables/utils/isVariable';
import { findParentFieldSchema, getFieldDefaultValue, SchemaSettingsModalItem } from './SchemaSettings';
import { Option } from './VariableInput/type';
import { VariableInputOption } from './VariableInput/type';
import { formatVariableScop } from './VariableInput/utils/formatVariableScop';
import { getShouldChange, VariableInput } from './VariableInput/VariableInput';

Expand Down Expand Up @@ -77,7 +77,7 @@ export const SchemaSettingsDefaultValue = function DefaultValueConfigure(props:
(parentCollectionField?.type === 'hasMany' && collectionField?.interface === 'm2o'));

const returnScope = useCallback(
(scope: Option[]) => {
(scope: VariableInputOption[]) => {
const currentForm = scope.find((item) => item.value === '$nForm');
const fields = getCollectionFields(name);

Expand Down Expand Up @@ -114,7 +114,7 @@ export const SchemaSettingsDefaultValue = function DefaultValueConfigure(props:
'x-decorator': 'FormItem',
'x-component': 'VariableInput',
'x-component-props': {
...(fieldSchema?.['x-component-props'] || {}),
...fieldSchema?.['x-component-props'],
collectionField,
contextCollectionName: isAllowContextVariable && tableCtx.collection,
schema: collectionField?.uiSchema,
Expand Down Expand Up @@ -155,7 +155,7 @@ export const SchemaSettingsDefaultValue = function DefaultValueConfigure(props:
}

const schema = {
...(s || {}),
...s,
'x-decorator': 'FormItem',
'x-component-props': {
...s['x-component-props'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useContextAssociationFields } from './hooks/useContextAssociationFields
import { useCurrentRecordVariable } from './hooks/useRecordVariable';
import { useCurrentUserVariable } from './hooks/useUserVariable';
import { useVariableOptions } from './hooks/useVariableOptions';
import { Option } from './type';
import { VariableInputOption } from './type';

interface GetShouldChangeProps {
collectionField: CollectionFieldOptions_deprecated;
Expand Down Expand Up @@ -57,7 +57,7 @@ type Props = {
* @param scope
* @returns
*/
returnScope?: (scope: Option[]) => any[];
returnScope?: (scope: VariableInputOption[]) => any[];
};

/**
Expand Down Expand Up @@ -243,14 +243,14 @@ export function useCompatOldVariables(props: {
});

const compatOldVariables = useCallback(
(variables: Option[], { value }) => {
(variables: VariableInputOption[], { value }) => {
if (!isVariable(value)) {
return variables;
}

variables = _.cloneDeep(variables);

const systemVariable: Option = {
const systemVariable: VariableInputOption = {
value: '$system',
key: '$system',
label: t('System variables'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ISchema, Schema } from '@tachybase/schema';
import { CollectionFieldOptions_deprecated, useCollectionManager_deprecated } from '../../../collection-manager';
import { useCompile, useGetFilterOptions } from '../../../schema-component';
import { isSpecialCaseField } from '../../../schema-component/antd/form-item/hooks/useSpecialCase';
import { FieldOption, Option } from '../type';
import { FieldOption, VariableInputOption } from '../type';

export interface IsDisabledParams {
option: FieldOption;
Expand All @@ -26,7 +26,7 @@ interface GetOptionsParams {
* 不需要禁用选项,一般会在表达式中使用
*/
noDisabled?: boolean;
loadChildren?: (option: Option) => Promise<void>;
loadChildren?: (option: VariableInputOption) => Promise<void>;
compile: (value: string) => any;
isDisabled?: (params: IsDisabledParams) => boolean;
getCollectionField?: (name: string) => CollectionFieldOptions_deprecated;
Expand Down Expand Up @@ -59,7 +59,7 @@ interface BaseProps {
* @param fields
* @param option
*/
returnFields?(fields: FieldOption[], option: Option): FieldOption[];
returnFields?(fields: FieldOption[], option: VariableInputOption): FieldOption[];
dataSource?: string;
}

Expand Down Expand Up @@ -91,9 +91,9 @@ const getChildren = (
targetFieldSchema,
getCollectionField,
}: GetOptionsParams,
): Option[] => {
): VariableInputOption[] => {
const result = options
.map((option): Option => {
.map((option): VariableInputOption => {
if (!option.target) {
return {
key: option.name,
Expand Down Expand Up @@ -148,7 +148,7 @@ export const useBaseVariable = ({
const { isDisabled } = useContext(BaseVariableContext) || {};
const { getCollectionField } = useCollectionManager_deprecated(dataSource);

const loadChildren = (option: Option): Promise<void> => {
const loadChildren = (option: VariableInputOption): Promise<void> => {
if (!option.field?.target) {
return Promise.resolve(void 0);
}
Expand Down Expand Up @@ -217,7 +217,7 @@ export const useBaseVariable = ({
depth: 0,
loadChildren,
children: [],
} as Option;
} as VariableInputOption;
}, [uiSchema?.['x-component']]);

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';

import { CollectionFieldOptions_deprecated, useCollectionManager_deprecated } from '../../../collection-manager';
import { useCompile, useGetFilterOptions } from '../../../schema-component';
import { FieldOption, Option } from '../type';
import { FieldOption, VariableInputOption } from '../type';

export const useIsSameOrChildCollection = () => {
const { getChildrenCollections } = useCollectionManager_deprecated();
Expand All @@ -22,7 +22,7 @@ interface GetOptionsParams {
schema: any;
depth: number;
maxDepth?: number;
loadChildren?: (option: Option) => Promise<void>;
loadChildren?: (option: VariableInputOption) => Promise<void>;
compile: (value: string) => any;
}

Expand All @@ -31,9 +31,9 @@ const getChildren = (
{ schema, depth, maxDepth, loadChildren, compile }: GetOptionsParams,
collectionField,
getIsSameOrChildCollection,
): Option[] => {
): VariableInputOption[] => {
const result = options
.map((option): Option => {
.map((option): VariableInputOption => {
const disabled = !getIsSameOrChildCollection(option.target, collectionField?.target);
if (!option.target) {
return {
Expand Down Expand Up @@ -79,7 +79,7 @@ export const useContextAssociationFields = ({
const compile = useCompile();
const getFilterOptions = useGetFilterOptions();
const getIsSameOrChildCollection = useIsSameOrChildCollection();
const loadChildren = (option: Option): Promise<void> => {
const loadChildren = (option: VariableInputOption): Promise<void> => {
if (!option.field?.target) {
return new Promise((resolve) => {
error('Must be set field target');
Expand Down Expand Up @@ -133,7 +133,7 @@ export const useContextAssociationFields = ({
},
depth: 0,
loadChildren,
} as Option;
} as VariableInputOption;
}, [schema?.['x-component']]);

return result;
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/schema-settings/VariableInput/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export * from './hooks';
export * from './VariableInput';
export * from './utils/formatVariableScop';
export type { VariableInputOption } from './type';
6 changes: 3 additions & 3 deletions packages/client/src/schema-settings/VariableInput/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { Schema } from '@tachybase/schema';

import type { DefaultOptionType } from 'antd/lib/cascader';

export interface Option extends DefaultOptionType {
export interface VariableInputOption extends DefaultOptionType {
key?: string | number;
value?: string | number;
label: React.ReactNode;
disabled?: boolean;
children?: Option[];
children?: VariableInputOption[];
// 标记是否为叶子节点,设置了 `loadData` 时有效
// 设为 `false` 时会强制标记为父节点,即使当前节点没有 children,也会显示展开图标
isLeaf?: boolean;
/** 当开启异步加载时有效,用于加载当前 node 的 children */
loadChildren?(option: Option): Promise<void>;
loadChildren?(option: VariableInputOption): Promise<void>;
field?: FieldOption;
depth?: number;
}
Expand Down
11 changes: 6 additions & 5 deletions packages/module-web/src/client/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { createRouterManager, Plugin, RouterManager } from '@tachybase/client';
import { createRouterManager, Plugin, RouterManager, SchemaInitializerPlugin } from '@tachybase/client';

import { Navigate } from 'react-router-dom';

Expand All @@ -25,10 +25,11 @@ export class ModuleWeb extends Plugin {
public mobileRouter: RouterManager;

async afterAdd() {
this.pm.add(PluginDataSelect, { name: 'plugin-data-select' });
this.app.pm.add(PluginSearchAndJump, { name: 'SearchAndJump' });
this.app.pm.add(PluginDesignableButton, { name: 'Designable' });
this.app.pm.add(PluginCalculator, { name: 'calculator' });
await this.app.pm.add(SchemaInitializerPlugin, { name: 'schema-initializer' });
await this.app.pm.add(PluginDataSelect, { name: 'plugin-data-select' });
await this.app.pm.add(PluginSearchAndJump, { name: 'SearchAndJump' });
await this.app.pm.add(PluginDesignableButton, { name: 'Designable' });
await this.app.pm.add(PluginCalculator, { name: 'calculator' });
}
async load() {
this.setMobileRouter();
Expand Down
Loading
Loading