@small-web/kitten-types 1.1.5 → 2.0.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.
Files changed (80) hide show
  1. package/README.md +9 -2
  2. package/fragments.d.ts +13 -14
  3. package/global.d.ts +6 -1096
  4. package/index.d.ts +7 -27
  5. package/kitten/src/AppDatabase.d.ts +10 -0
  6. package/kitten/src/AppRepository.d.ts +101 -0
  7. package/kitten/src/AutomaticUpdates.d.ts +21 -0
  8. package/kitten/src/Files.d.ts +61 -0
  9. package/kitten/src/GlobalInternalDatabase.d.ts +22 -0
  10. package/kitten/src/InternalDatabase.d.ts +7 -0
  11. package/kitten/src/REPL.d.ts +5 -0
  12. package/kitten/src/Routes.d.ts +41 -0
  13. package/kitten/src/Server.d.ts +76 -0
  14. package/kitten/src/ServerError.d.ts +6 -0
  15. package/kitten/src/Sessions.d.ts +32 -0
  16. package/kitten/src/Uploads.d.ts +20 -0
  17. package/kitten/src/Utils.d.ts +79 -0
  18. package/kitten/src/cli/commands/db.d.ts +48 -0
  19. package/kitten/src/cli/commands/deploy.d.ts +16 -0
  20. package/kitten/src/cli/commands/disable.d.ts +9 -0
  21. package/kitten/src/cli/commands/enable.d.ts +9 -0
  22. package/kitten/src/cli/commands/logs.d.ts +15 -0
  23. package/kitten/src/cli/commands/restart.d.ts +11 -0
  24. package/kitten/src/cli/commands/run.d.ts +15 -0
  25. package/kitten/src/cli/commands/serve.d.ts +13 -0
  26. package/kitten/src/cli/commands/shell.d.ts +1 -0
  27. package/kitten/src/cli/commands/start.d.ts +9 -0
  28. package/kitten/src/cli/commands/status.d.ts +15 -0
  29. package/kitten/src/cli/commands/stop.d.ts +9 -0
  30. package/kitten/src/cli/commands/uninstall.d.ts +9 -0
  31. package/kitten/src/cli/commands/update.d.ts +7 -0
  32. package/kitten/src/cli/index.d.ts +55 -0
  33. package/kitten/src/cli/lib/WarningBox.d.ts +8 -0
  34. package/kitten/src/cli/lib/header.d.ts +10 -0
  35. package/kitten/src/components/SvgSpinner.component.d.ts +9 -0
  36. package/kitten/src/lib/KittenComponent.d.ts +340 -0
  37. package/kitten/src/lib/KittenMoji.d.ts +35 -0
  38. package/kitten/src/lib/KittenPackage.d.ts +56 -0
  39. package/kitten/src/lib/KittenPage.d.ts +202 -0
  40. package/kitten/src/lib/Version.d.ts +49 -0
  41. package/kitten/src/lib/ansi-highlight-html.d.ts +5 -0
  42. package/kitten/src/lib/components/stateful/CopyButton.component.d.ts +14 -0
  43. package/kitten/src/lib/components/stateless/copyButton.component.d.ts +21 -0
  44. package/kitten/src/lib/crypto.d.ts +95 -0
  45. package/kitten/src/lib/deploy.d.ts +20 -0
  46. package/kitten/src/lib/ensure.d.ts +28 -0
  47. package/kitten/src/lib/fragments.d.ts +1 -0
  48. package/kitten/src/lib/globals.d.ts +10 -0
  49. package/kitten/src/lib/html.d.ts +61 -0
  50. package/kitten/src/lib/markdown.d.ts +16 -0
  51. package/kitten/src/lib/paths.d.ts +25 -0
  52. package/kitten/src/lib/service-status.d.ts +14 -0
  53. package/kitten/src/lib/system-exit-codes.d.ts +39 -0
  54. package/kitten/src/lib/terminal-link.d.ts +24 -0
  55. package/kitten/src/middleware/authentication.d.ts +8 -0
  56. package/kitten/src/middleware/index.d.ts +5 -0
  57. package/kitten/src/middleware/request-and-response-helpers.d.ts +6 -0
  58. package/kitten/src/middleware/request-log.d.ts +10 -0
  59. package/kitten/src/middleware/sessions.d.ts +3 -0
  60. package/kitten/src/middleware/stats.d.ts +8 -0
  61. package/kitten/src/middleware/trailing-slashes.d.ts +11 -0
  62. package/kitten/src/middleware/websocket.d.ts +14 -0
  63. package/kitten/src/routes/HttpRoute.d.ts +16 -0
  64. package/kitten/src/routes/LazilyLoadedRoute.d.ts +15 -0
  65. package/kitten/src/routes/PageRoute.d.ts +54 -0
  66. package/kitten/src/routes/PageSocketRoute.d.ts +42 -0
  67. package/kitten/src/routes/PostRoute.d.ts +64 -0
  68. package/kitten/src/routes/StaticRoute.d.ts +17 -0
  69. package/kitten/src/routes/WebSocketRoute.d.ts +21 -0
  70. package/kitten/src/routes/lib/validator.d.ts +18 -0
  71. package/kitten/src/types/fragments.d.ts +14 -0
  72. package/kitten/src/types/globals.d.ts +1239 -0
  73. package/kitten/src/types/index.d.ts +12 -0
  74. package/kitten/src/types/types.d.ts +476 -0
  75. package/kitten/third-party-libraries-with-missing-type-information/index.d.ts +37 -0
  76. package/package.json +16 -5
  77. package/types.d.ts +5 -712
  78. package/polka/index.d.ts +0 -111
  79. package/slugify/index.d.ts +0 -246
  80. /package/{ws → kitten/third-party-libraries-with-missing-type-information/ws}/index.d.ts +0 -0
package/index.d.ts CHANGED
@@ -3,38 +3,18 @@
3
3
 
4
4
  This entry point re-exports Kitten types for use in explicit annotations.
5
5
 
6
+ The types themselves are generated from Kitten’s TypeScript source code
7
+ (see kitten/ – regenerated via `npm run sync-types` in the Kitten repository),
8
+ so Kitten’s implementation is the single source of truth.
9
+
6
10
  Side-effect: Brings `declare global { var kitten }` into scope for any project that depends on this package.
7
11
  */
8
12
 
13
+ /// <reference path="./kitten/third-party-libraries-with-missing-type-information/index.d.ts" />
14
+
9
15
  import './global.d.ts'
10
16
  import './fragments.d.ts'
11
17
 
12
18
  // Reusable types, re-exported for explicit annotations
13
19
  // (e.g. `import type { KittenRequest } from '@small-web/kitten-types'`).
14
- export type {
15
- Session,
16
- WebSocket,
17
- BufferLike,
18
- slugify,
19
- Polka,
20
- MarkdownIt,
21
- Upload,
22
- LazilyLoadedRoute,
23
- MessageSender,
24
- Listener,
25
- KittenComponent,
26
- KittenPage,
27
- ParsedURL,
28
- PolkaResponse,
29
- PolkaRequest,
30
- KittenRequest,
31
- KittenResponse,
32
- KittenPostRequest,
33
- Point,
34
- Signature
35
- } from './types.d.ts'
36
-
37
- export type { yaml } from './types.d.ts'
38
-
39
- // Also export hand-written global namespace shape, in case an author wants to reference it explicitly (e.g. `typeof kitten`).
40
- export type { kitten } from './global.d.ts'
20
+ export type * from './kitten/src/types/index.d.ts'
@@ -0,0 +1,10 @@
1
+ /**
2
+ Initialise the default database of the app we’re serving.
3
+ This can either be via the database app module defined in
4
+ the app, or, if one does not exist, the default untyped
5
+ Kitten database.
6
+ */
7
+ export default class Database {
8
+ path: string | null;
9
+ initialise(): Promise<void>;
10
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ App class
3
+
4
+ Represents the git repository of the app that Kitten is currently serving.
5
+
6
+ (Only relevant in production.)
7
+ */
8
+ import Version from './lib/Version.ts';
9
+ import type { SimpleGit } from 'simple-git';
10
+ export default class AppRepository {
11
+ path: string;
12
+ git: SimpleGit;
13
+ kittenVersion: Version;
14
+ remoteTags: Array<string> | undefined;
15
+ lastRemoteTagUpdate: Date | undefined;
16
+ originRemoteUrl: string | undefined;
17
+ hasOrigin: boolean | undefined;
18
+ currentVersion: string | undefined;
19
+ latestAvailableCommit: string | undefined;
20
+ usesKittenVersioning: boolean | undefined;
21
+ manualUpdateAvailable: boolean | undefined;
22
+ currentApiVersion: number | undefined;
23
+ currentAppVersion: number | undefined;
24
+ tags: string[] | undefined;
25
+ tagsByApiAndAppVersion: [number, number][] | undefined;
26
+ latestVersionByApiVersion: number[] | undefined;
27
+ compatibleTags: string[] | undefined;
28
+ incompatibleTags: string[] | undefined;
29
+ latestApiVersion: number | undefined;
30
+ latestAppVersion: number | undefined;
31
+ latestVersion: string | undefined;
32
+ latestCompatibleAppVersion: number | undefined;
33
+ latestCompatibleVersion: string | undefined;
34
+ static instance: AppRepository | undefined;
35
+ static isBeingInitialisedAsSingleton: boolean;
36
+ /** Matches Kitten version tag strings in the form '<number>.<number>' */
37
+ static kittenVersionRegExp: RegExp;
38
+ /**
39
+ Singleton accessor.
40
+
41
+ Use this method to get an initialised/updated instance.
42
+
43
+ You can always call the update() method again later to get the latest data
44
+ from the remote repository.
45
+ */
46
+ static getInstance(): Promise<AppRepository>;
47
+ /**
48
+ Create an instance (should only be called in production).
49
+ */
50
+ constructor();
51
+ /**
52
+ Updates the app to the latest compatible version.
53
+ */
54
+ upgradeAppToLatestCompatibleVersion(): Promise<void>;
55
+ /**
56
+ Updates the app to the latest available commit.
57
+ */
58
+ upgradeAppToLatestAvailableCommit(): Promise<void>;
59
+ /**
60
+ Updates the app to the specified version tag.
61
+ */
62
+ updateAppToVersion(versionTag: string): Promise<void>;
63
+ /**
64
+ Updates the app repository with the latest information and content.
65
+
66
+ After this method is run, you should have all tags and their content available locally so
67
+ you can simply use the checkout() method to update the application to the required version.
68
+ */
69
+ update(): Promise<void>;
70
+ get hasCompatibleAppVersion(): boolean;
71
+ get canBeUpgraded(): boolean;
72
+ get hasNewerApiVersion(): boolean;
73
+ /**
74
+ Returns the string 'upgrade' or 'downgrade' based on whether
75
+ going from the current app version to the provided version string
76
+ would be an upgrade or a downgrade.
77
+
78
+ If lowercase is false, the string is returned in sentence case.
79
+
80
+ Does not handle the versions being include. For that, see the
81
+ isEqualToVersion() method.
82
+ */
83
+ upgradeOrDowngrade(versionTag: string, lowercase?: boolean): false | "downgrade" | "Downgrade" | "upgrade" | "Upgrade";
84
+ isEqualToVersion(versionTag: string): boolean;
85
+ UpdateButtonComponent(): ({ type, version, small }: {
86
+ type?: string | undefined;
87
+ version?: string | undefined;
88
+ small?: boolean | undefined;
89
+ }) => string | string[] | Promise<string | string[]>;
90
+ VersionComponent({ version, compatible, brief }: {
91
+ version: string;
92
+ compatible?: boolean;
93
+ brief?: boolean;
94
+ }): string | string[] | Promise<string | string[]>;
95
+ CurrentAppVersionComponent(): () => string | string[] | Promise<string | string[]>;
96
+ AllAvailableVersionsComponent(): string | string[] | Promise<string | string[]> | (() => string | string[] | Promise<string | string[]>);
97
+ /**
98
+ Display app version if Kitten is running in production.
99
+ */
100
+ displayAppVersion(): void;
101
+ }
@@ -0,0 +1,21 @@
1
+ import AppRepository from './AppRepository.ts';
2
+ import KittenPackage from './lib/KittenPackage.ts';
3
+ export default class AutomaticUpdates {
4
+ static instance: AutomaticUpdates;
5
+ running: boolean;
6
+ lastCheck: Date;
7
+ kittenPackage: KittenPackage | undefined;
8
+ appRepository: AppRepository | undefined;
9
+ intervalId: ReturnType<typeof setInterval> | undefined;
10
+ get interval(): number;
11
+ set interval(intervalInMiliseconds: number);
12
+ static getInstance(): AutomaticUpdates;
13
+ start(): Promise<void>;
14
+ requestRestart(): void;
15
+ updateLastCheck(): void;
16
+ checkForUpdates(): Promise<void>;
17
+ get intervalInHours(): number;
18
+ timeToNextCheck(): number;
19
+ timeToNextCheckPretty(): string | number;
20
+ stop(): void;
21
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ Files: handles the files in the project.
3
+
4
+ Copyright ⓒ 2021-present, Aral Balkan (mail@ar.al)
5
+ Small Technology Foundation (https://small-tech.org)
6
+ License: AGPL version 3.0.
7
+ */
8
+ import Watcher from 'watcher';
9
+ export declare class FileEventDetails {
10
+ itemType: string;
11
+ eventType: string;
12
+ itemPath: string;
13
+ constructor(itemType?: string, eventType?: string, itemPath?: string);
14
+ }
15
+ type FilesByExtension = Record<string, string[]>;
16
+ export declare class FilesByExtensionCategoryType {
17
+ [categoryType: string]: FilesByExtension;
18
+ constructor();
19
+ }
20
+ /**
21
+ Async filter function.
22
+
23
+ Thanks to: https://stackoverflow.com/a/62820464
24
+ */
25
+ export declare function asyncFilter(array: any[], predicate: (value: any, index: number, array?: any[]) => any): Promise<any[]>;
26
+ /**
27
+ Checks if passed symlink is within the root
28
+ directory of the project we’re serving and
29
+ thus whether it is safe.
30
+ */
31
+ export declare function isSafeSymlink(symlink: string): Promise<boolean>;
32
+ export default class Files extends EventTarget {
33
+ static isBeingInstantiatedByFactoryMethod: boolean;
34
+ /**
35
+ Static factory method: constructs a Files instance, asynchronously
36
+ initialises it, and returns the list of files found organised by
37
+ their extension category type.
38
+ */
39
+ static new(basePath?: string): Promise<Files>;
40
+ watcher: Watcher;
41
+ pathToWatch: string;
42
+ byExtensionCategoryType: FilesByExtensionCategoryType;
43
+ /**
44
+ Find files at given base path and start watching for changes.
45
+ */
46
+ constructor(basePath: string);
47
+ initialise(): Promise<void>;
48
+ /**
49
+ Adds file to the list of files.
50
+ */
51
+ addFile(filePath: string): void;
52
+ /**
53
+ Notifies file listeners that an action has happened on a file.
54
+ */
55
+ notifyListeners(fileEventDetails: FileEventDetails): Promise<void>;
56
+ /**
57
+ Closes the watcher.
58
+ */
59
+ close(): void;
60
+ }
61
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ Initialise Kitten’s global internal database (kitten.__db).
3
+
4
+ (That’s two underscores to – uhum – underscore the fact that this
5
+ is really, really internal so don’t go messing in here. *makes scary noises*
6
+ Here, have a ghost emoji: 👻)
7
+
8
+ Unlike Kitten‘s internal and app databases, this database is
9
+ scoped to the Kitten instance, *not* to the app that Kitten is serving.
10
+ */
11
+ declare class State {
12
+ isBeingDeployedByDomain: boolean;
13
+ constructor(properties?: {});
14
+ }
15
+ export type GlobalInternalDatabaseType = {
16
+ state: State;
17
+ };
18
+ export default class GlobalInternalDatabase {
19
+ static __db: GlobalInternalDatabaseType | null;
20
+ static initialise(): Promise<GlobalInternalDatabaseType>;
21
+ }
22
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ Initialise Kitten’s own internal database (kitten._db).
3
+ */
4
+ export default class InternalDatabase {
5
+ path: string | null;
6
+ initialise(): Promise<void>;
7
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ Sets up Kitten REPL (either an interactive one if running locally or on a socket if running as a daemon).
3
+
4
+ */
5
+ export default function (domainWithPort: string): void;
@@ -0,0 +1,41 @@
1
+ /**
2
+ Kitten Routes
3
+
4
+ Copyright ⓒ 2021-present, Aral Balkan
5
+ Small Technology Foundation
6
+ License: AGPL version 3.0.
7
+ */
8
+ import Files, { FileEventDetails } from './Files.ts';
9
+ import StaticRoute from './routes/StaticRoute.ts';
10
+ import type { LazilyLoadedRoute } from './types/index.ts';
11
+ export type RouteDictionary = Record<string, LazilyLoadedRoute | StaticRoute>;
12
+ export default class Routes {
13
+ routes: Record<string, RouteDictionary>;
14
+ basePath: string;
15
+ files: Files | undefined;
16
+ static isBeingInstantiatedByFactoryMethod: boolean;
17
+ /**
18
+ Returns the routes for the passed base path.
19
+
20
+ (The default base path is the primary place being served, as kept
21
+ in the `basePath` environment variable.)
22
+ */
23
+ static getRoutes(basePath?: string): Promise<Record<string, RouteDictionary>>;
24
+ /**
25
+ Private constructor.
26
+ */
27
+ constructor(basePath: string);
28
+ /**
29
+ Creates and returns the routes at the base path.
30
+ */
31
+ initialise(): Promise<Record<string, RouteDictionary>>;
32
+ /**
33
+ Handle file change events.
34
+ */
35
+ handleFileChange(event: CustomEvent<FileEventDetails>): void;
36
+ /**
37
+ Creates routes of a certain category type.
38
+ */
39
+ createRoutesOfCategoryType(categoryType: string): void;
40
+ createRoutes(): void;
41
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ Kitten Server.
3
+
4
+ Copyright © 2021-present, Aral Balkan
5
+ Small Technology Foundation
6
+ License: AGPL version 3.0.
7
+ */
8
+ import { WebSocketServer } from 'ws';
9
+ import AutomaticUpdates from './AutomaticUpdates.ts';
10
+ import AppRepository from './AppRepository.ts';
11
+ import http from 'node:http';
12
+ import type { KittenPolka } from './types/index.ts';
13
+ import type { RouteDictionary } from './Routes.ts';
14
+ export type ServerOptions = {
15
+ domains?: Array<string>;
16
+ domain?: string;
17
+ port?: number | boolean;
18
+ aliases?: string | Array<string>;
19
+ open?: boolean;
20
+ 'working-directory'?: string;
21
+ 'domain-token'?: string;
22
+ 'small-web-host-domain'?: string;
23
+ settingsPath?: string;
24
+ domainToken?: string;
25
+ smallWebHostDomain?: string;
26
+ minVersion?: string;
27
+ ipv4?: boolean;
28
+ ipv6?: boolean;
29
+ ipOnly?: boolean;
30
+ };
31
+ export default class Server {
32
+ /** Singleton instance. */
33
+ static instance: Server;
34
+ static isBeingConstructedViaFactoryMethod: boolean;
35
+ options: ServerOptions;
36
+ port: number;
37
+ domain: string | undefined;
38
+ open: boolean | undefined;
39
+ app: KittenPolka;
40
+ projectUploadsPath: string | undefined;
41
+ appRepository: AppRepository | undefined;
42
+ automaticUpdates: AutomaticUpdates | undefined;
43
+ routes: Record<string, RouteDictionary> | undefined;
44
+ kittenSettingsApplicationRoutes: Record<string, RouteDictionary> | undefined;
45
+ server: any;
46
+ wss: WebSocketServer | undefined;
47
+ /**
48
+ Singleton factory method.
49
+
50
+ Await this instead of calling `new Server(…)` and
51
+ `await server.initialise()`` manually.
52
+
53
+ Returns a promise for a reference to the server singleton,
54
+ that resolves immediately if it exists, and otherwise
55
+ resolves once it is created and initialised.
56
+ */
57
+ static getInstanceAsync(options: ServerOptions): Promise<Server>;
58
+ /**
59
+ Create server instance using passed options.
60
+ */
61
+ constructor();
62
+ /**
63
+ Create server instance using passed options.
64
+ */
65
+ initialise(options: ServerOptions): Promise<void>;
66
+ /**
67
+ Node http(s) upgrade event handler
68
+ (https://nodejs.org/api/http.html#event-upgrade)
69
+
70
+ Implementation based on express-websocket and tinyws, to keep
71
+ some of the modern interface of tinyws (async/await syntax)
72
+ while avoiding the client connection timeout issue in tinyws.
73
+ (See https://codeberg.org/kitten/app/issues/113).
74
+ */
75
+ upgradeHandler(request: http.IncomingMessage, socket: import('node:net').Socket, head: Buffer): any;
76
+ }
@@ -0,0 +1,6 @@
1
+ import type { NextHandler } from 'polka';
2
+ import type { KittenRequest, KittenResponse } from './types/index.ts';
3
+ /**
4
+ Formats and displays server errors.
5
+ */
6
+ export default function (error: any, request: KittenRequest, response: KittenResponse, _next?: NextHandler): Promise<void>;
@@ -0,0 +1,32 @@
1
+ import EventEmitter from 'node:events';
2
+ import type { KittenRequest, KittenResponse } from './types/index.ts';
3
+ /**
4
+ Represents an active session.
5
+
6
+ Important: since sessions can be deleted during the lifecycle of a server and since
7
+ you can listen for events on sessions, these need to be cleaned up before a session
8
+ object is destroyed. As we don’t have destructors in JavaScript, you must call the
9
+ cleanUp() method manually deleting a session.
10
+ */
11
+ export declare class Session extends EventEmitter {
12
+ redirectToAfterSignIn: string | undefined;
13
+ id: string;
14
+ createdAt: number;
15
+ authenticated: boolean;
16
+ constructor({ id, createdAt, authenticated, ...customData }: {
17
+ id: string;
18
+ createdAt?: number;
19
+ authenticated?: boolean;
20
+ [key: string]: any;
21
+ });
22
+ hasExpired(): boolean;
23
+ }
24
+ export default class Sessions {
25
+ static instance: Sessions | null;
26
+ /**
27
+ Singleton accessor.
28
+ */
29
+ static getInstance(): Sessions;
30
+ constructor();
31
+ session(request: KittenRequest, response: KittenResponse): Promise<Session>;
32
+ }
@@ -0,0 +1,20 @@
1
+ import { Upload } from './routes/PostRoute.ts';
2
+ import type { KittenRequest, KittenResponse } from './types/index.ts';
3
+ /**
4
+ Uploads collection class.
5
+
6
+ Persisted in the internal database at `_db.uploads`.
7
+ */
8
+ export default class Uploads {
9
+ [id: string]: any;
10
+ constructor(parameters?: {});
11
+ get(id: string): Upload;
12
+ length(): number;
13
+ all(): Upload[];
14
+ allIds(): string[];
15
+ delete(id: string): Promise<void>;
16
+ }
17
+ /**
18
+ Download handler (GET route) for uploaded files.
19
+ */
20
+ export declare function downloadHandler(): (request: KittenRequest, response: KittenResponse) => void;
@@ -0,0 +1,79 @@
1
+ import type { ServerOptions } from './Server.ts';
2
+ /**
3
+ Display error in console and exit process.
4
+ */
5
+ export declare function exitWithError(message: string): never;
6
+ /**
7
+ Determine which places to listen at.
8
+ */
9
+ export declare function getDomainsAndPort(options: ServerOptions): Promise<{
10
+ domains: string[];
11
+ port: number | boolean;
12
+ }>;
13
+ /**
14
+ Calculate the base path used by the Kitten server to find files in the served app.
15
+ */
16
+ export declare function setBasePath(workingDirectory: string, pathToServe: string): string;
17
+ /**
18
+ Returns unique project identifier based on the path of the project
19
+ that can be used as the name of a directory.
20
+ */
21
+ export declare function getProjectIdentifierForDomain(domain: string, port: number): string;
22
+ export declare const HTTP_METHODS: string[];
23
+ export declare const BACKEND_EXTENSIONS: string[];
24
+ export declare const FRONTEND_EXTENSIONS: string[];
25
+ export declare const DEPENDENCY_EXTENSIONS: string[];
26
+ export declare const DYNAMIC_ROUTE_EXTENSIONS: string[];
27
+ export declare const STATIC_ROUTE_EXTENSIONS: string[];
28
+ export declare const ALL_ROUTE_EXTENSIONS: string[];
29
+ export declare const extensionCategories: Record<string, string[]>;
30
+ export declare const supportedExtensionsRegExp: string;
31
+ /**
32
+ Since Polka does not handle unicode in paths correctly
33
+ (see https://github.com/lukeed/polka/issues/187), we have to
34
+ split the file path and URI encode each component ourselves.
35
+ */
36
+ export declare const encodeFilePath: (filePath: string) => string;
37
+ /**
38
+ Inverse of encodeFilePath. Used when we want to avoid
39
+ double escaping of file paths.
40
+ */
41
+ export declare const decodeFilePath: (filePath: string) => string;
42
+ /**
43
+ Returns the complete extension (e.g., page.js not just .js)
44
+ of the passed file path. Works with any number of extensions,
45
+ returning the last two without a dot at the start.
46
+ */
47
+ export declare function extensionOfFilePath(filePath: string): string;
48
+ /**
49
+ Given a file path, derives the unique class name for its route.
50
+ */
51
+ export declare function classNameFromFilePath(filePath: string, basePath: string): string;
52
+ /**
53
+ Derives the route pattern for the passed file path based on the base path.
54
+ */
55
+ export declare function routePatternFromFilePath(filePath: string, basePath: string): string;
56
+ /**
57
+ Converts a route in the form of, e.g.,
58
+ '/some_thing/with/underscores-and-hyphens' to
59
+ SomeThingWithUnderscoresAndHyphensPage.
60
+ */
61
+ export declare function classNameFromRoutePattern(pattern: string): string;
62
+ export declare const kittenAppPath: string;
63
+ /**
64
+ Run passed command (either 'ci' or 'install') on the given module path.
65
+ */
66
+ export declare function npm(command: 'ci' | 'install', modulePath: string): boolean;
67
+ /**
68
+ Runs npm ci on the passed module path.
69
+ */
70
+ export declare function runNpmCiOnModulePath(modulePath: string): void;
71
+ /**
72
+ db namespace for JSDB database-related utility functions.
73
+ */
74
+ export declare class db {
75
+ /**
76
+ Given a JSDB change string, returns the dot-separated keypath of the changed property.
77
+ */
78
+ static keypathForChange(change: string): string;
79
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ Commands for viewing, tailing, and deleting database and table information.
3
+
4
+ Copyright © 2023-present Aral Balkan, Small Technology Foundation.
5
+ Licensed under GNU AGPL version 3.0.
6
+ */
7
+ import InternalDatabase from '../../InternalDatabase.ts';
8
+ import AppDatabase from '../../AppDatabase.ts';
9
+ import type { ServerOptions, TailOptions } from '../index.ts';
10
+ type Databases = {
11
+ internalDatabase: InternalDatabase;
12
+ appDatabase: AppDatabase;
13
+ domain: string;
14
+ port: number;
15
+ };
16
+ /**
17
+ Initialise databases (internal and app).
18
+ */
19
+ export declare function initialiseDatabases(options: ServerOptions): Promise<Databases>;
20
+ /**
21
+ Show database information for default database.
22
+ */
23
+ export declare function showDefaultDatabaseInformationCommand(tableName: string | undefined, options: ServerOptions): Promise<void>;
24
+ /**
25
+ Show database information for internal database.
26
+ */
27
+ export declare function showInternalDatabaseInformationCommand(tableName: string | undefined, options: ServerOptions): Promise<void>;
28
+ /**
29
+ Delete whole database or specified table in default database.
30
+ */
31
+ export declare function deleteDefaultDatabaseCommand(tableName: string | undefined, options: ServerOptions): Promise<void>;
32
+ /**
33
+ Delete whole database or specified table in internal database.
34
+ */
35
+ export declare function deleteInternalDatabaseCommand(tableName: string | undefined, options: ServerOptions): Promise<void>;
36
+ /**
37
+ Show database information for default database.
38
+ */
39
+ export declare function tailDefaultDatabaseTableCommand(tableName: string, options: TailOptions): Promise<void>;
40
+ /**
41
+ Show database information for internal database.
42
+ */
43
+ export declare function tailInternalDatabaseTableCommand(tableName: string, options: TailOptions): Promise<void>;
44
+ /**
45
+ Show head and tail summary of specified table and follow additions to it.
46
+ */
47
+ export declare function tailDatabaseTableCommand(tableName: string, options: TailOptions, internal: boolean): Promise<void>;
48
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ Kitten command-line interface (CLI): deploy command.
3
+
4
+ Deploys an app from a Git repository as a
5
+ systemd --user service.
6
+
7
+ Copyright ⓒ 2021-present, Aral Balkan
8
+ Small Technology Foundation
9
+
10
+ License: AGPL version 3.0.
11
+ */
12
+ import type { DeploymentOptions } from '../index.ts';
13
+ /**
14
+ @param gitHttpsCloneUrl git clone url (HTTPS)
15
+ */
16
+ export default function deploy(gitHttpsCloneUrl: string, options: DeploymentOptions): Promise<void>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ Kitten command-line interface (CLI): disable command.
3
+
4
+ Copyright ⓒ 2022-present, Aral Balkan
5
+ Small Technology Foundation
6
+
7
+ License: AGPL version 3.0.
8
+ */
9
+ export default function disable(_options?: object): void;
@@ -0,0 +1,9 @@
1
+ /**
2
+ Kitten command-line interface (CLI): enable command.
3
+
4
+ Copyright ⓒ 2022-present, Aral Balkan
5
+ Small Technology Foundation
6
+
7
+ License: AGPL version 3.0.
8
+ */
9
+ export default function enable(_options?: object): void;
@@ -0,0 +1,15 @@
1
+ /**
2
+ Kitten command-line interface (CLI): logs command.
3
+
4
+ Follow Kitten systemd service logs.
5
+
6
+ Copyright ⓒ 2022-present, Aral Balkan
7
+ Small Technology Foundation
8
+
9
+ License: AGPL version 3.0.
10
+ */
11
+ import type { SinceOption } from '../index.ts';
12
+ /**
13
+ Show systemd server logs for Kitten process.
14
+ */
15
+ export default function logs(options: SinceOption): void;
@@ -0,0 +1,11 @@
1
+ /**
2
+ Kitten command-line interface (CLI): restart command.
3
+
4
+ Turn it off and then on again.
5
+
6
+ Copyright ⓒ 2024-present, Aral Balkan
7
+ Small Technology Foundation
8
+
9
+ License: AGPL version 3.0.
10
+ */
11
+ export default function stop(_options?: object): void;
@@ -0,0 +1,15 @@
1
+ /**
2
+ Kitten command-line interface (CLI): run command.
3
+
4
+ Clones an app from a Git repository and runs it locally.
5
+
6
+ Copyright ⓒ 2024-present, Aral Balkan
7
+ Small Technology Foundation
8
+
9
+ License: AGPL version 3.0.
10
+ */
11
+ import type { ServerOptions } from '../index.ts';
12
+ /**
13
+ @param gitHttpsCloneUrl git clone url (HTTPS)
14
+ */
15
+ export default function run(gitHttpsCloneUrl: string, options: ServerOptions): Promise<void>;