alepha 0.8.1 → 0.9.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.
@@ -1,91 +1,89 @@
1
- import { Alepha, HookDescriptor, KIND, Logger, OPTIONS } from "alepha";
1
+ import * as _alepha_core0$1 from "alepha";
2
+ import * as _alepha_core0 from "alepha";
3
+ import { Alepha, Descriptor, KIND, Logger } from "alepha";
2
4
  import { ServerHandler, ServerRouterProvider } from "alepha/server";
3
5
  import { DateTimeProvider, DurationLike } from "alepha/datetime";
4
6
 
5
7
  //#region src/descriptors/$serve.d.ts
6
- declare const KEY = "SERVE";
7
8
  /**
8
- * Create a new static file handler.
9
- */
9
+ * Create a new static file handler.
10
+ */
10
11
  declare const $serve: {
11
12
  (options?: ServeDescriptorOptions): ServeDescriptor;
12
- [KIND]: string;
13
+ [KIND]: typeof ServeDescriptor;
13
14
  };
14
15
  interface ServeDescriptorOptions {
15
16
  /**
16
- * Prefix for the served path.
17
- *
18
- * @default "/"
19
- */
17
+ * Prefix for the served path.
18
+ *
19
+ * @default "/"
20
+ */
20
21
  path?: string;
21
22
  /**
22
- * Path to the directory to serve.
23
- *
24
- * @default process.cwd()
25
- */
23
+ * Path to the directory to serve.
24
+ *
25
+ * @default process.cwd()
26
+ */
26
27
  root?: string;
27
28
  /**
28
- * If true, descriptor will be ignored.
29
- *
30
- * @default false
31
- */
29
+ * If true, descriptor will be ignored.
30
+ *
31
+ * @default false
32
+ */
32
33
  disabled?: boolean;
33
34
  /**
34
- * Whether to keep dot files (e.g. `.gitignore`, `.env`) in the served directory.
35
- *
36
- * @default true
37
- */
35
+ * Whether to keep dot files (e.g. `.gitignore`, `.env`) in the served directory.
36
+ *
37
+ * @default true
38
+ */
38
39
  ignoreDotEnvFiles?: boolean;
39
40
  /**
40
- * Whether to use the index.html file when the path is a directory.
41
- *
42
- * @default true
43
- */
41
+ * Whether to use the index.html file when the path is a directory.
42
+ *
43
+ * @default true
44
+ */
44
45
  indexFallback?: boolean;
45
46
  /**
46
- * Force all requests "not found" to be served with the index.html file.
47
- * This is useful for single-page applications (SPAs) that use client-side only routing.
48
- */
47
+ * Force all requests "not found" to be served with the index.html file.
48
+ * This is useful for single-page applications (SPAs) that use client-side only routing.
49
+ */
49
50
  historyApiFallback?: boolean;
50
51
  /**
51
- * Optional name of the descriptor.
52
- * This is used for logging and debugging purposes.
53
- *
54
- * @default Key name.
55
- */
52
+ * Optional name of the descriptor.
53
+ * This is used for logging and debugging purposes.
54
+ *
55
+ * @default Key name.
56
+ */
56
57
  name?: string;
57
58
  /**
58
- * Whether to use cache control headers.
59
- *
60
- * @default {}
61
- */
59
+ * Whether to use cache control headers.
60
+ *
61
+ * @default {}
62
+ */
62
63
  cacheControl?: Partial<CacheControlOptions> | false;
63
64
  }
64
65
  interface CacheControlOptions {
65
66
  /**
66
- * Whether to use cache control headers.
67
- *
68
- * @default [.js, .css]
69
- */
67
+ * Whether to use cache control headers.
68
+ *
69
+ * @default [.js, .css]
70
+ */
70
71
  fileTypes: string[];
71
72
  /**
72
- * The maximum age of the cache in seconds.
73
- *
74
- * @default 60 * 60 * 24 * 2 // 2 days
75
- */
73
+ * The maximum age of the cache in seconds.
74
+ *
75
+ * @default 60 * 60 * 24 * 2 // 2 days
76
+ */
76
77
  maxAge: DurationLike;
77
78
  /**
78
- * Whether to use immutable cache control headers.
79
- *
80
- * @default true
81
- */
79
+ * Whether to use immutable cache control headers.
80
+ *
81
+ * @default true
82
+ */
82
83
  immutable: boolean;
83
84
  }
84
- interface ServeDescriptor {
85
- [KIND]: typeof KEY;
86
- [OPTIONS]: ServeDescriptorOptions;
87
- list(): string[];
88
- }
85
+ declare class ServeDescriptor extends Descriptor<ServeDescriptorOptions> {}
86
+ //# sourceMappingURL=$serve.d.ts.map
89
87
  //#endregion
90
88
  //#region src/providers/ServerStaticProvider.d.ts
91
89
  declare class ServerStaticProvider {
@@ -94,9 +92,8 @@ declare class ServerStaticProvider {
94
92
  protected readonly dateTimeProvider: DateTimeProvider;
95
93
  protected readonly log: Logger;
96
94
  protected readonly directories: ServeDirectory[];
97
- protected readonly configure: HookDescriptor<"configure">;
98
- list(name: string): string[];
99
- serve(options: ServeDescriptorOptions): Promise<void>;
95
+ protected readonly configure: _alepha_core0$1.HookDescriptor<"configure">;
96
+ createStaticServer(options: ServeDescriptorOptions): Promise<void>;
100
97
  createFileHandler(filepath: string, options: ServeDescriptorOptions): Promise<ServerHandler>;
101
98
  protected getCacheFileTypes(): string[];
102
99
  protected getCacheControl(filename: string, options: ServeDescriptorOptions): {
@@ -109,19 +106,18 @@ interface ServeDirectory {
109
106
  options: ServeDescriptorOptions;
110
107
  files: string[];
111
108
  }
109
+ //# sourceMappingURL=ServerStaticProvider.d.ts.map
112
110
  //#endregion
113
111
  //#region src/index.d.ts
114
- // ---------------------------------------------------------------------------------------------------------------------
115
112
  /**
116
- * Create static file server with `$static()`.
117
- *
118
- * @see {@link ServerStaticProvider}
119
- * @module alepha.server.static
120
- */
121
- declare class AlephaServerStatic {
122
- readonly name = "alepha.server.static";
123
- readonly $services: (alepha: Alepha) => void;
124
- }
113
+ * Create static file server with `$static()`.
114
+ *
115
+ * @see {@link ServerStaticProvider}
116
+ * @module alepha.server.static
117
+ */
118
+ declare const AlephaServerStatic: _alepha_core0.ModuleDescriptor;
119
+ //# sourceMappingURL=index.d.ts.map
120
+
125
121
  //#endregion
126
122
  export { $serve, AlephaServerStatic, CacheControlOptions, ServeDescriptor, ServeDescriptorOptions, ServeDirectory, ServerStaticProvider };
127
123
  //# sourceMappingURL=index.d.ts.map
@@ -1,25 +1,27 @@
1
- import { Alepha, HookDescriptor, KIND, Module, OPTIONS, TObject } from "alepha";
2
- import { ServerActionDescriptorProvider, ServerRouteAction, ServerRouterProvider } from "alepha/server";
1
+ import * as _alepha_core0$1 from "alepha";
2
+ import * as _alepha_core0 from "alepha";
3
+ import { Alepha, Descriptor, KIND, TObject } from "alepha";
4
+ import { ActionDescriptor, RequestConfigSchema, ServerRouterProvider } from "alepha/server";
3
5
  import { ServerStaticProvider } from "alepha/server/static";
4
6
  import { OpenAPIV3 } from "openapi-types";
5
7
 
6
8
  //#region src/descriptors/$swagger.d.ts
7
9
  /**
8
- * Create a new OpenAPI.
9
- */
10
+ * Create a new OpenAPI.
11
+ */
10
12
  declare const $swagger: {
11
13
  (options: SwaggerDescriptorOptions): SwaggerDescriptor;
12
- [KIND]: string;
14
+ [KIND]: typeof SwaggerDescriptor;
13
15
  };
14
16
  interface SwaggerDescriptorOptions {
15
17
  info: OpenAPIV3.InfoObject;
16
18
  /**
17
- * @default: "/docs"
18
- */
19
+ * @default: "/docs"
20
+ */
19
21
  prefix?: string;
20
22
  /**
21
- * If true, docs will be disabled.
22
- */
23
+ * If true, docs will be disabled.
24
+ */
23
25
  disabled?: boolean;
24
26
  excludeTags?: string[];
25
27
  ui?: boolean | SwaggerUiOptions;
@@ -29,95 +31,104 @@ interface SwaggerUiOptions {
29
31
  root?: string;
30
32
  initOAuth?: {
31
33
  /**
32
- * Default clientId.
33
- */
34
+ * Default clientId.
35
+ */
34
36
  clientId?: string;
35
37
  /**
36
- * realm query parameter (for oauth1) added to authorizationUrl and tokenUrl.
37
- */
38
+ * realm query parameter (for oauth1) added to authorizationUrl and tokenUrl.
39
+ */
38
40
  realm?: string;
39
41
  /**
40
- * application name, displayed in authorization popup.
41
- */
42
+ * application name, displayed in authorization popup.
43
+ */
42
44
  appName?: string;
43
45
  /**
44
- * scope separator for passing scopes, encoded before calling, default
45
- * value is a space (encoded value %20).
46
- *
47
- * @default ' '
48
- */
46
+ * scope separator for passing scopes, encoded before calling, default
47
+ * value is a space (encoded value %20).
48
+ *
49
+ * @default ' '
50
+ */
49
51
  scopeSeparator?: string;
50
52
  /**
51
- * string array or scope separator (i.e. space) separated string of
52
- * initially selected oauth scopes
53
- *
54
- * @default []
55
- */
53
+ * string array or scope separator (i.e. space) separated string of
54
+ * initially selected oauth scopes
55
+ *
56
+ * @default []
57
+ */
56
58
  scopes?: string | string[];
57
59
  /**
58
- * Additional query parameters added to authorizationUrl and tokenUrl.
59
- * MUST be an object
60
- */
60
+ * Additional query parameters added to authorizationUrl and tokenUrl.
61
+ * MUST be an object
62
+ */
61
63
  additionalQueryStringParams?: {
62
64
  [key: string]: any;
63
65
  };
64
66
  /**
65
- * Only activated for the accessCode flow. During the authorization_code
66
- * request to the tokenUrl, pass the Client Password using the HTTP Basic
67
- * Authentication scheme (Authorization header with Basic
68
- * base64encode(client_id + client_secret)).
69
- *
70
- * @default false
71
- */
67
+ * Only activated for the accessCode flow. During the authorization_code
68
+ * request to the tokenUrl, pass the Client Password using the HTTP Basic
69
+ * Authentication scheme (Authorization header with Basic
70
+ * base64encode(client_id + client_secret)).
71
+ *
72
+ * @default false
73
+ */
72
74
  useBasicAuthenticationWithAccessCodeGrant?: boolean;
73
75
  /**
74
- * Only applies to Authorization Code flows. Proof Key for Code Exchange
75
- * brings enhanced security for OAuth public clients.
76
- *
77
- * @default false
78
- */
76
+ * Only applies to Authorization Code flows. Proof Key for Code Exchange
77
+ * brings enhanced security for OAuth public clients.
78
+ *
79
+ * @default false
80
+ */
79
81
  usePkceWithAuthorizationCodeGrant?: boolean;
80
82
  };
81
83
  }
82
- interface SwaggerDescriptor {
83
- [KIND]: "SWAGGER";
84
- [OPTIONS]: SwaggerDescriptorOptions;
85
- json(): OpenAPIV3.Document;
86
- }
84
+ declare class SwaggerDescriptor extends Descriptor<SwaggerDescriptorOptions> {}
85
+ //# sourceMappingURL=$swagger.d.ts.map
87
86
  //#endregion
88
87
  //#region src/ServerSwaggerProvider.d.ts
89
88
  declare class ServerSwaggerProvider {
90
- protected readonly serverActionProvider: ServerActionDescriptorProvider;
91
89
  protected readonly serverStaticProvider: ServerStaticProvider;
92
90
  protected readonly serverRouterProvider: ServerRouterProvider;
93
91
  protected readonly alepha: Alepha;
94
- protected readonly configure: HookDescriptor<"configure">;
95
- protected configureOpenApi(doc: SwaggerDescriptorOptions): OpenAPIV3.Document;
92
+ json?: OpenAPIV3.Document;
93
+ protected readonly configure: _alepha_core0$1.HookDescriptor<"configure">;
94
+ createSwagger(options: SwaggerDescriptorOptions): Promise<OpenAPIV3.Document | undefined>;
95
+ protected configureOpenApi(actions: ActionDescriptor<RequestConfigSchema>[], doc: SwaggerDescriptorOptions): OpenAPIV3.Document;
96
96
  isBodyMultipart(schema: TObject): boolean;
97
97
  replacePathParams(url: string): string;
98
- getResponseSchema(route: ServerRouteAction): {
98
+ getResponseSchema(route: ActionDescriptor<RequestConfigSchema>): {
99
99
  type?: string;
100
100
  schema?: any;
101
101
  status: number;
102
102
  } | undefined;
103
- protected configureSwaggerApi(prefix: string, json: OpenAPIV3.Document): Promise<void>;
103
+ protected configureSwaggerApi(prefix: string, json: OpenAPIV3.Document): void;
104
104
  protected configureSwaggerUi(prefix: string, options: SwaggerDescriptorOptions): Promise<void>;
105
105
  }
106
+ //# sourceMappingURL=ServerSwaggerProvider.d.ts.map
106
107
  //#endregion
107
108
  //#region src/index.d.ts
108
- // ---------------------------------------------------------------------------------------------------------------------
109
- /**
110
- * Plugin for Alepha Server that provides Swagger documentation capabilities.
111
- * It generates OpenAPI v3 documentation for the server's endpoints ($action).
112
- * It also provides a Swagger UI for interactive API documentation.
113
- *
114
- * @see {@link ServerSwaggerProvider}
115
- * @module alepha.server.swagger
116
- */
117
- declare class AlephaServerSwagger implements Module {
118
- readonly name = "alepha.server.swagger";
119
- readonly $services: (alepha: Alepha) => Alepha;
109
+ declare module "alepha/server" {
110
+ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> {
111
+ /**
112
+ * Short description of the route.
113
+ */
114
+ summary?: string;
115
+ /**
116
+ * Don't include this action in the Swagger documentation.
117
+ */
118
+ hide?: boolean;
119
+ }
120
120
  }
121
+ /**
122
+ * Plugin for Alepha Server that provides Swagger documentation capabilities.
123
+ * It generates OpenAPI v3 documentation for the server's endpoints ($action).
124
+ * It also provides a Swagger UI for interactive API documentation.
125
+ *
126
+ * @see {@link ServerSwaggerProvider}
127
+ * @module alepha.server.swagger
128
+ */
129
+ declare const AlephaServerSwagger: _alepha_core0.ModuleDescriptor;
130
+ //# sourceMappingURL=index.d.ts.map
131
+
121
132
  //#endregion
122
133
  export { $swagger, AlephaServerSwagger, ServerSwaggerProvider, SwaggerDescriptor, SwaggerDescriptorOptions, SwaggerUiOptions };
123
134
  //# sourceMappingURL=index.d.ts.map