fix: 修复TypeScript配置错误并更新项目文档
详细说明: - 修复了@n8n/config包的TypeScript配置错误 - 移除了不存在的jest-expect-message类型引用 - 清理了所有TypeScript构建缓存 - 更新了可行性分析文档,添加了技术实施方案 - 更新了Agent prompt文档 - 添加了会展策划工作流文档 - 包含了n8n-chinese-translation子项目 - 添加了exhibition-demo展示系统框架
This commit is contained in:
63
n8n-n8n-1.109.2/packages/@n8n/backend-common/src/cli-parser 2.ts
Executable file
63
n8n-n8n-1.109.2/packages/@n8n/backend-common/src/cli-parser 2.ts
Executable file
@@ -0,0 +1,63 @@
|
||||
import { Service } from '@n8n/di';
|
||||
import argvParser from 'yargs-parser';
|
||||
import type { z } from 'zod';
|
||||
|
||||
import { Logger } from './logging';
|
||||
|
||||
type CliInput<Flags extends z.ZodRawShape> = {
|
||||
argv: string[];
|
||||
flagsSchema?: z.ZodObject<Flags>;
|
||||
description?: string;
|
||||
examples?: string[];
|
||||
};
|
||||
|
||||
type ParsedArgs<Flags = Record<string, unknown>> = {
|
||||
flags: Flags;
|
||||
args: string[];
|
||||
};
|
||||
|
||||
@Service()
|
||||
export class CliParser {
|
||||
constructor(private readonly logger: Logger) {}
|
||||
|
||||
parse<Flags extends z.ZodRawShape>(
|
||||
input: CliInput<Flags>,
|
||||
): ParsedArgs<z.infer<z.ZodObject<Flags>>> {
|
||||
// eslint-disable-next-line id-denylist
|
||||
const { _: rest, ...rawFlags } = argvParser(input.argv, { string: ['id'] });
|
||||
|
||||
let flags = {} as z.infer<z.ZodObject<Flags>>;
|
||||
if (input.flagsSchema) {
|
||||
for (const key in input.flagsSchema.shape) {
|
||||
const flagSchema = input.flagsSchema.shape[key];
|
||||
let schemaDef = flagSchema._def as z.ZodTypeDef & {
|
||||
typeName: string;
|
||||
innerType?: z.ZodType;
|
||||
_alias?: string;
|
||||
};
|
||||
|
||||
if (schemaDef.typeName === 'ZodOptional' && schemaDef.innerType) {
|
||||
schemaDef = schemaDef.innerType._def as typeof schemaDef;
|
||||
}
|
||||
|
||||
const alias = schemaDef._alias;
|
||||
if (alias?.length && !(key in rawFlags) && rawFlags[alias]) {
|
||||
rawFlags[key] = rawFlags[alias] as unknown;
|
||||
}
|
||||
}
|
||||
|
||||
flags = input.flagsSchema.parse(rawFlags);
|
||||
}
|
||||
|
||||
const args = rest.map(String).slice(2);
|
||||
|
||||
this.logger.debug('Received CLI command', {
|
||||
execPath: rest[0],
|
||||
scriptPath: rest[1],
|
||||
args,
|
||||
flags,
|
||||
});
|
||||
|
||||
return { flags, args };
|
||||
}
|
||||
}
|
||||
5
n8n-n8n-1.109.2/packages/@n8n/backend-common/src/environment 2.ts
Executable file
5
n8n-n8n-1.109.2/packages/@n8n/backend-common/src/environment 2.ts
Executable file
@@ -0,0 +1,5 @@
|
||||
const { NODE_ENV } = process.env;
|
||||
|
||||
export const inTest = NODE_ENV === 'test';
|
||||
export const inProduction = NODE_ENV === 'production';
|
||||
export const inDevelopment = !NODE_ENV || NODE_ENV === 'development';
|
||||
10
n8n-n8n-1.109.2/packages/@n8n/backend-common/src/index 2.ts
Executable file
10
n8n-n8n-1.109.2/packages/@n8n/backend-common/src/index 2.ts
Executable file
@@ -0,0 +1,10 @@
|
||||
export * from './license-state';
|
||||
export * from './types';
|
||||
|
||||
export { inDevelopment, inProduction, inTest } from './environment';
|
||||
export { isObjectLiteral } from './utils/is-object-literal';
|
||||
export { Logger } from './logging/logger';
|
||||
export { ModuleRegistry } from './modules/module-registry';
|
||||
export { ModulesConfig, ModuleName } from './modules/modules.config';
|
||||
export { isContainedWithin, safeJoinPath } from './utils/path-util';
|
||||
export { CliParser } from './cli-parser';
|
||||
209
n8n-n8n-1.109.2/packages/@n8n/backend-common/src/license-state 2.ts
Executable file
209
n8n-n8n-1.109.2/packages/@n8n/backend-common/src/license-state 2.ts
Executable file
@@ -0,0 +1,209 @@
|
||||
import type { BooleanLicenseFeature } from '@n8n/constants';
|
||||
import { UNLIMITED_LICENSE_QUOTA } from '@n8n/constants';
|
||||
import { Service } from '@n8n/di';
|
||||
import { UnexpectedError } from 'n8n-workflow';
|
||||
|
||||
import type { FeatureReturnType, LicenseProvider } from './types';
|
||||
|
||||
class ProviderNotSetError extends UnexpectedError {
|
||||
constructor() {
|
||||
super('Cannot query license state because license provider has not been set');
|
||||
}
|
||||
}
|
||||
|
||||
@Service()
|
||||
export class LicenseState {
|
||||
licenseProvider: LicenseProvider | null = null;
|
||||
|
||||
setLicenseProvider(provider: LicenseProvider) {
|
||||
this.licenseProvider = provider;
|
||||
}
|
||||
|
||||
private assertProvider(): asserts this is { licenseProvider: LicenseProvider } {
|
||||
if (!this.licenseProvider) throw new ProviderNotSetError();
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// core queries
|
||||
// --------------------
|
||||
|
||||
isLicensed(feature: BooleanLicenseFeature) {
|
||||
this.assertProvider();
|
||||
|
||||
return this.licenseProvider.isLicensed(feature);
|
||||
}
|
||||
|
||||
getValue<T extends keyof FeatureReturnType>(feature: T): FeatureReturnType[T] {
|
||||
this.assertProvider();
|
||||
|
||||
return this.licenseProvider.getValue(feature);
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// booleans
|
||||
// --------------------
|
||||
|
||||
isSharingLicensed() {
|
||||
return this.isLicensed('feat:sharing');
|
||||
}
|
||||
|
||||
isLogStreamingLicensed() {
|
||||
return this.isLicensed('feat:logStreaming');
|
||||
}
|
||||
|
||||
isLdapLicensed() {
|
||||
return this.isLicensed('feat:ldap');
|
||||
}
|
||||
|
||||
isSamlLicensed() {
|
||||
return this.isLicensed('feat:saml');
|
||||
}
|
||||
|
||||
isOidcLicensed() {
|
||||
return this.isLicensed('feat:oidc');
|
||||
}
|
||||
|
||||
isMFAEnforcementLicensed() {
|
||||
return this.isLicensed('feat:mfaEnforcement');
|
||||
}
|
||||
|
||||
isApiKeyScopesLicensed() {
|
||||
return this.isLicensed('feat:apiKeyScopes');
|
||||
}
|
||||
|
||||
isAiAssistantLicensed() {
|
||||
return this.isLicensed('feat:aiAssistant');
|
||||
}
|
||||
|
||||
isAskAiLicensed() {
|
||||
return this.isLicensed('feat:askAi');
|
||||
}
|
||||
|
||||
isAiCreditsLicensed() {
|
||||
return this.isLicensed('feat:aiCredits');
|
||||
}
|
||||
|
||||
isAdvancedExecutionFiltersLicensed() {
|
||||
return this.isLicensed('feat:advancedExecutionFilters');
|
||||
}
|
||||
|
||||
isAdvancedPermissionsLicensed() {
|
||||
return this.isLicensed('feat:advancedPermissions');
|
||||
}
|
||||
|
||||
isDebugInEditorLicensed() {
|
||||
return this.isLicensed('feat:debugInEditor');
|
||||
}
|
||||
|
||||
isBinaryDataS3Licensed() {
|
||||
return this.isLicensed('feat:binaryDataS3');
|
||||
}
|
||||
|
||||
isMultiMainLicensed() {
|
||||
return this.isLicensed('feat:multipleMainInstances');
|
||||
}
|
||||
|
||||
isVariablesLicensed() {
|
||||
return this.isLicensed('feat:variables');
|
||||
}
|
||||
|
||||
isSourceControlLicensed() {
|
||||
return this.isLicensed('feat:sourceControl');
|
||||
}
|
||||
|
||||
isExternalSecretsLicensed() {
|
||||
return this.isLicensed('feat:externalSecrets');
|
||||
}
|
||||
|
||||
isWorkflowHistoryLicensed() {
|
||||
return this.isLicensed('feat:workflowHistory');
|
||||
}
|
||||
|
||||
isAPIDisabled() {
|
||||
return this.isLicensed('feat:apiDisabled');
|
||||
}
|
||||
|
||||
isWorkerViewLicensed() {
|
||||
return this.isLicensed('feat:workerView');
|
||||
}
|
||||
|
||||
isProjectRoleAdminLicensed() {
|
||||
return this.isLicensed('feat:projectRole:admin');
|
||||
}
|
||||
|
||||
isProjectRoleEditorLicensed() {
|
||||
return this.isLicensed('feat:projectRole:editor');
|
||||
}
|
||||
|
||||
isProjectRoleViewerLicensed() {
|
||||
return this.isLicensed('feat:projectRole:viewer');
|
||||
}
|
||||
|
||||
isCustomNpmRegistryLicensed() {
|
||||
return this.isLicensed('feat:communityNodes:customRegistry');
|
||||
}
|
||||
|
||||
isFoldersLicensed() {
|
||||
return this.isLicensed('feat:folders');
|
||||
}
|
||||
|
||||
isInsightsSummaryLicensed() {
|
||||
return this.isLicensed('feat:insights:viewSummary');
|
||||
}
|
||||
|
||||
isInsightsDashboardLicensed() {
|
||||
return this.isLicensed('feat:insights:viewDashboard');
|
||||
}
|
||||
|
||||
isInsightsHourlyDataLicensed() {
|
||||
return this.isLicensed('feat:insights:viewHourlyData');
|
||||
}
|
||||
|
||||
isWorkflowDiffsLicensed() {
|
||||
return this.isLicensed('feat:workflowDiffs');
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// integers
|
||||
// --------------------
|
||||
|
||||
getMaxUsers() {
|
||||
return this.getValue('quota:users') ?? UNLIMITED_LICENSE_QUOTA;
|
||||
}
|
||||
|
||||
getMaxActiveWorkflows() {
|
||||
return this.getValue('quota:activeWorkflows') ?? UNLIMITED_LICENSE_QUOTA;
|
||||
}
|
||||
|
||||
getMaxVariables() {
|
||||
return this.getValue('quota:maxVariables') ?? UNLIMITED_LICENSE_QUOTA;
|
||||
}
|
||||
|
||||
getMaxAiCredits() {
|
||||
return this.getValue('quota:aiCredits') ?? 0;
|
||||
}
|
||||
|
||||
getWorkflowHistoryPruneQuota() {
|
||||
return this.getValue('quota:workflowHistoryPrune') ?? UNLIMITED_LICENSE_QUOTA;
|
||||
}
|
||||
|
||||
getInsightsMaxHistory() {
|
||||
return this.getValue('quota:insights:maxHistoryDays') ?? 7;
|
||||
}
|
||||
|
||||
getInsightsRetentionMaxAge() {
|
||||
return this.getValue('quota:insights:retention:maxAgeDays') ?? 180;
|
||||
}
|
||||
|
||||
getInsightsRetentionPruneInterval() {
|
||||
return this.getValue('quota:insights:retention:pruneIntervalDays') ?? 24;
|
||||
}
|
||||
|
||||
getMaxTeamProjects() {
|
||||
return this.getValue('quota:maxTeamProjects') ?? 0;
|
||||
}
|
||||
|
||||
getMaxWorkflowsWithEvaluations() {
|
||||
return this.getValue('quota:evaluations:maxWorkflows') ?? 0;
|
||||
}
|
||||
}
|
||||
15
n8n-n8n-1.109.2/packages/@n8n/backend-common/src/types 2.ts
Executable file
15
n8n-n8n-1.109.2/packages/@n8n/backend-common/src/types 2.ts
Executable file
@@ -0,0 +1,15 @@
|
||||
import type { BooleanLicenseFeature, NumericLicenseFeature } from '@n8n/constants';
|
||||
|
||||
export type FeatureReturnType = Partial<
|
||||
{
|
||||
planName: string;
|
||||
} & { [K in NumericLicenseFeature]: number } & { [K in BooleanLicenseFeature]: boolean }
|
||||
>;
|
||||
|
||||
export interface LicenseProvider {
|
||||
/** Returns whether a feature is included in the user's license plan. */
|
||||
isLicensed(feature: BooleanLicenseFeature): boolean;
|
||||
|
||||
/** Returns the value of a feature in the user's license plan, typically a boolean or integer. */
|
||||
getValue<T extends keyof FeatureReturnType>(feature: T): FeatureReturnType[T];
|
||||
}
|
||||
Reference in New Issue
Block a user