@loutrejs/loutre 0.1.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/dist/adapters/aws-lambda.d.ts +52 -0
- package/dist/adapters/aws-lambda.js +114 -0
- package/dist/adapters/bun.d.ts +20 -0
- package/dist/adapters/bun.js +82 -0
- package/dist/adapters/cloudflare-workers.d.ts +18 -0
- package/dist/adapters/cloudflare-workers.js +55 -0
- package/dist/adapters/deno.d.ts +28 -0
- package/dist/adapters/deno.js +106 -0
- package/dist/adapters/electron.d.ts +27 -0
- package/dist/adapters/electron.js +52 -0
- package/dist/application/binding.d.ts +33 -0
- package/dist/application/binding.js +292 -0
- package/dist/application/host.d.ts +8 -0
- package/dist/application/host.js +14 -0
- package/dist/application/index.d.ts +62 -0
- package/dist/application/index.js +11 -0
- package/dist/application/openapi.d.ts +28 -0
- package/dist/application/openapi.js +362 -0
- package/dist/application/queue.d.ts +3 -0
- package/dist/application/queue.js +4 -0
- package/dist/application/scheduler.d.ts +2 -0
- package/dist/application/scheduler.js +45 -0
- package/dist/core/args.d.ts +16 -0
- package/dist/core/args.js +29 -0
- package/dist/core/context-key.d.ts +14 -0
- package/dist/core/context-key.js +14 -0
- package/dist/core/contract.d.ts +54 -0
- package/dist/core/contract.js +30 -0
- package/dist/core/env.d.ts +16 -0
- package/dist/core/env.js +29 -0
- package/dist/core/error.d.ts +24 -0
- package/dist/core/error.js +25 -0
- package/dist/core/execution.d.ts +78 -0
- package/dist/core/execution.js +61 -0
- package/dist/core/implementation.d.ts +34 -0
- package/dist/core/implementation.js +30 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.js +15 -0
- package/dist/core/injection.d.ts +28 -0
- package/dist/core/injection.js +35 -0
- package/dist/core/layer.d.ts +109 -0
- package/dist/core/layer.js +52 -0
- package/dist/core/lifecycle.d.ts +34 -0
- package/dist/core/lifecycle.js +3 -0
- package/dist/core/module.d.ts +53 -0
- package/dist/core/module.js +31 -0
- package/dist/core/provider.d.ts +57 -0
- package/dist/core/provider.js +63 -0
- package/dist/core/runtime-input.d.ts +11 -0
- package/dist/core/runtime-input.js +1 -0
- package/dist/core/schema.d.ts +13 -0
- package/dist/core/schema.js +20 -0
- package/dist/core/token.d.ts +16 -0
- package/dist/core/token.js +13 -0
- package/dist/graph/graph.d.ts +17 -0
- package/dist/graph/graph.js +1078 -0
- package/dist/graph/index.d.ts +2 -0
- package/dist/graph/index.js +2 -0
- package/dist/graph/ir.d.ts +159 -0
- package/dist/graph/ir.js +1 -0
- package/dist/http/application.d.ts +18 -0
- package/dist/http/application.js +506 -0
- package/dist/http/basic-auth.d.ts +37 -0
- package/dist/http/basic-auth.js +67 -0
- package/dist/http/cors.d.ts +17 -0
- package/dist/http/cors.js +171 -0
- package/dist/http/definitions.d.ts +217 -0
- package/dist/http/definitions.js +65 -0
- package/dist/http/hosted-protocol.d.ts +4 -0
- package/dist/http/hosted-protocol.js +4 -0
- package/dist/http/index.d.ts +7 -0
- package/dist/http/index.js +6 -0
- package/dist/http/params.d.ts +2 -0
- package/dist/http/params.js +19 -0
- package/dist/http/path.d.ts +55 -0
- package/dist/http/path.js +88 -0
- package/dist/http/request-body.d.ts +4 -0
- package/dist/http/request-body.js +6 -0
- package/dist/http/validate.d.ts +20 -0
- package/dist/http/validate.js +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/message-port/environment.d.ts +2 -0
- package/dist/message-port/environment.js +4 -0
- package/dist/message-port/index.d.ts +65 -0
- package/dist/message-port/index.js +182 -0
- package/dist/runtime/application.d.ts +37 -0
- package/dist/runtime/application.js +324 -0
- package/dist/runtime/capability.d.ts +16 -0
- package/dist/runtime/capability.js +18 -0
- package/dist/runtime/di.d.ts +37 -0
- package/dist/runtime/di.js +441 -0
- package/dist/runtime/error.d.ts +10 -0
- package/dist/runtime/error.js +15 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/logger.d.ts +36 -0
- package/dist/runtime/logger.js +207 -0
- package/dist/runtime/node-capabilities.d.ts +5 -0
- package/dist/runtime/node-capabilities.js +18 -0
- package/dist/runtime/pipeline.d.ts +11 -0
- package/dist/runtime/pipeline.js +161 -0
- package/package.json +81 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ArgsClass } from './args.js';
|
|
2
|
+
import type { EnvClass } from './env.js';
|
|
3
|
+
import type { RuntimeInputKey } from './runtime-input.js';
|
|
4
|
+
import type { Class, TokenLike, TokenValue } from './token.js';
|
|
5
|
+
export type Scope = 'application' | 'transient';
|
|
6
|
+
interface ProviderBase<TToken extends TokenLike> {
|
|
7
|
+
readonly provide: TToken;
|
|
8
|
+
readonly scope: Scope;
|
|
9
|
+
}
|
|
10
|
+
export interface ClassProvider<TToken extends TokenLike = TokenLike, TValue = TokenValue<TToken>> extends ProviderBase<TToken> {
|
|
11
|
+
readonly kind: 'class';
|
|
12
|
+
readonly useClass: Class<TValue>;
|
|
13
|
+
}
|
|
14
|
+
export interface ValueProvider<TToken extends TokenLike = TokenLike> extends ProviderBase<TToken> {
|
|
15
|
+
readonly kind: 'value';
|
|
16
|
+
readonly useValue: TokenValue<TToken>;
|
|
17
|
+
readonly scope: 'application';
|
|
18
|
+
}
|
|
19
|
+
export interface FactoryProvider<TToken extends TokenLike = TokenLike> extends ProviderBase<TToken> {
|
|
20
|
+
readonly kind: 'factory';
|
|
21
|
+
readonly inject: readonly TokenLike[];
|
|
22
|
+
readonly useFactory: (...dependencies: any[]) => TokenValue<TToken>;
|
|
23
|
+
}
|
|
24
|
+
export interface ConditionalProvider<TToken extends TokenLike = TokenLike> extends ProviderBase<TToken> {
|
|
25
|
+
readonly kind: 'conditional';
|
|
26
|
+
readonly select: RuntimeInputKey<PropertyKey>;
|
|
27
|
+
readonly mapping: Readonly<Record<PropertyKey, Class<TokenValue<TToken>>>>;
|
|
28
|
+
}
|
|
29
|
+
export interface EnvironmentProvider extends ProviderBase<EnvClass> {
|
|
30
|
+
readonly kind: 'environment';
|
|
31
|
+
readonly provide: EnvClass;
|
|
32
|
+
readonly scope: 'application';
|
|
33
|
+
}
|
|
34
|
+
export interface ArgumentsProvider extends ProviderBase<ArgsClass> {
|
|
35
|
+
readonly kind: 'arguments';
|
|
36
|
+
readonly provide: ArgsClass;
|
|
37
|
+
readonly scope: 'application';
|
|
38
|
+
}
|
|
39
|
+
export type ProviderDescriptor = ClassProvider | ValueProvider | FactoryProvider | ConditionalProvider | EnvironmentProvider | ArgumentsProvider;
|
|
40
|
+
export type ProviderDeclaration = Class | ProviderDescriptor;
|
|
41
|
+
export interface ProviderScopeOptions {
|
|
42
|
+
readonly scope?: Scope;
|
|
43
|
+
}
|
|
44
|
+
export interface FactoryDefinition<T> extends ProviderScopeOptions {
|
|
45
|
+
readonly inject?: readonly TokenLike[];
|
|
46
|
+
readonly use: (...dependencies: any[]) => T;
|
|
47
|
+
}
|
|
48
|
+
export declare function provide<TToken extends TokenLike>(token: TToken): {
|
|
49
|
+
useClass(implementation: Class<TokenValue<TToken>>, options?: ProviderScopeOptions): ClassProvider<TToken>;
|
|
50
|
+
useValue(value: TokenValue<TToken>): ValueProvider<TToken>;
|
|
51
|
+
useFactory(definition: FactoryDefinition<TokenValue<TToken>>): FactoryProvider<TToken>;
|
|
52
|
+
select<TKey extends PropertyKey>(key: RuntimeInputKey<TKey>, mapping: Readonly<Record<TKey, Class<TokenValue<TToken>>>>, options?: ProviderScopeOptions): ConditionalProvider<TToken>;
|
|
53
|
+
};
|
|
54
|
+
export declare function environmentProvider(environment: EnvClass): EnvironmentProvider;
|
|
55
|
+
export declare function argumentsProvider(argumentsContract: ArgsClass): ArgumentsProvider;
|
|
56
|
+
export declare function normalizeProvider(declaration: ProviderDeclaration): ProviderDescriptor;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export function provide(token) {
|
|
2
|
+
return {
|
|
3
|
+
useClass(implementation, options = {}) {
|
|
4
|
+
return {
|
|
5
|
+
kind: 'class',
|
|
6
|
+
provide: token,
|
|
7
|
+
useClass: implementation,
|
|
8
|
+
scope: options.scope ?? 'application',
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
useValue(value) {
|
|
12
|
+
return {
|
|
13
|
+
kind: 'value',
|
|
14
|
+
provide: token,
|
|
15
|
+
useValue: value,
|
|
16
|
+
scope: 'application',
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
useFactory(definition) {
|
|
20
|
+
return {
|
|
21
|
+
kind: 'factory',
|
|
22
|
+
provide: token,
|
|
23
|
+
inject: definition.inject ?? [],
|
|
24
|
+
useFactory: definition.use,
|
|
25
|
+
scope: definition.scope ?? 'application',
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
select(key, mapping, options = {}) {
|
|
29
|
+
return {
|
|
30
|
+
kind: 'conditional',
|
|
31
|
+
provide: token,
|
|
32
|
+
select: key,
|
|
33
|
+
mapping,
|
|
34
|
+
scope: options.scope ?? 'application',
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function environmentProvider(environment) {
|
|
40
|
+
return {
|
|
41
|
+
kind: 'environment',
|
|
42
|
+
provide: environment,
|
|
43
|
+
scope: 'application',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function argumentsProvider(argumentsContract) {
|
|
47
|
+
return {
|
|
48
|
+
kind: 'arguments',
|
|
49
|
+
provide: argumentsContract,
|
|
50
|
+
scope: 'application',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function normalizeProvider(declaration) {
|
|
54
|
+
if (typeof declaration === 'function') {
|
|
55
|
+
return {
|
|
56
|
+
kind: 'class',
|
|
57
|
+
provide: declaration,
|
|
58
|
+
useClass: declaration,
|
|
59
|
+
scope: 'application',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return declaration;
|
|
63
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TokenLike } from './token.js';
|
|
2
|
+
export type RuntimeInputContract = TokenLike<object> & {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
};
|
|
5
|
+
export interface RuntimeInputKey<TValue = unknown> {
|
|
6
|
+
readonly kind: 'runtime-input-key';
|
|
7
|
+
readonly source: 'environment' | 'arguments';
|
|
8
|
+
readonly contract: RuntimeInputContract;
|
|
9
|
+
readonly key: string;
|
|
10
|
+
readonly '~value'?: TValue;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
export type { StandardJSONSchemaV1, StandardSchemaV1, } from '@standard-schema/spec';
|
|
3
|
+
export type StandardSchemaResult<Output> = StandardSchemaV1.Result<Output>;
|
|
4
|
+
export type SchemaOutput<Schema> = Schema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Schema> : never;
|
|
5
|
+
export type SchemaInput<Schema> = Schema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Schema> : never;
|
|
6
|
+
export type JsonSchemaInput<Schema> = Schema extends StandardJSONSchemaV1 ? StandardJSONSchemaV1.InferInput<Schema> : never;
|
|
7
|
+
export type JsonSchemaOutput<Schema> = Schema extends StandardJSONSchemaV1 ? StandardJSONSchemaV1.InferOutput<Schema> : never;
|
|
8
|
+
export declare function supportsJsonSchema(schema: StandardSchemaV1): schema is StandardSchemaV1 & StandardJSONSchemaV1;
|
|
9
|
+
export declare function validateSchema<Schema extends StandardSchemaV1>(schema: Schema, value: unknown): Promise<SchemaOutput<Schema>>;
|
|
10
|
+
export declare class SchemaValidationError extends Error {
|
|
11
|
+
readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;
|
|
12
|
+
constructor(issues: SchemaValidationError['issues']);
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function supportsJsonSchema(schema) {
|
|
2
|
+
const standard = schema['~standard'];
|
|
3
|
+
return (typeof standard.jsonSchema?.input === 'function' &&
|
|
4
|
+
typeof standard.jsonSchema.output === 'function');
|
|
5
|
+
}
|
|
6
|
+
export async function validateSchema(schema, value) {
|
|
7
|
+
const result = await schema['~standard'].validate(value);
|
|
8
|
+
if (result.issues) {
|
|
9
|
+
throw new SchemaValidationError(result.issues);
|
|
10
|
+
}
|
|
11
|
+
return result.value;
|
|
12
|
+
}
|
|
13
|
+
export class SchemaValidationError extends Error {
|
|
14
|
+
issues;
|
|
15
|
+
constructor(issues) {
|
|
16
|
+
super('Schema validation failed');
|
|
17
|
+
this.name = 'SchemaValidationError';
|
|
18
|
+
this.issues = issues;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface TokenOptions {
|
|
2
|
+
readonly description?: string;
|
|
3
|
+
}
|
|
4
|
+
export interface Token<T> {
|
|
5
|
+
readonly kind: 'token';
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly description?: string;
|
|
8
|
+
readonly key: symbol;
|
|
9
|
+
readonly '~type'?: T;
|
|
10
|
+
}
|
|
11
|
+
export type Class<T = unknown> = new (...args: any[]) => T;
|
|
12
|
+
export type AbstractClass<T = unknown> = abstract new (...args: any[]) => T;
|
|
13
|
+
export type TokenLike<T = unknown> = Token<T> | AbstractClass<T>;
|
|
14
|
+
export type TokenValue<TToken> = TToken extends Token<infer Value> ? Value : TToken extends AbstractClass<infer Value> ? Value : never;
|
|
15
|
+
export declare function token<T>(id: string, options?: TokenOptions): Token<T>;
|
|
16
|
+
export declare function tokenName(value: TokenLike): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function token(id, options = {}) {
|
|
2
|
+
return Object.freeze({
|
|
3
|
+
kind: 'token',
|
|
4
|
+
id,
|
|
5
|
+
...(options.description === undefined
|
|
6
|
+
? {}
|
|
7
|
+
: { description: options.description }),
|
|
8
|
+
key: Symbol(id),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export function tokenName(value) {
|
|
12
|
+
return typeof value === 'function' ? value.name : value.id;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ArgsClass, type ModuleInstance, type ModuleTemplate, type TaskDescriptor, type TriggerDescriptor } from '../core/index.js';
|
|
2
|
+
import type { ApplicationGraphIR, CompilationResult, Diagnostic } from './ir.js';
|
|
3
|
+
export declare class StaticValidationError extends Error {
|
|
4
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
5
|
+
readonly graph?: ApplicationGraphIR | undefined;
|
|
6
|
+
constructor(diagnostics: readonly Diagnostic[], graph?: ApplicationGraphIR | undefined);
|
|
7
|
+
}
|
|
8
|
+
export interface ApplicationCompilationInput {
|
|
9
|
+
readonly modules: readonly (ModuleInstance | ModuleTemplate<void>)[];
|
|
10
|
+
readonly arguments?: ArgsClass | undefined;
|
|
11
|
+
readonly tasks?: readonly TaskDescriptor<any, any>[];
|
|
12
|
+
readonly triggers?: readonly TriggerDescriptor[];
|
|
13
|
+
}
|
|
14
|
+
export declare function compileApplication(input: ApplicationCompilationInput): CompilationResult;
|
|
15
|
+
export declare const buildApplicationGraph: typeof compileApplication;
|
|
16
|
+
export declare function validateGraph(graph: ApplicationGraphIR): readonly Diagnostic[];
|
|
17
|
+
export declare function assertValidCompilation(result: CompilationResult): ApplicationGraphIR;
|