@common-stack/server-stack 8.2.5-alpha.7 → 8.3.1-alpha.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/lib/MainStackServer.cjs +17 -10
- package/lib/MainStackServer.cjs.map +1 -1
- package/lib/MainStackServer.mjs +17 -10
- package/lib/MainStackServer.mjs.map +1 -1
- package/lib/StackServer.cjs +1 -1
- package/lib/StackServer.cjs.map +1 -1
- package/lib/StackServer.mjs +1 -1
- package/lib/StackServer.mjs.map +1 -1
- package/lib/config/env-config.cjs +6 -0
- package/lib/config/env-config.cjs.map +1 -1
- package/lib/config/env-config.mjs +6 -0
- package/lib/config/env-config.mjs.map +1 -1
- package/lib/connectors/mongo-connector.cjs +1 -1
- package/lib/connectors/mongo-connector.cjs.map +1 -1
- package/lib/connectors/mongo-connector.mjs +2 -2
- package/lib/connectors/mongo-connector.mjs.map +1 -1
- package/lib/infrastructure/container-module.cjs +2 -1
- package/lib/infrastructure/container-module.cjs.map +1 -1
- package/lib/infrastructure/container-module.mjs +2 -1
- package/lib/infrastructure/container-module.mjs.map +1 -1
- package/lib/infrastructure/inngest-factory.cjs +6 -2
- package/lib/infrastructure/inngest-factory.cjs.map +1 -1
- package/lib/infrastructure/inngest-factory.mjs +6 -2
- package/lib/infrastructure/inngest-factory.mjs.map +1 -1
- package/lib/servers/ExpressApp.cjs +3 -3
- package/lib/servers/ExpressApp.cjs.map +1 -1
- package/lib/servers/ExpressApp.mjs +1 -1
- package/lib/servers/ExpressApp.mjs.map +1 -1
- package/lib/servers/WebsocketMultipathUpdate.cjs +51 -9
- package/lib/servers/WebsocketMultipathUpdate.cjs.map +1 -1
- package/lib/servers/WebsocketMultipathUpdate.mjs +51 -9
- package/lib/servers/WebsocketMultipathUpdate.mjs.map +1 -1
- package/package.json +8 -8
- package/lib/MainStackServer.d.ts +0 -34
- package/lib/StackServer.d.ts +0 -29
- package/lib/api/remote-config.d.ts +0 -6
- package/lib/api/resolver.d.ts +0 -10
- package/lib/api/scalar.d.ts +0 -2
- package/lib/api/schema-builder.d.ts +0 -24
- package/lib/api/sub-graph-schema-builder.d.ts +0 -24
- package/lib/api/utils.d.ts +0 -4
- package/lib/config/env-config.d.ts +0 -28
- package/lib/config/index.d.ts +0 -1
- package/lib/config/moleculer.config.d.ts +0 -20
- package/lib/connectors/connection-broker.d.ts +0 -26
- package/lib/connectors/graphql-pubsub-connector.d.ts +0 -22
- package/lib/connectors/mongo-connector.d.ts +0 -21
- package/lib/connectors/nats-connector.d.ts +0 -20
- package/lib/connectors/redis-connector.d.ts +0 -30
- package/lib/examples/tenant-feature-example.d.ts +0 -13
- package/lib/examples/tenant-feature-integration.d.ts +0 -14
- package/lib/features/multi-module-example.d.ts +0 -17
- package/lib/index.d.ts +0 -4
- package/lib/infrastructure/container-module.d.ts +0 -3
- package/lib/infrastructure/example-workflows.d.ts +0 -16
- package/lib/infrastructure/index.d.ts +0 -5
- package/lib/infrastructure/infrastructure-factory.d.ts +0 -45
- package/lib/infrastructure/inngest-factory.d.ts +0 -8
- package/lib/infrastructure/types.d.ts +0 -28
- package/lib/infrastructure/usage-examples.d.ts +0 -9
- package/lib/infrastructure/workflow-orchestrator.d.ts +0 -10
- package/lib/inngest/client-id-generator.d.ts +0 -29
- package/lib/inngest/handler-factory.d.ts +0 -24
- package/lib/inngest/middleware/auto-resolve-invoke.middleware.d.ts +0 -111
- package/lib/inngest/middleware/function-reference-helper.d.ts +0 -211
- package/lib/inngest/middleware/index.d.ts +0 -31
- package/lib/inngest/middleware/types.d.ts +0 -162
- package/lib/inngest/multi-module-functions.d.ts +0 -133
- package/lib/inngest/setup.d.ts +0 -10
- package/lib/interfaces/dbMigration.d.ts +0 -8
- package/lib/interfaces/graphql-request-context.d.ts +0 -20
- package/lib/interfaces/index.d.ts +0 -4
- package/lib/interfaces/module-interface.d.ts +0 -13
- package/lib/interfaces/moleculer.d.ts +0 -7
- package/lib/middleware/cors.d.ts +0 -6
- package/lib/middleware/error.d.ts +0 -9
- package/lib/middleware/index.d.ts +0 -5
- package/lib/middleware/moleculer-inter-namespace.d.ts +0 -2
- package/lib/middleware/redis-client.d.ts +0 -16
- package/lib/middleware/sentry.d.ts +0 -2
- package/lib/middleware/services.d.ts +0 -2
- package/lib/plugins/index.d.ts +0 -2
- package/lib/plugins/invalidateCachePlugin.d.ts +0 -8
- package/lib/plugins/responseCachePlugin.d.ts +0 -12
- package/lib/servers/ExpressApp.d.ts +0 -3
- package/lib/servers/GraphqlServer.d.ts +0 -25
- package/lib/servers/GraphqlWs.d.ts +0 -14
- package/lib/servers/WebsocketMultipathUpdate.d.ts +0 -18
- package/lib/servers/mongodb-migration-update.d.ts +0 -12
- package/lib/servers/utils.d.ts +0 -14
- package/lib/servers/websocket-context.d.ts +0 -30
- package/lib/utils/add-shareable-directive-to-schema.d.ts +0 -1
- package/lib/utils/index.d.ts +0 -3
- package/lib/utils/migrations.d.ts +0 -8
- package/lib/utils/safe-model-factory.d.ts +0 -18
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { WorkflowStep, ConnectorConfig } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Example custom workflow steps that can be added to the infrastructure initialization
|
|
4
|
-
*/
|
|
5
|
-
export declare const metricsInitializationStep: WorkflowStep;
|
|
6
|
-
export declare const customMigrationStep: WorkflowStep;
|
|
7
|
-
export declare const healthCheckStep: WorkflowStep;
|
|
8
|
-
export declare const cacheWarmingStep: WorkflowStep;
|
|
9
|
-
export declare const HIGH_PERFORMANCE_CONFIG: ConnectorConfig;
|
|
10
|
-
export declare const MINIMAL_CONFIG: ConnectorConfig;
|
|
11
|
-
export declare function createCustomWorkflow(environment: string): WorkflowStep[];
|
|
12
|
-
export declare function createCustomInfrastructureConfig(environment: string): {
|
|
13
|
-
connectors: ConnectorConfig;
|
|
14
|
-
workflows: WorkflowStep[];
|
|
15
|
-
environment: string;
|
|
16
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ServiceBroker } from 'moleculer';
|
|
2
|
-
import { Container } from 'inversify';
|
|
3
|
-
import { Feature as ServerFeature } from '@common-stack/server-core';
|
|
4
|
-
import { CdmLogger } from '@cdm-logger/core';
|
|
5
|
-
import { InfrastructureContext, ConnectorConfig, WorkflowStep } from './types';
|
|
6
|
-
import { ConnectionBroker } from '../connectors/connection-broker';
|
|
7
|
-
export interface BrokerInitializationOptions {
|
|
8
|
-
type: 'main' | 'microservice';
|
|
9
|
-
nodeId?: string;
|
|
10
|
-
connectorConfig: ConnectorConfig;
|
|
11
|
-
enableMetrics?: boolean;
|
|
12
|
-
workflows?: WorkflowStep[];
|
|
13
|
-
/**
|
|
14
|
-
* Optional callback invoked immediately after container creation,
|
|
15
|
-
* before services are instantiated.
|
|
16
|
-
*/
|
|
17
|
-
onContainerCreated?: (params: {
|
|
18
|
-
container: Container;
|
|
19
|
-
broker: ServiceBroker;
|
|
20
|
-
context: InfrastructureContext;
|
|
21
|
-
}) => void | Promise<void>;
|
|
22
|
-
}
|
|
23
|
-
export declare class InfrastructureFactory {
|
|
24
|
-
private logger;
|
|
25
|
-
private connectionBroker;
|
|
26
|
-
private orchestrator;
|
|
27
|
-
constructor(logger: CdmLogger.ILogger);
|
|
28
|
-
initialize(): Promise<void>;
|
|
29
|
-
createBrokerAndContainer(options: BrokerInitializationOptions, serverFeature: ServerFeature, settings: any, existingAllModules?: ServerFeature): Promise<{
|
|
30
|
-
broker: ServiceBroker;
|
|
31
|
-
container: Container;
|
|
32
|
-
context: InfrastructureContext;
|
|
33
|
-
allModules: ServerFeature;
|
|
34
|
-
}>;
|
|
35
|
-
private loadAndComposeModules;
|
|
36
|
-
private createContainerFromModules;
|
|
37
|
-
private loadMoleculerServices;
|
|
38
|
-
private createInfrastructureContext;
|
|
39
|
-
private createServiceBroker;
|
|
40
|
-
getConnectionBroker(): ConnectionBroker;
|
|
41
|
-
cleanup(): Promise<void>;
|
|
42
|
-
static createMainServiceConfig(): BrokerInitializationOptions;
|
|
43
|
-
static createMicroserviceConfig(nodeId?: string): BrokerInitializationOptions;
|
|
44
|
-
static createDevelopmentMicroserviceConfig(): BrokerInitializationOptions;
|
|
45
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Inngest } from 'inngest';
|
|
2
|
-
import { CdmLogger } from '@cdm-logger/core';
|
|
3
|
-
export declare const generateInngestClientId: (configParams: {
|
|
4
|
-
APP_NAME: string;
|
|
5
|
-
NODE_ENV: string;
|
|
6
|
-
INNGEST_CLIENT_ID?: string;
|
|
7
|
-
}, logger: CdmLogger.ILogger) => string;
|
|
8
|
-
export declare const createInngestClient: (logger: CdmLogger.ILogger) => Inngest;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ServiceBroker } from 'moleculer';
|
|
2
|
-
import { CdmLogger } from '@cdm-logger/core';
|
|
3
|
-
import { Inngest } from 'inngest';
|
|
4
|
-
export interface InfrastructureContext {
|
|
5
|
-
broker: ServiceBroker;
|
|
6
|
-
pubsub: any;
|
|
7
|
-
mongoClient: any;
|
|
8
|
-
logger: CdmLogger.ILogger;
|
|
9
|
-
redisClient: any;
|
|
10
|
-
inngestClient?: Inngest;
|
|
11
|
-
}
|
|
12
|
-
export interface WorkflowStep {
|
|
13
|
-
name: string;
|
|
14
|
-
order: number;
|
|
15
|
-
enabled: boolean;
|
|
16
|
-
execute: (context: InfrastructureContext) => Promise<void> | void;
|
|
17
|
-
}
|
|
18
|
-
export interface ConnectorConfig {
|
|
19
|
-
redis: boolean;
|
|
20
|
-
mongo: boolean;
|
|
21
|
-
pubsub: boolean;
|
|
22
|
-
inngest: boolean;
|
|
23
|
-
}
|
|
24
|
-
export interface InfrastructureConfig {
|
|
25
|
-
connectors: ConnectorConfig;
|
|
26
|
-
workflows: WorkflowStep[];
|
|
27
|
-
environment: string;
|
|
28
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MainStackServer } from '../MainStackServer';
|
|
2
|
-
import { StackServer } from '../StackServer';
|
|
3
|
-
/**
|
|
4
|
-
* Example usage of the new modular infrastructure system
|
|
5
|
-
*/
|
|
6
|
-
export declare function startMainServer(): Promise<MainStackServer>;
|
|
7
|
-
export declare function startMicroservice(): Promise<StackServer>;
|
|
8
|
-
export declare function startServerWithCustomWorkflows(): Promise<MainStackServer>;
|
|
9
|
-
export declare function getEnvironmentConfig(environment: string): import("./types").ConnectorConfig;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { InfrastructureConfig, WorkflowStep, ConnectorConfig } from './types';
|
|
2
|
-
export declare class WorkflowOrchestrator {
|
|
3
|
-
private config;
|
|
4
|
-
private steps;
|
|
5
|
-
constructor(config: InfrastructureConfig);
|
|
6
|
-
addStep(step: WorkflowStep): void;
|
|
7
|
-
executeWorkflow(context: any): Promise<void>;
|
|
8
|
-
getEnabledSteps(): WorkflowStep[];
|
|
9
|
-
}
|
|
10
|
-
export declare const CONNECTOR_CONFIGS: Record<string, ConnectorConfig>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export interface InngestClientIdConfig {
|
|
2
|
-
APP_NAME: string;
|
|
3
|
-
NODE_ENV: string;
|
|
4
|
-
INNGEST_CLIENT_ID?: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Generates a unique Inngest client ID for multi-developer environments
|
|
8
|
-
* Combines app name, environment, username, and hostname for uniqueness
|
|
9
|
-
*/
|
|
10
|
-
export declare function generateInngestClientId(config: InngestClientIdConfig, logger?: any): string;
|
|
11
|
-
/**
|
|
12
|
-
* Examples of generated IDs:
|
|
13
|
-
*
|
|
14
|
-
* Production:
|
|
15
|
-
* - APP_NAME=OrderAPI, NODE_ENV=production → "orderapi"
|
|
16
|
-
*
|
|
17
|
-
* Staging:
|
|
18
|
-
* - APP_NAME=OrderAPI, NODE_ENV=staging → "orderapi-staging"
|
|
19
|
-
*
|
|
20
|
-
* Development:
|
|
21
|
-
* - APP_NAME=OrderAPI, NODE_ENV=development, USER=john, HOSTNAME=macbook-pro
|
|
22
|
-
* → "orderapi-development-john-macbookp"
|
|
23
|
-
*
|
|
24
|
-
* - APP_NAME=OrderAPI, NODE_ENV=development, USER=mary, HOSTNAME=mary-laptop
|
|
25
|
-
* → "orderapi-development-mary-marylap"
|
|
26
|
-
*
|
|
27
|
-
* Explicit Override:
|
|
28
|
-
* - INNGEST_CLIENT_ID=custom-client-id → "custom-client-id"
|
|
29
|
-
*/
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Container } from 'inversify';
|
|
2
|
-
import { Feature } from '@common-stack/server-core';
|
|
3
|
-
export type InngestFunctionFactory = (params: {
|
|
4
|
-
container: Container;
|
|
5
|
-
inngest: any;
|
|
6
|
-
settings?: any;
|
|
7
|
-
}) => Record<string, any>;
|
|
8
|
-
/**
|
|
9
|
-
* Creates an Inngest handler that combines functions from multiple modules
|
|
10
|
-
* Similar to how Moleculer services are loaded
|
|
11
|
-
*
|
|
12
|
-
* The improved loadInngestFunctions method now:
|
|
13
|
-
* - Handles both array and object returns from factories
|
|
14
|
-
* - Automatically extracts function instances from objects
|
|
15
|
-
* - Flattens nested arrays
|
|
16
|
-
* - Validates function instances
|
|
17
|
-
*/
|
|
18
|
-
export declare const createInngestHandler: (features: Feature[], container: Container, inngestClient: any, settings?: any) => Promise<any[]>;
|
|
19
|
-
/**
|
|
20
|
-
* Legacy factory for backward compatibility
|
|
21
|
-
* @param container - The inversify container
|
|
22
|
-
* @deprecated Use createInngestHandler with Feature system instead
|
|
23
|
-
*/
|
|
24
|
-
export declare const inngestHandlerFactory: (container: Container, inngestClient?: any) => Promise<any[]>;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-Resolve Invoke Middleware for Inngest
|
|
3
|
-
*
|
|
4
|
-
* Makes the `function` parameter optional in step.invoke() by automatically
|
|
5
|
-
* resolving functions from the registry based on step names.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const inngest = new Inngest({
|
|
10
|
-
* middleware: [
|
|
11
|
-
* createFunctionMapperMiddleware(), // Required first
|
|
12
|
-
* createAutoResolveInvokeMiddleware(), // Then this
|
|
13
|
-
* ]
|
|
14
|
-
* });
|
|
15
|
-
*
|
|
16
|
-
* // In your functions
|
|
17
|
-
* async ({ step }) => {
|
|
18
|
-
* // Function auto-resolved from step name!
|
|
19
|
-
* await step.invoke('user-create', {
|
|
20
|
-
* data: { email: 'test@example.com' }
|
|
21
|
-
* });
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export interface AutoResolveInvokeOptions {
|
|
26
|
-
/**
|
|
27
|
-
* Custom mappings from step name to function ID
|
|
28
|
-
* Example: { 'create-user': 'user-create' }
|
|
29
|
-
*/
|
|
30
|
-
mappings?: Record<string, string>;
|
|
31
|
-
/**
|
|
32
|
-
* Prefixes to strip from step names when resolving
|
|
33
|
-
* Default: ['invoke-', 'call-']
|
|
34
|
-
* Example: 'invoke-user-create' → 'user-create'
|
|
35
|
-
*/
|
|
36
|
-
stripPrefixes?: string[];
|
|
37
|
-
/**
|
|
38
|
-
* Whether function ID matching is case-sensitive
|
|
39
|
-
* Default: false
|
|
40
|
-
*/
|
|
41
|
-
caseSensitive?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Whether to throw an error if function cannot be resolved
|
|
44
|
-
* Default: true
|
|
45
|
-
*/
|
|
46
|
-
throwOnNotFound?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Enable debug logging
|
|
49
|
-
* Default: false
|
|
50
|
-
*/
|
|
51
|
-
debug?: boolean;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Creates middleware that auto-resolves functions for step.invoke()
|
|
55
|
-
*
|
|
56
|
-
* IMPORTANT: This middleware requires functions to be provided explicitly.
|
|
57
|
-
* Use `createAutoResolveInvokeMiddlewareWithFunctions()` helper instead,
|
|
58
|
-
* or pass functions manually after calling serve().
|
|
59
|
-
*
|
|
60
|
-
* Resolution strategy (in order):
|
|
61
|
-
* 1. If function explicitly provided → use it
|
|
62
|
-
* 2. Try custom mappings
|
|
63
|
-
* 3. Try exact match with function ID
|
|
64
|
-
* 4. Try stripping configured prefixes
|
|
65
|
-
* 5. Throw error or return null (based on throwOnNotFound)
|
|
66
|
-
*/
|
|
67
|
-
export declare function createAutoResolveInvokeMiddleware(options?: AutoResolveInvokeOptions): any;
|
|
68
|
-
/**
|
|
69
|
-
* Helper: Create middleware with functions pre-populated
|
|
70
|
-
* Use this version to ensure functions are available before middleware runs
|
|
71
|
-
*/
|
|
72
|
-
export declare function createAutoResolveInvokeMiddlewareWithFunctions(functions: any[], options?: AutoResolveInvokeOptions): any;
|
|
73
|
-
/**
|
|
74
|
-
* Helper: Create middleware with common defaults for common-stack
|
|
75
|
-
* Handles common-stack naming patterns like:
|
|
76
|
-
* - aicode-code-agent
|
|
77
|
-
* - project-mgmt-main-workflow
|
|
78
|
-
* - key-mgmt-openbao-create-secret
|
|
79
|
-
*/
|
|
80
|
-
export declare function createAutoResolveInvokeMiddlewareWithDefaults(): any;
|
|
81
|
-
/**
|
|
82
|
-
* Helper: Create middleware configured for common-stack WorkflowNamespace patterns
|
|
83
|
-
*
|
|
84
|
-
* Handles your naming convention where:
|
|
85
|
-
* - Function IDs: 'aicode-code-agent', 'project-mgmt-main-workflow'
|
|
86
|
-
* - Event Names: 'aicode/code-agent-trigger', 'project-mgmt-main-workflow/trigger'
|
|
87
|
-
*
|
|
88
|
-
* Example usage:
|
|
89
|
-
* ```typescript
|
|
90
|
-
* // In your workflow
|
|
91
|
-
* await step.invoke('aicode-code-agent', { data: {...} });
|
|
92
|
-
* // Resolves to function with ID 'aicode-code-agent'
|
|
93
|
-
*
|
|
94
|
-
* await step.invoke('project-mgmt-create-from-template', { data: {...} });
|
|
95
|
-
* // Resolves to function with ID 'project-mgmt-create-from-template'
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export declare function createCommonStackAutoResolveMiddleware(options?: {
|
|
99
|
-
/** Additional custom mappings for special cases */
|
|
100
|
-
customMappings?: Record<string, string>;
|
|
101
|
-
/** Enable debug logging */
|
|
102
|
-
debug?: boolean;
|
|
103
|
-
}): any;
|
|
104
|
-
/**
|
|
105
|
-
* Strict mode - only exact matches, case-sensitive
|
|
106
|
-
*/
|
|
107
|
-
export declare const createStrictAutoResolveInvokeMiddleware: () => any;
|
|
108
|
-
/**
|
|
109
|
-
* Lenient mode - tries everything, doesn't throw
|
|
110
|
-
*/
|
|
111
|
-
export declare const createLenientAutoResolveInvokeMiddleware: () => any;
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function Reference Helper for Inngest
|
|
3
|
-
*
|
|
4
|
-
* Provides automatic function reference resolution for all registered functions.
|
|
5
|
-
* Instead of manually importing functions, you can reference them by ID.
|
|
6
|
-
*
|
|
7
|
-
* This combines:
|
|
8
|
-
* 1. Inngest's native `referenceFunction()` pattern
|
|
9
|
-
* 2. Automatic registry from all Feature-registered functions
|
|
10
|
-
* 3. Type-safe helpers for common patterns
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // Instead of:
|
|
15
|
-
* import { someFunction } from '../other-module';
|
|
16
|
-
* await step.invoke('call-it', { function: someFunction, data: {...} });
|
|
17
|
-
*
|
|
18
|
-
* // You can do:
|
|
19
|
-
* await step.invoke('call-it', {
|
|
20
|
-
* function: ctx.resolveFunction('some-function-id'),
|
|
21
|
-
* data: {...}
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* // Or even simpler (if middleware auto-resolve enabled):
|
|
25
|
-
* await step.invoke('some-function-id', { data: {...} });
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
import { InngestFunction } from 'inngest';
|
|
29
|
-
/**
|
|
30
|
-
* Global function registry
|
|
31
|
-
* Populated by setup.ts after all functions are loaded
|
|
32
|
-
*/
|
|
33
|
-
declare class FunctionRegistry {
|
|
34
|
-
private functions;
|
|
35
|
-
private initialized;
|
|
36
|
-
/**
|
|
37
|
-
* Register all functions from Feature system
|
|
38
|
-
*/
|
|
39
|
-
register(functions: InngestFunction.Any[]): void;
|
|
40
|
-
/**
|
|
41
|
-
* Get function by ID (case-insensitive)
|
|
42
|
-
*/
|
|
43
|
-
get(functionId: string): InngestFunction.Any | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* Check if function exists
|
|
46
|
-
*/
|
|
47
|
-
has(functionId: string): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Get all registered function IDs
|
|
50
|
-
*/
|
|
51
|
-
getAllIds(): string[];
|
|
52
|
-
/**
|
|
53
|
-
* Get count of registered functions
|
|
54
|
-
*/
|
|
55
|
-
get count(): number;
|
|
56
|
-
/**
|
|
57
|
-
* Check if registry is initialized
|
|
58
|
-
*/
|
|
59
|
-
get isInitialized(): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Clear registry (for testing)
|
|
62
|
-
*/
|
|
63
|
-
clear(): void;
|
|
64
|
-
}
|
|
65
|
-
export declare const globalFunctionRegistry: FunctionRegistry;
|
|
66
|
-
/**
|
|
67
|
-
* Reference a function by its ID
|
|
68
|
-
* Similar to Inngest's native referenceFunction, but automatically uses global registry
|
|
69
|
-
*
|
|
70
|
-
* @param functionIdOrOptions - The ID of the function or options object with functionId
|
|
71
|
-
* @returns The function reference to use in step.invoke()
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* // Simple usage
|
|
76
|
-
* const userCreateFn = referenceFunction('user-create');
|
|
77
|
-
*
|
|
78
|
-
* // Type-safe usage
|
|
79
|
-
* const computePi = referenceFunction({ functionId: 'compute-pi' });
|
|
80
|
-
*
|
|
81
|
-
* await step.invoke('create-user', {
|
|
82
|
-
* function: userCreateFn,
|
|
83
|
-
* data: { email: 'user@example.com' }
|
|
84
|
-
* });
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
export declare function referenceFunction<T extends InngestFunction.Any = InngestFunction.Any>(functionIdOrOptions: string | {
|
|
88
|
-
functionId: string;
|
|
89
|
-
}): T;
|
|
90
|
-
/**
|
|
91
|
-
* Batch reference multiple functions at once
|
|
92
|
-
* Useful for orchestrator workflows that call many functions
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* const { userCreate, emailSend, analyticsTrack } = referenceFunctions([
|
|
97
|
-
* 'user-create',
|
|
98
|
-
* 'email-send-welcome',
|
|
99
|
-
* 'analytics-track-event'
|
|
100
|
-
* ]);
|
|
101
|
-
*
|
|
102
|
-
* await step.invoke('create-user', { function: userCreate, data: {...} });
|
|
103
|
-
* await step.invoke('send-email', { function: emailSend, data: {...} });
|
|
104
|
-
* await step.invoke('track', { function: analyticsTrack, data: {...} });
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
export declare function referenceFunctions<T extends readonly string[]>(functionIds: T): {
|
|
108
|
-
[K in T[number]]: InngestFunction.Any;
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Check if a function is registered
|
|
112
|
-
* Useful for conditional logic
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```typescript
|
|
116
|
-
* if (hasFunctionReference('email-send-welcome')) {
|
|
117
|
-
* const emailFn = referenceFunction('email-send-welcome');
|
|
118
|
-
* await step.invoke('send-email', { function: emailFn, data: {...} });
|
|
119
|
-
* }
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
export declare function hasFunctionReference(functionId: string): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Get all available function IDs
|
|
125
|
-
* Useful for debugging and introspection
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```typescript
|
|
129
|
-
* console.log('Available functions:', getAvailableFunctions());
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
export declare function getAvailableFunctions(): string[];
|
|
133
|
-
/**
|
|
134
|
-
* Resolve a workflow-style or ID-style function reference to an Inngest function reference.
|
|
135
|
-
*
|
|
136
|
-
* Supported inputs:
|
|
137
|
-
* - Exact function id: "user-create"
|
|
138
|
-
* - Workflow-style: "WORKFLOWNAME.Function/trigger" or "WORKFLOWNAME.Function.trigger"
|
|
139
|
-
*
|
|
140
|
-
* The resolver will first try the exact ID as provided. If not found it will
|
|
141
|
-
* normalize the string by replacing separators ("/", ".") with dashes and
|
|
142
|
-
* collapsing non-alphanumerics, then lower-case the result. Example:
|
|
143
|
-
*
|
|
144
|
-
* WORKFLOWNAME.Function/trigger -> workflowname-function-trigger
|
|
145
|
-
*
|
|
146
|
-
* If still not found, it will throw the same helpful error as `referenceFunction`.
|
|
147
|
-
*/
|
|
148
|
-
export declare function resolveFunctionId(functionRef: string | {
|
|
149
|
-
functionId: string;
|
|
150
|
-
}): InngestFunction.Any;
|
|
151
|
-
/**
|
|
152
|
-
* Middleware that injects referenceFunction into context
|
|
153
|
-
* Makes it available in all function handlers
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```typescript
|
|
157
|
-
* const inngest = new Inngest({
|
|
158
|
-
* middleware: [createFunctionReferenceMiddleware()],
|
|
159
|
-
* });
|
|
160
|
-
*
|
|
161
|
-
* const myFn = inngest.createFunction(..., async ({ step, ctx }) => {
|
|
162
|
-
* // Access via context!
|
|
163
|
-
* const userFn = ctx.resolveFunction('user-create');
|
|
164
|
-
* await step.invoke('create-user', { function: userFn, data: {...} });
|
|
165
|
-
* });
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
export declare function createFunctionReferenceMiddleware(): {
|
|
169
|
-
name: string;
|
|
170
|
-
init(): {
|
|
171
|
-
onFunctionRun({ ctx }: any): {
|
|
172
|
-
transformInput(inputCtx: any): any;
|
|
173
|
-
};
|
|
174
|
-
onSendEvent: () => {};
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Combined middleware: Reference + Auto-Resolve
|
|
179
|
-
* Provides both manual and automatic function resolution
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```typescript
|
|
183
|
-
* const inngest = new Inngest({
|
|
184
|
-
* middleware: [createCombinedFunctionMiddleware()],
|
|
185
|
-
* });
|
|
186
|
-
*
|
|
187
|
-
* // Method 1: Manual reference
|
|
188
|
-
* const userFn = ctx.resolveFunction('user-create');
|
|
189
|
-
* await step.invoke('create-user', { function: userFn, data: {...} });
|
|
190
|
-
*
|
|
191
|
-
* // Method 2: Automatic (if function ID matches)
|
|
192
|
-
* await step.invoke('user-create', { data: {...} }); // Auto-resolved!
|
|
193
|
-
* ```
|
|
194
|
-
*/
|
|
195
|
-
export declare function createCombinedFunctionMiddleware(options?: {
|
|
196
|
-
/** Enable auto-resolve (default: true) */
|
|
197
|
-
autoResolve?: boolean;
|
|
198
|
-
/** Case-sensitive matching (default: false) */
|
|
199
|
-
caseSensitive?: boolean;
|
|
200
|
-
/** Enable debug logging (default: false) */
|
|
201
|
-
debug?: boolean;
|
|
202
|
-
}): {
|
|
203
|
-
name: string;
|
|
204
|
-
init(): {
|
|
205
|
-
onFunctionRun({ ctx }: any): {
|
|
206
|
-
transformInput(inputCtx: any): any;
|
|
207
|
-
};
|
|
208
|
-
onSendEvent: () => {};
|
|
209
|
-
};
|
|
210
|
-
};
|
|
211
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inngest Middleware - Public Exports
|
|
3
|
-
*
|
|
4
|
-
* This module provides middleware to automatically resolve Inngest function references
|
|
5
|
-
* in step.invoke() calls, enabling cleaner workflow code.
|
|
6
|
-
*/
|
|
7
|
-
export { createAutoResolveInvokeMiddleware, createAutoResolveInvokeMiddlewareWithFunctions, createAutoResolveInvokeMiddlewareWithDefaults, createCommonStackAutoResolveMiddleware, createStrictAutoResolveInvokeMiddleware, type AutoResolveInvokeOptions, } from './auto-resolve-invoke.middleware';
|
|
8
|
-
export { referenceFunction, referenceFunctions, hasFunctionReference, getAvailableFunctions, resolveFunctionId, globalFunctionRegistry, createFunctionReferenceMiddleware, createCombinedFunctionMiddleware, } from './function-reference-helper';
|
|
9
|
-
export type { InngestFunction } from 'inngest';
|
|
10
|
-
export type { ExtendedContext, ExtendedStep, InlineEditorHandler, FullContextHandler } from './types';
|
|
11
|
-
/**
|
|
12
|
-
* Usage Example:
|
|
13
|
-
*
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { createCommonStackAutoResolveMiddleware } from '@common-stack/server-stack';
|
|
16
|
-
*
|
|
17
|
-
* const inngest = new Inngest({
|
|
18
|
-
* id: 'my-app',
|
|
19
|
-
* middleware: [
|
|
20
|
-
* createCommonStackAutoResolveMiddleware({
|
|
21
|
-
* debug: true,
|
|
22
|
-
* })
|
|
23
|
-
* ]
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* // In your workflows:
|
|
27
|
-
* await step.invoke(WorkflowNamespace.USER_CREATE, {
|
|
28
|
-
* data: { email: 'test@example.com' }
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|